Stamatis Zampetakis created CALCITE-7271:
--------------------------------------------
Summary: Prevent unsafe CAST pushdown in Druid
Key: CALCITE-7271
URL: https://issues.apache.org/jira/browse/CALCITE-7271
Project: Calcite
Issue Type: Bug
Components: druid-adapter
Reporter: Stamatis Zampetakis
Most of SQL queries are using the standard CAST operator that is unsafe and
should throw an error when the conversion is invalid. However, the [CAST
operation in
Druid|https://druid.apache.org/docs/latest/querying/sql-data-types/#standard-types]
returns null instead of throwing an error when the operation fails.
Currently the Druid adapter ignores the "error handling" discrepancies of the
CAST operator when pushing down such expressions. Ideally, to avoid altering
the semantics of the query the regular CAST should not be pushed to Druid.
SQL queries can use the SAFE_CAST operator instead of the standard CAST
operator and this can be pushed safely to Druid since the semantics are the
same with those offered by the engine.
The
[DruidSqlCastConverter|https://github.com/apache/calcite/blob/8b5c17e51e0c9c3f8e3db17c8d449e67e4e2974a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidSqlCastConverter.java]
and potentially other classes may need modifications to handle/push the CAST
variations properly in Druid.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)