[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-27 Thread GitBox


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



##
File path: core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java
##
@@ -125,6 +125,18 @@ public RelDataType inferReturnType(SqlOperatorBinding 
opBinding) {
 }
   }
 
+  /** "MYAGGFUNC" user-defined aggregate function. This agg function accept 
one or more arguments
+   * in order to reproduce the throws of CALCITE-3929. */
+  public static class MyAggFunc extends SqlAggFunction {

Review comment:
   @yanlin-Lynn
   Thanks, `SqlUserDefinedAggFunction`  has an AggregateFunction argument, it's 
not convenient for reproduce this case.So it's better to extends SqlAggFunction 
and define it as a user-defined function.
   
   
   
   





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:
us...@infra.apache.org




[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-22 Thread GitBox


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



##
File path: core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java
##
@@ -125,6 +125,18 @@ public RelDataType inferReturnType(SqlOperatorBinding 
opBinding) {
 }
   }
 
+  /** "MYAGGFUNC" user-defined aggregate function. This agg function accept 
one or more arguments
+   * in order to reproduce the throws of CALCITE-3929. */
+  public static class MyAggFunc extends SqlAggFunction {

Review comment:
   There is a `MockSqlOperatorTable#MyAvgAggFunction`, we should use it to 
reproduce this case.





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:
us...@infra.apache.org




[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-22 Thread GitBox


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



##
File path: core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
##
@@ -146,8 +147,9 @@
   + "{\n"
   + "  \"agg\": {\n"
   + "\"name\": \"COUNT\",\n"
-  + "\"kind\": \"COUNT\",\n"
-  + "\"syntax\": \"FUNCTION_STAR\"\n"
+  + "\"syntax\": \"FUNCTION_STAR\",\n"
+  + "\"class\": 
\"org.apache.calcite.sql.fun.SqlCountAggFunction\",\n"
+  + "\"kind\": \"COUNT\"\n"

Review comment:
   You are right. Code has been updated.
   
   





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:
us...@infra.apache.org




[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-22 Thread GitBox


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



##
File path: core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java
##
@@ -125,6 +125,18 @@ public RelDataType inferReturnType(SqlOperatorBinding 
opBinding) {
 }
   }
 
+  /** "MYAGGFUNC" user-defined aggregate function. This agg function accept 
one or more arguments
+   * in order to reproduce the throws of CALCITE-3929. */
+  public static class MyAggFunc extends SqlAggFunction {

Review comment:
   There is a `MockSqlOperatorTable#MyAvgAggFunction`, we should use it to 
reproduce this case.





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:
us...@infra.apache.org




[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-22 Thread GitBox


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



##
File path: core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
##
@@ -271,7 +271,9 @@ public RelDataType toType(RelDataTypeFactory typeFactory, 
Object o) {
 
   public Object toJson(AggregateCall node) {
 final Map map = jsonBuilder.map();
-map.put("agg", toJson(node.getAggregation()));
+Map aggMap = new HashMap(toJson(node.getAggregation()));
+aggMap.put("class", node.getAggregation().getClass().getName());

Review comment:
   Thanks for review. 





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:
us...@infra.apache.org




[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-19 Thread GitBox


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



##
File path: core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
##
@@ -271,7 +271,9 @@ public RelDataType toType(RelDataTypeFactory typeFactory, 
Object o) {
 
   public Object toJson(AggregateCall node) {
 final Map map = jsonBuilder.map();
-map.put("agg", toJson(node.getAggregation()));
+Map aggMap = new HashMap(toJson(node.getAggregation()));
+aggMap.put("class", node.getAggregation().getClass().getName());

Review comment:
   Thank you for your comments. This is a problem of lack of class 
information during udaf serialization. When we deserialize udaf, we will try to 
load udaf function through class attribute[1].If we can't load 
SqlAggregateFunction correctly, there will be an exception when creating 
AggregateCall.
   
[1][RelJson#toOp](https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java#L680)
   





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:
us...@infra.apache.org




[GitHub] [calcite] xy2953396112 commented on a change in pull request #2021: [CALCITE-3929] When deserialize UDAF aggregate call from json string,…

2020-06-19 Thread GitBox


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



##
File path: core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
##
@@ -271,7 +271,9 @@ public RelDataType toType(RelDataTypeFactory typeFactory, 
Object o) {
 
   public Object toJson(AggregateCall node) {
 final Map map = jsonBuilder.map();
-map.put("agg", toJson(node.getAggregation()));
+Map aggMap = new HashMap(toJson(node.getAggregation()));
+aggMap.put("class", node.getAggregation().getClass().getName());

Review comment:
   Thank you for your comments. This is a problem of lack of class 
information during udaf serialization. When we deserialize udaf, we will try to 
load udaf function through class attribute[1].If we can't load 
SqlAggregateFunction correctly, there will be an exception when creating 
AggregateCall.
   
[[1]](https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java#L680)
   





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:
us...@infra.apache.org