use of com.google.cloud.teleport.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class CopyDbTest method checkConstraints.
// TODO: enable this test once CHECK constraints are enabled
// @Test
public void checkConstraints() throws Exception {
// spotless:off
Ddl ddl = Ddl.builder().createTable("T").column("id").int64().endColumn().column("A").int64().endColumn().primaryKey().asc("id").end().checkConstraints(ImmutableList.of("CONSTRAINT `ck` CHECK(TO_HEX(SHA1(CAST(A AS STRING))) <= '~')")).endTable().build();
// spotless:on
createAndPopulate(ddl, 100);
runTest();
}
use of com.google.cloud.teleport.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class CopyDbTest method allEmptyPgTables.
@Test
public void allEmptyPgTables() throws Exception {
// spotless:off
Ddl ddl = Ddl.builder(Dialect.POSTGRESQL).createTable("Users").column("first_name").pgVarchar().max().endColumn().column("last_name").pgVarchar().size(5).endColumn().column("age").pgInt8().endColumn().primaryKey().asc("first_name").asc("last_name").end().endTable().createTable("AllTYPES").column("first_name").pgVarchar().max().endColumn().column("last_name").pgVarchar().size(5).endColumn().column("id").pgInt8().notNull().endColumn().column("bool_field").pgBool().endColumn().column("int_field").pgInt8().endColumn().column("float_field").pgFloat8().endColumn().column("string_field").pgText().endColumn().column("bytes_field").pgBytea().endColumn().column("timestamp_field").pgTimestamptz().endColumn().column("numeric_field").pgNumeric().endColumn().primaryKey().asc("first_name").asc("last_name").asc("id").end().interleaveInParent("Users").onDeleteCascade().endTable().build();
// spotless:on
createAndPopulate(ddl, 0);
runTest(Dialect.POSTGRESQL);
}
use of com.google.cloud.teleport.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class CopyDbTest method pgCheckConstraints.
@Test
public void pgCheckConstraints() throws Exception {
// spotless:off
Ddl ddl = Ddl.builder(Dialect.POSTGRESQL).createTable("T").column("id").pgInt8().endColumn().column("A").pgInt8().endColumn().primaryKey().asc("id").end().checkConstraints(ImmutableList.of("CONSTRAINT \"ck\" CHECK(LENGTH(CAST(\"A\" AS VARCHAR)) >= '0'::bigint)")).endTable().build();
// spotless:on
createAndPopulate(ddl, 100);
runTest(Dialect.POSTGRESQL);
}
use of com.google.cloud.teleport.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class CopyDbTest method allEmptyTables.
@Test
public void allEmptyTables() throws Exception {
// spotless:off
Ddl ddl = Ddl.builder().createTable("Users").column("first_name").string().max().endColumn().column("last_name").string().size(5).endColumn().column("age").int64().endColumn().primaryKey().asc("first_name").desc("last_name").end().endTable().createTable("AllTYPES").column("first_name").string().max().endColumn().column("last_name").string().size(5).endColumn().column("id").int64().notNull().endColumn().column("bool_field").bool().endColumn().column("int64_field").int64().endColumn().column("float64_field").float64().endColumn().column("string_field").string().max().endColumn().column("bytes_field").bytes().max().endColumn().column("timestamp_field").timestamp().endColumn().column("date_field").date().endColumn().column("arr_bool_field").type(Type.array(Type.bool())).endColumn().column("arr_int64_field").type(Type.array(Type.int64())).endColumn().column("arr_float64_field").type(Type.array(Type.float64())).endColumn().column("arr_string_field").type(Type.array(Type.string())).max().endColumn().column("arr_bytes_field").type(Type.array(Type.bytes())).max().endColumn().column("arr_timestamp_field").type(Type.array(Type.timestamp())).endColumn().column("arr_date_field").type(Type.array(Type.date())).endColumn().primaryKey().asc("first_name").desc("last_name").asc("id").end().interleaveInParent("Users").endTable().build();
// spotless:on
createAndPopulate(ddl, 0);
runTest();
}
use of com.google.cloud.teleport.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class CopyDbTest method emptyPgTables.
@Test
public void emptyPgTables() throws Exception {
// spotless:off
Ddl ddl = Ddl.builder(Dialect.POSTGRESQL).createTable("Users").column("first_name").pgVarchar().max().endColumn().column("last_name").pgVarchar().size(5).endColumn().column("age").pgInt8().endColumn().primaryKey().asc("first_name").asc("last_name").end().endTable().createTable("AllTYPES").column("first_name").pgVarchar().max().endColumn().column("last_name").pgVarchar().size(5).endColumn().column("id").pgInt8().notNull().endColumn().column("bool_field").pgBool().endColumn().column("int_field").pgInt8().endColumn().column("float_field").pgFloat8().endColumn().column("string_field").pgText().endColumn().column("bytes_field").pgBytea().endColumn().column("timestamp_field").pgTimestamptz().endColumn().column("numeric_field").pgNumeric().endColumn().primaryKey().asc("first_name").asc("last_name").asc("id").end().interleaveInParent("Users").onDeleteCascade().endTable().build();
createAndPopulate(ddl, 10);
// Add empty tables.
Ddl emptyTables = Ddl.builder(Dialect.POSTGRESQL).createTable("empty_one").column("first").pgVarchar().max().endColumn().column("second").pgVarchar().size(5).endColumn().column("value").pgInt8().endColumn().primaryKey().asc("first").asc("second").end().endTable().createTable("empty_two").column("first").pgVarchar().max().endColumn().column("second").pgVarchar().size(5).endColumn().column("value").pgInt8().endColumn().column("another_value").pgInt8().endColumn().primaryKey().asc("first").end().endTable().build();
// spotless:on
spannerServer.updateDatabase(sourceDb, emptyTables.createTableStatements());
runTest(Dialect.POSTGRESQL);
}
Aggregations