@Override public TranslatableTable apply(final List<Object> arguments) { final RelDataType rowType; // Using an escalator here is a hack, but it's currently needed to get the row type. Ideally, some // later refactoring would make this unnecessary, since there is no actual query going out herem. final AuthenticationResult authenticationResult = escalator.createEscalatedAuthenticationResult(); try (final DruidPlanner planner = plannerFactory.createPlanner(null, authenticationResult)) { rowType = planner.plan(viewSql).rowType(); } catch (Exception e) { throw Throwables.propagate(e); } return new ViewTable( null, RelDataTypeImpl.proto(rowType), viewSql, ImmutableList.of(DruidSchema.NAME), null ); }
conf, new HashMap<>(), new HashMap<>(), new AtomicInteger()); DruidTable druidTable = new DruidTable(new DruidSchema(address, address, false), dataSource, RelDataTypeImpl.proto(rowType), metrics, DruidTable.DEFAULT_TIMESTAMP_COLUMN, intervals, null, null); final TableScan scan = new HiveTableScan(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION),
dataSource, RelDataTypeImpl.proto(rowType), metrics, DruidTable.DEFAULT_TIMESTAMP_COLUMN, intervals); final TableScan scan = new HiveTableScan(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION), optTable, viewTable.getTableName(), null, false, false);
dataSource, RelDataTypeImpl.proto(rowType), metrics, DruidTable.DEFAULT_TIMESTAMP_COLUMN, intervals); final TableScan scan = new HiveTableScan(cluster, cluster.traitSetOf(HiveRelNode.CONVENTION), optTable, null == tableAlias ? tabMetaData.getTableName() : tableAlias,
rowType = dtFactory.createStructType(druidColTypes, druidColNames); DruidTable druidTable = new DruidTable(new DruidSchema(address, address, false), dataSource, RelDataTypeImpl.proto(rowType), metrics, DruidTable.DEFAULT_TIMESTAMP_COLUMN, intervals, null, null); optTable = new RelOptHiveTable(relOptSchema, relOptSchema.getTypeFactory(), fullyQualifiedTabName,
/** * Creates an inference rule which returns a copy of a given data type. */ public static ExplicitReturnTypeInference explicit(RelDataType type) { return explicit(RelDataTypeImpl.proto(type)); }
/** * Creates an inference rule which returns a copy of a given data type. */ public static ExplicitReturnTypeInference explicit(RelDataType type) { return explicit(RelDataTypeImpl.proto(type)); }
/** * Creates an inference rule which returns a type with no precision or scale, * such as {@code DATE}. */ public static ExplicitReturnTypeInference explicit(SqlTypeName typeName) { return explicit(RelDataTypeImpl.proto(typeName, false)); }
/** * Creates an inference rule which returns a type with no precision or scale, * such as {@code DATE}. */ public static ExplicitReturnTypeInference explicit(SqlTypeName typeName) { return explicit(RelDataTypeImpl.proto(typeName, false)); }
/** * Creates an inference rule which returns a type with precision but no scale, * such as {@code VARCHAR(100)}. */ public static ExplicitReturnTypeInference explicit(SqlTypeName typeName, int precision) { return explicit(RelDataTypeImpl.proto(typeName, precision, false)); }
/** * Creates an inference rule which returns a type with precision but no scale, * such as {@code VARCHAR(100)}. */ public static ExplicitReturnTypeInference explicit(SqlTypeName typeName, int precision) { return explicit(RelDataTypeImpl.proto(typeName, precision, false)); }
public CsvTable create(SchemaPlus schema, String name, Map<String, Object> operand, RelDataType rowType) { String fileName = (String) operand.get("file"); final File base = (File) operand.get(ModelHandler.ExtraOperand.BASE_DIRECTORY.camelName); final Source source = Sources.file(base, fileName); final RelProtoDataType protoRowType = rowType != null ? RelDataTypeImpl.proto(rowType) : null; return new CsvScannableTable(source, protoRowType); } }
public CsvTable create(SchemaPlus schema, String name, Map<String, Object> operand, RelDataType rowType) { String fileName = (String) operand.get("file"); final File base = (File) operand.get(ModelHandler.ExtraOperand.BASE_DIRECTORY.camelName); final Source source = Sources.file(base, fileName); final RelProtoDataType protoRowType = rowType != null ? RelDataTypeImpl.proto(rowType) : null; return new CsvScannableTable(source, protoRowType); } }
/** Allows a sub-class to return an extension of {@link ViewTable} by * overriding this method. */ protected ViewTable viewTable(CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new ViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath); } }
/** Allows a sub-class to return an extension of {@link ViewTable} by * overriding this method. */ protected ViewTable viewTable(CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new ViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath); } }
/** Allows a sub-class to return an extension of {@link ModifiableViewTable} * by overriding this method. */ protected ModifiableViewTable modifiableViewTable(CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath, CalciteSchema schema) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new ModifiableViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath, parsed.table, Schemas.path(schema.root(), parsed.tablePath), parsed.constraint, parsed.columnMapping); }
@Override public void onRegister(RelDataTypeFactory typeFactory) { super.onRegister(typeFactory); // To simulate getRowType() behavior in ViewTable. final RelProtoDataType protoRowType = RelDataTypeImpl.proto(rowType); rowType = protoRowType.apply(typeFactory); }
@Override public void onRegister(RelDataTypeFactory typeFactory) { super.onRegister(typeFactory); // To simulate getRowType() behavior in ViewTable. final RelProtoDataType protoRowType = RelDataTypeImpl.proto(rowType); rowType = protoRowType.apply(typeFactory); }
@Override protected ModifiableViewTable modifiableViewTable( CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath, CalciteSchema schema) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new MockModifiableViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath, parsed.table, Schemas.path(schema.root(), parsed.tablePath), parsed.constraint, parsed.columnMapping); } }
@Override protected ModifiableViewTable modifiableViewTable( CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath, CalciteSchema schema) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new MockModifiableViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath, parsed.table, Schemas.path(schema.root(), parsed.tablePath), parsed.constraint, parsed.columnMapping); } }