Skip to content

Commit

Permalink
TEIID-4530 updating ddl generation
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 20, 2016
1 parent 08b3695 commit 0513d0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -179,6 +179,8 @@ private void visit(Table table) {
if (table.isDeletePlanEnabled()) {
buildTrigger(name, DELETE, table.getDeletePlan());
}
} else {
append(SQLConstants.Tokens.SEMICOLON);
}
}

Expand Down Expand Up @@ -615,6 +617,8 @@ private void visit(Procedure procedure) {
String plan = procedure.getQueryPlan();
append(plan);
}

append(SEMICOLON);
}

private String buildProcedureOptions(Procedure procedure) {
Expand Down
Expand Up @@ -193,15 +193,15 @@ public void testFKWithOptions() throws Exception {

@Test
public void testMultipleCommands() throws Exception {
String ddl = "CREATE VIEW V1 AS SELECT * FROM PM1.G1 " +
String ddl = "CREATE VIEW V1 AS SELECT * FROM PM1.G1; " +
"CREATE PROCEDURE FOO(P1 integer) RETURNS (e1 integer, e2 varchar) AS SELECT * FROM PM1.G1;";
String expected = "CREATE VIEW V1\n" +
"AS\n" +
"SELECT * FROM PM1.G1;\n" +
"\n" +
"CREATE VIRTUAL PROCEDURE FOO(IN P1 integer) RETURNS TABLE (e1 integer, e2 string)\n" +
"AS\n" +
"SELECT * FROM PM1.G1;";
"SELECT * FROM PM1.G1;;";
helpTest(ddl, expected);

}
Expand Down Expand Up @@ -249,7 +249,7 @@ public void testSourceProcedure() throws Exception {
"OPTIONS(RANDOM 'any', UUID 'uuid', NAMEINSOURCE 'nis', ANNOTATION 'desc', UPDATECOUNT '2');";

String expected = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean OPTIONS (foo 'bar'), IN p2 string, INOUT p3 bigdecimal) RETURNS OPTIONS (x 'y') TABLE (r1 string, r2 bigdecimal)\n" +
"OPTIONS (UUID 'uuid', ANNOTATION 'desc', NAMEINSOURCE 'nis', UPDATECOUNT 2, RANDOM 'any')";
"OPTIONS (UUID 'uuid', ANNOTATION 'desc', NAMEINSOURCE 'nis', UPDATECOUNT 2, RANDOM 'any');";
helpTest(ddl, expected);
}

Expand Down Expand Up @@ -284,7 +284,7 @@ public void testNonPushdownFunction() throws Exception {
public void testNonPushdownFunction1() throws Exception {
String ddl = "CREATE VIRTUAL FUNCTION SourceFunc(p1 integer, p2 string) RETURNS integer\n" +
"as return repeat(p2, p1);";
String expected = "CREATE VIRTUAL FUNCTION SourceFunc(OUT \"return\" integer RESULT, IN p1 integer, IN p2 string)\nAS\nRETURN repeat(p2, p1);";
String expected = "CREATE VIRTUAL FUNCTION SourceFunc(OUT \"return\" integer RESULT, IN p1 integer, IN p2 string)\nAS\nRETURN repeat(p2, p1);;";
helpTest(ddl, expected);
}

Expand All @@ -299,7 +299,7 @@ public void testSourceProcedureVariadic() throws Exception {
String ddl = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, VARIADIC p3 decimal) " +
"RETURNS (r1 varchar, r2 decimal);";

String expected = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, VARIADIC p3 bigdecimal) RETURNS TABLE (r1 string, r2 bigdecimal)";
String expected = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, VARIADIC p3 bigdecimal) RETURNS TABLE (r1 string, r2 bigdecimal);";
helpTest(ddl, expected);
}

Expand All @@ -317,15 +317,15 @@ public void testSourceProcedureVariadic() throws Exception {

@Test public void testGlobalTemporaryTable() throws Exception {
String ddl = "create global temporary table myTemp (x string, y serial, primary key (x))";
String expected = "CREATE GLOBAL TEMPORARY TABLE myTemp (\n x string,\n y SERIAL,\n PRIMARY KEY(x)\n)";
String expected = "CREATE GLOBAL TEMPORARY TABLE myTemp (\n x string,\n y SERIAL,\n PRIMARY KEY(x)\n);";
helpTest(ddl, expected);
}

@Test public void testArrayTypes() throws Exception {
String ddl = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, p2 varchar, INOUT p3 decimal) " +
"RETURNS (r1 varchar(100)[], r2 decimal[][])";

String expected = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, IN p2 string, INOUT p3 bigdecimal) RETURNS TABLE (r1 string(100)[], r2 bigdecimal[][])";
String expected = "CREATE FOREIGN PROCEDURE myProc(OUT p1 boolean, IN p2 string, INOUT p3 bigdecimal) RETURNS TABLE (r1 string(100)[], r2 bigdecimal[][]);";
helpTest(ddl, expected);
}

Expand Down

0 comments on commit 0513d0b

Please sign in to comment.