morningman opened a new pull request, #64757:
URL: https://github.com/apache/doris/pull/64757

   ### What problem does this PR solve?
   
   Issue Number: #64464
   
   Related PR: apache/doris#64756 (master regression test)
   
   Problem Summary:
   
   When querying a SQL Server JDBC catalog, a predicate on a `bit` column such 
as `WHERE bit_value = '1'` is folded to a boolean literal during analysis. On 
this branch the JDBC pushdown path (`JdbcScanNode.conjunctExprToString()` -> 
`Expr.toExternalSql()`) renders `BoolLiteral` as the dialect-agnostic 
`TRUE`/`FALSE` keyword, so the pushed-down SQL becomes:
   
   ```sql
   ... WHERE (([bit_value] = TRUE))
   ```
   
   SQL Server has no boolean literal and treats `TRUE` as an identifier:
   
   ```
   SQLServerException: Invalid column name 'TRUE'.
   ```
   
   (2.1.10 did not have this issue; it pushed `= 1`.)
   
   This PR renders boolean literals as `1`/`0` for databases without a native 
boolean type (`SQLSERVER`, `ORACLE`, `OCEANBASE_ORACLE`), mirroring the 
existing dialect-specific date-literal handling in the same method. `MySQL` / 
`PostgreSQL` / `Trino` keep `TRUE`/`FALSE` (PostgreSQL requires the keyword for 
its strict boolean type).
   
   On master this is already handled by the refactored connector SPI 
(`JdbcQueryBuilder.formatBooleanLiteral()`); this PR is the equivalent fix for 
the `branch-4.1` `JdbcScanNode` path.
   
   ### Release note
   
   Fix SQL Server / Oracle JDBC catalog query failure ("Invalid column name 
'TRUE'") when filtering a boolean/`bit` column.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test.
   
   - Behavior changed:
       - [x] No.
       - [ ] Yes.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to