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

Get the origin column, even if it is derived

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.27.0
    • None

    Description

      A case:

      final String sql1 = ""
          + "select empno, sum(sal) as all_sal\n"
          + "from emp\n"
          + "group by empno";
      

      When i try to get the `all_sal` origin column field,it will return null and it is derived. we always get the origin column although it is derived. We should overload this method and determine whether the column is derived by setting parameters.

       org.apache.calcite.rel.metadata.RelMetadataQuery#getColumnOrigin

      // code placeholder
      public RelColumnOrigin getColumnOrigin(RelNode rel, int column) {
        final Set<RelColumnOrigin> origins = getColumnOrigins(rel, column);
        if (origins == null || origins.size() != 1) {
          return null;
        }
        final RelColumnOrigin origin = Iterables.getOnlyElement(origins);
        return origin.isDerived() ? null : origin;
      }
      

       

       

       

       

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            xzh_dz xzh_dz
            Votes:
            0 Vote for this issue
            Watchers:
            4 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 - 3.5h
                3.5h

                Slack

                  Issue deployment