Skip to content

Commit a822937

Browse files
committed
[Test only] Vendor Calcite 1.40
1 parent 204c0a1 commit a822937

12 files changed

Lines changed: 219 additions & 20 deletions

File tree

sdks/java/extensions/sql/src/main/codegen/config.fmpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ data: {
2525
"org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.sql.SqlCreate"
2626
"org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.sql.SqlDrop"
2727
"org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.sql.type.SqlTypeName"
28+
"org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.util.NlsString"
2829
"org.apache.beam.sdk.extensions.sql.impl.parser.SqlCreateCatalog"
2930
"org.apache.beam.sdk.extensions.sql.impl.parser.SqlCreateExternalTable"
3031
"org.apache.beam.sdk.extensions.sql.impl.parser.SqlCreateFunction"
@@ -61,6 +62,8 @@ data: {
6162
"AFTER"
6263
"ALWAYS"
6364
"APPLY"
65+
"ARRAY_AGG"
66+
"ARRAY_CONCAT_AGG"
6467
"ASC"
6568
"ASSERTION"
6669
"ASSIGNMENT"
@@ -99,12 +102,19 @@ data: {
99102
"CONSTRAINTS"
100103
"CONSTRAINT_SCHEMA"
101104
"CONSTRUCTOR"
105+
"CONTAINS_SUBSTR"
102106
"CONTINUE"
103107
"CURSOR_NAME"
104108
"DATA"
105109
"DATABASE"
110+
"DATE_DIFF"
111+
"DATE_TRUNC"
112+
"DATETIME_DIFF"
106113
"DATETIME_INTERVAL_CODE"
107114
"DATETIME_INTERVAL_PRECISION"
115+
"DATETIME_TRUNC"
116+
"DAYOFWEEK"
117+
"DAYOFYEAR"
108118
"DAYS"
109119
"DECADE"
110120
"DEFAULTS"
@@ -123,6 +133,7 @@ data: {
123133
"DOMAIN"
124134
"DOW"
125135
"DOY"
136+
"DOT_FORMAT"
126137
"DYNAMIC_FUNCTION"
127138
"DYNAMIC_FUNCTION_CODE"
128139
"ENCODING"
@@ -145,13 +156,16 @@ data: {
145156
"GO"
146157
"GOTO"
147158
"GRANTED"
159+
"GROUP_CONCAT"
148160
"HIERARCHY"
149161
"HOP"
150162
"HOURS"
151163
"IGNORE"
164+
"ILIKE"
152165
"IMMEDIATE"
153166
"IMMEDIATELY"
154167
"IMPLEMENTATION"
168+
"INCLUDE"
155169
"INCLUDING"
156170
"INCREMENT"
157171
"INITIALLY"
@@ -219,6 +233,7 @@ data: {
219233
"PASSTHROUGH"
220234
"PAST"
221235
"PATH"
236+
"PIVOT"
222237
"PLACING"
223238
"PLAN"
224239
"PLI"
@@ -228,6 +243,7 @@ data: {
228243
"PRIVILEGES"
229244
"PUBLIC"
230245
"QUARTER"
246+
"QUARTERS"
231247
"READ"
232248
"RELATIVE"
233249
"REPEATABLE"
@@ -240,6 +256,7 @@ data: {
240256
"RETURNED_OCTET_LENGTH"
241257
"RETURNED_SQLSTATE"
242258
"RETURNING"
259+
"RLIKE"
243260
"ROLE"
244261
"ROUTINE"
245262
"ROUTINE_CATALOG"
@@ -257,6 +274,7 @@ data: {
257274
"SECTION"
258275
"SECURITY"
259276
"SELF"
277+
"SEPARATOR"
260278
"SEQUENCE"
261279
"SERIALIZABLE"
262280
"SERVER"
@@ -319,15 +337,20 @@ data: {
319337
"SQL_VARCHAR"
320338
"STATE"
321339
"STATEMENT"
340+
"STRING_AGG"
322341
"STRUCTURE"
323342
"STYLE"
324343
"SUBCLASS_ORIGIN"
325344
"SUBSTITUTE"
326345
"TABLE_NAME"
327346
"TEMPORARY"
328347
"TIES"
348+
"TIME_DIFF"
349+
"TIME_TRUNC"
329350
"TIMESTAMPADD"
330351
"TIMESTAMPDIFF"
352+
"TIMESTAMP_DIFF"
353+
"TIMESTAMP_TRUNC"
331354
"TOP_LEVEL_COUNT"
332355
"TRANSACTION"
333356
"TRANSACTIONS_ACTIVE"
@@ -344,6 +367,7 @@ data: {
344367
"UNCOMMITTED"
345368
"UNCONDITIONAL"
346369
"UNDER"
370+
"UNPIVOT"
347371
"UNNAMED"
348372
"USAGE"
349373
"USER_DEFINED_TYPE_CATALOG"
@@ -356,6 +380,7 @@ data: {
356380
"VERSION"
357381
"VIEW"
358382
"WEEK"
383+
"WEEKS"
359384
"WORK"
360385
"WRAPPER"
361386
"WRITE"
@@ -439,6 +464,12 @@ data: {
439464
"SqlDropCatalog"
440465
]
441466

467+
# List of methods for parsing extensions to "TRUNCATE" calls.
468+
# Each must accept arguments "(SqlParserPos pos)".
469+
# Example: "SqlTruncate".
470+
truncateStatementParserMethods: [
471+
]
472+
442473
# Binary operators tokens
443474
binaryOperatorsTokens: [
444475
]
@@ -455,11 +486,12 @@ data: {
455486
"parserImpls.ftl"
456487
]
457488

489+
setOptionParserMethod: "SqlSetOption"
458490
includePosixOperators: false
459491
includeCompoundIdentifier: true
460492
includeBraces: true
461493
includeAdditionalDeclarations: false
462-
494+
includeParsingStringLiteralAsArrayLiteral: false
463495
}
464496
}
465497

sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/CalciteConnectionWrapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.linq4j.Queryable;
4444
import org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.linq4j.tree.Expression;
4545
import org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.schema.SchemaPlus;
46+
import org.checkerframework.checker.nullness.qual.Nullable;
4647

4748
/**
4849
* Abstract wrapper for {@link CalciteConnection} to simplify extension.
@@ -333,8 +334,10 @@ public void setSchema(String schema) throws SQLException {
333334
connection.setSchema(schema);
334335
}
335336

337+
// CalciteConnection.getSchema() marked nullable but Connection.getSchema() does not
338+
@SuppressWarnings("override.return")
336339
@Override
337-
public String getSchema() throws SQLException {
340+
public @Nullable String getSchema() throws SQLException {
338341
return connection.getSchema();
339342
}
340343

sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/CalciteQueryPlanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public RelOptCost getNonCumulativeCost(RelNode rel, RelMetadataQuery mq) {
249249
// here and based on the design we also need to remove the cached values
250250

251251
// We need to first remove the cached values.
252-
List<Table.Cell<RelNode, List, Object>> costKeys =
252+
List<Table.Cell<RelNode, ?, Object>> costKeys =
253253
bmq.map.cellSet().stream()
254254
.filter(entry -> entry.getValue() instanceof BeamCostModel)
255255
.filter(entry -> ((BeamCostModel) entry.getValue()).isInfinite())

sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/planner/RelMdNodeStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private NodeStats getBeamNodeStats(BeamRelNode rel, BeamRelMetadataQuery mq) {
7575
// wraps the metadata provider with CachingRelMetadataProvider. However,
7676
// CachingRelMetadataProvider checks timestamp before returning previous results. Therefore,
7777
// there wouldn't be a problem in that case.
78-
List<Table.Cell<RelNode, List, Object>> keys =
78+
List<Table.Cell<RelNode, ?, Object>> keys =
7979
mq.map.cellSet().stream()
8080
.filter(entry -> entry != null)
8181
.filter(entry -> entry.getValue() != null)

sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamIOSinkRel.java

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public BeamIOSinkRel(
6363
boolean flattened,
6464
BeamSqlTable sqlTable,
6565
Map<String, String> pipelineOptions) {
66-
super(
66+
this(
6767
cluster,
6868
cluster.traitSetOf(BeamLogicalConvention.INSTANCE),
6969
table,
@@ -72,6 +72,33 @@ public BeamIOSinkRel(
7272
operation,
7373
updateColumnList,
7474
sourceExpressionList,
75+
flattened,
76+
sqlTable,
77+
pipelineOptions);
78+
}
79+
80+
/** For copy. */
81+
private BeamIOSinkRel(
82+
RelOptCluster cluster,
83+
RelTraitSet traitSet,
84+
RelOptTable table,
85+
Prepare.CatalogReader catalogReader,
86+
RelNode child,
87+
Operation operation,
88+
@Nullable List<String> updateColumnList,
89+
@Nullable List<RexNode> sourceExpressionList,
90+
boolean flattened,
91+
BeamSqlTable sqlTable,
92+
Map<String, String> pipelineOptions) {
93+
super(
94+
cluster,
95+
traitSet,
96+
table,
97+
catalogReader,
98+
child,
99+
operation,
100+
updateColumnList,
101+
sourceExpressionList,
75102
flattened);
76103
this.sqlTable = sqlTable;
77104
this.pipelineOptions = pipelineOptions;
@@ -91,20 +118,18 @@ public BeamCostModel beamComputeSelfCost(RelOptPlanner planner, BeamRelMetadataQ
91118
@Override
92119
public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) {
93120
boolean flattened = isFlattened() || isFlattening;
94-
BeamIOSinkRel newRel =
95-
new BeamIOSinkRel(
96-
getCluster(),
97-
getTable(),
98-
getCatalogReader(),
99-
sole(inputs),
100-
getOperation(),
101-
getUpdateColumnList(),
102-
getSourceExpressionList(),
103-
flattened,
104-
sqlTable,
105-
pipelineOptions);
106-
newRel.traitSet = traitSet;
107-
return newRel;
121+
return new BeamIOSinkRel(
122+
getCluster(),
123+
traitSet,
124+
getTable(),
125+
getCatalogReader(),
126+
sole(inputs),
127+
getOperation(),
128+
getUpdateColumnList(),
129+
getSourceExpressionList(),
130+
flattened,
131+
sqlTable,
132+
pipelineOptions);
108133
}
109134

110135
@Override

sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamWindowRel.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,11 @@ public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) {
431431
return this.copy(traitSet, sole(inputs), this.constants, this.rowType, this.groups);
432432
}
433433

434+
@Override
435+
public Window copy(List<RexLiteral> constants) {
436+
return this.copy(traitSet, input, constants, this.rowType, this.groups);
437+
}
438+
434439
public BeamWindowRel copy(
435440
RelTraitSet traitSet,
436441
RelNode input,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
compilerFactory=org.apache.beam.vendor.calcite.v1_40_0.org.codehaus.janino.CompilerFactory

sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/SqlOperators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static SqlUserDefinedFunction createUdfOperator(String name, Method method, Stri
279279
}
280280

281281
private static SqlUserDefinedFunction createUdfOperator(
282-
String name, Method method, final SqlSyntax syntax, String funGroup, String jarPath) {
282+
String name, Method method, final SqlSyntax unused, String funGroup, String jarPath) {
283283
Function function = ZetaSqlScalarFunctionImpl.create(method, funGroup, jarPath);
284284
final RelDataTypeFactory typeFactory = createTypeFactory();
285285

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<modelVersion>4.0.0</modelVersion>
18+
<groupId>org.apache.beam</groupId>
19+
<artifactId>beam-vendor-calcite-1_40_0</artifactId>
20+
<version>0.1-SNAPSHOT</version>
21+
<name>Apache Beam :: Vendored Dependencies :: Calcite 1.40.0</name>
22+
<url>http://beam.apache.org</url>
23+
<inceptionYear>2016</inceptionYear>
24+
<licenses>
25+
<license>
26+
<name>Apache License, Version 2.0</name>
27+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
28+
<distribution>repo</distribution>
29+
</license>
30+
</licenses>
31+
<developers>
32+
<developer>
33+
<name>The Apache Beam Team</name>
34+
<email>dev@beam.apache.org</email>
35+
<url>http://beam.apache.org</url>
36+
<organization>Apache Software Foundation</organization>
37+
<organizationUrl>http://www.apache.org</organizationUrl>
38+
</developer>
39+
</developers>
40+
<mailingLists>
41+
<mailingList>
42+
<name>Beam Dev</name>
43+
<subscribe>dev-subscribe@beam.apache.org</subscribe>
44+
<unsubscribe>dev-unsubscribe@beam.apache.org</unsubscribe>
45+
<post>dev@beam.apache.org</post>
46+
<archive>http://www.mail-archive.com/dev%beam.apache.org</archive>
47+
</mailingList>
48+
<mailingList>
49+
<name>Beam User</name>
50+
<subscribe>user-subscribe@beam.apache.org</subscribe>
51+
<unsubscribe>user-unsubscribe@beam.apache.org</unsubscribe>
52+
<post>user@beam.apache.org</post>
53+
<archive>http://www.mail-archive.com/user%beam.apache.org</archive>
54+
</mailingList>
55+
<mailingList>
56+
<name>Beam Commits</name>
57+
<subscribe>commits-subscribe@beam.apache.org</subscribe>
58+
<unsubscribe>commits-unsubscribe@beam.apache.org</unsubscribe>
59+
<post>commits@beam.apache.org</post>
60+
<archive>http://www.mail-archive.com/commits%beam.apache.org</archive>
61+
</mailingList>
62+
</mailingLists>
63+
<scm>
64+
<connection>scm:git:https://gitbox.apache.org/repos/asf/beam.git</connection>
65+
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/beam.git</developerConnection>
66+
<url>https://gitbox.apache.org/repos/asf?p=beam.git;a=summary</url>
67+
</scm>
68+
<issueManagement>
69+
<system>github</system>
70+
<url>https://github.com/apache/beam/issues</url>
71+
</issueManagement>
72+
<dependencies>
73+
<dependency>
74+
<groupId>org.slf4j</groupId>
75+
<artifactId>slf4j-api</artifactId>
76+
<version>2.0.16</version>
77+
<scope>runtime</scope>
78+
</dependency>
79+
</dependencies>
80+
</project>

0 commit comments

Comments
 (0)