use of org.apache.kudu.client.CreateTableOptions 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.getName(), 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