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

In RelToSqlConverter, AssertionError for values with more than two items when SqlDialect#supportsAliasedValues is false

    XMLWordPrintableJSON

Details

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

    Description

      The code at https://github.com/apache/calcite/blob/4b349032c17b95735b12593a65f7027d54d8b8b6/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L802-L803 creates a UNION ALL with an arbitrary number of operands, but the UNION_ALL operator is a SqlSetOperator which is a "SqlBinaryOperator" (Binary syntax). So that generates an assertion error when it unparses more than two values at https://github.com/apache/calcite/blob/4b349032c17b95735b12593a65f7027d54d8b8b6/core/src/main/java/org/apache/calcite/sql/SqlUtil.java#L426

       

      I don't think I've done anything nonstandard, other than use a dialect with that flag set to false. To reproduce, create a values RelNode with more than two items, convert it with RelToSqlConverter with a dialect using supportsAliasedValues() = false (like Redshift), and attempt to unparse the resulting SqlNode.

      Attachments

        Issue Links

          Activity

            People

              jiajunbernoulli Jiajun Xie
              swtalbot Steven Talbot
              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 - 50m
                  50m