2

I want to run sqlfluff fix command to this sql file. This SQL is for Snowflake and will be executed in Airflow. ti.xcom_pull is a function used in Airflow DAG.

DELETE FROM test
WHERE date = '{{ti.xcom_pull(key='filedate')}}';    

then I got this error in fix command.

L:   1 | P:   1 |  TMP | Unrecoverable failure in Jinja templating: 'ti' is
                       | undefined. Have you configured your variables?
                       | https://docs.sqlfluff.com/en/latest/configuration.html

This means that sqlfluff does not directly support Airflow template and we have to provide variable for ti.xcom_pull. How can I do it?

Yohei Onishi
  • 1,362
  • 1
  • 19
  • 42

1 Answers1

1

Use --ignore=templating with sqlfluff fix, if you don't want to provide variables. See https://docs.sqlfluff.com/en/stable/configuration.html#interaction-with-ignore-templating

Yoichi Nakayama
  • 704
  • 6
  • 9