You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! sqlglot is great! I'm building up some expressions manually and then generating sql from there. This SQL should be valid in DuckDB (minus the missing leading letter in the function name) if it gets included with a select, etc...
Fully reproducible code snippet
[ins] In [1]: importsqlglotassg
[ins] In [2]: sg.__version__Out[2]: '18.2.1.dev11'
[ins] In [3]: sg.expressions.Filter(
...: this=sg.expressions.Count(this="int_col"), expression=sg.func("list_contains", 1, 2)
...: ).sql(dialect="duckdb")
Out[3]: 'COUNT(int_col) FILTER(IST_CONTAINS(1, 2))'
I expect to get:
'COUNT(int_col) FILTER(LIST_CONTAINS(1, 2))'
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered:
you're not building the ast correctly when you do it by hand, the filter() node expects a WHERE node in expression which is why it was generating weird sql. i've made it a bit more robust, but the way you're doing it has various errors.
this="int_col" is wrong, it needs to be a column expression for example.
it's going to be easier to instead do like
exp.parse_one(...), building complex AST node expressions by hand is error prone and not going to be API stable
thanks @tobymao ! yeah, it was a cobbled together example just to show the clipping. I'll definitely ping on slack when I've got something a bit more robust to show off.
Hi!
sqlglot
is great! I'm building up some expressions manually and then generating sql from there. This SQL should be valid in DuckDB (minus the missing leading letter in the function name) if it gets included with a select, etc...Fully reproducible code snippet
I expect to get:
'COUNT(int_col) FILTER(LIST_CONTAINS(1, 2))'
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered: