Skip to content

Commit

Permalink
branchig adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
delchev committed Apr 3, 2024
1 parent b1527c8 commit 67c2611
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,54 @@ public SnowflakeCreateTableBuilder table(String table) {
return new SnowflakeCreateTableBuilder(this.getDialect(), table, ISqlDialect.KEYWORD_HYBRID);
}

/**
* Hybrid table.
*
* @param table the table
* @return the creates the table builder
*/
public SnowflakeCreateTableBuilder hybridTable(String table) {
return new SnowflakeCreateTableBuilder(this.getDialect(), table, ISqlDialect.KEYWORD_HYBRID);
}

/**
* Dynamic table.
*
* @param table the table
* @return the creates the table builder
*/
public SnowflakeCreateTableBuilder dynamicTable(String table) {
return new SnowflakeCreateTableBuilder(this.getDialect(), table, ISqlDialect.KEYWORD_DYNAMIC);
}

/**
* Event table.
*
* @param table the table
* @return the creates the table builder
*/
public SnowflakeCreateTableBuilder eventTable(String table) {
return new SnowflakeCreateTableBuilder(this.getDialect(), table, ISqlDialect.KEYWORD_EVENT);
}

/**
* External table.
*
* @param table the table
* @return the creates the table builder
*/
public SnowflakeCreateTableBuilder externalTable(String table) {
return new SnowflakeCreateTableBuilder(this.getDialect(), table, ISqlDialect.KEYWORD_EXTERNAL);
}

/**
* Iceberg table.
*
* @param table the table
* @return the creates the table builder
*/
public SnowflakeCreateTableBuilder icebergTable(String table) {
return new SnowflakeCreateTableBuilder(this.getDialect(), table, ISqlDialect.KEYWORD_ICEBERG);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* The Snowflake SQL Dialect.
*/
public class SnowflakeSqlDialect extends
DefaultSqlDialect<SelectBuilder, InsertBuilder, UpdateBuilder, DeleteBuilder, CreateBranchingBuilder, AlterBranchingBuilder, DropBranchingBuilder, SnowflakeNextValueSequenceBuilder, SnowflakeLastValueIdentityBuilder> {
DefaultSqlDialect<SelectBuilder, InsertBuilder, UpdateBuilder, DeleteBuilder, SnowflakeCreateBranchingBuilder, AlterBranchingBuilder, DropBranchingBuilder, SnowflakeNextValueSequenceBuilder, SnowflakeLastValueIdentityBuilder> {

/** The Constant FUNCTIONS. */
public static final Set<String> FUNCTIONS = Collections.synchronizedSet(new HashSet<String>(Arrays.asList(new String[] {"ABS", "ACOS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void createTableGeneric() {

assertNotNull(sql);
assertEquals(
"CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )",
"CREATE HYBRID TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) NOT NULL UNIQUE , LAST_NAME VARCHAR (30) )",
sql);
}

Expand All @@ -55,7 +55,27 @@ public void createTableTypeSafe() {
.build();

assertNotNull(sql);
assertEquals("CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )",
assertEquals(
"CREATE HYBRID TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )",
sql);
}

/**
* Creates the table type safe.
*/
@Test
public void createTableTypeIceberg() {
String sql = SqlFactory.getNative(new SnowflakeSqlDialect())
.create()
.icebergTable("CUSTOMERS")
.columnInteger("ID", true, false, false)
.columnVarchar("FIRST_NAME", 20, false, true, true)
.columnVarchar("LAST_NAME", 30, false, true, false)
.build();

assertNotNull(sql);
assertEquals(
"CREATE ICEBERG TABLE CUSTOMERS ( ID INTEGER NOT NULL PRIMARY KEY , FIRST_NAME VARCHAR (20) UNIQUE , LAST_NAME VARCHAR (30) )",
sql);
}

Expand Down

0 comments on commit 67c2611

Please sign in to comment.