Skip to content

Conversation

@fivetran-amrutabhimsenayachit
Copy link
Collaborator

Add transpilation support for the negative integer args for BITNOT

@VaggelisD VaggelisD changed the title feat(duckdb): Add transpilation support for the negative integer args for BITNOT Chore(duckdb): Add transpilation support for the negative integer args for BITNOT Dec 5, 2025
@VaggelisD VaggelisD changed the title Chore(duckdb): Add transpilation support for the negative integer args for BITNOT Feat(duckdb): Add transpilation support for the negative integer args for BITNOT Dec 5, 2025
@VaggelisD
Copy link
Collaborator

Apologies for the title change, wanted to amend a different PR.

Comment on lines 1665 to 1669
this_sql = self.sql(expression, "this")
# Wrap in parentheses if starts with minus to prevent ~- parsing issues
if this_sql.startswith("-"):
this_sql = f"({this_sql})"
return f"~{this_sql}"
Copy link
Collaborator

@VaggelisD VaggelisD Dec 5, 2025

Choose a reason for hiding this comment

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

[Nit] It is generally better if we can avoid string logic and instead construct/transform expressions, we can rewrite this as:

Suggested change
this_sql = self.sql(expression, "this")
# Wrap in parentheses if starts with minus to prevent ~- parsing issues
if this_sql.startswith("-"):
this_sql = f"({this_sql})"
return f"~{this_sql}"
this = expression.this
# Wrap in parentheses to prevent parsing issues such as "SELECT ~-1"
if isinstance(this, exp.Neg):
this = exp.Paren(this=this)
return f"~{self.sql(this)}"

@VaggelisD VaggelisD merged commit 7d485c7 into main Dec 5, 2025
8 checks passed
@VaggelisD VaggelisD deleted the RD-1069242-bitnot branch December 5, 2025 13:25
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.

3 participants