Skip to content

Commit 046a5e6

Browse files
authored
Add custom SQL parser and improve Calcite integration (#957)
* Add schemas for all formats * Add sql parser files copied from calcite * Add ddl directive to support the WITH clause in CREATE TABLE statements
1 parent 2b90033 commit 046a5e6

File tree

79 files changed

+15059
-828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+15059
-828
lines changed

baremaps-calcite/pom.xml

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ limitations under the License.
2727
<name>Apache Baremaps Calcite</name>
2828

2929
<properties>
30-
<maven.compiler.source>21</maven.compiler.source>
31-
<maven.compiler.target>21</maven.compiler.target>
3230
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3331
</properties>
3432

@@ -85,10 +83,94 @@ limitations under the License.
8583
<groupId>org.apache.calcite</groupId>
8684
<artifactId>calcite-core</artifactId>
8785
</dependency>
88-
<dependency>
89-
<groupId>org.apache.calcite</groupId>
90-
<artifactId>calcite-server</artifactId>
91-
</dependency>
9286
</dependencies>
9387

88+
<build>
89+
<plugins>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-deploy-plugin</artifactId>
93+
<version>2.8.2</version>
94+
<configuration>
95+
<skip>false</skip>
96+
</configuration>
97+
</plugin>
98+
<plugin>
99+
<artifactId>maven-resources-plugin</artifactId>
100+
<executions>
101+
<execution>
102+
<id>copy-fmpp-resources</id>
103+
<goals>
104+
<goal>copy-resources</goal>
105+
</goals>
106+
<phase>initialize</phase>
107+
<configuration>
108+
<outputDirectory>${project.build.directory}/codegen</outputDirectory>
109+
<resources>
110+
<resource>
111+
<directory>src/main/codegen</directory>
112+
<filtering>false</filtering>
113+
</resource>
114+
</resources>
115+
</configuration>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
<plugin>
120+
<groupId>org.apache.maven.plugins</groupId>
121+
<artifactId>maven-antrun-plugin</artifactId>
122+
<dependencies>
123+
<dependency>
124+
<groupId>net.sourceforge.fmpp</groupId>
125+
<artifactId>fmpp</artifactId>
126+
<version>0.9.16</version>
127+
</dependency>
128+
</dependencies>
129+
<executions>
130+
<execution>
131+
<id>generate-fmpp-sources</id>
132+
<goals>
133+
<goal>run</goal>
134+
</goals>
135+
<phase>initialize</phase>
136+
<configuration>
137+
<target>
138+
<taskdef classname="fmpp.tools.AntTask" name="fmpp" />
139+
<fmpp configuration="${project.build.directory}/codegen/config.fmpp" data="tdd(${project.build.directory}/codegen/config.fmpp), default: tdd(${project.build.directory}/codegen/default_config.fmpp)" outputRoot="${project.build.directory}/generated-sources/fmpp" sourceRoot="${project.build.directory}/codegen/templates" />
140+
</target>
141+
</configuration>
142+
</execution>
143+
</executions>
144+
</plugin>
145+
<plugin>
146+
<groupId>org.codehaus.mojo</groupId>
147+
<artifactId>javacc-maven-plugin</artifactId>
148+
<version>3.1.1</version>
149+
<executions>
150+
<execution>
151+
<id>javacc</id>
152+
<goals>
153+
<goal>javacc</goal>
154+
</goals>
155+
<configuration>
156+
<sourceDirectory>${project.build.directory}/generated-sources/fmpp</sourceDirectory>
157+
<outputDirectory>${project.build.directory}/generated-sources/calcite</outputDirectory>
158+
<includes>
159+
<include>**/Parser.jj</include>
160+
</includes>
161+
<lookAhead>2</lookAhead>
162+
<isStatic>false</isStatic>
163+
</configuration>
164+
</execution>
165+
</executions>
166+
</plugin>
167+
<plugin>
168+
<groupId>org.apache.maven.plugins</groupId>
169+
<artifactId>maven-javadoc-plugin</artifactId>
170+
<configuration>
171+
<excludePackageNames>org.apache.baremaps.calcite.sql</excludePackageNames>
172+
</configuration>
173+
</plugin>
174+
</plugins>
175+
</build>
94176
</project>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to you under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
data: {
17+
# Data declarations for this parser.
18+
#
19+
# Default declarations are in default_config.fmpp; if you do not include a
20+
# declaration ('imports' or 'nonReservedKeywords', for example) in this file,
21+
# FMPP will use the declaration from default_config.fmpp.
22+
parser: {
23+
# Generated parser implementation class package and name
24+
package: "org.apache.baremaps.calcite.sql",
25+
class: "BaremapsSqlDdlParser",
26+
27+
# List of import statements.
28+
imports: [
29+
"org.apache.calcite.schema.ColumnStrategy"
30+
"org.apache.calcite.sql.SqlBasicCall"
31+
"org.apache.calcite.sql.SqlCreate"
32+
"org.apache.calcite.sql.SqlDrop"
33+
"org.apache.calcite.sql.SqlTruncate"
34+
"org.apache.calcite.sql.ddl.SqlCreateTableLike"
35+
"org.apache.baremaps.calcite.ddl.SqlDdlNodes"
36+
]
37+
38+
# List of new keywords. Example: "DATABASES", "TABLES". If the keyword is
39+
# not a reserved keyword, add it to the 'nonReservedKeywords' section.
40+
keywords: [
41+
"IF"
42+
"MATERIALIZED"
43+
"STORED"
44+
"VIRTUAL"
45+
"JAR"
46+
"FILE"
47+
"ARCHIVE"
48+
]
49+
50+
# List of non-reserved keywords to add;
51+
# items in this list become non-reserved
52+
nonReservedKeywordsToAdd: [
53+
# not in core, added in server
54+
"IF"
55+
"MATERIALIZED"
56+
"STORED"
57+
"VIRTUAL"
58+
"JAR"
59+
"FILE"
60+
"ARCHIVE"
61+
]
62+
63+
# List of methods for parsing extensions to "CREATE [OR REPLACE]" calls.
64+
# Each must accept arguments "(SqlParserPos pos, boolean replace)".
65+
# Example: "SqlCreateForeignSchema".
66+
createStatementParserMethods: [
67+
"SqlCreateForeignSchema"
68+
"SqlCreateMaterializedView"
69+
"SqlCreateSchema"
70+
"SqlCreateTable"
71+
"SqlCreateType"
72+
"SqlCreateView"
73+
"SqlCreateFunction"
74+
]
75+
76+
# List of methods for parsing extensions to "DROP" calls.
77+
# Each must accept arguments "(SqlParserPos pos)".
78+
# Example: "SqlDropSchema".
79+
dropStatementParserMethods: [
80+
"SqlDropMaterializedView"
81+
"SqlDropSchema"
82+
"SqlDropTable"
83+
"SqlDropType"
84+
"SqlDropView"
85+
"SqlDropFunction"
86+
]
87+
88+
# List of methods for parsing extensions to "TRUNCATE" calls.
89+
# Each must accept arguments "(SqlParserPos pos)".
90+
# Example: "SqlTruncateTable".
91+
truncateStatementParserMethods: [
92+
"SqlTruncateTable"
93+
]
94+
95+
# List of files in @includes directory that have parser method
96+
# implementations for parsing custom SQL statements, literals or types
97+
# given as part of "statementParserMethods", "literalParserMethods" or
98+
# "dataTypeParserMethods".
99+
# Example: "parserImpls.ftl".
100+
implementationFiles: [
101+
"parserImpls.ftl"
102+
]
103+
}
104+
}
105+
106+
freemarkerLinks: {
107+
includes: includes/
108+
}

0 commit comments

Comments
 (0)