[GitHub] [calcite] DonnyZone commented on a change in pull request #1849: [CALCITE-3815] Add missing SQL standard aggregate functions: EVERY, SO…

2020-03-12 Thread GitBox
DonnyZone commented on a change in pull request #1849: [CALCITE-3815] Add 
missing SQL standard aggregate functions: EVERY, SO…
URL: https://github.com/apache/calcite/pull/1849#discussion_r392051190
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/sql/SqlKind.java
 ##
 @@ -966,6 +966,9 @@
   /** The {@code FUSION} aggregate function. */
   FUSION,
 
+  /** The {@code INTERSECTION} aggregate function. */
+  INTERSECTION,
 
 Review comment:
   Please also add `INTERSECTION` in `AGGREGATE` EnumSet [1].
   
   [1] 
https://github.com/apache/calcite/blob/4c3cef95377ea16efca037012385c40822b4426e/core/src/main/java/org/apache/calcite/sql/SqlKind.java#L1159


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


With regards,
Apache Git Services


[GitHub] [calcite] DonnyZone commented on issue #1849: [CALCITE-3815] Add missing SQL standard aggregate functions: EVERY, SO…

2020-03-12 Thread GitBox
DonnyZone commented on issue #1849: [CALCITE-3815] Add missing SQL standard 
aggregate functions: EVERY, SO…
URL: https://github.com/apache/calcite/pull/1849#issuecomment-598573248
 
 
   LGTM, thanks for your work! @HanumathRao, could you please rebase and squash 
the commits. 


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


With regards,
Apache Git Services


[GitHub] [calcite] DonnyZone commented on a change in pull request #1849: [CALCITE-3815] Add missing SQL standard aggregate functions: EVERY, SO…

2020-03-12 Thread GitBox
DonnyZone commented on a change in pull request #1849: [CALCITE-3815] Add 
missing SQL standard aggregate functions: EVERY, SO…
URL: https://github.com/apache/calcite/pull/1849#discussion_r392051190
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/sql/SqlKind.java
 ##
 @@ -966,6 +966,9 @@
   /** The {@code FUSION} aggregate function. */
   FUSION,
 
+  /** The {@code INTERSECTION} aggregate function. */
+  INTERSECTION,
 
 Review comment:
   Please also add `INTERSECTION` in `AGGREGATE` EnumSet [1].
   
   
https://github.com/apache/calcite/blob/4c3cef95377ea16efca037012385c40822b4426e/core/src/main/java/org/apache/calcite/sql/SqlKind.java#L1159


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1811: [CALCITE-3789] Support validation of UNNEST multiple array columns like Presto

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1811: [CALCITE-3789] Support 
validation of UNNEST multiple array columns like Presto
URL: https://github.com/apache/calcite/pull/1811#discussion_r392047695
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/sql/SqlUnnestOperator.java
 ##
 @@ -97,6 +97,17 @@ public SqlUnnestOperator(boolean withOrdinality) {
 return builder.build();
   }
 
