[GitHub] [calcite] yanlin-Lynn commented on pull request #2030: minor, remove redundant code in "RelJson.toJson(RelDistribution)".

2020-06-27 Thread GitBox


yanlin-Lynn commented on pull request #2030:
URL: https://github.com/apache/calcite/pull/2030#issuecomment-650521380


   you are changing the code, worth a jira for this PR.



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




[calcite] branch master updated: [CALCITE-4062] Support deserialize UDF array type from json string (Xu Zhaohui)

2020-06-27 Thread yanlin
This is an automated email from the ASF dual-hosted git repository.

yanlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
 new d8e5590  [CALCITE-4062] Support deserialize UDF array type from json 
string (Xu Zhaohui)
d8e5590 is described below

commit d8e559093f22ee5eefdee5758296efe3683d765b
Author: xzh <953396...@qq.com>
AuthorDate: Fri Jun 12 15:56:35 2020 +0800

[CALCITE-4062] Support deserialize UDF array type from json string (Xu 
Zhaohui)
---
 .../org/apache/calcite/rel/externalize/RelJson.java  |  4 +++-
 .../java/org/apache/calcite/plan/RelWriterTest.java  | 18 ++
 .../apache/calcite/test/MockSqlOperatorTable.java| 20 
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java 
b/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
index f4cb62a..2c9a0ca 100644
--- a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
+++ b/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
@@ -252,7 +252,9 @@ public class RelJson {
   new SqlIntervalQualifier(startUnit, endUnit, SqlParserPos.ZERO));
 }
 final RelDataType type;
-if (precision == null) {
+if (sqlTypeName == SqlTypeName.ARRAY) {
+  type = 
typeFactory.createArrayType(typeFactory.createSqlType(SqlTypeName.ANY), -1);
+} else if (precision == null) {
   type = typeFactory.createSqlType(sqlTypeName);
 } else if (scale == null) {
   type = typeFactory.createSqlType(sqlTypeName, precision);
diff --git a/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java 
b/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
index a564ddd..55a3d58 100644
--- a/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
@@ -797,6 +797,24 @@ class RelWriterTest {
 assertThat(s, isLinux(expected));
   }
 
+  @Test void testArrayType() {
+final FrameworkConfig config = RelBuilderTest.config().build();
+final RelBuilder builder = RelBuilder.create(config);
+final RelNode rel = builder
+.scan("EMP")
+.project(
+builder.call(new MockSqlOperatorTable.SplitFunction(),
+builder.field("ENAME"), builder.literal(",")))
+.build();
+final String relJson = RelOptUtil.dumpPlan("", rel,
+SqlExplainFormat.JSON, SqlExplainLevel.EXPPLAN_ATTRIBUTES);
+final String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson);
+final String expected = ""
++ "LogicalProject($f0=[SPLIT($1, ',')])\n"
++ "  LogicalTableScan(table=[[scott, EMP]])\n";
+assertThat(s, isLinux(expected));
+  }
+
   /** Returns the schema of a {@link org.apache.calcite.rel.core.TableScan}
* in this plan, or null if there are no scans. */
   private RelOptSchema getSchema(RelNode rel) {
diff --git 
a/core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java 
b/core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java
index 0ba07bb..0c574a5 100644
--- a/core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java
+++ b/core/src/test/java/org/apache/calcite/test/MockSqlOperatorTable.java
@@ -125,6 +125,26 @@ public class MockSqlOperatorTable extends 
ChainedSqlOperatorTable {
 }
   }
 
+  /**
+   * "SPLIT" user-defined function. This function return array type
+   * in order to reproduce the throws of CALCITE-4062.
+   */
+  public static class SplitFunction extends SqlFunction {
+
+public SplitFunction() {
+  super("SPLIT", new SqlIdentifier("SPLIT", SqlParserPos.ZERO), 
SqlKind.OTHER_FUNCTION, null,
+  null, OperandTypes.family(SqlTypeFamily.STRING, 
SqlTypeFamily.STRING), null,
+  SqlFunctionCategory.USER_DEFINED_FUNCTION);
+}
+
+@Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) 
{
+  final RelDataTypeFactory typeFactory =
+  opBinding.getTypeFactory();
+  return 
typeFactory.createArrayType(typeFactory.createSqlType(SqlTypeName.VARCHAR), -1);
+}
+
+  }
+
   /** "MYAGG" user-defined aggregate function. This agg function accept two 
numeric arguments
* in order to reproduce the throws of CALCITE-2744. */
   public static class MyAvgAggFunction extends SqlAggFunction {



[GitHub] [calcite] yanlin-Lynn merged pull request #2022: [CALCITE-4062] Support deserialize UDF array type from json string

2020-06-27 Thread GitBox


yanlin-Lynn merged pull request #2022:
URL: https://github.com/apache/calcite/pull/2022


   



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] yanlin-Lynn commented on a change in pull request #2013: [CALCITE-3935] Materialization-Failed, when querying with LeftJoinWithFilter

2020-06-27 Thread GitBox


yanlin-Lynn commented on a change in pull request #2013:
URL: https://github.com/apache/calcite/pull/2013#discussion_r446513799



##
File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
##
@@ -2011,6 +2006,38 @@ public static boolean equalType(String desc0, MutableRel 
rel0, String desc1,
 return RelOptUtil.equal(desc0, rel0.rowType, desc1, rel1.rowType, litmus);
   }
 
