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

Subfields of array columns containing structs are not qualified in getFieldOrigins

    XMLWordPrintableJSON

Details

    Description

      Attempting to follow on the suggestions from Julian in this thread, found a potential improvement.

      Given a table schema containing a repeated array of structs and a query projecting fields of that struct via UNNEST, the present implementation of getFieldOrigins in SqlValidatorImpl will return a list representation suggesting that the subfield is actually a member of the top level table row type.

      For example, when using the DEPT_NESTED table from the MockCatalogReaderSimple within tests with the following query:

      select e.empno from dept_nested, unnest(employees) as e
      

      The return value currently is:

      {CATALOG.SALES.DEPT_NESTED.EMPNO}
      

      Rather than:

      {CATALOG.SALES.DEPT_NESTED.EMPLOYEES.EMPNO}
      

      No such column EMPNO exists in the root schema of the DEPT_NESTED table. The javadoc for the method however suggests that the return from this method should always be four entries long, although it would seem this doesn't account for nesting. Is this intended behavior, or should column entry of this list be of variable length?

      Attachments

        Issue Links

          Activity

            People

              mgthesecond Mark Grey
              mgthesecond Mark Grey
              Votes:
              0 Vote for this issue
              Watchers:
              6 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 - 40m
                  40m