Skip to content

Commit 6a30ab0

Browse files
authored
Support CREATE TABLE WITH (#194)
1 parent de62fbd commit 6a30ab0

9 files changed

Lines changed: 5852 additions & 5683 deletions

File tree

hoptimator-jdbc/src/main/codegen/config.fmpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ data: {
3434
"org.apache.calcite.sql.ddl.SqlDdlNodes"
3535
"com.linkedin.hoptimator.jdbc.ddl.SqlCreateFunction"
3636
"com.linkedin.hoptimator.jdbc.ddl.SqlCreateMaterializedView"
37+
"com.linkedin.hoptimator.jdbc.ddl.SqlCreateTable"
3738
"com.linkedin.hoptimator.jdbc.ddl.SqlCreateTrigger"
3839
"com.linkedin.hoptimator.jdbc.ddl.SqlFire"
3940
"com.linkedin.hoptimator.jdbc.ddl.SqlFireMaterializedView"

hoptimator-jdbc/src/main/codegen/includes/parserImpls.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ SqlCreate SqlCreateTable(Span s, boolean replace) :
192192
final boolean ifNotExists;
193193
final SqlIdentifier id;
194194
SqlNodeList tableElementList = null;
195+
SqlNodeList optionList = null;
195196
SqlNode query = null;
196197

197198
SqlCreate createTableLike = null;
@@ -204,9 +205,10 @@ SqlCreate SqlCreateTable(Span s, boolean replace) :
204205
}
205206
|
206207
[ tableElementList = TableElementList() ]
208+
[ optionList = Options() ]
207209
[ <AS> query = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) ]
208210
{
209-
return SqlDdlNodes.createTable(s.end(this), replace, ifNotExists, id, tableElementList, query);
211+
return new SqlCreateTable(s.end(this), replace, ifNotExists, id, tableElementList, optionList, query);
210212
}
211213
)
212214
}

hoptimator-jdbc/src/main/java/com/linkedin/hoptimator/jdbc/HoptimatorDdlExecutor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.linkedin.hoptimator.View;
3131
import com.linkedin.hoptimator.jdbc.ddl.HoptimatorDdlParserImpl;
3232
import com.linkedin.hoptimator.jdbc.ddl.SqlCreateMaterializedView;
33+
import com.linkedin.hoptimator.jdbc.ddl.SqlCreateTable;
3334
import com.linkedin.hoptimator.jdbc.ddl.SqlCreateTrigger;
3435
import com.linkedin.hoptimator.util.ArrayTable;
3536
import com.linkedin.hoptimator.jdbc.ddl.SqlDropTrigger;
@@ -70,7 +71,6 @@
7071
import org.apache.calcite.sql.SqlLiteral;
7172
import org.apache.calcite.sql.SqlNode;
7273
import org.apache.calcite.sql.ddl.SqlColumnDeclaration;
73-
import org.apache.calcite.sql.ddl.SqlCreateTable;
7474
import org.apache.calcite.sql.ddl.SqlCreateView;
7575
import org.apache.calcite.sql.ddl.SqlDropMaterializedView;
7676
import org.apache.calcite.sql.ddl.SqlDropObject;
@@ -461,7 +461,9 @@ public void execute(SqlCreateTable create, CalcitePrepare.Context context) {
461461
List<String> tablePath = new ArrayList<>(schemaPath);
462462
tablePath.add(tableName);
463463

464-
Source source = new Source(database, tablePath, Collections.emptyMap());
464+
Map<String, String> tableOptions = HoptimatorDdlUtils.options(create.options);
465+
466+
Source source = new Source(database, tablePath, tableOptions);
465467
logger.info("Validating new table {}", source);
466468
ValidationService.validateOrThrow(source);
467469
deployers = DeploymentService.deployers(source, connection);

0 commit comments

Comments
 (0)