You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2025/11/05 13:05:00 UTC

[jira] [Commented] (CALCITE-7271) Prevent unsafe CAST pushdown in Druid

    [ https://issues.apache.org/jira/browse/CALCITE-7271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18035573#comment-18035573 ] 

Stamatis Zampetakis commented on CALCITE-7271:
----------------------------------------------

The "error handling" discrepancies of the CAST operator may not be that important for real use-cases so fixing this bug is rather low priority.

> 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
>            Priority: Major
>
> 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)