databrickslabs / remorph

Cross-compiler and Data Reconciler into Databricks Lakehouse
Other
21 stars 13 forks source link

Fix LEFT and RIGHT JOIN syntax in Snowflake ANTLR grammar #526

Closed jimidle closed 1 month ago

jimidle commented 1 month ago

The keywords LEFT and RIGHT were being allowed as identifiers in the grammar. They are in fact hard keywords and must be [escaped] to be used as column names.

However, SQL parsers are often hand crafted and can do special checks in context. Should we encounter an input set that uses LEFT or RIGHT as a column name without escaping, we can implement semantic predicates (which are generally avoided), as so (note, that this is for illustration purposes, and would actually be a call to a member function where we can explore the lookahead more exactly):

asAlias: { !(_input.LA(1) == LEFT && _input.LA(2) == OUTER) }? AS? alias ;
github-actions[bot] commented 1 month ago

Coverage tests results

394 tests   353 :white_check_mark:  4s :stopwatch:   2 suites    2 :zzz:   2 files     39 :x:

For more details on these failures, see this check.

Results for commit bc52f86e.