[GitHub] [calcite] tjbanghart commented on pull request #2973: [CALCITE-5180] Implement some of the overloads for BigQuery's DATE and TIMESTAMP

2022-11-17 Thread GitBox


tjbanghart commented on PR #2973:
URL: https://github.com/apache/calcite/pull/2973#issuecomment-1319499323

   Wouldn't `DATETIME` map to Calcite's interpretation of a `TIMESTAMP` due to 
the lack of TZ info?
   
   Also, should we move this into the core parser? I don't feel strongly either 
way (or if it matters all that much) but the BQ style literals and some 
functions live in core already.
   
   Otherwise, LGTM and a great example for adding other functions.


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

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

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



[calcite] branch main updated: [CALCITE-5239] Site: JDBC Adapter's current limitations is incorrect

2022-11-17 Thread jbalint
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new dc56fcc912 [CALCITE-5239] Site: JDBC Adapter's current limitations is 
incorrect
dc56fcc912 is described below

commit dc56fcc912261a09021a74f13de35b426f3d0d8b
Author: Benchao Li 
AuthorDate: Wed Aug 17 15:46:36 2022 +0800

[CALCITE-5239] Site: JDBC Adapter's current limitations is incorrect
---
 site/_docs/tutorial.md | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/site/_docs/tutorial.md b/site/_docs/tutorial.md
index bf9f23acb2..01a3ea87dc 100644
--- a/site/_docs/tutorial.md
+++ b/site/_docs/tutorial.md
@@ -573,7 +573,7 @@ public class CsvProjectTableScanRule
   return new CsvProjectTableScanRule(this);
 }
   }
-} 
+}
 {% endhighlight %}
 
 The default instance of the rule resides in the `CsvRules` holder class:
@@ -665,9 +665,7 @@ set. To load the data set, follow https://mondrian.pentaho.com/documentation/installation.php#2_Set_up_test_data";>Mondrian's
 installation instructions.)
 
-Current limitations: The JDBC adapter currently only pushes
-down table scan operations; all other processing (filtering, joins,
-aggregations and so forth) occurs within Calcite. Our goal is to push
+The JDBC adapter will push
 down as much processing as possible to the source system, translating
 syntax, data types and built-in functions as we go. If a Calcite query
 is based on tables from a single JDBC database, in principle the whole



[GitHub] [calcite] jbalint merged pull request #2874: [CALCITE-5239] Site: JDBC Adapter's current limitations is incorrect

2022-11-17 Thread GitBox


jbalint merged PR #2874:
URL: https://github.com/apache/calcite/pull/2874


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

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

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



[GitHub] [calcite] wnob commented on pull request #2973: [CALCITE-5180] Implement some of the overloads for BigQuery's DATE and TIMESTAMP

2022-11-17 Thread GitBox


wnob commented on PR #2973:
URL: https://github.com/apache/calcite/pull/2973#issuecomment-1319428833

   I've now implemented all the overloads that do not involve `DATETIME` 
objects. I'm not sure what is the best way to proceed with these because there 
doesn't seem to be a good fit in standard SQL to act as an alias. 
`TIMESTAMP_WITH_LOCAL_TIME_ZONE` is not a great fit; it has an implied time 
zone, whereas a `DATETIME` has no time zone at all.
   
   It's not necessary for MVP since we don't yet support `DATETIME` at all, so 
I'm inclined to punt on this for now.


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

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

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



[GitHub] [calcite] wnob commented on a diff in pull request #2973: [CALCITE-5180] Implement some of the overloads for BigQuery's DATE and TIMESTAMP

2022-11-17 Thread GitBox


wnob commented on code in PR #2973:
URL: https://github.com/apache/calcite/pull/2973#discussion_r1025778875


##
babel/src/main/codegen/includes/parserImpls.ftl:
##
@@ -42,6 +42,26 @@ SqlNode DateFunctionCall() :
 }
 }
 
+SqlNode TimestampFunctionCall() :

Review Comment:
   Here's my understanding: Babel is the "universal" parser ¹ that does not 
