i am trying to call a sql file with multiple statements separated by ; through the OracleOperator in airflow , but its giving below error with multiple statements
E.g File Containing
CALL DROP_OBJECTS('TABLE_XYZ');
CREATE TABLE TABLE_XYZ AS SELECT 1 Dummy from DUAL;
[2019-06-18 18:19:12,582] {init.py:1580} ERROR - ORA-00933: SQL command not properly ended Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/airflow/models/init.py", line 1441, in _run_raw_task result = task_copy.execute(context=context) File "/usr/local/lib/python3.6/site-packages/airflow/operators/oracle_operator.py", line 63, in execute parameters=self.parameters) File "/usr/local/lib/python3.6/site-packages/airflow/hooks/dbapi_hook.py", line 172, in run cur.execute(s) cx_Oracle.DatabaseError: ORA-00933: SQL command not properly ended
Even with single statement ending with ; giving below error :
e.g file
CREATE TABLE TABLE_XYZ AS SELECT 1 Dummy from DUAL;
[2019-06-18 17:47:53,137] {init.py:1580} ERROR - ORA-00922: missing or invalid option Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/airflow/models/init.py", line 1441, in _run_raw_task result = task_copy.execute(context=context) File "/usr/local/lib/python3.6/site-packages/airflow/operators/oracle_operator.py", line 63, in execute parameters=self.parameters) File "/usr/local/lib/python3.6/site-packages/airflow/hooks/dbapi_hook.py", line 172, in run cur.execute(s)
with DAG('my_simple_dag',
default_args=default_args,
template_searchpath=['/root/rahul/'],
schedule_interval='*/10 * * * *',
) as dag:
opr_oracle = OracleOperator(task_id='oracleTest',oracle_conn_id='STG',
sql='test.sql')
do i need to pass any additional parameter to make the dbhook understand that the file need to be split in separate statement ?
as per the documentation it expects param sql: the sql code to be executed. Can receive a str representing a sql statement, a list of str (sql statements), or reference to a template file. Template reference are recognized by str ending in '.sql' (templated)
but the .sql template is not working with multiple statement. any help will be greatly appreciated . Thanks !!