def test_create_schema(self): col1 = kudu.ColumnSchema.create('key', kudu.INT32) col2 = kudu.ColumnSchema.create('int_val', kudu.INT32) col3 = kudu.ColumnSchema.create('string_val', kudu.STRING) cols = [col1, col2, col3] # One key column schema = kudu.schema_from_list(cols, 1) self.assertEqual(len(schema), 3) # Question whether we want to go the overloading route self.assertTrue(schema.at(0).equals(col1)) self.assertTrue(schema.at(1).equals(col2)) self.assertTrue(schema.at(2).equals(col3))
def open_or_create_table(client, table, drop=False): """Based on the default dstat column names create a new table indexed by a timstamp col""" exists = False if client.table_exists(table): exists = True if drop: client.delete_table(table) exists = False if not exists: # Create the schema for the table, basically all float cols cols = [kudu.ColumnSchema.create("ts", kudu.INT64)] cols += [kudu.ColumnSchema.create(x, kudu.FLOAT) for x in DSTAT_COL_NAMES] # Based on the column meta data create a new schema object, where the first column # is the key column. schema = kudu.schema_from_list(cols, 1) client.create_table(table, schema) return client.open_table(table)
def open_or_create_table(client, table, drop=False): """Based on the default dstat column names create a new table indexed by a timstamp col""" exists = False if client.table_exists(table): exists = True if drop: client.delete_table(table) exists = False if not exists: # Create the schema for the table, basically all float cols cols = [kudu.ColumnSchema.create("ts", kudu.INT64)] cols += [ kudu.ColumnSchema.create(x, kudu.FLOAT) for x in DSTAT_COL_NAMES ] # Based on the column meta data create a new schema object, where the first column # is the key column. schema = kudu.schema_from_list(cols, 1) client.create_table(table, schema) return client.open_table(table)
def example_schema(cls): col1 = kudu.ColumnSchema.create('key', kudu.INT32) col2 = kudu.ColumnSchema.create('int_val', kudu.INT32) col3 = kudu.ColumnSchema.create('string_val', kudu.STRING) return kudu.schema_from_list([col1, col2, col3], 1)