understand the semantics of individual dialects (hence the name). 
Dialect-specific semantic validation is a separate step that occurs after 
dialect-agnostic parsing.
   
   This is a [FreeMarker template file][1]. It does not contain any 
interpolation or tags, so running this through FreeMarker would simply remove 
the license comment at the top of the file. It's processed by [FMPP][2] in 
`config.fmpp` [here][3], which is in-turn referenced in the [JavaCC][4] grammar 
[here][5], as well as [here][6] via the `builtinFunctionCallMethods` list where 
the function name was added above in `config.fmpp`.
   
   Together, these 2 additions to the grammar indicate that there is a 
*production* called `TimestampFunctionCall` which consists of the 
[`` token][7] followed by a [`FunctionParameterList`][8] production, 
which consists of left-parenthesis, comma-separated arguments, 
right-parenthesis. The parser does nothing to validate how many arguments there 
are or what types they are.
   
   So yes, long story short, you're right that we didn't have to modify the 
`DateFunctionCall` production because it's just a function call either way, and 
I just added this new production with a different name token but which is 
otherwise identical to the `DATE` one.
   
   ¹ I've heard Julian make reference to other parsers being potentially usable 
with Calcite but I don't know of any examples.
   
   [1]: https://freemarker.apache.org/docs/dgui_template_overallstructure.html
   [2]: https://fmpp.sourceforge.net/index.html
   [3]: 
https://github.com/apache/calcite/blob/a505b25eacc473c6ec0ef8abd40c1ccae86297b6/babel/src/main/codegen/config.fmpp#L566
   [4]: https://javacc.github.io/javacc/
   [5]: 
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L1163
   [6]: 
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L5992
   [7]: 
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L7922
   [8]: 
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L948
   



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

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

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



[calcite-avatica] branch main updated (00c60533d -> 1eb58d95a)

2022-11-17 Thread snuyanzin
This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/calcite-avatica.git


from 00c60533d [CALCITE-5373] Upgrade bouncycastle to 1.70
 add 1eb58d95a [CALCITE-5379] Upgrade protobuf to 3.21.9

No new revisions were added by this update.

Summary of changes:
 gradle.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[GitHub] [calcite-avatica] snuyanzin merged pull request #196: [CALCITE-5379] Upgrade protobuf to 3.21.9

2022-11-17 Thread GitBox


snuyanzin merged PR #196:
URL: https://github.com/apache/calcite-avatica/pull/196


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

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

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



[calcite] branch CALCITE-5209 created (now dffd907222)

2022-11-17 Thread dmsysolyatin
This is an automated email from the ASF dual-hosted git repository.

dmsysolyatin pushed a change to branch CALCITE-5209
in repository https://gitbox.apache.org/repos/asf/calcite.git


  at dffd907222 [CALCITE-5209] ArrayIndexOutOfBoundsException during 
SqlToRelConverter for group-by on `case` having `in` expression predicates 
exceeding SqlRelConverter.Config InSubQueryThreshold

This branch includes the following new commits:

 new dffd907222 [CALCITE-5209] ArrayIndexOutOfBoundsException during 
SqlToRelConverter for group-by on `case` having `in` expression predicates 
exceeding SqlRelConverter.Config InSubQueryThreshold

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[calcite] 01/01: [CALCITE-5209] ArrayIndexOutOfBoundsException during SqlToRelConverter for group-by on `case` having `in` expression predicates exceeding SqlRelConverter.Config InSubQueryThreshold

2022-11-17 Thread dmsysolyatin
This is an automated email from the ASF dual-hosted git repository.

dmsysolyatin pushed a commit to branch CALCITE-5209
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit dffd907222c1afca9a971ea5b712b6d0d3c3f30a
Author: dssysolyatin 
AuthorDate: Tue Nov 15 16:41:38 2022 +0200

