xiedeyantu opened a new pull request, #22314: URL: https://github.com/apache/datafusion/pull/22314
## Which issue does this PR close? - Closes #22252. ## Rationale for this change In PostgreSQL, the `^` operator represents exponentiation, but DataFusion was interpreting it as bitwise XOR. This caused PostgreSQL-dialect queries such as `SELECT 2 ^ 3;` to return `1` instead of `8`. This change aligns DataFusion's PostgreSQL SQL semantics with PostgreSQL for this operator while preserving existing non-PostgreSQL behavior. ## What changes are included in this PR? - Added PostgreSQL-specific handling for `BinaryOperator::PGExp` during SQL expression lowering. - Lowered PostgreSQL `^` expressions to the built-in `power(left, right)` scalar function instead of treating them as bitwise XOR. - Kept existing generic-dialect `^` behavior unchanged. - Kept PostgreSQL bitwise XOR behavior unchanged via `#`. - Added a sqllogictest regression covering `SELECT 2 ^ 3;` under the PostgreSQL parser dialect. ## Are these changes tested? Yes. Added a regression test in scalar.slt to verify that PostgreSQL-dialect `^` is evaluated as exponentiation. Validated with: ```bash cargo test -p datafusion-sqllogictest --test sqllogictests scalar ``` ## Are there any user-facing changes? Yes. For the PostgreSQL SQL parser dialect, `^` now behaves as exponentiation instead of bitwise XOR, matching PostgreSQL semantics. Generic-dialect behavior is unchanged, and PostgreSQL bitwise XOR remains available through `#`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
