@Override public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath) { expansionDepth++; SqlParser parser = prepare.createParser(queryString); SqlNode sqlNode; try { sqlNode = parser.parseQuery(); } catch (SqlParseException e) { throw new RuntimeException("parse failed", e); } // View may have different schema path than current connection. final CatalogReader catalogReader = this.catalogReader.withSchemaPath(schemaPath); SqlValidator validator = createSqlValidator(catalogReader); final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder() .withTrimUnusedFields(true).build(); SqlToRelConverter sqlToRelConverter = getSqlToRelConverter(validator, catalogReader, config); RelRoot root = sqlToRelConverter.convertQuery(sqlNode, true, false); --expansionDepth; return root; }
queryString = null; Class runtimeContextClass = Object.class; init(runtimeContextClass); root = root.withRel(flattenTypes(root.rel, true)); root = trimUnusedFields(root); long start = System.currentTimeMillis(); LOGGER.info("Begin optimize"); root = optimize(root, materializations, lattices); LOGGER.info("End optimize, take : " + (System.currentTimeMillis() - start)); return implement(root);
: ImmutableList.of(root.collation), root.rel, mapTableModOp(isDml, root.kind), isDml) { public String getCode() {
: EnumerableConvention.INSTANCE; final CalcitePreparingStmt preparingStmt = new CalcitePreparingStmt(this, context, catalogReader, typeFactory, context.getRootSchema(), prefer, planner, resultConvention, createConvertletTable()); validator.setDefaultNullCollation(config.defaultNullCollation()); preparedResult = preparingStmt.prepareSql( sqlNode, Object.class, validator, true); switch (sqlNode.getKind()) { x = context.getTypeFactory().createType(elementType); preparedResult = preparingStmt.prepareQueryable(query.queryable, x); statementType = getStatementType(preparedResult); } else { assert query.rel != null; x = query.rel.getRowType(); preparedResult = preparingStmt.prepareRel(query.rel); statementType = getStatementType(preparedResult);
: EnumerableConvention.INSTANCE; final CalcitePreparingStmt preparingStmt = new CalcitePreparingStmt(this, context, catalogReader, typeFactory, context.getRootSchema(), prefer, planner, resultConvention, createConvertletTable()); validator.setDefaultNullCollation(config.defaultNullCollation()); preparedResult = preparingStmt.prepareSql( sqlNode, Object.class, validator, true); switch (sqlNode.getKind()) { x = context.getTypeFactory().createType(elementType); preparedResult = preparingStmt.prepareQueryable(query.queryable, x); statementType = getStatementType(preparedResult); } else { assert query.rel != null; x = query.rel.getRowType(); preparedResult = preparingStmt.prepareRel(query.rel); statementType = getStatementType(preparedResult);
: EnumerableConvention.INSTANCE; final CalcitePreparingStmt preparingStmt = new CalcitePreparingStmt(this, context, catalogReader, typeFactory, context.getRootSchema(), prefer, planner, resultConvention, createConvertletTable()); validator.setDefaultNullCollation(config.defaultNullCollation()); preparedResult = preparingStmt.prepareSql( sqlNode, Object.class, validator, true); switch (sqlNode.getKind()) { x = context.getTypeFactory().createType(elementType); preparedResult = preparingStmt.prepareQueryable(query.queryable, x); statementType = getStatementType(preparedResult); } else { assert query.rel != null; x = query.rel.getRowType(); preparedResult = preparingStmt.prepareRel(query.rel); statementType = getStatementType(preparedResult);
: ImmutableList.of(root.collation), root.rel, mapTableModOp(isDml, root.kind), isDml) { public String getCode() {
: ImmutableList.of(root.collation), root.rel, mapTableModOp(isDml, root.kind), isDml) { public String getCode() {
private ParseResult convert_(Context context, String sql, boolean analyze, boolean fail, CalciteCatalogReader catalogReader, SqlValidator validator, SqlNode sqlNode1) { final JavaTypeFactory typeFactory = context.getTypeFactory(); final Convention resultConvention = enableBindable ? BindableConvention.INSTANCE : EnumerableConvention.INSTANCE; final HepPlanner planner = new HepPlanner(new HepProgramBuilder().build()); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); final SqlToRelConverter.ConfigBuilder configBuilder = SqlToRelConverter.configBuilder().withTrimUnusedFields(true); if (analyze) { configBuilder.withConvertTableAccess(false); } final CalcitePreparingStmt preparingStmt = new CalcitePreparingStmt(this, context, catalogReader, typeFactory, context.getRootSchema(), null, planner, resultConvention, createConvertletTable()); final SqlToRelConverter converter = preparingStmt.getSqlToRelConverter(validator, catalogReader, configBuilder.build()); final RelRoot root = converter.convertQuery(sqlNode1, false, true); if (analyze) { return analyze_(validator, sql, sqlNode1, root, fail); } return new ConvertResult(this, validator, sql, sqlNode1, validator.getValidatedNodeType(sqlNode1), root); }
private PreparedResult prepare_(Supplier<RelNode> fn, RelDataType resultType) { Class runtimeContextClass = Object.class; init(runtimeContextClass); root = root.withRel(flattenTypes(root.rel, true)); root = trimUnusedFields(root); root = optimize(root, materializations, lattices); return implement(root);
private PreparedResult prepare_(Supplier<RelNode> fn, RelDataType resultType) { Class runtimeContextClass = Object.class; init(runtimeContextClass); root = root.withRel(flattenTypes(root.rel, true)); root = trimUnusedFields(root); root = optimize(root, materializations, lattices); return implement(root);
private ParseResult convert_(Context context, String sql, boolean analyze, boolean fail, CalciteCatalogReader catalogReader, SqlValidator validator, SqlNode sqlNode1) { final JavaTypeFactory typeFactory = context.getTypeFactory(); final Convention resultConvention = enableBindable ? BindableConvention.INSTANCE : EnumerableConvention.INSTANCE; final HepPlanner planner = new HepPlanner(new HepProgramBuilder().build()); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); final SqlToRelConverter.ConfigBuilder configBuilder = SqlToRelConverter.configBuilder().withTrimUnusedFields(true); if (analyze) { configBuilder.withConvertTableAccess(false); } final CalcitePreparingStmt preparingStmt = new CalcitePreparingStmt(this, context, catalogReader, typeFactory, context.getRootSchema(), null, planner, resultConvention, createConvertletTable()); final SqlToRelConverter converter = preparingStmt.getSqlToRelConverter(validator, catalogReader, configBuilder.build()); final RelRoot root = converter.convertQuery(sqlNode1, false, true); if (analyze) { return analyze_(validator, sql, sqlNode1, root, fail); } return new ConvertResult(this, validator, sql, sqlNode1, validator.getValidatedNodeType(sqlNode1), root); }
@Override public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath) { expansionDepth++; SqlParser parser = prepare.createParser(queryString); SqlNode sqlNode; try { sqlNode = parser.parseQuery(); } catch (SqlParseException e) { throw new RuntimeException("parse failed", e); } // View may have different schema path than current connection. final CatalogReader catalogReader = this.catalogReader.withSchemaPath(schemaPath); SqlValidator validator = createSqlValidator(catalogReader); final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder() .withTrimUnusedFields(true).build(); SqlToRelConverter sqlToRelConverter = getSqlToRelConverter(validator, catalogReader, config); RelRoot root = sqlToRelConverter.convertQuery(sqlNode, true, false); --expansionDepth; return root; }
private ParseResult convert_(Context context, String sql, boolean analyze, boolean fail, CalciteCatalogReader catalogReader, SqlValidator validator, SqlNode sqlNode1) { final JavaTypeFactory typeFactory = context.getTypeFactory(); final Convention resultConvention = enableBindable ? BindableConvention.INSTANCE : EnumerableConvention.INSTANCE; final HepPlanner planner = new HepPlanner(new HepProgramBuilder().build()); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); final SqlToRelConverter.ConfigBuilder configBuilder = SqlToRelConverter.configBuilder().withTrimUnusedFields(true); if (analyze) { configBuilder.withConvertTableAccess(false); } final CalcitePreparingStmt preparingStmt = new CalcitePreparingStmt(this, context, catalogReader, typeFactory, context.getRootSchema(), null, planner, resultConvention, createConvertletTable()); final SqlToRelConverter converter = preparingStmt.getSqlToRelConverter(validator, catalogReader, configBuilder.build()); final RelRoot root = converter.convertQuery(sqlNode1, false, true); if (analyze) { return analyze_(validator, sql, sqlNode1, root, fail); } return new ConvertResult(this, validator, sql, sqlNode1, validator.getValidatedNodeType(sqlNode1), root); }
@Override public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath) { expansionDepth++; SqlParser parser = prepare.createParser(queryString); SqlNode sqlNode; try { sqlNode = parser.parseQuery(); } catch (SqlParseException e) { throw new RuntimeException("parse failed", e); } // View may have different schema path than current connection. final CatalogReader catalogReader = this.catalogReader.withSchemaPath(schemaPath); SqlValidator validator = createSqlValidator(catalogReader); SqlNode sqlNode1 = validator.validate(sqlNode); final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder() .withTrimUnusedFields(true).build(); SqlToRelConverter sqlToRelConverter = getSqlToRelConverter(validator, catalogReader, config); RelRoot root = sqlToRelConverter.convertQuery(sqlNode1, true, false); --expansionDepth; return root; }
protected SqlValidator createSqlValidator(CatalogReader catalogReader) { return prepare.createSqlValidator(context, (CalciteCatalogReader) catalogReader); }
protected SqlValidator createSqlValidator(CatalogReader catalogReader) { return prepare.createSqlValidator(context, (CalciteCatalogReader) catalogReader); }
protected SqlValidator createSqlValidator(CatalogReader catalogReader) { return prepare.createSqlValidator(context, (CalciteCatalogReader) catalogReader); }
@Override protected SqlValidator getSqlValidator() { if (sqlValidator == null) { sqlValidator = createSqlValidator(catalogReader); } return sqlValidator; }
@Override protected SqlValidator getSqlValidator() { if (sqlValidator == null) { sqlValidator = createSqlValidator(catalogReader); } return sqlValidator; }