}
@Override
public Expr visitCreate_table_statement(SQLParser.Create_table_statementContext ctx) {
String tableName = ctx.table_name().getText();
CreateTable createTable = new CreateTable(tableName, checkIfExist(ctx.if_not_exists()));
if (checkIfExist(ctx.EXTERNAL())) {
createTable.setExternal();
ColumnDefinition[] elements = getDefinitions(ctx.table_elements());
String fileType = ctx.file_type.getText();
String path = stripQuote(ctx.path.getText());
createTable.setTableElements(elements);
createTable.setStorageType(fileType);
createTable.setLocation(path);
} else {
if (checkIfExist(ctx.table_elements())) {
ColumnDefinition[] elements = getDefinitions(ctx.table_elements());
createTable.setTableElements(elements);
}
if (checkIfExist(ctx.USING())) {
String fileType = ctx.file_type.getText();
createTable.setStorageType(fileType);
}
if (checkIfExist(ctx.query_expression())) {
Expr subquery = visitQuery_expression(ctx.query_expression());
createTable.setSubQuery(subquery);
}
}
if (checkIfExist(ctx.param_clause())) {
Map<String, String> params = escapeTableMeta(getParams(ctx.param_clause()));
createTable.setParams(params);
}
if (checkIfExist(ctx.table_partitioning_clauses())) {
PartitionMethodDescExpr partitionMethodDesc =
parseTablePartitioningClause(ctx.table_partitioning_clauses());
createTable.setPartitionMethod(partitionMethodDesc);
}
return createTable;
}