+  private boolean allowFlattenStruct(SqlOperatorBinding operatorBinding) {
+if (!(operatorBinding instanceof SqlCallBinding)) {
 
 Review comment:
   I know you only to support `SqlCallBinding` for unnest alias columns, but 
the logic seems weird, can you change
   `allowFlattenStruct` => `allowAliasUnnestColumns` ?


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1811: [CALCITE-3789] Support validation of UNNEST multiple array columns like Presto

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1811: [CALCITE-3789] Support 
validation of UNNEST multiple array columns like Presto
URL: https://github.com/apache/calcite/pull/1811#discussion_r392046603
 
 

 ##
 File path: 
core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderSimple.java
 ##
 @@ -155,6 +155,8 @@ public MockCatalogReaderSimple(RelDataTypeFactory 
typeFactory,
 deptNestedTable.addColumn("NAME", fixture.varchar10Type);
 deptNestedTable.addColumn("SKILL", fixture.skillRecordType);
 deptNestedTable.addColumn("EMPLOYEES", fixture.empListType);
+deptNestedTable.addColumn("ADMINS", fixture.varchar5ArrayType);
+deptNestedTable.addColumn("OFFICES", 
fixture.rectilinearPeekCoordMultisetType);
 
 Review comment:
   Do not modify existing table/schema to avoid introducing unnecessary change 
of plans.


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


With regards,
Apache Git Services


[calcite] branch master updated: [CALCITE-3856] Remove code to be removed before 1.23

2020-03-12 Thread danny0405
This is an automated email from the ASF dual-hosted git repository.

danny0405 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 4c3cef9  [CALCITE-3856] Remove code to be removed before 1.23
4c3cef9 is described below

commit 4c3cef95377ea16efca037012385c40822b4426e
Author: yuzhao.cyz 
AuthorDate: Thu Mar 12 16:48:10 2020 +0800

[CALCITE-3856] Remove code to be removed before 1.23
---
 .../org/apache/calcite/rel/core/RelFactories.java  | 79 +---
 .../apache/calcite/rel/logical/LogicalJoin.java| 30 
 .../apache/calcite/rel/logical/LogicalProject.java | 12 ---
 .../calcite/rel/logical/LogicalTableScan.java  |  6 --
 .../calcite/rel/rel2sql/RelToSqlConverter.java |  5 +-
 .../org/apache/calcite/rel/stream/StreamRules.java | 16 +++-
 .../apache/calcite/sql2rel/SqlToRelConverter.java  | 18 -
 .../apache/calcite/sql/parser/SqlParserTest.java   | 33 -
 .../org/apache/calcite/test/RelOptTestBase.java| 33 -
 .../apache/calcite/test/SqlToRelConverterTest.java |  7 --
 .../apache/calcite/test/SqlValidatorTestCase.java  | 86 --
 .../calcite/adapter/pig/PigRelFactories.java   |  6 --
 12 files changed, 18 insertions(+), 313 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java 
b/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java
index 55d3a9f..4d838e0 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/RelFactories.java
@@ -22,7 +22,6 @@ import org.apache.calcite.plan.Contexts;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptTable;
 import org.apache.calcite.plan.RelTraitSet;
-import org.apache.calcite.plan.ViewExpanders;
 import org.apache.calcite.rel.RelCollation;
 import org.apache.calcite.rel.RelDistribution;
 import org.apache.calcite.rel.RelNode;
@@ -49,7 +48,6 @@ import org.apache.calcite.rel.metadata.RelColumnMapping;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rex.RexLiteral;
 import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.schema.TranslatableTable;
 import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.tools.RelBuilder;
 import org.apache.calcite.tools.RelBuilderFactory;
@@ -162,12 +160,6 @@ public class RelFactories {
  */
 RelNode createProject(RelNode input, List hints,
 List childExprs, List fieldNames);
-
-@Deprecated // to be removed before 1.23
-default RelNode createProject(RelNode input,
-List childExprs, List fieldNames) {
-  return createProject(input, ImmutableList.of(), childExprs, fieldNames);
-}
   }
 
   /**
@@ -296,20 +288,6 @@ public class RelFactories {
 /** Creates an aggregate. */
 RelNode createAggregate(RelNode input, List hints, 
ImmutableBitSet groupSet,
 ImmutableList groupSets, List 
aggCalls);
-
-@Deprecated // to be removed before 1.23
-default RelNode createAggregate(RelNode input, ImmutableBitSet groupSet,
-ImmutableList groupSets, List 
aggCalls) {
-  return createAggregate(input, ImmutableList.of(), groupSet, groupSets, 
aggCalls);
-}
-
-@Deprecated // to be removed before 1.23
-default RelNode createAggregate(RelNode input, boolean indicator,
-ImmutableBitSet groupSet, ImmutableList groupSets,
-List aggCalls) {
-  Aggregate.checkIndicator(indicator);
-  return createAggregate(input, ImmutableList.of(), groupSet, groupSets, 
aggCalls);
-}
   }
 
   /**
@@ -386,22 +364,6 @@ public class RelFactories {
 RelNode createJoin(RelNode left, RelNode right, List hints,
 RexNode condition, Set variablesSet, JoinRelType 
joinType,
 boolean semiJoinDone);
-
-@Deprecated // to be removed before 1.23
-default RelNode createJoin(RelNode left, RelNode right, RexNode condition,
-Set variablesSet, JoinRelType joinType,
-boolean semiJoinDone) {
-  return createJoin(left, right, ImmutableList.of(), condition, 
variablesSet,
-  joinType, semiJoinDone);
-}
-
-@Deprecated // to be removed before 1.23
-default RelNode createJoin(RelNode left, RelNode right, RexNode condition,
-JoinRelType joinType, Set variablesStopped,
-boolean semiJoinDone) {
-  return createJoin(left, right, ImmutableList.of(), condition,
-  CorrelationId.setOf(variablesStopped), joinType, semiJoinDone);
-}
   }
 
   /**
@@ -479,8 +441,8 @@ public class RelFactories {
   private static class SemiJoinFactoryImpl implements SemiJoinFactory {
 public RelNode createSemiJoin(RelNode left, RelNode right,
 RexNode condition) {
-  return LogicalJoin.create(left, right, condition, ImmutableSet.of(), 
JoinRelType.SEMI,
-  false, ImmutableList.of());
+  return Logic

[GitHub] [calcite] danny0405 merged pull request #1856: [CALCITE-3856] Remove code to be removed before 1.23

2020-03-12 Thread GitBox
danny0405 merged pull request #1856: [CALCITE-3856] Remove code to be removed 
before 1.23
URL: https://github.com/apache/calcite/pull/1856
 
 
   


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


With regards,
Apache Git Services


[calcite] branch master updated: [CALCITE-3855] Supports snapshot on table with virtual columns during sql-to-rel conversion

2020-03-12 Thread danny0405
This is an automated email from the ASF dual-hosted git repository.

danny0405 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 b523007  [CALCITE-3855] Supports snapshot on table with virtual 
columns during sql-to-rel conversion
b523007 is described below

commit b5230070e5f495e2c5a7e4baa726a9f7a8877630
Author: yuzhao.cyz 
AuthorDate: Thu Mar 12 16:01:18 2020 +0800

[CALCITE-3855] Supports snapshot on table with virtual columns during 
sql-to-rel conversion

In SqlToRelConverter#convertTemporalTable, we actually should not assume
that the rel to snapshot is always a TableScan.
---
 .../apache/calcite/sql2rel/SqlToRelConverter.java  |  4 +-
 .../apache/calcite/test/SqlToRelConverterTest.java | 31 ++--
 .../test/catalog/MockCatalogReaderExtended.java|  6 ++-
 .../catalog/VirtualColumnsExpressionFactory.java   | 18 +++
 .../apache/calcite/test/SqlToRelConverterTest.xml  | 58 --
 5 files changed, 106 insertions(+), 11 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java 
b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index 783e981..f249643 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -47,7 +47,6 @@ import org.apache.calcite.rel.core.Project;
 import org.apache.calcite.rel.core.RelFactories;
 import org.apache.calcite.rel.core.Sample;
 import org.apache.calcite.rel.core.Sort;
-import org.apache.calcite.rel.core.TableScan;
 import org.apache.calcite.rel.core.Uncollect;
 import org.apache.calcite.rel.core.Values;
 import org.apache.calcite.rel.hint.HintStrategyTable;
@@ -2490,9 +2489,8 @@ public class SqlToRelConverter {
 // convert inner query, could be a table name or a derived table
 SqlNode expr = snapshot.getTableRef();
 convertFrom(bb, expr);
-final TableScan scan = (TableScan) bb.root;
 
-final RelNode snapshotRel = relBuilder.push(scan).snapshot(period).build();
+final RelNode snapshotRel = 
relBuilder.push(bb.root).snapshot(period).build();
 
 bb.setRoot(snapshotRel, false);
   }
diff --git 
a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
index dc133ea..ac78d1b 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -1121,13 +1121,20 @@ public class SqlToRelConverterTest extends 
SqlToRelTestBase {
 sql("select * from dept, lateral table(ramp(deptno))").ok();
   }
 
-  @Test public void testSnapshotOnTemporalTable() {
+  @Test public void testSnapshotOnTemporalTable1() {
 final String sql = "select * from products_temporal "
 + "for system_time as of TIMESTAMP '2011-01-02 00:00:00'";
 sql(sql).ok();
   }
 
-  @Test public void testJoinTemporalTableOnSpecificTime() {
+  @Test public void testSnapshotOnTemporalTable2() {
+// Test temporal table with virtual columns.
+final String sql = "select * from VIRTUALCOLUMNS.VC_T1 "
++ "for system_time as of TIMESTAMP '2011-01-02 00:00:00'";
+sql(sql).with(getExtendedTester()).ok();
+  }
+
+  @Test public void testJoinTemporalTableOnSpecificTime1() {
 final String sql = "select stream *\n"
 + "from orders,\n"
 + "  products_temporal for system_time as of\n"
@@ -1135,7 +1142,16 @@ public class SqlToRelConverterTest extends 
SqlToRelTestBase {
 sql(sql).ok();
   }
 
-  @Test public void testJoinTemporalTableOnColumnReference() {
+  @Test public void testJoinTemporalTableOnSpecificTime2() {
+// Test temporal table with virtual columns.
+final String sql = "select stream *\n"
++ "from orders,\n"
++ "  VIRTUALCOLUMNS.VC_T1 for system_time as of\n"
++ "TIMESTAMP '2011-01-02 00:00:00'";
+sql(sql).with(getExtendedTester()).ok();
+  }
+
+  @Test public void testJoinTemporalTableOnColumnReference1() {
 final String sql = "select stream *\n"
 + "from orders\n"
 + "join products_temporal for system_time as of orders.rowtime\n"
@@ -1143,6 +1159,15 @@ public class SqlToRelConverterTest extends 
SqlToRelTestBase {
 sql(sql).ok();
   }
 
+  @Test public void testJoinTemporalTableOnColumnReference2() {
+// Test temporal table with virtual columns.
+final String sql = "select stream *\n"
++ "from orders\n"
++ "join VIRTUALCOLUMNS.VC_T1 for system_time as of orders.rowtime\n"
++ "on orders.productid = VIRTUALCOLUMNS.VC_T1.a";
+sql(sql).with(getExtendedTester()).ok();
+  }
+
   /**
* Lateral join with temporal table, both snapshot's input scan
* and snapshot's period reference outer columns. Should not
diff --git 
a/core/src/test/java

[GitHub] [calcite] danny0405 merged pull request #1855: [CALCITE-3855] Supports snapshot on table with virtual columns during…

2020-03-12 Thread GitBox
danny0405 merged pull request #1855: [CALCITE-3855] Supports snapshot on table 
with virtual columns during…
URL: https://github.com/apache/calcite/pull/1855
 
 
   


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


With regards,
Apache Git Services


[GitHub] [calcite] ritesh-kapoor commented on a change in pull request #1733: [CALCITE-3679] Allow lambda expressions in SQL queries

2020-03-12 Thread GitBox
ritesh-kapoor commented on a change in pull request #1733: [CALCITE-3679] Allow 
lambda expressions in SQL queries
URL: https://github.com/apache/calcite/pull/1733#discussion_r391785810
 
 

 ##
 File path: 
core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
 ##
 @@ -4559,6 +4559,46 @@ private void checkNullOperand(SqlTester tester, String 
op) {
 });
   }
 
+  @Test public void testLambda() {
+tester.checkType("(a)->2+2*a", "LAMBDA NOT NULL");
+tester.checkType("(a,b)->a+b", "LAMBDA NOT NULL");
+tester.checkType("(a,b,c)->2*a+b+c", "LAMBDA NOT NULL");
+  }
+
+  @Test public void testMapFilterFunc() {
+final SqlTester tester = tester(SqlLibrary.MYSQL);
 
 Review comment:
   Added few more test cases


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


With regards,
Apache Git Services


[GitHub] [calcite] ritesh-kapoor commented on a change in pull request #1733: [CALCITE-3679] Allow lambda expressions in SQL queries

2020-03-12 Thread GitBox
ritesh-kapoor commented on a change in pull request #1733: [CALCITE-3679] Allow 
lambda expressions in SQL queries
URL: https://github.com/apache/calcite/pull/1733#discussion_r391718119
 
 

 ##
 File path: 
core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java
 ##
 @@ -271,7 +271,7 @@ protected static Connection getRemoteConnection() throws 
SQLException {
   @Test public void testRemoteTypeInfo() throws Exception {
 CalciteAssert.hr().with(REMOTE_CONNECTION_FACTORY)
 .metaData(GET_TYPEINFO)
-.returns(CalciteAssert.checkResultCount(is(45)));
+.returns(CalciteAssert.checkResultCount(is(46)));
   }
 
 Review comment:
   As LAMBDA Type is added, count is increased by 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


With regards,
Apache Git Services


[GitHub] [calcite] ritesh-kapoor commented on a change in pull request #1750: [CALCITE-3726] Allow declaring type objects

2020-03-12 Thread GitBox
ritesh-kapoor commented on a change in pull request #1750: [CALCITE-3726] Allow 
declaring type objects
URL: https://github.com/apache/calcite/pull/1750#discussion_r391715283
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/sql/SqlFunction.java
 ##
 @@ -291,13 +291,20 @@ private RelDataType deriveType(
 }
   }
 }
+
+// check if the identifier represents type
+final SqlFunction x = (SqlFunction) call.getOperator();
+final SqlIdentifier identifier = Util.first(x.getSqlIdentifier(),
+new SqlIdentifier(x.getName(), SqlParserPos.ZERO));
+RelDataType type = 
validator.getCatalogReader().getNamedType(identifier);
+if (type != null) {
+  function = new SqlTypeConstructorFunction(identifier, type);
+  break validCoercionType;
+}
+
 // if function doesn't exist within operator table and known function
 // handling is turned off then create a more permissive function
 if (function == null && validator.isLenientOperatorLookup()) {
-  final SqlFunction x = (SqlFunction) call.getOperator();
-  final SqlIdentifier identifier =
-  Util.first(x.getSqlIdentifier(),
-  new SqlIdentifier(x.getName(), SqlParserPos.ZERO));
   function = new SqlUnresolvedFunction(identifier, null,
 
 Review comment:
   Just refactored the code, moved it out of **if** block 


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


With regards,
Apache Git Services


[GitHub] [calcite] ritesh-kapoor commented on a change in pull request #1847: [CALCITE-3647] MySQL COMPRESS function support

2020-03-12 Thread GitBox
ritesh-kapoor commented on a change in pull request #1847: [CALCITE-3647] MySQL 
COMPRESS function support
URL: https://github.com/apache/calcite/pull/1847#discussion_r391701761
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/runtime/CompressionFunctions.java
 ##
 @@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.runtime;
+
+import org.apache.calcite.avatica.util.ByteString;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.Charset;
+import java.util.zip.DeflaterOutputStream;
+
+/**
+ * A collection of functions used in compression and decompression.
+ */
+public class CompressionFunctions {
+
+  private CompressionFunctions() {
+  }
+
+  public static ByteString compress(String data) {
+try {
+  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+  ByteBuffer dataLength = ByteBuffer.allocate(4);
+  dataLength.order(ByteOrder.LITTLE_ENDIAN);
+  dataLength.putInt(data.length());
+  outputStream.write(dataLength.array());
+  DeflaterOutputStream inflaterStream = new 
DeflaterOutputStream(outputStream);
+  inflaterStream.write(data.getBytes(Charset.defaultCharset()));
+  inflaterStream.close();
 
 Review comment:
   No problem :)


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


With regards,
Apache Git Services


[GitHub] [calcite] ritesh-kapoor commented on a change in pull request #1847: [CALCITE-3647] MySQL COMPRESS function support

2020-03-12 Thread GitBox
ritesh-kapoor commented on a change in pull request #1847: [CALCITE-3647] MySQL 
COMPRESS function support
URL: https://github.com/apache/calcite/pull/1847#discussion_r391701029
 
 

 ##
 File path: site/_docs/reference.md
 ##
 @@ -2320,6 +2320,7 @@ semantics.
 | o | CHR(integer) | Returns the character having the binary equivalent to 
*integer* as a CHAR value
 | o | COSH(numeric)  | Returns the hyperbolic 
cosine of *numeric*
 | m o p | CONCAT(string [, string ]*)| Concatenates two or 
more strings
+| m | COMPRESS(string)   | Compresses a string and 
returns the result as a binary string.
 | p | CONVERT_TIMEZONE(tz1, tz2, datetime)   | Converts the timezone 
of *datetime* from *tz1* to *tz2*
 
 Review comment:
   Done :)


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


With regards,
Apache Git Services


[calcite] branch master updated: [CALCITE-3853] Minor improvements in SortJoinCopyRule

2020-03-12 Thread rubenql
This is an automated email from the ASF dual-hosted git repository.

rubenql 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 bc2d7e1  [CALCITE-3853] Minor improvements in SortJoinCopyRule
bc2d7e1 is described below

commit bc2d7e1ce0ff0a2193df2ce6e59d5501766bbca5
Author: rubenada 
AuthorDate: Thu Mar 12 11:33:42 2020 +0100

[CALCITE-3853] Minor improvements in SortJoinCopyRule
---
 .../src/main/java/org/apache/calcite/rel/rules/SortJoinCopyRule.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/SortJoinCopyRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/SortJoinCopyRule.java
index 08c9974..ca9b4d5 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/SortJoinCopyRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/SortJoinCopyRule.java
@@ -26,6 +26,7 @@ import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Join;
 import org.apache.calcite.rel.core.RelFactories;
 import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.logical.LogicalJoin;
 import org.apache.calcite.rel.logical.LogicalSort;
 import org.apache.calcite.rel.metadata.RelMdUtil;
 import org.apache.calcite.rel.metadata.RelMetadataQuery;
@@ -51,12 +52,12 @@ public class SortJoinCopyRule extends RelOptRule {
 
   public static final SortJoinCopyRule INSTANCE =
   new SortJoinCopyRule(LogicalSort.class,
-  Join.class, RelFactories.LOGICAL_BUILDER);
+  LogicalJoin.class, RelFactories.LOGICAL_BUILDER);
 
   //~ Constructors ---
 
   /** Creates a SortJoinCopyRule. */
-  protected SortJoinCopyRule(Class sortClass,
+  public SortJoinCopyRule(Class sortClass,
   Class joinClass, RelBuilderFactory relBuilderFactory) {
 super(
 operand(sortClass,



[GitHub] [calcite] rubenada merged pull request #1857: [CALCITE-3853] Minor improvements in SortJoinCopyRule

2020-03-12 Thread GitBox
rubenada merged pull request #1857: [CALCITE-3853] Minor improvements in 
SortJoinCopyRule
URL: https://github.com/apache/calcite/pull/1857
 
 
   


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1856: [CALCITE-3856] Remove code to be removed before 1.23

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1856: [CALCITE-3856] Remove 
code to be removed before 1.23
URL: https://github.com/apache/calcite/pull/1856#discussion_r391475192
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/rel/logical/LogicalJoin.java
 ##
 @@ -170,36 +170,6 @@ public static LogicalJoin create(RelNode left, RelNode 
right, List hint
 variablesSet, joinType, semiJoinDone, systemFieldList);
   }
 
-  @Deprecated // to be removed before 1.23
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, Set variablesSet, JoinRelType 
joinType) {
-return create(left, right, ImmutableList.of(), condition, variablesSet,
-joinType, false, ImmutableList.of());
-  }
-
-  @Deprecated // to be removed before 1.23
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, Set variablesSet, JoinRelType joinType,
-  boolean semiJoinDone, ImmutableList systemFieldList) {
-return create(left, right, ImmutableList.of(), condition, variablesSet,
-joinType, semiJoinDone, systemFieldList);
-  }
-
-  @Deprecated // to be removed before 2.0
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, JoinRelType joinType, Set variablesStopped,
-  boolean semiJoinDone, ImmutableList systemFieldList) {
-return create(left, right, condition, 
CorrelationId.setOf(variablesStopped),
-joinType, semiJoinDone, systemFieldList);
-  }
-
-  @Deprecated // to be removed before 2.0
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, JoinRelType joinType, Set variablesStopped) {
 
 Review comment:
   These 2 create method are also removed, because i think the `create#` method 
is low frequency used API (usually we use the `RelBuilder`).


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


With regards,
Apache Git Services


[GitHub] [calcite] rubenada opened a new pull request #1857: [CALCITE-3853] Minor improvements in SortJoinCopyRule

2020-03-12 Thread GitBox
rubenada opened a new pull request #1857: [CALCITE-3853] Minor improvements in 
SortJoinCopyRule
URL: https://github.com/apache/calcite/pull/1857
 
 
   Jira: [CALCITE-3853](https://issues.apache.org/jira/browse/CALCITE-3853).
   
   Several improvements can be made on SortJoinCopyRule (introduced via 
CALCITE-2624):
   - The default INSTANCE currently matches LogicalSort + Join, which seems 
inconsistent, it should match LogicalSort + LogicalJoin
   - The constructor should be public, in order to allow clients to create 
their own version of the rule
   
   


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1847: [CALCITE-3647] MySQL COMPRESS function support

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1847: [CALCITE-3647] MySQL 
COMPRESS function support
URL: https://github.com/apache/calcite/pull/1847#discussion_r391483126
 
 

 ##
 File path: site/_docs/reference.md
 ##
 @@ -2320,6 +2320,7 @@ semantics.
 | o | CHR(integer) | Returns the character having the binary equivalent to 
*integer* as a CHAR value
 | o | COSH(numeric)  | Returns the hyperbolic 
cosine of *numeric*
 | m o p | CONCAT(string [, string ]*)| Concatenates two or 
more strings
+| m | COMPRESS(string)   | Compresses a string and 
returns the result as a binary string.
 | p | CONVERT_TIMEZONE(tz1, tz2, datetime)   | Converts the timezone 
of *datetime* from *tz1* to *tz2*
 
 Review comment:
   Can we specify the compress algorithm in the doc, e.g. the zlib.


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1847: [CALCITE-3647] MySQL COMPRESS function support

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1847: [CALCITE-3647] MySQL 
COMPRESS function support
URL: https://github.com/apache/calcite/pull/1847#discussion_r391482267
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/runtime/CompressionFunctions.java
 ##
 @@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.runtime;
+
+import org.apache.calcite.avatica.util.ByteString;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.Charset;
+import java.util.zip.DeflaterOutputStream;
+
+/**
+ * A collection of functions used in compression and decompression.
+ */
+public class CompressionFunctions {
+
+  private CompressionFunctions() {
+  }
+
+  public static ByteString compress(String data) {
 
 Review comment:
   Thanks @XuQianJin-Stars for the doc, it seems that the page you reference 
here is about the system variables of MySQL server, not the `COMPRESS` 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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1847: [CALCITE-3647] MySQL COMPRESS function support

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1847: [CALCITE-3647] MySQL 
COMPRESS function support
URL: https://github.com/apache/calcite/pull/1847#discussion_r391480780
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/runtime/CompressionFunctions.java
 ##
 @@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.runtime;
+
+import org.apache.calcite.avatica.util.ByteString;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.Charset;
+import java.util.zip.DeflaterOutputStream;
+
+/**
+ * A collection of functions used in compression and decompression.
+ */
+public class CompressionFunctions {
+
+  private CompressionFunctions() {
+  }
+
+  public static ByteString compress(String data) {
+try {
+  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+  ByteBuffer dataLength = ByteBuffer.allocate(4);
+  dataLength.order(ByteOrder.LITTLE_ENDIAN);
+  dataLength.putInt(data.length());
+  outputStream.write(dataLength.array());
+  DeflaterOutputStream inflaterStream = new 
DeflaterOutputStream(outputStream);
+  inflaterStream.write(data.getBytes(Charset.defaultCharset()));
+  inflaterStream.close();
 
 Review comment:
   My fault, i didn't notice that there is a `DeflaterOutputStream`.


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1855: [CALCITE-3855] Supports snapshot on table with virtual columns during…

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1855: [CALCITE-3855] Supports 
snapshot on table with virtual columns during…
URL: https://github.com/apache/calcite/pull/1855#discussion_r391476299
 
 

 ##
 File path: 
core/src/test/java/org/apache/calcite/test/catalog/VirtualColumnsExpressionFactory.java
 ##
 @@ -32,4 +36,17 @@
   return super.generationStrategy(table, iColumn);
 }
   }
+
+  @Override public RexNode newColumnDefaultValue(
+  RelOptTable table, int iColumn, InitializerContext context) {
+if(iColumn == 4) {
 
 Review comment:
   Yep, thanks for the reminder ~


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 commented on a change in pull request #1856: [CALCITE-3856] Remove code to be removed before 1.23

2020-03-12 Thread GitBox
danny0405 commented on a change in pull request #1856: [CALCITE-3856] Remove 
code to be removed before 1.23
URL: https://github.com/apache/calcite/pull/1856#discussion_r391475192
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/rel/logical/LogicalJoin.java
 ##
 @@ -170,36 +170,6 @@ public static LogicalJoin create(RelNode left, RelNode 
right, List hint
 variablesSet, joinType, semiJoinDone, systemFieldList);
   }
 
-  @Deprecated // to be removed before 1.23
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, Set variablesSet, JoinRelType 
joinType) {
-return create(left, right, ImmutableList.of(), condition, variablesSet,
-joinType, false, ImmutableList.of());
-  }
-
-  @Deprecated // to be removed before 1.23
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, Set variablesSet, JoinRelType joinType,
-  boolean semiJoinDone, ImmutableList systemFieldList) {
-return create(left, right, ImmutableList.of(), condition, variablesSet,
-joinType, semiJoinDone, systemFieldList);
-  }
-
-  @Deprecated // to be removed before 2.0
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, JoinRelType joinType, Set variablesStopped,
-  boolean semiJoinDone, ImmutableList systemFieldList) {
-return create(left, right, condition, 
CorrelationId.setOf(variablesStopped),
-joinType, semiJoinDone, systemFieldList);
-  }
-
-  @Deprecated // to be removed before 2.0
-  public static LogicalJoin create(RelNode left, RelNode right,
-  RexNode condition, JoinRelType joinType, Set variablesStopped) {
 
 Review comment:
   These 2 create method are also removed, because i think the `create#` method 
is low frequency used API (usuallu we use the `RelBuilder`).


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 opened a new pull request #1856: [CALCITE-3856] Remove code to be removed before 1.23

2020-03-12 Thread GitBox
danny0405 opened a new pull request #1856: [CALCITE-3856] Remove code to be 
removed before 1.23
URL: https://github.com/apache/calcite/pull/1856
 
 
   


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


With regards,
Apache Git Services


[GitHub] [calcite] DonnyZone commented on a change in pull request #1855: [CALCITE-3855] Supports snapshot on table with virtual columns during…

2020-03-12 Thread GitBox
DonnyZone commented on a change in pull request #1855: [CALCITE-3855] Supports 
snapshot on table with virtual columns during…
URL: https://github.com/apache/calcite/pull/1855#discussion_r391466342
 
 

 ##
 File path: 
core/src/test/java/org/apache/calcite/test/catalog/VirtualColumnsExpressionFactory.java
 ##
 @@ -32,4 +36,17 @@
   return super.generationStrategy(table, iColumn);
 }
   }
+
+  @Override public RexNode newColumnDefaultValue(
+  RelOptTable table, int iColumn, InitializerContext context) {
+if(iColumn == 4) {
 
 Review comment:
   Checkstyle fails on "if (...)"


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


With regards,
Apache Git Services


[GitHub] [calcite] cshuo commented on issue #1855: [CALCITE-3855] Supports snapshot on table with virtual columns during…

2020-03-12 Thread GitBox
cshuo commented on issue #1855: [CALCITE-3855] Supports snapshot on table with 
virtual columns during…
URL: https://github.com/apache/calcite/pull/1855#issuecomment-598061257
 
 
   LGTM, Thanks Danny for fixing this bug! 


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


With regards,
Apache Git Services


[GitHub] [calcite] danny0405 opened a new pull request #1855: [CALCITE-3855] Supports snapshot on table with virtual columns during…

2020-03-12 Thread GitBox
danny0405 opened a new pull request #1855: [CALCITE-3855] Supports snapshot on 
table with virtual columns during…
URL: https://github.com/apache/calcite/pull/1855
 
 
   … sql-to-rel conversion
   
   In SqlToRelConverter#convertTemporalTable, we actually should not assume
   that the rel to snapshot is always a TableScan.


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


With regards,
Apache Git Services


[GitHub] [calcite] XuQianJin-Stars commented on a change in pull request #1847: [CALCITE-3647] MySQL COMPRESS function support

2020-03-12 Thread GitBox
XuQianJin-Stars commented on a change in pull request #1847: [CALCITE-3647] 
MySQL COMPRESS function support
URL: https://github.com/apache/calcite/pull/1847#discussion_r391442945
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/runtime/CompressionFunctions.java
 ##
 @@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.runtime;
+
+import org.apache.calcite.avatica.util.ByteString;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.Charset;
+import java.util.zip.DeflaterOutputStream;
+
+/**
+ * A collection of functions used in compression and decompression.
+ */
+public class CompressionFunctions {
+
+  private CompressionFunctions() {
+  }
+
+  public static ByteString compress(String data) {
 
 Review comment:
   @ritesh-kapoor @DonnyZone @danny0405 Regarding compression algorithm 
support, I also noticed that Mysql8 provides the following support.
   
   > The compression algorithms that the server permits for incoming 
connections. These include connections by client programs and by servers 
participating in master/slave replication or Group Replication. Compression 
does not apply to connections for FEDERATED tables.
   
   > protocol_compression_algorithms does not control connection compression 
for X Protocol. See Section 20.5.5, “Connection Compression with X Plugin” for 
information on how this operates.
   
   > The variable value is a list of one or more comma-separated compression 
algorithm names, in any order, chosen from the following items (not 
case-sensitive):
   
   > zlib: Permit connections that use the zlib compression algorithm.
   
   > zstd: Permit connections that use the zstd compression algorithm (zstd 
1.3).
   
   > uncompressed: Permit uncompressed connections. If this algorithm name is 
not included in the protocol_compression_algorithms value, the server does not 
permit uncompressed connections. It permits only compressed connections that 
use whichever other algorithms are specified in the value, and there is no 
fallback to uncompressed connections.
   
   > The default value of zlib,zstd,uncompressed indicates that the server 
permits all compression algorithms.
   

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_protocol_compression_algorithms


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


With regards,
Apache Git Services