From 22c71bab5e32ce7938e39abe9fa55ac4a058b4b2 Mon Sep 17 00:00:00 2001 From: Femi3211 Date: Wed, 18 Jan 2023 15:03:04 +0100 Subject: [PATCH 1/9] Modified: Added more comments explaining driver usage for pyspark and scala template --- .../resources/templates/python/spark_code.sqlt | 12 ++++++++++++ .../main/resources/templates/scala/scala_code.sqlt | 14 ++++++++++++++ 2 files changed, 26 insertions(+) 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) From f2f7a35423d975847a6109ff4a324e1b5b7da4ee Mon Sep 17 00:00:00 2001 From: Femi3211 Date: Thu, 19 Jan 2023 11:18:25 +0100 Subject: [PATCH 2/9] Modified: fixed typo in ReadMe for generate command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] From 9d7807fed9ba5428df48fdf0bb5de5e0fb34e3c0 Mon Sep 17 00:00:00 2001 From: nbesimi Date: Tue, 24 Jan 2023 23:50:02 +0100 Subject: [PATCH 3/9] fixed: kinetica ddl generator --- .../ddl/targets/kinetica/KineticaDDLGenerator.java | 12 +++++++----- .../resources/translations/postgres_kinetica.json | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) 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..ca89382e 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 @@ -100,11 +100,13 @@ public String createDatabase(Database database, boolean dropTableIfExists) { @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"; + return ""; +// return "ALTER TABLE" + handleNullSchema(foreignKey.getSchema(), foreignKey.getTableName()) +// + " ADD FOREIGN KEY ("+ DEFAULT_WRAPPER + foreignKey.getColumnName() + DEFAULT_WRAPPER +") REFERENCES " +// + handleNullSchema(foreignKey.getPrimaryTableSchema(), foreignKey.getPrimaryTableName()) +// + "("+ DEFAULT_WRAPPER + foreignKey.getPrimaryColumnName()+ DEFAULT_WRAPPER + ")" +// + foreignKeyDeleteRuleSanitation(foreignKeyDeleteRule(foreignKey)) +// + " AS " + foreignKey.getName() + ";\r"; } @Override 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" } ] }, From 3185503bd2f617fec0cdd8b45a290d11cab85872 Mon Sep 17 00:00:00 2001 From: nbesimi Date: Wed, 25 Jan 2023 13:57:42 +0100 Subject: [PATCH 4/9] fixed: Kinetica ddl issue --- .../ddl/targets/kinetica/KineticaDDLGenerator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 ca89382e..27526820 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 @@ -52,7 +52,7 @@ public String createTable(Table table, boolean dropTableIfExists) { stringBuilder.append(DEFAULT_WRAPPER).append(table.getName()).append(DEFAULT_WRAPPER).append("; \n"); } - stringBuilder.append("CREATE TABLE "); + stringBuilder.append("CREATE REPLICATED TABLE "); if (table.getSchema() != null && !table.getSchema().isBlank()) { stringBuilder.append(DEFAULT_WRAPPER) @@ -100,13 +100,13 @@ public String createDatabase(Database database, boolean dropTableIfExists) { @Override public String createForeignKey(ForeignKey foreignKey) { - return ""; -// return "ALTER TABLE" + handleNullSchema(foreignKey.getSchema(), foreignKey.getTableName()) -// + " ADD FOREIGN KEY ("+ DEFAULT_WRAPPER + foreignKey.getColumnName() + DEFAULT_WRAPPER +") REFERENCES " -// + handleNullSchema(foreignKey.getPrimaryTableSchema(), foreignKey.getPrimaryTableName()) -// + "("+ DEFAULT_WRAPPER + foreignKey.getPrimaryColumnName()+ DEFAULT_WRAPPER + ")" +// return ""; + return "ALTER TABLE" + handleNullSchema(foreignKey.getSchema(), foreignKey.getTableName()) + + " ADD FOREIGN KEY ("+ DEFAULT_WRAPPER + foreignKey.getColumnName() + DEFAULT_WRAPPER +") REFERENCES " + + handleNullSchema(foreignKey.getPrimaryTableSchema(), foreignKey.getPrimaryTableName()) + + "("+ DEFAULT_WRAPPER + foreignKey.getPrimaryColumnName()+ DEFAULT_WRAPPER + ")" // + foreignKeyDeleteRuleSanitation(foreignKeyDeleteRule(foreignKey)) -// + " AS " + foreignKey.getName() + ";\r"; + + " AS " + foreignKey.getName() + ";\r"; } @Override From 916d6533a47e762c25a62f3223c36ab2ee4dda68 Mon Sep 17 00:00:00 2001 From: Nuhi Date: Wed, 25 Jan 2023 14:27:54 +0100 Subject: [PATCH 5/9] Fix/views diff check npe (#130) * fixed: kinetica ddl generator * fixed: views diff check npe * fixed: views diff check npe * Update KineticaDDLGenerator.java * fixed: view diff check npe * fixed: view diff check npe --- .../java/com/adaptivescale/rosetta/diff/DefaultTester.java | 7 +++++-- .../src/main/resources/translations/postgres_kinetica.json | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) 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" } ] }, From 8fc738d7f0fe876b1ef219ff9798de9fc2960c05 Mon Sep 17 00:00:00 2001 From: nbesimi Date: Thu, 26 Jan 2023 14:29:04 +0100 Subject: [PATCH 6/9] fixed: kinetica ddl generator --- .../kinetica/KineticaDDLGenerator.java | 202 +++++++++--------- .../decorators/KineticaColumnTypeName.java | 6 + .../templates/kinetica/column/add.sqlt | 1 + .../templates/kinetica/column/drop.sqlt | 1 + .../templates/kinetica/column/modify.sqlt | 1 + .../templates/kinetica/foreignkey/create.sqlt | 1 + .../templates/kinetica/foreignkey/drop.sqlt | 1 + .../templates/kinetica/schema/create.sqlt | 1 + .../templates/kinetica/table/alter.sqlt | 0 .../templates/kinetica/table/create.sqlt | 1 + .../templates/kinetica/table/drop.sqlt | 1 + .../rosetta/ddl/test/KineticaDDLTest.java | 81 +++---- .../ddl/kinetica/add_column/actual_model.yaml | 4 + .../kinetica/add_column/expected_model.yaml | 4 + .../actual_model.yaml | 1 + .../expected_model.yaml | 1 + .../actual_model.yaml | 1 + .../expected_model.yaml | 5 +- .../add_foreign_key/actual_model.yaml | 8 + .../add_foreign_key/expected_model.yaml | 10 + .../add_primary_key/actual_model.yaml | 4 + .../add_primary_key/expected_model.yaml | 4 + .../ddl/kinetica/add_table/actual_model.yaml | 3 + .../kinetica/add_table/expected_model.yaml | 4 + .../alter_column_data_type/actual_model.yaml | 4 + .../expected_model.yaml | 4 + .../actual_model.yaml | 1 + .../expected_model.yaml | 1 + .../actual_model.yaml | 1 + .../expected_model.yaml | 1 + .../alter_foreign_key/actual_model.yaml | 10 + .../alter_foreign_key/expected_model.yaml | 10 + .../alter_foreign_key_name/actual_model.yaml | 10 + .../expected_model.yaml | 10 + .../alter_primary_key/actual_model.yaml | 4 + .../alter_primary_key/expected_model.yaml | 4 + .../clean_database/expected_model.yaml | 2 + .../kinetica/drop_column/actual_model.yaml | 4 + .../kinetica/drop_column/expected_model.yaml | 4 + .../actual_model.yaml | 8 + .../expected_model.yaml | 8 + .../drop_foreign_key/actual_model.yaml | 10 + .../drop_foreign_key/expected_model.yaml | 8 + .../actual_model.yaml | 8 + .../expected_model.yaml | 8 + .../drop_primary_key/actual_model.yaml | 4 + .../drop_primary_key/expected_model.yaml | 4 + .../ddl/kinetica/drop_table/actual_model.yaml | 4 + .../kinetica/drop_table/expected_model.yaml | 3 + .../actual_model.yaml | 8 + .../expected_model.yaml | 7 + .../actual_model.yaml | 8 + .../expected_model.yaml | 7 + 53 files changed, 354 insertions(+), 157 deletions(-) create mode 100644 ddl/src/main/resources/templates/kinetica/column/add.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/column/drop.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/column/modify.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/foreignkey/create.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/foreignkey/drop.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/schema/create.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/table/alter.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/table/create.sqlt create mode 100644 ddl/src/main/resources/templates/kinetica/table/drop.sqlt 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 27526820..410db0bc 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 REPLICATED TABLE "); + createParams.put("schemaName", table.getSchema()); + createParams.put("tableName", table.getName()); + createParams.put("tableCode", definitionAsString); + stringBuilder.append(TemplateEngine.process(TABLE_CREATE_TEMPLATE, createParams)); - if (table.getSchema() != null && !table.getSchema().isBlank()) { - stringBuilder.append(DEFAULT_WRAPPER) - .append(table.getSchema()).append(DEFAULT_WRAPPER).append("."); - } - - stringBuilder.append(DEFAULT_WRAPPER).append(table.getName()).append(DEFAULT_WRAPPER).append("(").append(definitionAsString).append(");"); return stringBuilder.toString(); } @@ -70,27 +82,26 @@ 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"))); + .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()); + .getTables() + .stream() + .map(this::foreignKeys) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.joining()); if (!foreignKeys.isEmpty()) { stringBuilder.append("\r").append(foreignKeys).append("\r"); @@ -100,13 +111,15 @@ public String createDatabase(Database database, boolean dropTableIfExists) { @Override public String createForeignKey(ForeignKey foreignKey) { -// return ""; - return "ALTER TABLE" + handleNullSchema(foreignKey.getSchema(), foreignKey.getTableName()) - + " ADD FOREIGN KEY ("+ DEFAULT_WRAPPER + foreignKey.getColumnName() + DEFAULT_WRAPPER +") REFERENCES " - + handleNullSchema(foreignKey.getPrimaryTableSchema(), foreignKey.getPrimaryTableName()) - + "("+ DEFAULT_WRAPPER + foreignKey.getPrimaryColumnName()+ DEFAULT_WRAPPER + ")" -// + foreignKeyDeleteRuleSanitation(foreignKeyDeleteRule(foreignKey)) - + " AS " + foreignKey.getName() + ";\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 @@ -117,9 +130,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(), @@ -133,9 +149,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 @@ -143,15 +161,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 @@ -161,43 +183,28 @@ 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()); + + primaryKeys.addAll(foreignKeysForTable); if (primaryKeys.isEmpty()) { return Optional.empty(); @@ -208,12 +215,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); } + 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()); + } + //ALTER TABLE rosetta.contacts ADD CONSTRAINT contacts_fk FOREIGN KEY (contact_id) REFERENCES rosetta."user"(user_id); private String createForeignKeys(Column column) { return column.getForeignKeys().stream().map(this::createForeignKey).collect(Collectors.joining()); @@ -230,24 +245,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..a1ce7895 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,9 @@ public String nameForColumn(Column column) { if ( !PRECISION_DEFAULTS.contains(column.getPrecision()) && PRECISION_TYPES.contains(column.getTypeName().toLowerCase())) { builder.append("(").append(column.getPrecision()).append(")"); } + 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/test/java/com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java b/ddl/src/test/java/com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java index 792ed24b..d68d0225 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(SHARD_KEY);\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 From 4b1fdd0b20011ddfd66aab0ec1e9fa3d10fdeb5e Mon Sep 17 00:00:00 2001 From: nbesimi Date: Thu, 26 Jan 2023 22:41:18 +0100 Subject: [PATCH 7/9] disbaled: foreign keys in kinetica --- .../kinetica/KineticaDDLGenerator.java | 27 ++++++++++--------- .../decorators/KineticaColumnTypeName.java | 7 ++--- 2 files changed, 19 insertions(+), 15 deletions(-) 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 410db0bc..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 @@ -95,17 +95,20 @@ public String createDatabase(Database database, boolean dropTableIfExists) { .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()); + //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"); +// } - if (!foreignKeys.isEmpty()) { - stringBuilder.append("\r").append(foreignKeys).append("\r"); - } return stringBuilder.toString(); } @@ -204,7 +207,8 @@ private Optional createPrimaryKeysForTable(Table table, List for .map(pk -> String.format(DEFAULT_WRAPPER+"%s"+DEFAULT_WRAPPER, pk.getName())) .collect(Collectors.toList()); - primaryKeys.addAll(foreignKeysForTable); + //TODO: Enable this with foreign key functionality +// primaryKeys.addAll(foreignKeysForTable); if (primaryKeys.isEmpty()) { return Optional.empty(); @@ -229,7 +233,6 @@ private List getForeignKeysColumnNames(Table table) { .collect(Collectors.toList()); } - //ALTER TABLE rosetta.contacts ADD CONSTRAINT contacts_fk FOREIGN KEY (contact_id) REFERENCES rosetta."user"(user_id); private String createForeignKeys(Column column) { return column.getForeignKeys().stream().map(this::createForeignKey).collect(Collectors.joining()); } 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 a1ce7895..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 @@ -17,9 +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(")"); } - if (column.getForeignKeys() != null && !column.getForeignKeys().isEmpty()) { - builder.append(SHARD_KEY); - } + //TODO: Enable this with foreign key functionality +// if (column.getForeignKeys() != null && !column.getForeignKeys().isEmpty()) { +// builder.append(SHARD_KEY); +// } return builder.toString(); } } From 7c53e6e9076f97373d8287d168eba839a050f7b3 Mon Sep 17 00:00:00 2001 From: nbesimi Date: Thu, 26 Jan 2023 22:46:04 +0100 Subject: [PATCH 8/9] fixed: tests --- .../com/adaptivescale/rosetta/ddl/test/KineticaDDLTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d68d0225..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 @@ -64,7 +64,7 @@ public void addColumn() throws IOException { @Test public void addColumnWithForeignKey() throws IOException { String ddl = generateDDL("add_column_with_foreign_key"); - Assertions.assertEquals("ALTER TABLE \"ROSETTA\".\"PLAYER\" ADD \"POSITION_ID\" numeric(SHARD_KEY);\r" + + 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); } From cf01afcb8e3f7fad552f924ce41cb7b31b6afc74 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 21:56:01 +0000 Subject: [PATCH 9/9] Version bump: to 1.8.3 --- build.gradle | 2 +- cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 {