@Test public void w_tblproperties() throws Exception { TableInfo table = new TableInfo.Builder("testing") .withColumn("col1", TypeName.INT) .withProperty("orc.compress", "SNAPPY") .withProperty("orc.compress.size", "262145") .withProperty("orc.stripe.size", "268435457") .withProperty("orc.row.index.stride", "20000") .withProperty("orc.create.index", "false") .build(); emit(new SimpleCreateTable(table)); }
public static void emit(HiveCreateTable statement, Appendable writer) throws IOException { TableInfo table = statement.getTableInfo(); Context c = new Context(writer); emitCreateTableHead(c, statement); RowFormatInfo rowFormat = table.getRowFormat(); if (rowFormat != null) { c.tokens("ROW", "FORMAT"); switch (rowFormat.getFormatKind()) { case DELIMITED: emitRowFormat(c, (DelimitedRowFormatInfo) rowFormat); break; case SERDE: emitRowFormat(c, (SerdeRowFormatInfo) rowFormat); break; default: throw new AssertionError(rowFormat.getFormatKind()); } c.newLine(); } StorageFormatInfo storageFormat = table.getStorageFormat(); if (storageFormat != null) { c.tokens("STORED", "AS"); switch (storageFormat.getFormatKind().getCategory()) { case BUILTIN: emitStorageFormat(c, (BuiltinStorageFormatInfo) storageFormat); break; case CUSTOM: emitStorageFormat(c, (CustomStorageFormatInfo) storageFormat); break; default: throw new AssertionError(storageFormat); } c.newLine(); } if (statement.getLocation() != null) { c.token("LOCATION"); c.string(statement.getLocation()); c.newLine(); } if (table.getProperties().isEmpty() == false) { c.token("TBLPROPERTIES"); c.token("("); c.newLine(); c.indent(+1); emitProperties(c, table.getProperties()); c.indent(-1); c.token(")"); c.newLine(); } }
HiveQlEmitter { public static void emit(HiveCreateTable statement, Appendable writer) throws IOException { TableInfo table = statement.getTableInfo(); Context c = new Context(writer); emitCreateTableHead(c, statement); RowFormatInfo rowFormat = table.getRowFormat(); if (rowFormat != null) { c.tokens("ROW", "FORMAT"); switch (rowFormat.getFormatKind()) { case DELIMITED: emitRowFormat(c, (DelimitedRowFormatInfo) rowFormat); break; case SERDE: emitRowFormat(c, (SerdeRowFormatInfo) rowFormat); break; default: throw new AssertionError(rowFormat.getFormatKind()); } c.newLine(); } StorageFormatInfo storageFormat = table.getStorageFormat(); if (storageFormat != null) { c.tokens("STORED", "AS"); switch (storageFormat.getFormatKind().getCategory()) { case BUILTIN: emitStorageFormat(c, (BuiltinStorageFormatInfo) storageFormat); break; case CUSTOM: emitStorageFormat(c, (CustomStorageFormatInfo) storageFormat); break; default: throw new AssertionError(storageFormat); } c.newLine(); } if (statement.getLocation() != null) { c.token("LOCATION"); c.string(statement.getLocation()); c.newLine(); } if (table.getProperties().isEmpty() == false) { c.token("TBLPROPERTIES"); c.token("("); c.newLine(); c.indent(+1); emitProperties(c, table.getProperties()); c.indent(-1); c.token(")"); c.newLine(); } } }
HiveQlEmitter { public static void emit(HiveCreateTable statement, Appendable writer) throws IOException { TableInfo table = statement.getTableInfo(); Context c = new Context(writer); emitCreateTableHead(c, statement); RowFormatInfo rowFormat = table.getRowFormat(); if (rowFormat != null) { c.tokens("ROW", "FORMAT"); switch (rowFormat.getFormatKind()) { case DELIMITED: emitRowFormat(c, (DelimitedRowFormatInfo) rowFormat); break; case SERDE: emitRowFormat(c, (SerdeRowFormatInfo) rowFormat); break; default: throw new AssertionError(rowFormat.getFormatKind()); } c.newLine(); } StorageFormatInfo storageFormat = table.getStorageFormat(); if (storageFormat != null) { c.tokens("STORED", "AS"); switch (storageFormat.getFormatKind().getCategory()) { case BUILTIN: emitStorageFormat(c, (BuiltinStorageFormatInfo) storageFormat); break; case CUSTOM: emitStorageFormat(c, (CustomStorageFormatInfo) storageFormat); break; default: throw new AssertionError(storageFormat); } c.newLine(); } if (statement.getLocation() != null) { c.token("LOCATION"); c.string(statement.getLocation()); c.newLine(); } if (table.getProperties().isEmpty() == false) { c.token("TBLPROPERTIES"); c.token("("); c.newLine(); c.indent(+1); emitProperties(c, table.getProperties()); c.indent(-1); c.token(")"); c.newLine(); } } private  HiveQlEmitter(); }
HiveQlEmitter { public static void emit(HiveCreateTable statement, Appendable writer) throws IOException { TableInfo table = statement.getTableInfo(); Context c = new Context(writer); emitCreateTableHead(c, statement); RowFormatInfo rowFormat = table.getRowFormat(); if (rowFormat != null) { c.tokens("ROW", "FORMAT"); switch (rowFormat.getFormatKind()) { case DELIMITED: emitRowFormat(c, (DelimitedRowFormatInfo) rowFormat); break; case SERDE: emitRowFormat(c, (SerdeRowFormatInfo) rowFormat); break; default: throw new AssertionError(rowFormat.getFormatKind()); } c.newLine(); } StorageFormatInfo storageFormat = table.getStorageFormat(); if (storageFormat != null) { c.tokens("STORED", "AS"); switch (storageFormat.getFormatKind().getCategory()) { case BUILTIN: emitStorageFormat(c, (BuiltinStorageFormatInfo) storageFormat); break; case CUSTOM: emitStorageFormat(c, (CustomStorageFormatInfo) storageFormat); break; default: throw new AssertionError(storageFormat); } c.newLine(); } if (statement.getLocation() != null) { c.token("LOCATION"); c.string(statement.getLocation()); c.newLine(); } if (table.getProperties().isEmpty() == false) { c.token("TBLPROPERTIES"); c.token("("); c.newLine(); c.indent(+1); emitProperties(c, table.getProperties()); c.indent(-1); c.token(")"); c.newLine(); } } private  HiveQlEmitter(); static void emit(HiveCreateTable statement, Appendable writer); }
HiveQlEmitter { public static void emit(HiveCreateTable statement, Appendable writer) throws IOException { TableInfo table = statement.getTableInfo(); Context c = new Context(writer); emitCreateTableHead(c, statement); RowFormatInfo rowFormat = table.getRowFormat(); if (rowFormat != null) { c.tokens("ROW", "FORMAT"); switch (rowFormat.getFormatKind()) { case DELIMITED: emitRowFormat(c, (DelimitedRowFormatInfo) rowFormat); break; case SERDE: emitRowFormat(c, (SerdeRowFormatInfo) rowFormat); break; default: throw new AssertionError(rowFormat.getFormatKind()); } c.newLine(); } StorageFormatInfo storageFormat = table.getStorageFormat(); if (storageFormat != null) { c.tokens("STORED", "AS"); switch (storageFormat.getFormatKind().getCategory()) { case BUILTIN: emitStorageFormat(c, (BuiltinStorageFormatInfo) storageFormat); break; case CUSTOM: emitStorageFormat(c, (CustomStorageFormatInfo) storageFormat); break; default: throw new AssertionError(storageFormat); } c.newLine(); } if (statement.getLocation() != null) { c.token("LOCATION"); c.string(statement.getLocation()); c.newLine(); } if (table.getProperties().isEmpty() == false) { c.token("TBLPROPERTIES"); c.token("("); c.newLine(); c.indent(+1); emitProperties(c, table.getProperties()); c.indent(-1); c.token(")"); c.newLine(); } } private  HiveQlEmitter(); static void emit(HiveCreateTable statement, Appendable writer);  }