[CALCITE-5209] ArrayIndexOutOfBoundsException during SqlToRelConverter for 
group-by on `case` having `in` expression predicates exceeding 
SqlRelConverter.Config InSubQueryThreshold
---
 .../apache/calcite/sql2rel/SqlToRelConverter.java  | 64 ++
 core/src/test/resources/sql/agg.iq | 34 
 2 files changed, 75 insertions(+), 23 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 1e5a9ab8aa..948d2bbd50 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -71,6 +71,7 @@ import org.apache.calcite.rel.logical.LogicalUnion;
 import org.apache.calcite.rel.logical.LogicalValues;
 import org.apache.calcite.rel.metadata.RelColumnMapping;
 import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rel.rel2sql.SqlImplementor;
 import org.apache.calcite.rel.stream.Delta;
 import org.apache.calcite.rel.stream.LogicalDelta;
 import org.apache.calcite.rel.type.RelDataType;
@@ -1136,7 +1137,15 @@ public class SqlToRelConverter {
   final Blackboard bb,
   final SqlNode expr,
   RelOptUtil.Logic logic) {
-findSubQueries(bb, expr, logic, false);
+replaceSubQueries(bb, expr, logic, null);
+  }
+
+  private void replaceSubQueries(
+  final Blackboard bb,
+  final SqlNode expr,
+  RelOptUtil.Logic logic,
+  final SqlImplementor.@Nullable Clause parentClause) {
+findSubQueries(bb, expr, logic, false, parentClause);
 for (SubQuery node : bb.subQueryList) {
   substituteSubQuery(bb, node);
 }
@@ -2018,12 +2027,14 @@ public class SqlToRelConverter {
* corresponds to a variation of a select
* node, only register it if it's a 
scalar
* sub-query
+   * @param parentClause A clause inside which sub-query is searched
*/
   private void findSubQueries(
   Blackboard bb,
   SqlNode node,
   RelOptUtil.Logic logic,
-  boolean registerOnlyScalarSubQueries) {
+  boolean registerOnlyScalarSubQueries,
+  SqlImplementor.@Nullable Clause parentClause) {
 final SqlKind kind = node.getKind();
 switch (kind) {
 case EXISTS:
@@ -2038,7 +2049,7 @@ public class SqlToRelConverter {
 case SCALAR_QUERY:
   if (!registerOnlyScalarSubQueries
   || (kind == SqlKind.SCALAR_QUERY)) {
-bb.registerSubQuery(node, RelOptUtil.Logic.TRUE_FALSE);
+bb.registerSubQuery(node, RelOptUtil.Logic.TRUE_FALSE, parentClause);
   }
   return;
 case IN:
@@ -2070,7 +2081,7 @@ public class SqlToRelConverter {
   findSubQueries(bb, operand, logic,
   kind == SqlKind.IN || kind == SqlKind.NOT_IN
   || kind == SqlKind.SOME || kind == SqlKind.ALL
-  || registerOnlyScalarSubQueries);
+  || registerOnlyScalarSubQueries, parentClause);
 }
   }
 } else if (node instanceof SqlNodeList) {
@@ -2078,7 +2089,7 @@ public class SqlToRelConverter {
 findSubQueries(bb, child, logic,
 kind == SqlKind.IN || kind == SqlKind.NOT_IN
 || kind == SqlKind.SOME || kind == SqlKind.ALL
-|| registerOnlyScalarSubQueries);
+|| registerOnlyScalarSubQueries, parentClause);
   }
 }
 
@@ -2107,7 +2118,7 @@ public class SqlToRelConverter {
   default:
 break;
   }
-  bb.registerSubQuery(node, logic);
+  bb.registerSubQuery(node, logic, parentClause);
   break;
 default:
   break;
@@ -3376,13 +3387,13 @@ public class SqlToRelConverter {
 // also replace sub-queries inside ordering spec in the aggregates
 replaceSubQueries(bb, aggregateFinder.orderList,
 RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
-
 // If group-by clause is missing, pretend that it has zero elements.
 if (groupList == null) {
   groupList = SqlNodeList.EMPTY;
 }
 
-replaceSubQueries(bb, groupList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
+replaceSubQueries(bb, groupList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN, 
+SqlImplementor.Clause.GROUP_BY);
 
 // register the group exprs
 
@@ -3474,7 +3485,8 @@ public class SqlToRelConverter {
   // This needs to be done separately from the sub-query inside
   // any aggregate in the select list, and after the aggregate rel
   // is allocated.
-  replaceSubQueries(bb, selectList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
+