The sample.sql file
INSERT INTO db.table
VALUES (
'{{ ds }}',
'${item1}',
'{item2}'
)
;
The airflow operator
task = DatabricksSqlOperator(
task_id=task_id,
sql_endpoint_name="my-serverless-endpoint",
sql="sample.sql",
parameters={
"item1": "abc",
"item2": "xyz"
},
)
The result db.table
| Column A | Column B | Column C |
|---|---|---|
| 2022-05-05 | ${item1} | {item2} |
The marcro {{ ds }} works just fine. But I can't figure out how to get other parameter to work DatabricksSqlOperator is extending the SQLExecuteQueryOperator https://github.com/apache/airflow/blob/main/airflow/providers/databricks/operators/databricks_sql.py
I tried
- '${item1}',
- '{item1}
- '{params["item1"]}',
- '{param.item1}',
- '{parameters["item1"]}',
- '{parameters.item1}',
Hoping to get
| Column A | Column B | Column C |
|---|---|---|
| 2022-05-05 | abc | xyz |