diff --git a/README.md b/README.md index 9808713e..e98fec7d 100644 --- a/README.md +++ b/README.md @@ -563,7 +563,7 @@ tables: Description: Our actual database does not contain `first_name` so we expect it to alter the table and add the column, inside the source directory there will be the executed DDL and a snapshot of the current database. #### generate -This command will generate Spark Python (file) or Spark Scala (file), firstly it extracts a schema from a source database and gets connection properties form the source connection, then it creates a python (file) or scala (file) that translates schemas, which is ready to transfer data from source to target. +This command will generate Spark Python (file) or Spark Scala (file), firstly it extracts a schema from a source database and gets connection properties from the source connection, then it creates a python (file) or scala (file) that translates schemas, which is ready to transfer data from source to target. rosetta [-c, --config CONFIG_FILE] generate [-h, --help] [-s, --source CONNECTION_NAME] [-t, --target CONNECTION_NAME] [--pyspark] [--scala] diff --git a/build.gradle b/build.gradle index a80e095d..014d6e18 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ repositories { allprojects { group = 'com.adaptivescale' - version = '1.8.2' + version = '1.8.3' sourceCompatibility = 11 targetCompatibility = 11 } diff --git a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java index 42059015..c2006560 100644 --- a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java +++ b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java @@ -56,7 +56,7 @@ @Slf4j @CommandLine.Command(name = "cli", mixinStandardHelpOptions = true, - version = "1.8.2", + version = "1.8.3", description = "Declarative Database Management - DDL Transpiler" ) class Cli implements Callable { diff --git a/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/KineticaDDLGenerator.java b/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/KineticaDDLGenerator.java index 8accc79d..f7338c00 100644 --- a/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/KineticaDDLGenerator.java +++ b/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/KineticaDDLGenerator.java @@ -10,13 +10,11 @@ import com.adaptivescale.rosetta.ddl.change.model.ColumnChange; import com.adaptivescale.rosetta.ddl.change.model.ForeignKeyChange; import com.adaptivescale.rosetta.ddl.targets.ColumnSQLDecoratorFactory; +import com.adaptivescale.rosetta.ddl.utils.TemplateEngine; import lombok.extern.slf4j.Slf4j; import java.sql.DatabaseMetaData; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import static com.adaptivescale.rosetta.ddl.targets.kinetica.Constants.DEFAULT_WRAPPER; @@ -28,6 +26,24 @@ ) public class KineticaDDLGenerator implements DDL { + private final static String TABLE_CREATE_TEMPLATE = "kinetica/table/create"; + + private final static String TABLE_ALTER_TEMPLATE = "kinetica/table/alter"; + + private final static String TABLE_DROP_TEMPLATE = "kinetica/table/drop"; + + private final static String SCHEMA_CREATE_TEMPLATE = "kinetica/schema/create"; + + private final static String FOREIGN_KEY_CREATE_TEMPLATE = "kinetica/foreignkey/create"; + + private final static String FOREIGN_KEY_DROP_TEMPLATE = "kinetica/foreignkey/drop"; + + private final static String COLUMN_ADD_TEMPLATE = "kinetica/column/add"; + + private final static String COLUMN_MODIFY_TEMPLATE = "kinetica/column/modify"; + + private final static String COLUMN_DROP_TEMPLATE = "kinetica/column/drop"; + private final ColumnSQLDecoratorFactory columnSQLDecoratorFactory = new KineticaColumnDecoratorFactory(); @Override @@ -37,29 +53,25 @@ public String createColumn(Column column) { @Override public String createTable(Table table, boolean dropTableIfExists) { + Map createParams = new HashMap<>(); + List definitions = table.getColumns().stream().map(this::createColumn).collect(Collectors.toList()); - Optional primaryKeysForTable = createPrimaryKeysForTable(table); + List foreignKeysForTable = getForeignKeysColumnNames(table); + Optional primaryKeysForTable = createPrimaryKeysForTable(table, foreignKeysForTable); primaryKeysForTable.ifPresent(definitions::add); String definitionAsString = String.join(", ", definitions); StringBuilder stringBuilder = new StringBuilder(); if (dropTableIfExists) { - stringBuilder.append("DROP TABLE IF EXISTS "); - if (table.getSchema() != null && !table.getSchema().isBlank()) { - stringBuilder.append("`").append(table.getSchema()).append("`."); - } - stringBuilder.append(DEFAULT_WRAPPER).append(table.getName()).append(DEFAULT_WRAPPER).append("; \n"); + stringBuilder.append(dropTable(table)); } - stringBuilder.append("CREATE TABLE "); - - if (table.getSchema() != null && !table.getSchema().isBlank()) { - stringBuilder.append(DEFAULT_WRAPPER) - .append(table.getSchema()).append(DEFAULT_WRAPPER).append("."); - } + createParams.put("schemaName", table.getSchema()); + createParams.put("tableName", table.getName()); + createParams.put("tableCode", definitionAsString); + stringBuilder.append(TemplateEngine.process(TABLE_CREATE_TEMPLATE, createParams)); - stringBuilder.append(DEFAULT_WRAPPER).append(table.getName()).append(DEFAULT_WRAPPER).append("(").append(definitionAsString).append(");"); return stringBuilder.toString(); } @@ -70,41 +82,47 @@ public String createDatabase(Database database, boolean dropTableIfExists) { Set schemas = database.getTables().stream().map(Table::getSchema).filter(s -> s != null && !s.isEmpty()).collect(Collectors.toSet()); if (!schemas.isEmpty()) { stringBuilder.append( - schemas - .stream() - .map(schema -> "CREATE SCHEMA IF NOT EXISTS " + DEFAULT_WRAPPER + schema + DEFAULT_WRAPPER) - .collect(Collectors.joining(";\r\r")) - + schemas + .stream() + .map(this::createSchema) + .collect(Collectors.joining()) ); - stringBuilder.append(";\r"); + stringBuilder.append("\r"); } stringBuilder.append(database.getTables() - .stream() - .map(table -> createTable(table, dropTableIfExists)) - .collect(Collectors.joining("\r\r"))); - - String foreignKeys = database - .getTables() - .stream() - .map(this::foreignKeys) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.joining()); - - if (!foreignKeys.isEmpty()) { - stringBuilder.append("\r").append(foreignKeys).append("\r"); - } + .stream() + .map(table -> createTable(table, dropTableIfExists)) + .collect(Collectors.joining("\r\r"))); + + //TODO: Check if we can enable foreign keys in Kinetica + //Disable temporarily the foreign keys in Kinetica +// String foreignKeys = database +// .getTables() +// .stream() +// .map(this::foreignKeys) +// .filter(Optional::isPresent) +// .map(Optional::get) +// .collect(Collectors.joining("\r")); +// +// if (!foreignKeys.isEmpty()) { +// stringBuilder.append("\r").append(foreignKeys).append("\r"); +// } + return stringBuilder.toString(); } @Override public String createForeignKey(ForeignKey foreignKey) { - return "ALTER TABLE" + handleNullSchema(foreignKey.getSchema(), foreignKey.getTableName()) + " ADD CONSTRAINT " - + foreignKey.getName() + " FOREIGN KEY ("+ DEFAULT_WRAPPER + foreignKey.getColumnName() + DEFAULT_WRAPPER +") REFERENCES " - + handleNullSchema(foreignKey.getPrimaryTableSchema(), foreignKey.getPrimaryTableName()) - + "("+ DEFAULT_WRAPPER + foreignKey.getPrimaryColumnName()+ DEFAULT_WRAPPER + ")" - + foreignKeyDeleteRuleSanitation(foreignKeyDeleteRule(foreignKey)) + ";\r"; + Map params = new HashMap<>(); + params.put("schemaName", foreignKey.getSchema()); + params.put("tableName", foreignKey.getTableName()); + params.put("foreignkeyColumn", foreignKey.getColumnName()); + params.put("primaryTableSchema", foreignKey.getPrimaryTableSchema()); + params.put("primaryTableName", foreignKey.getPrimaryTableName()); + params.put("foreignKeyPrimaryColumnName", foreignKey.getPrimaryColumnName()); + params.put("foreignkeyName", foreignKey.getName()); + return TemplateEngine.process(FOREIGN_KEY_CREATE_TEMPLATE, params); } @Override @@ -115,9 +133,12 @@ public String alterColumn(ColumnChange change) { if (!Objects.equals(expected.getTypeName(), actual.getTypeName()) || !Objects.equals(expected.isNullable(), actual.isNullable())) { - return String.format("ALTER TABLE%s MODIFY %s;", - handleNullSchema(table.getSchema(), table.getName()), - columnSQLDecoratorFactory.decoratorFor(expected).expressSQl()); + + Map params = new HashMap<>(); + params.put("schemaName", table.getSchema()); + params.put("tableName", table.getName()); + params.put("columnDefinition", columnSQLDecoratorFactory.decoratorFor(expected).expressSQl()); + return TemplateEngine.process(COLUMN_MODIFY_TEMPLATE, params); } log.info("No action taken for changes detected in column: {}.{}.{}", change.getTable().getSchema(), @@ -131,9 +152,11 @@ public String dropColumn(ColumnChange change) { Table table = change.getTable(); Column actual = change.getActual(); - return "ALTER TABLE" + - handleNullSchema(table.getSchema(), table.getName()) + " DROP COLUMN "+ DEFAULT_WRAPPER + - actual.getName() + DEFAULT_WRAPPER +";"; + Map params = new HashMap<>(); + params.put("schemaName", table.getSchema()); + params.put("tableName", table.getName()); + params.put("columnName", actual.getName()); + return TemplateEngine.process(COLUMN_DROP_TEMPLATE, params); } @Override @@ -141,15 +164,19 @@ public String addColumn(ColumnChange change) { Table table = change.getTable(); Column expected = change.getExpected(); - return "ALTER TABLE" + - handleNullSchema(table.getSchema(), table.getName()) + - " ADD COLUMN " + - columnSQLDecoratorFactory.decoratorFor(expected).expressSQl() + ";"; + Map params = new HashMap<>(); + params.put("schemaName", table.getSchema()); + params.put("tableName", table.getName()); + params.put("columnDefinition", columnSQLDecoratorFactory.decoratorFor(expected).expressSQl()); + return TemplateEngine.process(COLUMN_ADD_TEMPLATE, params); } @Override public String dropTable(Table actual) { - return "DROP TABLE" + handleNullSchema(actual.getSchema(), actual.getName()) + ";"; + Map params = new HashMap<>(); + params.put("schemaName", actual.getSchema()); + params.put("tableName", actual.getName()); + return TemplateEngine.process(TABLE_DROP_TEMPLATE, params); } @Override @@ -159,43 +186,29 @@ public String alterForeignKey(ForeignKeyChange change) { @Override public String dropForeignKey(ForeignKey actual) { - return "ALTER TABLE" + handleNullSchema(actual.getSchema(), actual.getTableName()) + " DROP FOREIGN KEY "+ DEFAULT_WRAPPER + actual.getName() + DEFAULT_WRAPPER +";"; + Map params = new HashMap<>(); + params.put("schemaName", actual.getSchema()); + params.put("tableName", actual.getTableName()); + params.put("foreignkeyName", actual.getName()); + return TemplateEngine.process(FOREIGN_KEY_DROP_TEMPLATE, params); } @Override public String alterTable(Table expected, Table actual) { - boolean doesPKExist = actual.getColumns().stream().map(Column::isPrimaryKey).reduce((aBoolean, aBoolean2) -> aBoolean || aBoolean2).orElse(false); - boolean doWeNeedToCreatePk = expected.getColumns().stream().map(Column::isPrimaryKey).reduce((aBoolean, aBoolean2) -> aBoolean || aBoolean2).orElse(false); - - StringBuilder stringBuilder = new StringBuilder("ALTER TABLE") - .append(handleNullSchema(expected.getSchema(), expected.getName())); - - if (doesPKExist) { - stringBuilder.append(" DROP PRIMARY KEY"); - } - - if (doWeNeedToCreatePk) { - Optional primaryKeysForTable = createPrimaryKeysForTable(expected); - if (primaryKeysForTable.isPresent()) { - if (doesPKExist) { - stringBuilder.append(","); - } - stringBuilder.append(" ADD ").append(primaryKeysForTable.get()); - } - } - - stringBuilder.append(";"); - return stringBuilder.toString(); + return ""; } - private Optional createPrimaryKeysForTable(Table table) { + private Optional createPrimaryKeysForTable(Table table, List foreignKeysForTable) { List primaryKeys = table - .getColumns() - .stream() - .filter(Column::isPrimaryKey) - .sorted((o1, o2) -> o1.getPrimaryKeySequenceId() < o2.getPrimaryKeySequenceId() ? -1 : 1) - .map(pk -> String.format(DEFAULT_WRAPPER+"%s"+DEFAULT_WRAPPER, pk.getName())) - .collect(Collectors.toList()); + .getColumns() + .stream() + .filter(Column::isPrimaryKey) + .sorted((o1, o2) -> o1.getPrimaryKeySequenceId() < o2.getPrimaryKeySequenceId() ? -1 : 1) + .map(pk -> String.format(DEFAULT_WRAPPER+"%s"+DEFAULT_WRAPPER, pk.getName())) + .collect(Collectors.toList()); + + //TODO: Enable this with foreign key functionality +// primaryKeys.addAll(foreignKeysForTable); if (primaryKeys.isEmpty()) { return Optional.empty(); @@ -206,13 +219,20 @@ private Optional createPrimaryKeysForTable(Table table) { private Optional foreignKeys(Table table) { String result = table.getColumns().stream() - .filter(column -> column.getForeignKeys() != null && !column.getForeignKeys().isEmpty()) - .map(this::createForeignKeys).collect(Collectors.joining()); + .filter(column -> column.getForeignKeys() != null && !column.getForeignKeys().isEmpty()) + .map(this::createForeignKeys).collect(Collectors.joining()); return result.isEmpty() ? Optional.empty() : Optional.of(result); } - //ALTER TABLE rosetta.contacts ADD CONSTRAINT contacts_fk FOREIGN KEY (contact_id) REFERENCES rosetta."user"(user_id); + private List getForeignKeysColumnNames(Table table) { + return table.getColumns().stream() + .filter(column -> column.getForeignKeys() != null && !column.getForeignKeys().isEmpty()) + .map(Column::getName) + .map(fk -> String.format(DEFAULT_WRAPPER+"%s"+DEFAULT_WRAPPER, fk)) + .collect(Collectors.toList()); + } + private String createForeignKeys(Column column) { return column.getForeignKeys().stream().map(this::createForeignKey).collect(Collectors.joining()); } @@ -228,24 +248,9 @@ private String foreignKeyDeleteRuleSanitation(String deleteRule) { return " " + deleteRule + " "; } - private String foreignKeyDeleteRule(ForeignKey foreignKey) { - if (foreignKey.getDeleteRule() == null || foreignKey.getDeleteRule().isEmpty()) { - return ""; - } - switch (Integer.parseInt(foreignKey.getDeleteRule())) { - case DatabaseMetaData.importedKeyCascade: - return "ON DELETE CASCADE"; - case DatabaseMetaData.importedKeySetNull: - return "ON DELETE SET NULL"; - case DatabaseMetaData.importedKeyNoAction: - return "ON DELETE NO ACTION"; - case DatabaseMetaData.importedKeySetDefault: - case DatabaseMetaData.importedKeyInitiallyDeferred: - case DatabaseMetaData.importedKeyInitiallyImmediate: - case DatabaseMetaData.importedKeyNotDeferrable: - default: - //todo add warn log - return ""; - } + private String createSchema(String schema) { + Map params = new HashMap<>(); + params.put("schemaName", schema); + return TemplateEngine.process(SCHEMA_CREATE_TEMPLATE, params); } } diff --git a/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/decorators/KineticaColumnTypeName.java b/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/decorators/KineticaColumnTypeName.java index 8bd4818d..40529243 100644 --- a/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/decorators/KineticaColumnTypeName.java +++ b/ddl/src/main/java/com/adaptivescale/rosetta/ddl/targets/kinetica/decorators/KineticaColumnTypeName.java @@ -7,6 +7,9 @@ import static com.adaptivescale.rosetta.ddl.targets.kinetica.Constants.PRECISION_TYPES; public class KineticaColumnTypeName implements ColumnDataTypeName { + + private final static String SHARD_KEY = "(SHARD_KEY)"; + @Override public String nameForColumn(Column column) { StringBuilder builder = new StringBuilder(); @@ -14,6 +17,10 @@ public String nameForColumn(Column column) { if ( !PRECISION_DEFAULTS.contains(column.getPrecision()) && PRECISION_TYPES.contains(column.getTypeName().toLowerCase())) { builder.append("(").append(column.getPrecision()).append(")"); } + //TODO: Enable this with foreign key functionality +// if (column.getForeignKeys() != null && !column.getForeignKeys().isEmpty()) { +// builder.append(SHARD_KEY); +// } return builder.toString(); } } diff --git a/ddl/src/main/resources/templates/kinetica/column/add.sqlt b/ddl/src/main/resources/templates/kinetica/column/add.sqlt new file mode 100644 index 00000000..493f0b0b --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/column/add.sqlt @@ -0,0 +1 @@ +ALTER TABLE "[(${schemaName})]"."[(${tableName})]" ADD [(${columnDefinition})]; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/column/drop.sqlt b/ddl/src/main/resources/templates/kinetica/column/drop.sqlt new file mode 100644 index 00000000..c2a179d9 --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/column/drop.sqlt @@ -0,0 +1 @@ +ALTER TABLE "[(${schemaName})]"."[(${tableName})]" DROP COLUMN "[(${columnName})]"; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/column/modify.sqlt b/ddl/src/main/resources/templates/kinetica/column/modify.sqlt new file mode 100644 index 00000000..974472fb --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/column/modify.sqlt @@ -0,0 +1 @@ +ALTER TABLE "[(${schemaName})]"."[(${tableName})]" MODIFY [(${columnDefinition})]; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/foreignkey/create.sqlt b/ddl/src/main/resources/templates/kinetica/foreignkey/create.sqlt new file mode 100644 index 00000000..3ef4a320 --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/foreignkey/create.sqlt @@ -0,0 +1 @@ +ALTER TABLE "[(${schemaName})]"."[(${tableName})]" ADD FOREIGN KEY ("[(${foreignkeyColumn})]") REFERENCES "[(${primaryTableSchema})]"."[(${primaryTableName})]"("[(${foreignKeyPrimaryColumnName})]") AS [(${foreignkeyName})]; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/foreignkey/drop.sqlt b/ddl/src/main/resources/templates/kinetica/foreignkey/drop.sqlt new file mode 100644 index 00000000..4d8f6089 --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/foreignkey/drop.sqlt @@ -0,0 +1 @@ +ALTER TABLE "[(${schemaName})]"."[(${tableName})]" DROP FOREIGN KEY "[(${foreignkeyName})]"; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/schema/create.sqlt b/ddl/src/main/resources/templates/kinetica/schema/create.sqlt new file mode 100644 index 00000000..a00455ee --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/schema/create.sqlt @@ -0,0 +1 @@ +CREATE SCHEMA IF NOT EXISTS "[(${schemaName})]"; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/table/alter.sqlt b/ddl/src/main/resources/templates/kinetica/table/alter.sqlt new file mode 100644 index 00000000..e69de29b diff --git a/ddl/src/main/resources/templates/kinetica/table/create.sqlt b/ddl/src/main/resources/templates/kinetica/table/create.sqlt new file mode 100644 index 00000000..2d5414c2 --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/table/create.sqlt @@ -0,0 +1 @@ +CREATE TABLE "[(${schemaName})]"."[(${tableName})]"([(${tableCode})]); \ No newline at end of file diff --git a/ddl/src/main/resources/templates/kinetica/table/drop.sqlt b/ddl/src/main/resources/templates/kinetica/table/drop.sqlt new file mode 100644 index 00000000..fb536f5b --- /dev/null +++ b/ddl/src/main/resources/templates/kinetica/table/drop.sqlt @@ -0,0 +1 @@ +DROP TABLE IF EXISTS "[(${schemaName})]"."[(${tableName})]"; \ No newline at end of file diff --git a/ddl/src/main/resources/templates/python/spark_code.sqlt b/ddl/src/main/resources/templates/python/spark_code.sqlt index 1c059138..5dced521 100644 --- a/ddl/src/main/resources/templates/python/spark_code.sqlt +++ b/ddl/src/main/resources/templates/python/spark_code.sqlt @@ -1,5 +1,16 @@ # Guide for using this snippet code: https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html +# If you want to use the spark shell you can provide the information about JDBC drivers using: +# ./bin/spark-shell --driver-class-path postgresql-9.4.1207.jar --jars postgresql-9.4.1207.jar + +# Otherwise you can configure your SparkSession to use specific drivers using the example: +# spark = (SparkSession.builder +# .appName("myapp") +# .master('local') +# .config('spark.driver.extraClassPath','postgresql-42.3.6.jar:mysql-connector-java-8.0.28.jar') +# .getOrCreate() +# ) + from pyspark.sql import SparkSession, SQLContext spark = (SparkSession.builder @@ -29,6 +40,7 @@ for table in tables: df = (sqlContext.read .format("jdbc") .option("url", source_jdbc_url) + .option("driver", source_driver) .option("dbtable", table) .option("user", source_username) .option("password", source_password) diff --git a/ddl/src/main/resources/templates/scala/scala_code.sqlt b/ddl/src/main/resources/templates/scala/scala_code.sqlt index e42874e6..4cc68388 100644 --- a/ddl/src/main/resources/templates/scala/scala_code.sqlt +++ b/ddl/src/main/resources/templates/scala/scala_code.sqlt @@ -1,3 +1,16 @@ +# Guide for using this snippet code: https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html + +# If you want to use the spark shell you can provide the information about JDBC drivers using: +# ./bin/spark-shell --driver-class-path postgresql-9.4.1207.jar --jars postgresql-9.4.1207.jar + +# Otherwise you can configure your SparkSession to use specific drivers using the example: +# val spark = SparkSession.builder() +# .appName("myapp") +# .master("local") +# .config("spark.driver.extraClassPath","postgresql-42.3.6.jar:mysql-connector-java-8.0.28.jar") +# .getOrCreate() +# + import org.apache.spark.sql.SparkSession val spark = SparkSession.builder() @@ -26,6 +39,7 @@ for (table <- tables) { val df = sqlContext.read .format("jdbc") .option("url", sourceJdbcUrl) + .option("driver", sourceDriver) .option("dbtable", table) .option("user", sourceUsername) .option("password", sourcePassword) diff --git a/ddl/src/test/java/com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java b/ddl/src/test/java/com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java index 792ed24b..43ef51b5 100644 --- a/ddl/src/test/java/com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java +++ b/ddl/src/test/java/com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java @@ -45,58 +45,51 @@ public void createDB() throws IOException { @Test public void addTable() throws IOException { String ddl = generateDDL("add_table"); - Assertions.assertEquals("CREATE TABLE \"Position\"(\"ID\" DECIMAL(10) NOT NULL , \"DESCRIPTION\" VARCHAR," + + Assertions.assertEquals("CREATE TABLE \"ROSETTA\".\"Position\"(\"ID\" DECIMAL(10) NOT NULL , \"DESCRIPTION\" VARCHAR," + " \"Name\" VARCHAR, PRIMARY KEY (\"ID\"));", ddl); } @Test public void dropTable() throws IOException { String ddl = generateDDL("drop_table"); - Assertions.assertEquals("DROP TABLE \"TEAMPLAYERS\";", ddl); + Assertions.assertEquals("DROP TABLE IF EXISTS \"ROSETTA\".\"TEAMPLAYERS\";", ddl); } @Test public void addColumn() throws IOException { String ddl = generateDDL("add_column"); - Assertions.assertEquals("ALTER TABLE \"Position\" ADD COLUMN \"DESCRIPTION\" varchar(100);", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"Position\" ADD \"DESCRIPTION\" varchar(100);", ddl); } @Test public void addColumnWithForeignKey() throws IOException { String ddl = generateDDL("add_column_with_foreign_key"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" ADD COLUMN \"POSITION_ID\" numeric;\r" + - "ALTER TABLE \"FBAL\".\"PLAYER\" ADD CONSTRAINT PLAYER_FK FOREIGN KEY (\"POSITION_ID\") REFERENCES \"FBAL\".\"Position\"(\"ID\") ON DELETE NO ACTION ;\r", ddl); - } - - @Test - public void addColumnAsPrimaryKey() throws IOException { - String ddl = generateDDL("add_column_as_primary_key"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" ADD COLUMN \"ID\" numeric NOT NULL ;\r" + - "ALTER TABLE \"PLAYER\" ADD PRIMARY KEY (\"ID\");", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"PLAYER\" ADD \"POSITION_ID\" numeric;\r" + + "ALTER TABLE \"ROSETTA\".\"PLAYER\" ADD FOREIGN KEY (\"POSITION_ID\") REFERENCES \"ROSETTA\".\"Position\"(\"ID\") AS PLAYER_FK;", ddl); } @Test public void dropColumn() throws IOException { String ddl = generateDDL("drop_column"); - Assertions.assertEquals("ALTER TABLE \"Position\" DROP COLUMN \"DESCRIPTION\";", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"Position\" DROP COLUMN \"DESCRIPTION\";", ddl); } @Test public void alterColumnDataType() throws IOException { String ddl = generateDDL("alter_column_data_type"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" MODIFY \"name\" INTEGER;", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"PLAYER\" MODIFY \"name\" INTEGER;", ddl); } @Test public void alterColumnToNullable() throws IOException { String ddl = generateDDL("alter_column_to_nullable"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" MODIFY \"ID\" numeric;", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"PLAYER\" MODIFY \"ID\" numeric;", ddl); } @Test public void alterColumnToNotNullable() throws IOException { String ddl = generateDDL("alter_column_to_not_nullable"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" MODIFY \"ID\" numeric NOT NULL ;", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"PLAYER\" MODIFY \"ID\" numeric NOT NULL ;", ddl); } @Test @@ -109,79 +102,59 @@ public void dropColumnWithForeignKey() throws IOException { @Test public void dropColumnWithPrimaryKeyReferenced() throws IOException { String ddl = generateDDL("drop_column_with_primary_key_referenced"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + - "ALTER TABLE \"PLAYER\" DROP COLUMN \"ID\";", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + + "ALTER TABLE \"ROSETTA\".\"PLAYER\" DROP COLUMN \"ID\";", ddl); } @Test public void dropTableWhereColumnIsReferenced() throws IOException { String ddl = generateDDL("drop_table_where_column_is_referenced"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK_TEAM\";\r" + - "DROP TABLE \"TEAM\";", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK_TEAM\";\r" + + "DROP TABLE IF EXISTS \"ROSETTA\".\"TEAM\";", ddl); } @Test public void addForeignKey() throws IOException { String ddl = generateDDL("add_foreign_key"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" ADD CONSTRAINT PLAYER_FK FOREIGN KEY (\"POSITION_ID\") " + - "REFERENCES \"Position\"(\"ID\") ON DELETE NO ACTION ;\r", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"PLAYER\" ADD FOREIGN KEY (\"POSITION_ID\") " + + "REFERENCES \"ROSETTA\".\"Position\"(\"ID\") AS PLAYER_FK;", ddl); } @Test public void dropForeignKey() throws IOException { String ddl = generateDDL("drop_foreign_key"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";", ddl); - } - - @Test - public void dropPrimaryKey() throws IOException { - String ddl = generateDDL("drop_primary_key"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + - "ALTER TABLE \"PLAYER\" DROP PRIMARY KEY;", ddl); - } - - @Test - public void addPrimaryKey() throws IOException { - String ddl = generateDDL("add_primary_key"); - Assertions.assertEquals("ALTER TABLE \"PLAYER\" ADD PRIMARY KEY (\"ID\");", ddl); - } - - @Test - public void alterPrimaryKey() throws IOException { - String ddl = generateDDL("alter_primary_key"); - Assertions.assertEquals("\r" + - "ALTER TABLE \"PLAYER\" DROP PRIMARY KEY, ADD PRIMARY KEY (\"ID\", \"POSITION_ID\");\r", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";", ddl); } @Test public void alterForeignKeyName() throws IOException { String ddl = generateDDL("alter_foreign_key_name"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + - "ALTER TABLE \"TEAMPLAYERS\" ADD CONSTRAINT TEAMPLAYERS_CHANGED_FK FOREIGN KEY (\"PLAYERID\") REFERENCES " + - "\"PLAYER\"(\"ID\") ON DELETE NO ACTION ;\r", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + + "ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" ADD FOREIGN KEY (\"PLAYERID\") REFERENCES " + + "\"ROSETTA\".\"PLAYER\"(\"ID\") AS TEAMPLAYERS_CHANGED_FK;", ddl); } @Test public void alterForeignKey() throws IOException { String ddl = generateDDL("alter_foreign_key"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + - "ALTER TABLE \"TEAMPLAYERS\" ADD CONSTRAINT TEAMPLAYERS_FK FOREIGN KEY (\"PLAYERID\") REFERENCES \"PLAYER\"(\"ID\") ON DELETE SET NULL ;\r", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + + "ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" ADD FOREIGN KEY (\"PLAYERID\") REFERENCES \"ROSETTA\".\"PLAYER\"(\"ID\") AS TEAMPLAYERS_FK;", ddl); } @Test public void dropPrimaryKeyColumnAndAlterForeignKey() throws IOException { String ddl = generateDDL("drop_pk_column_and_alter_fk"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + - "ALTER TABLE \"PLAYER\" DROP COLUMN \"ID\";\r" + - "ALTER TABLE \"TEAMPLAYERS\" ADD CONSTRAINT TEAMPLAYERS_FK FOREIGN KEY (\"PLAYERID\") REFERENCES \"POSITION\"(\"ID\");\r", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + + "ALTER TABLE \"ROSETTA\".\"PLAYER\" DROP COLUMN \"ID\";\r" + + "ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" ADD FOREIGN KEY (\"PLAYERID\") REFERENCES \"ROSETTA\".\"POSITION\"(\"ID\") AS TEAMPLAYERS_FK;", ddl); } @Test public void dropTableWithPrimaryKeyColumnAndAlterForeignKey() throws IOException { String ddl = generateDDL("drop_table_with_pk_column_and_alter_fk"); - Assertions.assertEquals("ALTER TABLE \"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + - "DROP TABLE \"PLAYER\";\r" + - "ALTER TABLE \"TEAMPLAYERS\" ADD CONSTRAINT TEAMPLAYERS_FK FOREIGN KEY (\"PLAYERID\") REFERENCES \"POSITION\"(\"ID\");\r", ddl); + Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" DROP FOREIGN KEY \"TEAMPLAYERS_FK\";\r" + + "DROP TABLE IF EXISTS \"ROSETTA\".\"PLAYER\";\r" + + "ALTER TABLE \"ROSETTA\".\"TEAMPLAYERS\" ADD FOREIGN KEY (\"PLAYERID\") REFERENCES \"ROSETTA\".\"POSITION\"(\"ID\") AS TEAMPLAYERS_FK;", ddl); } private String generateDDL(String testType) throws IOException { diff --git a/ddl/src/test/resources/ddl/kinetica/add_column/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_column/actual_model.yaml index bf6b9096..f77bc3ae 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_column/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_column/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -42,6 +43,7 @@ tables: primaryKey: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "numeric" @@ -65,6 +67,7 @@ tables: primaryKey: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -98,6 +101,7 @@ tables: primaryKey: true - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "numeric" diff --git a/ddl/src/test/resources/ddl/kinetica/add_column/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_column/expected_model.yaml index 5c524f72..22c38c6d 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_column/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_column/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -42,6 +43,7 @@ tables: primaryKey: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "numeric" @@ -75,6 +77,7 @@ tables: primaryKey: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -108,6 +111,7 @@ tables: primaryKey: true - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "numeric" diff --git a/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/actual_model.yaml index 9e57f418..f89fcbbc 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/expected_model.yaml index 7dce64dc..5f7523dc 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_column_as_primary_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/actual_model.yaml index 9b8d60f2..fcd178a8 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/expected_model.yaml index 7dce64dc..9ef9cef3 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_column_with_foreign_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -22,11 +23,11 @@ tables: precision: 38 foreignKeys: - name: "PLAYER_FK" - schema: "FBAL" + schema: "ROSETTA" tableName: "PLAYER" columnName: "POSITION_ID" deleteRule: "3" - primaryTableSchema: "FBAL" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/add_foreign_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_foreign_key/actual_model.yaml index e25376d7..5aba4835 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_foreign_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_foreign_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -25,6 +26,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -58,6 +60,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -101,6 +104,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -112,8 +116,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -130,7 +136,9 @@ tables: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" columnName: "PLAYERID" + schema: "ROSETTA" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/add_foreign_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_foreign_key/expected_model.yaml index 83d0c45e..327e49a0 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_foreign_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_foreign_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -14,7 +15,9 @@ tables: - name: "PLAYER_FK" tableName: "PLAYER" columnName: "POSITION_ID" + schema: "ROSETTA" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -32,6 +35,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +69,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +113,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -137,7 +145,9 @@ tables: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" columnName: "PLAYERID" + schema: "ROSETTA" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/add_primary_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_primary_key/actual_model.yaml index e19629dd..b7ea0be7 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_primary_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_primary_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -32,6 +33,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/add_primary_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_primary_key/expected_model.yaml index 83d0c45e..94493c47 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_primary_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_primary_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -32,6 +33,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/add_table/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_table/actual_model.yaml index c9775762..671d2d1d 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_table/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_table/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -42,6 +43,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -75,6 +77,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" diff --git a/ddl/src/test/resources/ddl/kinetica/add_table/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/add_table/expected_model.yaml index e1105b91..e610e98a 100644 --- a/ddl/src/test/resources/ddl/kinetica/add_table/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/add_table/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -42,6 +43,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -75,6 +77,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/actual_model.yaml index 5c524f72..22c38c6d 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -42,6 +43,7 @@ tables: primaryKey: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "numeric" @@ -75,6 +77,7 @@ tables: primaryKey: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -108,6 +111,7 @@ tables: primaryKey: true - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "numeric" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/expected_model.yaml index 5078dbe9..d2f026c6 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_column_data_type/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "INTEGER" @@ -42,6 +43,7 @@ tables: primaryKey: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "numeric" @@ -75,6 +77,7 @@ tables: primaryKey: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -108,6 +111,7 @@ tables: primaryKey: true - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "numeric" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/actual_model.yaml index 52dc7165..79041164 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/expected_model.yaml index 7dce64dc..5f7523dc 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_column_to_not_nullable/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/actual_model.yaml index 7dce64dc..5f7523dc 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/expected_model.yaml index 52dc7165..79041164 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_column_to_nullable/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/actual_model.yaml index 5c524f72..062ca256 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -23,8 +24,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -42,6 +45,7 @@ tables: primaryKey: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "numeric" @@ -75,6 +79,7 @@ tables: primaryKey: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -108,6 +113,7 @@ tables: primaryKey: true - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "numeric" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -136,8 +144,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/expected_model.yaml index 5ea32768..6c537b81 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -23,8 +24,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -42,6 +45,7 @@ tables: primaryKey: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "numeric" @@ -75,6 +79,7 @@ tables: primaryKey: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "varchar" @@ -108,6 +113,7 @@ tables: primaryKey: true - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "numeric" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -136,8 +144,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "2" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/actual_model.yaml index 83d0c45e..58c79d1a 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -13,8 +14,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -32,6 +35,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +69,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +113,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -136,8 +144,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/expected_model.yaml index 1b90c34f..31c21d12 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_foreign_key_name/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -13,8 +14,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -32,6 +35,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +69,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +113,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -136,8 +144,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_CHANGED_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/alter_primary_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_primary_key/actual_model.yaml index 83d0c45e..94493c47 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_primary_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_primary_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -32,6 +33,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/alter_primary_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/alter_primary_key/expected_model.yaml index 41365595..a621cdb4 100644 --- a/ddl/src/test/resources/ddl/kinetica/alter_primary_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/alter_primary_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -32,6 +33,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/clean_database/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/clean_database/expected_model.yaml index e23d6e8c..24ead885 100644 --- a/ddl/src/test/resources/ddl/kinetica/clean_database/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/clean_database/expected_model.yaml @@ -3,6 +3,7 @@ tables: - name: "PLAYER" type: "TABLE" schema: "ROSETTA" + schema: "ROSETTA" columns: - name: "Name" typeName: "VARCHAR" @@ -37,6 +38,7 @@ tables: - name: "USER" type: "TABLE" schema: "ROSETTA" + schema: "ROSETTA" columns: - name: "USER_ID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_column/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_column/actual_model.yaml index e1105b91..e610e98a 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_column/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_column/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -42,6 +43,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -75,6 +77,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_column/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_column/expected_model.yaml index 620ddecd..eaf0c438 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_column/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_column/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -42,6 +43,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -98,6 +101,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/actual_model.yaml index 036b7b54..3e90c4e2 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -25,6 +26,7 @@ tables: nullable: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -58,6 +60,7 @@ tables: nullable: true - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -91,6 +94,7 @@ tables: nullable: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" @@ -102,8 +106,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" primaryKey: false @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" primaryKey: false diff --git a/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/expected_model.yaml index 39a2541b..2e0c5e71 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_column_with_primary_key_referenced/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -15,6 +16,7 @@ tables: nullable: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -48,6 +50,7 @@ tables: nullable: true - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -81,6 +84,7 @@ tables: nullable: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" @@ -92,8 +96,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" primaryKey: false @@ -109,8 +115,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" primaryKey: false diff --git a/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/actual_model.yaml index 83d0c45e..58c79d1a 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -13,8 +14,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -32,6 +35,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +69,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +113,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true @@ -136,8 +144,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/expected_model.yaml index 6a4d7abd..f158fdbb 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_foreign_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -13,8 +14,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -32,6 +35,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +69,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +113,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/actual_model.yaml index 036b7b54..3e90c4e2 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -25,6 +26,7 @@ tables: nullable: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -58,6 +60,7 @@ tables: nullable: true - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -91,6 +94,7 @@ tables: nullable: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" @@ -102,8 +106,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" primaryKey: false @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" primaryKey: false diff --git a/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/expected_model.yaml index 286b37d4..4f0614c6 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_pk_column_and_alter_fk/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -15,6 +16,7 @@ tables: nullable: true - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -48,6 +50,7 @@ tables: nullable: true - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -81,6 +84,7 @@ tables: nullable: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" @@ -92,8 +96,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" primaryKey: false @@ -109,8 +115,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "POSITION" primaryColumnName: "ID" primaryKey: false diff --git a/ddl/src/test/resources/ddl/kinetica/drop_primary_key/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_primary_key/actual_model.yaml index 83d0c45e..94493c47 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_primary_key/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_primary_key/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -32,6 +33,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_primary_key/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_primary_key/expected_model.yaml index e19629dd..b7ea0be7 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_primary_key/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_primary_key/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "POSITION_ID" typeName: "NUMBER" @@ -32,6 +33,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -65,6 +67,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_table/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_table/actual_model.yaml index e1105b91..e610e98a 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_table/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_table/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -42,6 +43,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -75,6 +77,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -108,6 +111,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_table/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_table/expected_model.yaml index 2c781453..5d205b4d 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_table/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_table/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -42,6 +43,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -75,6 +77,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" diff --git a/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/actual_model.yaml index 0e00f6f8..14bda9c0 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -23,8 +24,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -42,6 +45,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -75,6 +79,7 @@ tables: autoincrement: false - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -118,6 +123,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -129,8 +135,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/expected_model.yaml index 6692dd2a..616f4dd3 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_table_where_column_is_referenced/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -23,8 +24,10 @@ tables: foreignKeys: - name: "PLAYER_FK" tableName: "PLAYER" + schema: "ROSETTA" columnName: "POSITION_ID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "Position" primaryColumnName: "ID" nullable: true @@ -42,6 +45,7 @@ tables: autoincrement: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "NUMBER" @@ -75,6 +79,7 @@ tables: autoincrement: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "NUMBER" @@ -86,8 +91,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "3" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" nullable: true diff --git a/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/actual_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/actual_model.yaml index 036b7b54..3e90c4e2 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/actual_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/actual_model.yaml @@ -2,6 +2,7 @@ tables: - name: "PLAYER" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -25,6 +26,7 @@ tables: nullable: false - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -58,6 +60,7 @@ tables: nullable: true - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -91,6 +94,7 @@ tables: nullable: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" @@ -102,8 +106,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" primaryKey: false @@ -119,8 +125,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "PLAYER" primaryColumnName: "ID" primaryKey: false diff --git a/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/expected_model.yaml b/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/expected_model.yaml index e53a2f06..284b89dc 100644 --- a/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/expected_model.yaml +++ b/ddl/src/test/resources/ddl/kinetica/drop_table_with_pk_column_and_alter_fk/expected_model.yaml @@ -2,6 +2,7 @@ tables: - name: "Position" type: "TABLE" + schema: "ROSETTA" columns: - name: "ID" typeName: "DECIMAL" @@ -35,6 +36,7 @@ tables: nullable: true - name: "TEAM" type: "TABLE" + schema: "ROSETTA" columns: - name: "name" typeName: "VARCHAR" @@ -68,6 +70,7 @@ tables: nullable: false - name: "TEAMPLAYERS" type: "TABLE" + schema: "ROSETTA" columns: - name: "TEAMID" typeName: "DECIMAL" @@ -79,8 +82,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK_TEAM" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "TEAMID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "TEAM" primaryColumnName: "ID" primaryKey: false @@ -96,8 +101,10 @@ tables: foreignKeys: - name: "TEAMPLAYERS_FK" tableName: "TEAMPLAYERS" + schema: "ROSETTA" columnName: "PLAYERID" deleteRule: "1" + primaryTableSchema: "ROSETTA" primaryTableName: "POSITION" primaryColumnName: "ID" primaryKey: false diff --git a/diff/src/main/java/com/adaptivescale/rosetta/diff/DefaultTester.java b/diff/src/main/java/com/adaptivescale/rosetta/diff/DefaultTester.java index 01809078..d3293872 100644 --- a/diff/src/main/java/com/adaptivescale/rosetta/diff/DefaultTester.java +++ b/diff/src/main/java/com/adaptivescale/rosetta/diff/DefaultTester.java @@ -149,8 +149,11 @@ public List find(Database localValue, Database targetValue) { } private void testViews(Database localValue, Database targetValue, List changes) { + Collection localViews = Optional.ofNullable(localValue.getViews()) + .orElse(Collections.emptyList()); + //do we need to check for root properties if are changed - for (View view : localValue.getViews()) { + for (View view : localViews) { List columnsChangesLogs = new ArrayList<>(); Optional targetView = getView(view.getName(), targetValue); if (targetView.isEmpty()) { @@ -251,7 +254,7 @@ private void testViews(Database localValue, Database targetValue, List c changes.addAll(sameIndices(view.getIndices(), targetView.get().getIndices())); } - Set localViewName = localValue.getViews().stream().map(View::getName).collect(Collectors.toSet()); + Set localViewName = localViews.stream().map(View::getName).collect(Collectors.toSet()); List viewsAdded = targetValue .getViews() .stream() diff --git a/translator/src/main/resources/translations/postgres_kinetica.json b/translator/src/main/resources/translations/postgres_kinetica.json index 20d58825..9cd15079 100644 --- a/translator/src/main/resources/translations/postgres_kinetica.json +++ b/translator/src/main/resources/translations/postgres_kinetica.json @@ -81,9 +81,6 @@ }, { "typeName": "smallserial" - }, - { - "typeName": "int2" } ] }, @@ -104,6 +101,9 @@ }, { "typeName": "year" + }, + { + "typeName": "int2" } ] },