Search in sources :

Example 6 with InformationSchemaScanner

use of com.google.cloud.teleport.spanner.ddl.InformationSchemaScanner in project DataflowTemplates by GoogleCloudPlatform.

the class CopyDbTest method readDdl.

/* Returns the Ddl representing a Spanner database for given a String for the database name */
private Ddl readDdl(String db, Dialect dialect) {
    DatabaseClient dbClient = spannerServer.getDbClient(db);
    Ddl ddl;
    try (ReadOnlyTransaction ctx = dbClient.readOnlyTransaction()) {
        ddl = new InformationSchemaScanner(ctx, dialect).scan();
    }
    return ddl;
}
Also used : InformationSchemaScanner(com.google.cloud.teleport.spanner.ddl.InformationSchemaScanner) DatabaseClient(com.google.cloud.spanner.DatabaseClient) ReadOnlyTransaction(com.google.cloud.spanner.ReadOnlyTransaction) Ddl(com.google.cloud.teleport.spanner.ddl.Ddl)

Example 7 with InformationSchemaScanner

use of com.google.cloud.teleport.spanner.ddl.InformationSchemaScanner in project DataflowTemplates by GoogleCloudPlatform.

the class ExportTimestampTest method readDdl.

private Ddl readDdl(String db) {
    SpannerOptions spannerOptions = SpannerOptions.newBuilder().build();
    Spanner client = spannerOptions.getService();
    Ddl ddl;
    try (ReadOnlyTransaction ctx = spannerServer.getDbClient(db).readOnlyTransaction()) {
        ddl = new InformationSchemaScanner(ctx).scan();
    }
    return ddl;
}
Also used : InformationSchemaScanner(com.google.cloud.teleport.spanner.ddl.InformationSchemaScanner) ReadOnlyTransaction(com.google.cloud.spanner.ReadOnlyTransaction) Ddl(com.google.cloud.teleport.spanner.ddl.Ddl) SpannerOptions(com.google.cloud.spanner.SpannerOptions) Spanner(com.google.cloud.spanner.Spanner)

Aggregations

ReadOnlyTransaction (com.google.cloud.spanner.ReadOnlyTransaction)7 Ddl (com.google.cloud.teleport.spanner.ddl.Ddl)7 InformationSchemaScanner (com.google.cloud.teleport.spanner.ddl.InformationSchemaScanner)7 DatabaseClient (com.google.cloud.spanner.DatabaseClient)3 File (java.io.File)3 DataFileWriter (org.apache.avro.file.DataFileWriter)3 GenericRecord (org.apache.avro.generic.GenericRecord)3 PipelineResult (org.apache.beam.sdk.PipelineResult)3 Spanner (com.google.cloud.spanner.Spanner)1 SpannerOptions (com.google.cloud.spanner.SpannerOptions)1 HashMap (java.util.HashMap)1 Schema (org.apache.avro.Schema)1 Test (org.junit.Test)1