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

Generate LogicalProject in RelRoot.project() when mapping is not name trivial

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.38.0
    • 1.39.0
    • core

    Description

      Currently, the RelRoot.project() method only generates a project relation if the RelRoot fields are:

      • not ref trivial
      • or if one of the following is not true:
        • is not a DML operation
        • is not a force project
        • the existing top relation is not already a LogicalProject

      https://github.com/apache/calcite/blob/802fce3c41be76fca899ddb8c856d72c754d1520/core/src/main/java/org/apache/calcite/rel/RelRoot.java#L163-L169

      The result is that for a simple SQL query that selects a single field from a table and renames the same field we are losing the renaming of the field if we call RelRoot.project() even if we set the force parameter to true since the relational tree embedded in the RelRoot already contains a LogicalProject at the top of the tree.

      My expectation would be that when I call RelRoot.project() that a LogicalProject is being added also if the RelRoot fields are not name trivial aka they are being renamed.

      Attachments

        Issue Links

          Activity

            People

              zrlpar Niels Pardon
              zrlpar Niels Pardon
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: