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

DuckDB ^ operator is parsed incorrectly as XOR when it should be POW #4186

Closed
rustyconover opened this issue Oct 1, 2024 · 0 comments · Fixed by #4193
Closed

DuckDB ^ operator is parsed incorrectly as XOR when it should be POW #4186

rustyconover opened this issue Oct 1, 2024 · 0 comments · Fixed by #4193
Assignees

Comments

@rustyconover
Copy link
Contributor

When testing SQLGlot with DuckDB, there is a parsing error when using the ^ operator in SQL statements. SQLGlot incorrectly translates this to the XOR function, whereas in DuckDB, the ^ operator is used for exponentiation (power).

Original Query:

SELECT ?::DOUBLE ^ ?::DOUBLE LIMIT 1

SQLGlot Translation:

SELECT XOR(CAST(? AS DOUBLE), CAST(? AS DOUBLE)) LIMIT 1

Expected Behavior:

The translation should retain the ^ operator, as it computes the power of x to y in DuckDB:

SELECT ?::DOUBLE ^ ?::DOUBLE LIMIT 1

DuckDB Reference:

By inspecting the DuckDB function definitions, the ^ operator is defined as the exponentiation function:

SELECT * FROM duckdb_functions() WHERE function_name = '^';
@rustyconover rustyconover changed the title DuckDB ^ operator is parsed incorrectly as XOR when it should be POW DuckDB ^ operator is parsed incorrectly as XOR when it should be POW Oct 1, 2024
@VaggelisD VaggelisD self-assigned this Oct 1, 2024
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 a pull request may close this issue.

2 participants