Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("IF NOT EXISTS");
}
tableName.unparse(writer, leftPrec, rightPrec);
if (columnList.size() > 0) {
if (columnList.size() > 0 || tableConstraints.size() > 0 || watermark != null) {
SqlWriter.Frame frame =
writer.startList(SqlWriter.FrameTypeEnum.create("sds"), "(", ")");
for (SqlNode column : columnList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,35 @@ public void testCreateTableWithLikeClause() {
sql(sql).ok(expected);
}

@Test
public void testCreateTableWithLikeClauseWithoutColumns() {
final String sql =
""
+ "create TEMPORARY table source_table (\n"
+ " WATERMARK FOR ts AS ts - INTERVAL '5' SECOND\n"
+ ") with (\n"
+ " 'scan.startup.mode' = 'specific-offsets',\n"
+ " 'scan.startup.specific-offsets' = 'partition:0,offset:1169129'\n"
+ ") like t_order_course (\n"
+ " OVERWRITING WATERMARKS\n"
+ " OVERWRITING OPTIONS\n"
+ " EXCLUDING CONSTRAINTS\n"
+ ")";
final String expected =
"CREATE TEMPORARY TABLE `SOURCE_TABLE` (\n"
+ " WATERMARK FOR `TS` AS (`TS` - INTERVAL '5' SECOND)\n"
+ ") WITH (\n"
+ " 'scan.startup.mode' = 'specific-offsets',\n"
+ " 'scan.startup.specific-offsets' = 'partition:0,offset:1169129'\n"
+ ")\n"
+ "LIKE `T_ORDER_COURSE` (\n"
+ " OVERWRITING WATERMARKS\n"
+ " OVERWRITING OPTIONS\n"
+ " EXCLUDING CONSTRAINTS\n"
+ ")";
sql(sql).ok(expected);
}

@Test
public void testCreateTemporaryTable() {
final String sql =
Expand Down Expand Up @@ -851,6 +880,25 @@ public void testCreateTableWithNoColumns() {
sql(sql).ok(expected);
}

@Test
public void testCreateTableWithOnlyWaterMark() {
final String sql =
"create table source_table (\n"
+ " watermark FOR ts AS ts - interval '3' second\n"
+ ") with (\n"
+ " 'x' = 'y',\n"
+ " 'abc' = 'def'\n"
+ ")";
final String expected =
"CREATE TABLE `SOURCE_TABLE` (\n"
+ " WATERMARK FOR `TS` AS (`TS` - INTERVAL '3' SECOND)\n"
+ ") WITH (\n"
+ " 'x' = 'y',\n"
+ " 'abc' = 'def'\n"
+ ")";
sql(sql).ok(expected);
}

@Test
public void testDropTable() {
final String sql = "DROP table catalog1.db1.tbl1";
Expand Down