brucearctor opened a new pull request, #14464:
URL: https://github.com/apache/gravitino/pull/14464

   ### What changes were proposed in this pull request?
   
   - `DorisColumnDefaultValueConverter.fromGravitinoForAddColumn`: validate and 
trim non-blank `Type.NumericType` defaults via 
`super.fromGravitino(defaultValue)` before wrapping with `quoteDorisLiteral`, 
matching `JdbcColumnDefaultValueConverter` (#13975).
   - `DorisColumnDefaultValueConverter.toGravitino`: handle canonical Doris 
`STRING` (`DorisTypeConverter.STRING`) and `DATEV2` 
(`DorisTypeConverter.DATEV2`) column types alongside `TEXT` and `DATE` so 
defaults read back as `Literals.stringLiteral(unescapeDorisLiteral(...))` and 
`Literals.dateLiteral(...)` instead of falling through to `UnparsedExpression`.
   - `DorisTableOperations`:
     - In `generateCreateTableSql`, run `validateIncrementCol` and 
`validateDistribution` before querying `getDorisVersion`, and reuse the 
resolved Doris version across `validateAutoIncrementVersion` and 
`useDoubleQuotedCreateTableStringDefaults`.
     - In `generateAlterTableSql`, validate 
`TableChange.UpdateColumnNullability` before `resolveModifyColumnVersion` so 
invalid nullability changes fail fast without querying `getDorisVersion`.
   
   ### Why are the changes needed?
   
   1. `DorisColumnDefaultValueConverter.fromGravitinoForAddColumn` intercepted 
`Type.NumericType` before `super.fromGravitino(defaultValue)`, bypassing the 
numeric literal validation added in #13975 and allowing non-numeric strings on 
numeric columns to be emitted into `ADD COLUMN` DDL.
   2. `DorisTypeConverter` maps `Types.StringType` to `STRING` and 
`Types.DateType` to `DATEV2`, but 
`DorisColumnDefaultValueConverter.toGravitino` only matched `TEXT` and `DATE`, 
returning `UnparsedExpression` (and skipping `unescapeDorisLiteral` and 
subsequent `MODIFY COLUMN` string-literal escaping for `STRING` columns).
   3. `generateCreateTableSql` and `UpdateColumnNullability` queried 
`getDorisVersion` before local argument validation, and 
`generateCreateTableSql` queried `getDorisVersion` twice when a table had both 
an `AUTO_INCREMENT` column and a string default containing quotes or 
backslashes.
   
   Fix: #14460
   
   cc @jiangxt2 @yuqi1129 for review when you have a moment — thank you!
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Invalid non-numeric default values on numeric columns in Doris `ADD 
COLUMN` are now rejected with `IllegalArgumentException`, and Doris `STRING` / 
`DATEV2` column defaults are parsed as typed `Literal` values instead of 
`UnparsedExpression`.
   
   ### How was this patch tested?
   
   - Unit tests in `TestDorisColumnDefaultValueConverter` and 
`TestDorisTableOperationsSqlGeneration`:
     - `./gradlew :catalogs:catalog-jdbc-doris:spotlessCheck 
:catalogs:catalog-jdbc-doris:test -PskipITs` (all 137 tests passed).


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

Reply via email to