* @param statement the source statement
* @param writer the target writer
* @throws IOException if failed by I/O error
*/
public static void emit(HiveCreateTable statement, Appendable writer) throws IOException {
HiveTableInfo table = statement.getTableInfo();
Context c = new Context(writer);
emitCreateTableHead(c, statement);
// TODO PARTITIONED BY
// TODO CLUSTERED BY
// TODO SKEWED BY
RowFormatInfo rowFormat = table.getRowFormat();
if (rowFormat != null) {
switch (rowFormat.getKind()) {
case DELIMITED:
emitDelimitedRowFormat(c, (DelimitedRowFormatInfo) table.getRowFormat());
break;
case SERDE:
throw new UnsupportedOperationException("ROW FORMAT SERDE");
default:
throw new AssertionError(rowFormat.getKind());
}
}
if (table.getFormatName() != null) {
c.tokens("STORED", "AS");
c.token(table.getFormatName());
c.newLine();
}
// or TODO STORED BY
if (statement.getLocation() != null) {
c.token("LOCATION");
c.string(statement.getLocation());
c.newLine();
}
if (table.getTableProperties().isEmpty() == false) {
c.token("TBLPROPERTIES");
c.token("(");
c.newLine();
c.indent(+1);
emitProperties(c, table.getTableProperties());
c.indent(-1);
c.token(")");
c.newLine();
}
}