morningman commented on code in PR #70369:
URL: https://github.com/apache/doris/pull/70369#discussion_r4505044803
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverter.java:
##########
@@ -301,12 +302,26 @@ private static ConnectorExpression
convertLiteral(LiteralExpr literal) {
return new ConnectorLiteral(ct, ((StringLiteral)
literal).getValue());
} else if (literal instanceof DateLiteral) {
return convertDateLiteral((DateLiteral) literal, ct);
+ } else if (literal instanceof ArrayLiteral) {
+ return new ConnectorLiteral(ct, arrayElements((ArrayLiteral)
literal));
} else {
return new ConnectorLiteral(ct, literal.getStringValue());
}
}
- private static ConnectorExpression convertDateLiteral(DateLiteral dl,
ConnectorType ct) {
+ /**
+ * The element values of an ARRAY literal, each in the shape it would have
as a literal of its own:
+ * {@code null} for a NULL element, a nested list for a nested array.
+ */
+ private static List<Object> arrayElements(ArrayLiteral literal) {
+ List<Object> elements = new ArrayList<>(literal.getChildren().size());
+ for (Expr element : literal.getChildren()) {
+ elements.add(convertLiteral((LiteralExpr) element).getValue());
Review Comment:
Thanks, the path is real, but I'm leaving it as is in this PR. The array
form now fails at the same call where the scalar form of the same parameter
already fails on master, and the one query that passed before needs a
non-default BE setting.
Reproduced on a local cluster whose FE has master's `handleDateLiteral`,
converter and `PluginDrivenScanNode`: an Iceberg table with a DATE column,
COM_STMT_EXECUTE with a 4-byte DATE whose year, month and day are 0.
| Predicate | BE `allow_zero_date` | master | this PR |
|---|---|---|---|
| `d = ?` | false or true | FE: `Invalid value for MonthOfYear (valid values
1 - 12): 0`, from `convertDateLiteral` → `LocalDate.of` | same |
| `array_contains(array(?), d)` | false (default) | BE: `[E33] Invalid
value: 0000-00-00 for type DateV2` | the FE error above |
| `array_contains(array(?), d)` | true | returns the 0000-01-01 row | the FE
error above |
Only the last row changes, and `config.h` recommends keeping
`allow_zero_date` false. A 4-byte 2024-00-00 fails on the BE even with it on.
libmysqlclient sends an all-zero `MYSQL_TIME` with length 0, which
`handleDateLiteral` decodes as 0000-01-01, and the text form `cast('0000-00-00'
as date)` folds to NULL.
After this PR an element converts exactly as the same literal does on its
own, which is what the PR sets out to do. Keeping dates that `LocalDate` cannot
represent in Doris has to cover `d = ?` as well, so it belongs with the binary
DATE decoding (it accepts dates the text parser turns into NULL), not in this
PR.
--
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]