use of io.crate.sql.tree.CreateTable in project crate by crate.
the class MetaDataToASTNodeResolverTest method testBuildCreateTableClusteredByPartitionedBy.
@Test
public void testBuildCreateTableClusteredByPartitionedBy() throws Exception {
TableIdent ident = new TableIdent("myschema", "test");
List<Reference> columns = ImmutableList.of(newReference(ident, "id", DataTypes.LONG), newReference(ident, "partition_column", DataTypes.STRING, null, null, true), newReference(ident, "cluster_column", DataTypes.STRING));
DocTableInfo tableInfo = new TestDocTableInfo(ident, 5, "0-all", columns, ImmutableList.of(columns.get(1)), ImmutableList.<GeneratedReference>of(), ImmutableMap.<ColumnIdent, IndexReference>of(), referencesMap(columns), ImmutableMap.<ColumnIdent, String>of(), ImmutableList.<ColumnIdent>of(), new ColumnIdent("cluster_column"), ImmutableMap.<String, Object>of(), ImmutableList.of(columns.get(1).ident().columnIdent()), ColumnPolicy.DYNAMIC);
CreateTable node = MetaDataToASTNodeResolver.resolveCreateTable(tableInfo);
assertEquals("CREATE TABLE IF NOT EXISTS \"myschema\".\"test\" (\n" + " \"id\" LONG,\n" + " \"partition_column\" STRING,\n" + " \"cluster_column\" STRING\n" + ")\n" + "CLUSTERED BY (\"cluster_column\") INTO 5 SHARDS\n" + "PARTITIONED BY (\"partition_column\")\n" + "WITH (\n" + " column_policy = 'dynamic',\n" + " number_of_replicas = '0-all'\n" + ")", SqlFormatter.formatSql(node));
}
Aggregations