columnMetas.add(new SelectedColumnMeta(false, config.caseSensitive(), false, false, basicSqlType.isNullable() ? 1 : 0, true, basicSqlType.getPrecision(), columnName, columnName, null, null, null, basicSqlType.getPrecision(),
public CalciteCatalogReader(CalciteSchema rootSchema, List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) { this(rootSchema, SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()), ImmutableList.of(Objects.requireNonNull(defaultSchema), ImmutableList.of()), typeFactory, config); }
public CalciteCatalogReader(CalciteSchema rootSchema, List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) { this(rootSchema, SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()), ImmutableList.of(Objects.requireNonNull(defaultSchema), ImmutableList.of()), typeFactory, config); }
public FlinkCalciteCatalogReader( CalciteSchema rootSchema, List<List<String>> defaultSchemas, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) { this( rootSchema, SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()), getDefaultSchemas(defaultSchemas), typeFactory, config); }
protected QuarkConnectionImpl(QuarkDriver driver, AvaticaFactory factory, String url, Properties info, CalciteRootSchema rootSchema, JavaTypeFactory typeFactory) throws SQLException { super(driver, factory, url, info); CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info); if (typeFactory != null) { this.typeFactory = typeFactory; } else { final RelDataTypeSystem typeSystem = cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT); this.typeFactory = new JavaTypeFactoryImpl(typeSystem); } this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive()); this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing()); this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing()); this.properties.put(InternalProperty.QUOTING, cfg.quoting()); }
new CalciteCatalogReader( context.getRootSchema(), context.config().caseSensitive(), context.getDefaultSchemaPath(), typeFactory);
: CalciteSchema.createRootSchema(true)); Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema"); this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive()); this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing()); this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
: CalciteSchema.createRootSchema(true)); Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema"); this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive()); this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing()); this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
protected void populateMaterializations(Context context, RelOptPlanner planner, Prepare.Materialization materialization) { // REVIEW: initialize queryRel and tableRel inside MaterializationService, // not here? try { final CalciteSchema schema = materialization.materializedTable.schema; CalciteCatalogReader catalogReader = new CalciteCatalogReader( schema.root(), context.config().caseSensitive(), materialization.viewSchemaPath, context.getTypeFactory()); final CalciteMaterializer materializer = new CalciteMaterializer(this, context, catalogReader, schema, planner, createConvertletTable()); materializer.populate(materialization); } catch (Exception e) { throw new RuntimeException("While populating materialization " + materialization.materializedTable.path(), e); } }
private SqlAdvisor getSqlAdvisor() { final CalciteConnectionImpl con = (CalciteConnectionImpl) queryProvider; final String schemaName; try { schemaName = con.getSchema(); } catch (SQLException e) { throw new RuntimeException(e); } final List<String> schemaPath = schemaName == null ? ImmutableList.of() : ImmutableList.of(schemaName); final SqlValidatorWithHints validator = new SqlAdvisorValidator(SqlStdOperatorTable.instance(), new CalciteCatalogReader(rootSchema, schemaPath, typeFactory, con.config()), typeFactory, SqlConformanceEnum.DEFAULT); final CalciteConnectionConfig config = con.config(); // This duplicates org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_ final SqlParser.Config parserConfig = SqlParser.configBuilder() .setQuotedCasing(config.quotedCasing()) .setUnquotedCasing(config.unquotedCasing()) .setQuoting(config.quoting()) .setConformance(config.conformance()) .setCaseSensitive(config.caseSensitive()) .build(); return new SqlAdvisor(validator, parserConfig); }
private SqlAdvisor getSqlAdvisor() { final CalciteConnectionImpl con = (CalciteConnectionImpl) queryProvider; final String schemaName; try { schemaName = con.getSchema(); } catch (SQLException e) { throw new RuntimeException(e); } final List<String> schemaPath = schemaName == null ? ImmutableList.of() : ImmutableList.of(schemaName); final SqlValidatorWithHints validator = new SqlAdvisorValidator(SqlStdOperatorTable.instance(), new CalciteCatalogReader(rootSchema, schemaPath, typeFactory, con.config()), typeFactory, SqlConformanceEnum.DEFAULT); final CalciteConnectionConfig config = con.config(); // This duplicates org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_ final SqlParser.Config parserConfig = SqlParser.configBuilder() .setQuotedCasing(config.quotedCasing()) .setUnquotedCasing(config.unquotedCasing()) .setQuoting(config.quoting()) .setConformance(config.conformance()) .setCaseSensitive(config.caseSensitive()) .build(); return new SqlAdvisor(validator, parserConfig); }
/** Shared implementation for {@link #parse}, {@link #convert} and * {@link #analyzeView}. */ private ParseResult parse_(Context context, String sql, boolean convert, boolean analyze, boolean fail) { final JavaTypeFactory typeFactory = context.getTypeFactory(); CalciteCatalogReader catalogReader = new CalciteCatalogReader( context.getRootSchema(), context.config().caseSensitive(), context.getDefaultSchemaPath(), typeFactory); SqlParser parser = createParser(sql); SqlNode sqlNode; try { sqlNode = parser.parseStmt(); } catch (SqlParseException e) { throw new RuntimeException("parse failed", e); } final SqlValidator validator = createSqlValidator(context, catalogReader); SqlNode sqlNode1 = validator.validate(sqlNode); if (convert) { return convert_( context, sql, analyze, fail, catalogReader, validator, sqlNode1); } return new ParseResult(this, validator, sql, sqlNode1, validator.getValidatedNodeType(sqlNode1)); }
.setQuoting(config.quoting()) .setConformance(config.conformance()) .setCaseSensitive(config.caseSensitive()); final SqlParserImplFactory parserFactory = config.parserFactory(SqlParserImplFactory.class, null);
.setQuoting(config.quoting()) .setConformance(config.conformance()) .setCaseSensitive(config.caseSensitive()); final SqlParserImplFactory parserFactory = config.parserFactory(SqlParserImplFactory.class, null);
/** Executes a prepare action. */ public <R> R perform(CalciteServerStatement statement, Frameworks.PrepareAction<R> action) { final CalcitePrepare.Context prepareContext = statement.createPrepareContext(); final JavaTypeFactory typeFactory = prepareContext.getTypeFactory(); final CalciteSchema schema = action.getConfig().getDefaultSchema() != null ? CalciteSchema.from(action.getConfig().getDefaultSchema()) : prepareContext.getRootSchema(); CalciteCatalogReader catalogReader = new CalciteCatalogReader(schema.root(), prepareContext.config().caseSensitive(), schema.path(null), typeFactory); final RexBuilder rexBuilder = new RexBuilder(typeFactory); final RelOptPlanner planner = createPlanner(prepareContext, action.getConfig().getContext(), action.getConfig().getCostFactory()); final RelOptCluster cluster = createCluster(planner, rexBuilder); return action.apply(cluster, catalogReader, prepareContext.getRootSchema().plus(), statement); }