public static String buildDDLForExternalTable(TableDesc desc) { StringBuilder sb = new StringBuilder(); sb.append("--\n") .append("-- Name: ").append(IdentifierUtil.denormalizeIdentifier(desc.getName())).append("; Type: TABLE;") .append(" Storage: ").append(desc.getMeta().getDataFormat()); sb.append("\n-- Path: ").append(desc.getUri()); sb.append("\n--\n"); sb.append("CREATE EXTERNAL TABLE ").append(IdentifierUtil.denormalizeIdentifier(desc.getName())); buildSchema(sb, desc.getSchema()); buildUsingClause(sb, desc.getMeta()); buildWithClause(sb, desc.getMeta()); if (desc.hasPartition()) { buildPartitionClause(sb, desc); } buildLocationClause(sb, desc); sb.append(";"); return sb.toString(); }
public static String buildDDLForBaseTable(TableDesc desc) { StringBuilder sb = new StringBuilder(); sb.append("--\n") .append("-- Name: ").append(IdentifierUtil.denormalizeIdentifier(desc.getName())).append("; Type: TABLE;") .append(" Storage: ").append(desc.getMeta().getDataFormat()); sb.append("\n--\n"); sb.append("CREATE TABLE ").append(IdentifierUtil.denormalizeIdentifier(desc.getName())); buildSchema(sb, desc.getSchema()); buildUsingClause(sb, desc.getMeta()); buildWithClause(sb, desc.getMeta()); if (desc.hasPartition()) { buildPartitionClause(sb, desc); } sb.append(";"); return sb.toString(); }
writer.write(DDLBuilder.buildDDLForExternalTable(table)); } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { writer.write("\n\n"); writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto)));
@Test public void testBuildDDLQuotedTableName() throws Exception { Schema schema2 = SchemaBuilder.builder() .add("name", TajoDataTypes.Type.BLOB) .add("addr", TajoDataTypes.Type.TEXT) .add("FirstName", TajoDataTypes.Type.TEXT) .add("LastName", TajoDataTypes.Type.TEXT) .add("with", TajoDataTypes.Type.TEXT) .build(); Schema expressionSchema2 = SchemaBuilder.builder() .add("BirthYear", TajoDataTypes.Type.INT4) .build(); PartitionMethodDesc partitionMethod2 = new PartitionMethodDesc( "db1", "table1", CatalogProtos.PartitionType.COLUMN, "key,key2", expressionSchema2); TableDesc desc = new TableDesc("db1.TABLE2", schema2, meta1, new Path("/table1").toUri()); desc.setPartitionMethod(partitionMethod2); desc.setExternal(true); assertEquals(JavaResourceUtil.readTextFromResource("results/testDDLBuilder/testBuildDDLQuotedTableName1.result"), DDLBuilder.buildDDLForExternalTable(desc)); desc = new TableDesc("db1.TABLE1", schema2, meta1, new Path("/table1").toUri()); desc.setPartitionMethod(partitionMethod2); desc.setExternal(false); assertEquals(JavaResourceUtil.readTextFromResource("results/testDDLBuilder/testBuildDDLQuotedTableName2.result"), DDLBuilder.buildDDLForBaseTable(desc)); }
@Test public void testBuildDDLForBaseTable() throws Exception { TableDesc desc = new TableDesc("db1.table2", schema1, meta1, new Path("/table1").toUri()); assertEquals(JavaResourceUtil.readTextFromResource("results/testDDLBuilder/testBuildDDLForBaseTable.result"), DDLBuilder.buildDDLForBaseTable(desc)); }
@Test public void testBuildDDLForExternalTable() throws Exception { TableDesc desc = new TableDesc("db1.table1", schema1, meta1, new Path("/table1").toUri()); desc.setPartitionMethod(partitionMethod1); desc.setExternal(true); assertEquals(JavaResourceUtil.readTextFromResource("results/testDDLBuilder/testBuildDDLForExternalTable.result"), DDLBuilder.buildDDLForExternalTable(desc)); }
public static String toDisplayString(Schema schema) { StringBuilder sb = new StringBuilder(); DDLBuilder.buildSchema(sb, schema); return sb.toString(); }
writer.write(DDLBuilder.buildDDLForExternalTable(table)); } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { writer.write("\n\n"); writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto)));
public static String toDisplayString(Schema schema) { StringBuilder sb = new StringBuilder(); DDLBuilder.buildSchema(sb, schema); return sb.toString(); }
public static String buildDDLForExternalTable(TableDesc desc) { StringBuilder sb = new StringBuilder(); sb.append("--\n") .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append("; Type: TABLE;") .append(" Storage: ").append(desc.getMeta().getDataFormat()); sb.append("\n-- Path: ").append(desc.getUri()); sb.append("\n--\n"); sb.append("CREATE EXTERNAL TABLE ").append(CatalogUtil.denormalizeIdentifier(desc.getName())); buildSchema(sb, desc.getSchema()); buildUsingClause(sb, desc.getMeta()); buildWithClause(sb, desc.getMeta()); if (desc.hasPartition()) { buildPartitionClause(sb, desc); } buildLocationClause(sb, desc); sb.append(";"); return sb.toString(); }
public static String buildDDLForBaseTable(TableDesc desc) { StringBuilder sb = new StringBuilder(); sb.append("--\n") .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append("; Type: TABLE;") .append(" Storage: ").append(desc.getMeta().getDataFormat()); sb.append("\n--\n"); sb.append("CREATE TABLE ").append(CatalogUtil.denormalizeIdentifier(desc.getName())); buildSchema(sb, desc.getSchema()); buildUsingClause(sb, desc.getMeta()); buildWithClause(sb, desc.getMeta()); if (desc.hasPartition()) { buildPartitionClause(sb, desc); } sb.append(";"); return sb.toString(); }