Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-32363

calcite 1.21 supports type coercion but flink don't enable it in validate

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      1) calcite 1.21 supports type coercion and enabled default while flink disabled

      2) spark /mysql can run it 

      3) although, we can make it run by select count(distinct `if`(1>5, 'x', cast(null as varchar)));

      i think we should enable it or offers a config to enable it

       

      Flink SQL> select count(distinct `if`(1>5, 'x', null));
      [ERROR] Could not execute SQL statement. Reason:
      org.apache.calcite.sql.validate.SqlValidatorException: Illegal use of 'NULL'
      // it can run in spark
      spark-sql (default)> select count(distinct `if`(1>5, 'x', null)); 
      0
      

       

      private def createSqlValidator(catalogReader: CalciteCatalogReader) = {
        val validator = new FlinkCalciteSqlValidator(
          operatorTable,
          catalogReader,
          typeFactory,
          SqlValidator.Config.DEFAULT
            .withIdentifierExpansion(true)
            .withDefaultNullCollation(FlinkPlannerImpl.defaultNullCollation)
            .withTypeCoercionEnabled(false)
        ) // Disable implicit type coercion for now.
        validator
      } 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jackylau Jacky Lau
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: