use of org.apache.kudu.ColumnSchema in project drill by apache.
the class KuduRecordWriterImpl method updateSchema.
@Override
public void updateSchema(VectorAccessible batch) throws IOException {
BatchSchema schema = batch.getSchema();
int i = 0;
try {
if (!checkForTable(name)) {
List<ColumnSchema> columns = new ArrayList<>();
for (MaterializedField f : schema) {
columns.add(new ColumnSchema.ColumnSchemaBuilder(f.getLastName(), getType(f.getType())).nullable(f.getType().getMode() == DataMode.OPTIONAL).key(i == 0).build());
i++;
}
Schema kuduSchema = new Schema(columns);
table = client.createTable(name, kuduSchema, new CreateTableOptions());
}
} catch (Exception e) {
throw new IOException(e);
}
}
Aggregations