You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/11/12 11:23:45 UTC

[GitHub] [calcite] xy2953396112 commented on a change in pull request #2189: [CALCITE-4251] Get the origin column, even if it is derived (xzh)

xy2953396112 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r522033219



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -351,11 +353,32 @@ public Double getPercentageOriginalRows(RelNode rel) {
    * returns null
    */
   public RelColumnOrigin getColumnOrigin(RelNode rel, int column) {
+    return getColumnOrigin(rel, column, false);
+  }
+
+  /**
+   * Determines the origin of a column. If the param derived is false, provided the column maps
+   * to a single column that isn't derived, otherwise the column is derived.
+   *
+   * @see #getColumnOrigins(org.apache.calcite.rel.RelNode, int)
+   *
+   * @param rel the RelNode of the column
+   * @param column the offset of the column whose origin we are trying to
+   * determine
+   * @param derived allow column derived
+   *
+   * @return the origin of a column provided it's a simple column; otherwise,
+   * returns null
+   */
+  public RelColumnOrigin getColumnOrigin(RelNode rel, int column, Boolean derived) {
     final Set<RelColumnOrigin> origins = getColumnOrigins(rel, column);
     if (origins == null || origins.size() != 1) {
       return null;
     }
     final RelColumnOrigin origin = Iterables.getOnlyElement(origins);
+    if (BooleanUtils.isTrue(derived)) {
+      return origin;
+    }
     return origin.isDerived() ? null : origin;

Review comment:
       you are right. return the `origin` directly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org