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

If the inputs to a join have duplicate filed names, JDBC adapter should not generate “SELECT *”

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.29.0
    • None
    • jdbc-adapter
    • jdk8

    Description

      @Test void testJoinInputsProjectingSameFieldName() {
        final String query = "SELECT \"t\".\"id\", \"t0\".\"id\" AS \"id0\"\n"
            + "FROM (VALUES (NULL)) AS \"t\" (\"id\"),\n"
            + "(VALUES (NULL)) AS \"t0\" (\"id\")";
        final String expected = query;
        sql(query).ok(expected);
      } 

      The Join left and right have same field name id, we should generate an expected statement which equals to query, but Calcite generates SELECT * rather SELECT expression list.

       

      In many dialects such as MYSQL, SPARK SQL, SELECT * which contains same field name can't be used in CTAS, for example

      CREATE TABLE SELECT * FROM (VALUES (NULL)) AS \"t\" (\"id\"),
      (VALUES (NULL)) AS \"t0\" (\"id\")

      This will cause exception: Found duplicate column(s) in the table definition.

       

      Attachments

        Issue Links

          Activity

            People

              yanjing.wang yanjing.wang
              yanjing.wang yanjing.wang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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