morningman opened a new pull request, #64760:
URL: https://github.com/apache/doris/pull/64760
### What problem does this PR solve?
Issue Number: #64464
Related PR: apache/doris#64757 (branch-4.1), 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).
This is the `branch-4.0` backport of the same fix (`branch-4.1`:
apache/doris#64757). On master the JDBC pushdown was refactored to the
connector SPI and already renders booleans per dialect via
`JdbcQueryBuilder.formatBooleanLiteral()`.
### 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]