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/10/03 09:22:08 UTC

[GitHub] [calcite] xy2953396112 opened a new pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

xy2953396112 opened a new pull request #2189:
URL: https://github.com/apache/calcite/pull/2189


   https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-4251?filter=recentlyviewed


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r523876124



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,23 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column.
    *
    * @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
    *
-   * @return the origin of a column provided it's a simple column; otherwise,
-   * returns null
+   * @return the origin of a column;
    */

Review comment:
       ok, Thanks




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 edited a comment on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-727768655


   > This change is breaking, can you add some notion in the `history.md` ?
   
   ok.Please help review again.Thanks a lot.


----------------------------------------------------------------
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



[GitHub] [calcite] xy2953396112 commented on a change in pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r509918884



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -351,11 +351,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 (derived) {

Review comment:
       > If derived == null, we would get an NPE here.
   
   Thanks, update the code.




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-729623742


   > +1
   
   Thanks


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
danny0405 commented on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-727717284


   This change is breaking, can you add some notion in the `history.md` ?


----------------------------------------------------------------
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



[GitHub] [calcite] danny0405 commented on a change in pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r521777324



##########
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:
       Instead of overload the methods, why not return the `origin` directly, no matter if it is derived.




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r523864711



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,23 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column.
    *
    * @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
    *
-   * @return the origin of a column provided it's a simple column; otherwise,
-   * returns null
+   * @return the origin of a column;
    */

Review comment:
       Remove `;`.




----------------------------------------------------------------
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



[GitHub] [calcite] yanlin-Lynn merged pull request #2189: [CALCITE-4251] Get the origin column, even if it is derived (xzh)

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn merged pull request #2189:
URL: https://github.com/apache/calcite/pull/2189


   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-726017100


   > Update the commit log please, you should describe what you want to do briefly in the commit log. Overload is not a good commit log.
   
   Thanks, update the code.


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r523860327



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,23 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column.
    *
    * @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
    *
-   * @return the origin of a column provided it's a simple column; otherwise,
-   * returns null
+   * @return the origin of a column;
    */
   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;
+    return origin;

Review comment:
       Thanks, Please review the code again.
   
   




----------------------------------------------------------------
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



[GitHub] [calcite] yanlin-Lynn commented on a change in pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r521350910



##########
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.

Review comment:
       I think what you mean is 
   "
   Determines the origin of a column, allow users to choose whether to include the derived column."




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r522106767



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,24 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column, provided the column maps to a origin
+   * column.

Review comment:
       The annotation here is in-correct.




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-727768655


   > This change is breaking, can you add some notion in the `history.md` ?
   
   ok.


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r522107178



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,24 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column, provided the column maps to a origin
+   * column.
    *
    * @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
    *
-   * @return the origin of a column provided it's a simple column; otherwise,
-   * returns null
+   * @return the origin of a column provided it's a simple column;

Review comment:
       The doc here does not match with the code.




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r522559504



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,23 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column.
    *
    * @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
    *
-   * @return the origin of a column provided it's a simple column; otherwise,
-   * returns null
+   * @return the origin of a column;
    */
   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;
+    return origin;

Review comment:
       The code that uses this method should also be tweaked, such as the `LoptMultiJoin`.




----------------------------------------------------------------
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



[GitHub] [calcite] xy2953396112 commented on pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-715322928


   @julianhyde
   Updated the code, please help review this pr, thanks a lot.
   
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
xy2953396112 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r522525278



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -338,25 +338,24 @@ public Double getPercentageOriginalRows(RelNode rel) {
   }
 
   /**
-   * Determines the origin of a column, provided the column maps to a single
-   * column that isn't derived.
+   * Determines the origin of a column, provided the column maps to a origin
+   * column.
    *
    * @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
    *
-   * @return the origin of a column provided it's a simple column; otherwise,
-   * returns null
+   * @return the origin of a column provided it's a simple column;

Review comment:
       Thanks for review, update the doc.




----------------------------------------------------------------
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



[GitHub] [calcite] liyafan82 commented on a change in pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#discussion_r508360264



##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMetadataQuery.java
##########
@@ -351,11 +351,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 (derived) {

Review comment:
       If derived == null, we would get an NPE here. 




----------------------------------------------------------------
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



[GitHub] [calcite] yanlin-Lynn commented on pull request #2189: [CALCITE-4251] Overload RelMetadataQuery#getColumnOrigin method (xzh)

Posted by GitBox <gi...@apache.org>.
yanlin-Lynn commented on pull request #2189:
URL: https://github.com/apache/calcite/pull/2189#issuecomment-725419750


   Update the commit log please, you should describe what you want to do briefly in the commit log.  Overload is not a good commit log.


----------------------------------------------------------------
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