Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6762

Preserving the CAST conversion for operands in Presto

    XMLWordPrintableJSON

Details

    Description

      In Calcite, if the dialect's `supportsImplicitTypeCoercion` is set to `true` (the default value is `true`), Calcite will remove the cast in the `SqlImplementor#stripCastFromString()` method. For example, the following SQL:

      ```
      FROM applydata_bigdata.kafka_topic_cluster_user_dept_month_one_day_msg_info
      WHERE ymd > CAST('20240801' AS INTEGER)
      ORDER BY ymd DESC
      ```

      will be transformed into:

      ```
      FROM "hive"."applydata_bigdata"."kafka_topic_cluster_user_dept_month_one_day_msg_info"
      WHERE "ymd" > '20240801'
      ORDER BY "ymd" IS NULL DESC, "ymd" DESC LIMIT 200
      ```

      Here, the `CAST` is removed.

      However, in Presto, different data types cannot be directly compared, which will result in an error. 

      To avoid this issue, `supportsImplicitTypeCoercion` should be set to `false` in `PrestoSqlDialect`.

      Attachments

        1. image-2025-01-05-02-16-32-718.png
          40 kB
          xiaochen.zhou

        Issue Links

          Activity

            People

              Unassigned Unassigned
              xiaochen.hello xiaochen.zhou
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: