Skip to content

Chore: do not warn if non-literal is used in then/else_value of PIVOT macro#4423

Merged
georgesittas merged 2 commits intomainfrom
jo/fix_pivot_coercion_warning
May 16, 2025
Merged

Chore: do not warn if non-literal is used in then/else_value of PIVOT macro#4423
georgesittas merged 2 commits intomainfrom
jo/fix_pivot_coercion_warning

Conversation

@georgesittas
Copy link
Contributor

@georgesittas georgesittas commented May 15, 2025

Fixes #4421

@georgesittas georgesittas requested a review from a team May 15, 2025 14:34
@georgesittas georgesittas force-pushed the jo/fix_pivot_coercion_warning branch from e80ed91 to 4629541 Compare May 15, 2025 17:34
Comment on lines +1090 to +1100
column: SQL,
values: t.List[SQL],
alias: bool = True,
agg: SQL = SQL("SUM"),
cmp: SQL = SQL("="),
prefix: SQL = SQL(""),
suffix: SQL = SQL(""),
then_value: SQL = SQL("1"),
else_value: SQL = SQL("0"),
quote: bool = True,
distinct: bool = False,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only use these arguments to construct a string to parse, I figured that coercing the corresponding expressions into their sql() representations should suffice.

cc @tobymao @z3z1ma

@georgesittas georgesittas merged commit 06a51dc into main May 16, 2025
23 checks passed
@georgesittas georgesittas deleted the jo/fix_pivot_coercion_warning branch May 16, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coercion of expression '<column_name>' to type '<class 'sqlglot.expressions.Literal'>' failed. Using non coerced expression at '<file_name>'

3 participants