Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluated macro condition errors when SQL IN operator has array length 1 #892

Closed
treysp opened this issue May 24, 2023 · 1 comment · Fixed by tobymao/sqlglot#1815
Closed
Labels
Bug Something isn't working

Comments

@treysp
Copy link
Contributor

treysp commented May 24, 2023

For evaluated macro conditions (like those in @IF, body macros like @WHEN), the IN operator errors when the comparison array is length 1.

Works: 1 in (1,2)
Errors: 1 in (1)

from sqlglot import parse_one
from sqlmesh.core.macros import MacroEvaluator

query = "@IF(1 in (1,2), a, b)"
MacroEvaluator().transform(parse_one(query)).sql()
# 'a'

query = "@IF(1 in (1), a, b)"
MacroEvaluator().transform(parse_one(query)).sql()
# TypeError: argument of type 'int' is not iterable
# sqlmesh.utils.errors.MacroEvalError: Error trying to eval macro.
# Generated code: 1 in (1)
# Original sql: 1 IN (1)

@georgesittas
Copy link
Contributor

This should be fixed when we bump SQLGlot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants