Home > other >  SQLGlot is throwing an errow when trying to parse a parameter in a SQL statement, i.e "{{parame
SQLGlot is throwing an errow when trying to parse a parameter in a SQL statement, i.e "{{parame

Time:01-05

Example query:

SELECT * FROM table
WHERE parameter is {{parameter}}

It's throwing a sqlglot.errors.ParseError. Is there an option to enable this type of option/parameter interpolation, as found in Databricks SQL queries for example?

I want to be able to validate SQL as a part of testing, so I don't want to strip the {{ and }} tokens.

CodePudding user response:

SQLGlot only parses SQL. since {{ parameter }} is not SQL, it cannot be parsed. You need to first render the parameter, and then SQLGlot can parse the result.

  • Related