+  /**
+   * Check filter bottom join can be pull-up,

Review comment:
   Check if filter under join can be pulled up





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] hsyuan commented on pull request #2035: [CALCITE-4008] Implement Code generation for EnumerableSortedAggregat…

2020-06-27 Thread GitBox


hsyuan commented on pull request #2035:
URL: https://github.com/apache/calcite/pull/2035#issuecomment-650560583


   @rubenada Thanks for your help.



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-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] hsyuan edited a comment on pull request #2035: [CALCITE-4008] Implement Code generation for EnumerableSortedAggregat…

2020-06-27 Thread GitBox


hsyuan edited a comment on pull request #2035:
URL: https://github.com/apache/calcite/pull/2035#issuecomment-650560583


   @rubenada Thanks for your help.
   As long as you approved on it, we are good to go.



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] yanlin-Lynn commented on a change in pull request #2013: [CALCITE-3935] Materialization-Failed, when querying with LeftJoinWithFilter

2020-06-27 Thread GitBox


yanlin-Lynn commented on a change in pull request #2013:
URL: https://github.com/apache/calcite/pull/2013#discussion_r446513643



##
File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
##
@@ -2011,6 +2006,38 @@ public static boolean equalType(String desc0, MutableRel 
rel0, String desc1,
 return RelOptUtil.equal(desc0, rel0.rowType, desc1, rel1.rowType, litmus);
   }
 
+  /**
+   * Check filter bottom join can be pull-up,
+   * when meeting JoinOnCalc of query unify to Join of target.
+   * Such as {@link JoinOnLeftCalcToJoinUnifyRule} 
+   * {@link JoinOnRightCalcToJoinUnifyRule} 
+   * {@link JoinOnCalcsToJoinUnifyRule} 
+   */
+  private static boolean canPullUpFilterBottomJoin(JoinRelType joinType,
+   RexNode leftFilterRexNode,
+   RexNode rightFilterRexNode) 
{

Review comment:
   we do not format like this





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




[calcite] branch master updated (d8e5590 -> da89b41)

2020-06-27 Thread chunwei
This is an automated email from the ASF dual-hosted git repository.

chunwei pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from d8e5590  [CALCITE-4062] Support deserialize UDF array type from json 
string (Xu Zhaohui)
 add da89b41  Site: Add Tencent and TBDS logo in powered-by image

No new revisions were added by this update.

Summary of changes:
 site/_docs/powered_by.md |   4 
 site/img/powered-by.png  | Bin 47813 -> 425710 bytes
 2 files changed, 4 insertions(+)



[GitHub] [calcite] chunweilei merged pull request #1964: Site: Add Tencent and TBDS logo in powered-by image

2020-06-27 Thread GitBox


chunweilei merged pull request #1964:
URL: https://github.com/apache/calcite/pull/1964


   



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] danny0405 closed pull request #1169: [CALCITE-2948] SqlToRelConverter generates complicated logical plan f…

2020-06-27 Thread GitBox


danny0405 closed pull request #1169:
URL: https://github.com/apache/calcite/pull/1169


   



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] liyafan82 commented on a change in pull request #2027: [CALCITE-4049] Improve the implementation of the shortest-path algorithm

2020-06-27 Thread GitBox


liyafan82 commented on a change in pull request #2027:
URL: https://github.com/apache/calcite/pull/2027#discussion_r446590442



##
File path: 
core/src/test/java/org/apache/calcite/util/graph/DirectedGraphTest.java
##
@@ -64,14 +64,21 @@
 g.addEdge("B", "D");
 assertEquals("[A, B, D]", shortestPath(g, "A", "D").toString());
 assertNull(shortestPath(g, "A", "E"), "There is no path from A to E");
-assertEquals("[]", shortestPath(g, "D", "D").toString());
+assertEquals("[D, C, D]", shortestPath(g, "D", "D").toString());

Review comment:
   Sounds reasonable. I have revised the code to include the empty path to 
itself.
   
   BTW, the empty path from node D to itself should be denoted "[D]"? as it 
helps to maintain the relation:
   
   pathLength == path.size() - 1





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] danny0405 closed pull request #1279: [CALCITE-3128] Joining two tables producing only NULLs will return 0 …

2020-06-27 Thread GitBox


danny0405 closed pull request #1279:
URL: https://github.com/apache/calcite/pull/1279


   



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] liyafan82 commented on a change in pull request #2027: [CALCITE-4049] Improve the implementation of the shortest-path algorithm

2020-06-27 Thread GitBox


liyafan82 commented on a change in pull request #2027:
URL: https://github.com/apache/calcite/pull/2027#discussion_r446590701



##
File path: core/src/main/java/org/apache/calcite/util/graph/Graphs.java
##
@@ -102,41 +99,28 @@ public int size() {
*/
   public static class FrozenGraph {
 private final DefaultDirectedGraph graph;
-private final Map, List> shortestPaths;
+private final Map, int[]> shortestDistances;
 
 /** Creates a frozen graph as a copy of another graph. */
 FrozenGraph(DefaultDirectedGraph graph,
-Map, List> shortestPaths) {
+Map, int[]> shortestDistances) {
   this.graph = graph;
-  this.shortestPaths = shortestPaths;
+  this.shortestDistances = shortestDistances;
 }
 
 /**
- * Returns an iterator of all paths between two nodes, shortest first.
+ * Returns an iterator of all paths between two nodes,
+ * in non-decreasing order of path lengths.

Review comment:
   Thanks a lot for your careful review.
   
   It seems there is a minor difference between increasing and non-decreasing 
order. A sequence is said to be in increasing order, if 
   
   ```
   a0 < a1 < ... < an
   ```
   
   It is said to be in non-decreasing order, if
   
   ```
   a0 <= a1 <= ... <= an
   ```
   
   For paths between two nodes in a graph, it is possible that there are 
multiple paths with the same length. So the sequence of path lengths should be 
in non-decreasing order. What do you think





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