Search in sources :

Example 1 with MysqlColumn

use of com.google.api.services.datastream.v1alpha1.model.MysqlColumn in project DataflowTemplates by GoogleCloudPlatform.

the class DataStreamClient method getMysqlObjectSchema.

private Map<String, StandardSQLTypeName> getMysqlObjectSchema(String streamName, String schemaName, String tableName, SourceConfig sourceConnProfile) throws IOException {
    Map<String, StandardSQLTypeName> objectSchema = new HashMap<String, StandardSQLTypeName>();
    MysqlTable table = discoverMysqlTableSchema(streamName, schemaName, tableName, sourceConnProfile);
    for (MysqlColumn column : table.getMysqlColumns()) {
        StandardSQLTypeName bqType = convertMysqlToBigQueryColumnType(column);
        objectSchema.put(column.getColumnName(), bqType);
    }
    return objectSchema;
}
Also used : MysqlTable(com.google.api.services.datastream.v1alpha1.model.MysqlTable) HashMap(java.util.HashMap) StandardSQLTypeName(com.google.cloud.bigquery.StandardSQLTypeName) MysqlColumn(com.google.api.services.datastream.v1alpha1.model.MysqlColumn)

Example 2 with MysqlColumn

use of com.google.api.services.datastream.v1alpha1.model.MysqlColumn in project DataflowTemplates by GoogleCloudPlatform.

the class DataStreamClient method getMysqlPrimaryKeys.

public List<String> getMysqlPrimaryKeys(String streamName, String schemaName, String tableName, SourceConfig sourceConnProfile) throws IOException {
    List<String> primaryKeys = new ArrayList<String>();
    MysqlTable table = discoverMysqlTableSchema(streamName, schemaName, tableName, sourceConnProfile);
    for (MysqlColumn column : table.getMysqlColumns()) {
        Boolean isPrimaryKey = column.getPrimaryKey();
        if (BooleanUtils.isTrue(isPrimaryKey)) {
            primaryKeys.add(column.getColumnName());
        }
    }
    return primaryKeys;
}
Also used : MysqlTable(com.google.api.services.datastream.v1alpha1.model.MysqlTable) ArrayList(java.util.ArrayList) MysqlColumn(com.google.api.services.datastream.v1alpha1.model.MysqlColumn)

Aggregations

MysqlColumn (com.google.api.services.datastream.v1alpha1.model.MysqlColumn)2 MysqlTable (com.google.api.services.datastream.v1alpha1.model.MysqlTable)2 StandardSQLTypeName (com.google.cloud.bigquery.StandardSQLTypeName)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1