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

SQL to Rel conversion is broken for coalesce on nullable field

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.22.0
    • None

    Description

      Reproducible in master (06ac187a342f82a4b69e4c752ccdce0c269a350d): 1.22.0-SNAPSHOT

      SqlToRelConverterTest:

        @Test public void testCoalesceOnNullableField() {
          final String sql = "select coalesce(mgr, 0) from emp";
          sql(sql).ok();
        }
      

      Error:

      Conversion to relational algebra failed to preserve datatypes:
      validated type:
      RecordType(INTEGER NOT NULL EXPR$0) NOT NULL
      converted type:
      RecordType(INTEGER EXPR$0) NOT NULL
      rel:
      LogicalProject(EXPR$0=[CASE(IS NOT NULL($3), $3, 0)])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            anha Anton Haidai
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 10m
                2h 10m

                Slack

                  Issue deployment