@Override public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... o) { assert functionQualifier == null; return new SqlCreateTable(pos, (SqlIdentifier) o[0], (SqlNodeList) o[1], o[2], o[3], o[4], o[5], o[6], o[7]); }
public String inputFormatClass() { return getString(inputFormatClass); }
private void handleCreateTable( SqlCreateTable n, Map<String, DataSource> dataSources) { List<FieldInfo> fields = updateSchema(n); DataSource ds = DataSourcesRegistry.construct(n.location(), n .inputFormatClass(), n.outputFormatClass(), fields); if (ds == null) { throw new RuntimeException("Cannot construct data source for " + n .tableName()); } else if (dataSources.containsKey(n.tableName())) { throw new RuntimeException("Duplicated definition for table " + n .tableName()); } dataSources.put(n.tableName(), ds); }
private List<FieldInfo> updateSchema(SqlCreateTable n) { CompilerUtil.TableBuilderInfo builder = new CompilerUtil.TableBuilderInfo(typeFactory); List<FieldInfo> fields = new ArrayList<>(); for (ColumnDefinition col : n.fieldList()) { builder.field(col.name(), col.type(), col.constraint()); RelDataType dataType = col.type().deriveType(typeFactory); Class<?> javaType = (Class<?>)typeFactory.getJavaClass(dataType); ColumnConstraint constraint = col.constraint(); boolean isPrimary = constraint != null && constraint instanceof ColumnConstraint.PrimaryKey; fields.add(new FieldInfo(col.name(), javaType, isPrimary)); } if (n.parallelism() != null) { builder.parallelismHint(n.parallelism()); } Table table = builder.build(); schema.add(n.tableName(), table); return fields; }
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { getOperator().unparse(writer, this, leftPrec, rightPrec); }
{if (true) return new SqlCreateTable(pos, tblName, fieldList, input_format_class_name, output_format_class_name, location, parallelism, tbl_properties, select);}
public String outputFormatClass() { return getString(outputFormatClass); }
{if (true) return new SqlCreateTable(pos, tblName, fieldList, input_format_class_name, output_format_class_name, location, parallelism, tbl_properties, select);}
public Integer parallelism() { String parallelismStr = getString(parallelism); if (parallelismStr != null) { return Integer.parseInt(parallelismStr); } else { return DEFAULT_PARALLELISM; } }
public URI location() { return URI.create(getString(location)); }
public Properties properties() { Properties props = new Properties(); if (properties != null) { try { ObjectMapper mapper = new ObjectMapper(); HashMap<String, Object> map = mapper.readValue(getString(properties), HashMap.class); props.putAll(map); } catch (IOException e) { throw new RuntimeException(e); } } return props; }