client.createTable(tableName, schema, builder); } catch (Exception e) { if (!e.getMessage().contains("already exists")) {
private void createAndFillSchemasTable(KuduClient client) throws KuduException { List<String> existingSchemaNames = listSchemaNamesFromTablets(client); ColumnSchema schemaColumnSchema = new ColumnSchema.ColumnSchemaBuilder("schema", Type.STRING) .key(true).build(); Schema schema = new Schema(ImmutableList.of(schemaColumnSchema)); CreateTableOptions options = new CreateTableOptions(); options.addHashPartitions(ImmutableList.of(schemaColumnSchema.getName()), 2); KuduTable schemasTable = client.createTable(rawSchemasTableName, schema, options); KuduSession session = client.newSession(); try { session.setFlushMode(SessionConfiguration.FlushMode.AUTO_FLUSH_BACKGROUND); for (String schemaName : existingSchemaNames) { Insert insert = schemasTable.newInsert(); insert.getRow().addString(0, schemaName); session.apply(insert); } } finally { session.close(); } }
@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); } }
public KuduTable createTable(ConnectorTableMetadata tableMetadata, boolean ignoreExisting) { try { String rawName = schemaEmulation.toRawName(tableMetadata.getTable()); if (ignoreExisting) { if (client.tableExists(rawName)) { return null; } } if (!schemaEmulation.existsSchema(client, tableMetadata.getTable().getSchemaName())) { throw new SchemaNotFoundException(tableMetadata.getTable().getSchemaName()); } List<ColumnMetadata> columns = tableMetadata.getColumns(); Map<String, Object> properties = tableMetadata.getProperties(); Schema schema = buildSchema(columns, properties); CreateTableOptions options = buildCreateTableOptions(schema, properties); return client.createTable(rawName, schema, options); } catch (KuduException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, e); } }
client.createTable(tableName, schema, builder);
client.createTable(tableInfo.getTableName(), schema, builder); logger.debug("Table: " + tableInfo.getTableName() + " created successfully");
private void createSchema(String tableName, Schema schema, int numTablets) throws Exception { if (client.tableExists(tableName)) { return; } CreateTableOptions builder = getCreateTableOptions(schema, parser.getNumReplicas(), numTablets, 1); client.createTable(tableName, schema, builder); }
private KuduTable table(KuduTableInfo infoTable) throws IOException { KuduClient syncClient = client.syncClient(); String tableName = infoTable.getName(); if (syncClient.tableExists(tableName)) { return syncClient.openTable(tableName); } if (infoTable.createIfNotExist()) { return syncClient.createTable(tableName, infoTable.getSchema(), infoTable.getCreateTableOptions()); } throw new UnsupportedOperationException("table not exists and is marketed to not be created"); }
/** * A generic helper function to create a table with default test options. */ public static KuduTable createDefaultTable(KuduClient client, String tableName) throws KuduException { return client.createTable(tableName, getBasicSchema(), getBasicCreateTableOptions()); }
@Test(expected=IllegalArgumentException.class) public void testNoDefaultPartitioning() throws Exception { client.createTable(TABLE_NAME, basicSchema, new CreateTableOptions()); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, schema, new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key"))); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, schema, new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key"))); }
@Before public void setUp() throws Exception { client = harness.getClient(); // Using multiple tablets doesn't work with the current way this test works since we could // jump from one TS to another which changes the logical clock. CreateTableOptions builder = new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key")); table = client.createTable(TABLE_NAME, schema, builder); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, schema, new CreateTableOptions().setRangePartitionColumns(ImmutableList.of("key"))); }
@Test(timeout = 100000) public void testFormatRangePartitionsUnbounded() throws Exception { CreateTableOptions builder = getBasicCreateTableOptions(); client.createTable(tableName, basicSchema, builder); assertEquals( ImmutableList.of("UNBOUNDED"), client.openTable(tableName).getFormattedRangePartitions(10000)); }
@Before public void setUp() throws Exception { client = harness.getAsyncClient(); table = harness.getClient().createTable(TABLE_NAME, schema, getBasicCreateTableOptions()); }
@Before public void setUp() throws Exception { CreateTableOptions options = getBasicCreateTableOptions().setNumReplicas(1); table = harness.getClient().createTable(TABLE_NAME, getBasicSchema(), options); }
@Test(timeout = 100000) public void testGetRangePartitionsUnbounded() throws Exception { CreateTableOptions builder = getBasicCreateTableOptions(); KuduTable table = client.createTable(tableName, BASIC_SCHEMA, builder); List<Partition> rangePartitions = table.getRangePartitions(client.getDefaultOperationTimeoutMs()); assertEquals(rangePartitions.size(), 1); Partition partition = rangePartitions.get(0); assertEquals(0, partition.getRangeKeyStart().length); assertEquals(0, partition.getRangeKeyEnd().length); }
@Before public void setUp() throws Exception { harness.getClient().createTable(TABLE_NAME, allTypesSchema, getAllTypesCreateTableOptions()); table = harness.getClient().openTable(TABLE_NAME); }
@Before public void setUp() throws Exception { CreateTableOptions builder = getBasicCreateTableOptions(); harness.getClient().createTable(TABLE_NAME, getBasicSchema(), builder); table = harness.getClient().openTable(TABLE_NAME); }