Java Code Examples for org.apache.calcite.sql2rel.SqlRexConvertletTable

The following examples show how to use org.apache.calcite.sql2rel.SqlRexConvertletTable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: marble   Source File: TableEnv.java    License: Apache License 2.0 6 votes vote down vote up
private FrameworkConfig createFrameworkConfig(
    SqlParser.Config sqlParserConfig, SqlOperatorTable sqlOperatorTable,
    SqlRexConvertletTable convertletTable,
    CalciteConnectionConfig calciteConnectionConfig,
    RelDataTypeSystem relDataTypeSystem, RexExecutor rexExecutor) {
  return Frameworks
      .newConfigBuilder()
      .defaultSchema(rootSchema)
      .parserConfig(sqlParserConfig)
      .operatorTable(sqlOperatorTable)
      .convertletTable(convertletTable)
      .typeSystem(relDataTypeSystem)
      .executor(rexExecutor)
      .context(Contexts.of(calciteConnectionConfig))
      .build();
}
 
Example 2
Source Project: calcite   Source File: CalcitePrepareImpl.java    License: Apache License 2.0 6 votes vote down vote up
CalcitePreparingStmt(CalcitePrepareImpl prepare,
    Context context,
    CatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    CalciteSchema schema,
    EnumerableRel.Prefer prefer,
    RelOptCluster cluster,
    Convention resultConvention,
    SqlRexConvertletTable convertletTable) {
  super(context, catalogReader, resultConvention);
  this.prepare = prepare;
  this.schema = schema;
  this.prefer = prefer;
  this.cluster = cluster;
  this.planner = cluster.getPlanner();
  this.rexBuilder = cluster.getRexBuilder();
  this.typeFactory = typeFactory;
  this.convertletTable = convertletTable;
}
 
Example 3
Source Project: Bats   Source File: BatsOptimizerTest.java    License: Apache License 2.0 5 votes vote down vote up
static RelNode testSqlToRelConverter(RelOptPlanner planner) throws Exception {
    RexBuilder rexBuilder = createRexBuilder();
    RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder);
    RelOptTable.ViewExpander viewExpander = ViewExpanders.simpleContext(cluster);

    Pair<SqlNode, SqlValidator> pair = testSqlValidator();
    SqlNode sqlNode = pair.left;
    SqlValidator validator = pair.right;
    CatalogReader catalogReader = createCalciteCatalogReader();
    SqlRexConvertletTable convertletTable = StandardConvertletTable.INSTANCE;
    SqlToRelConverter.Config config = SqlToRelConverter.Config.DEFAULT;
    // 不转换成EnumerableTableScan,而是LogicalTableScan
    config = SqlToRelConverter.configBuilder().withConvertTableAccess(false).build();

    SqlToRelConverter converter = new SqlToRelConverter(viewExpander, validator, catalogReader, cluster,
            convertletTable, config);

    boolean needsValidation = false;
    boolean top = false;
    RelRoot root = converter.convertQuery(sqlNode, needsValidation, top);
    RelNode relNode = root.rel;

    String plan = RelOptUtil.toString(relNode);
    System.out.println("Logical Plan:");
    System.out.println("------------------------------------------------------------------");
    System.out.println(plan);
    System.out.println();

    // testPrograms(root.rel);

    return relNode;
}
 
Example 4
Source Project: dremio-oss   Source File: DremioSqlToRelConverter.java    License: Apache License 2.0 5 votes vote down vote up
public DremioSqlToRelConverter(
    SqlConverter sqlConverter,
    SqlValidator validator,
    SqlRexConvertletTable convertletTable,
    Config config) {
  super(new NoOpExpander(), validator, sqlConverter.getCatalogReader(), sqlConverter.getCluster(), convertletTable, config);
  this.sqlConverter = sqlConverter;
}
 
Example 5
Source Project: calcite   Source File: CalciteMaterializer.java    License: Apache License 2.0 5 votes vote down vote up
CalciteMaterializer(CalcitePrepareImpl prepare,
    CalcitePrepare.Context context,
    CatalogReader catalogReader, CalciteSchema schema,
    RelOptCluster cluster, SqlRexConvertletTable convertletTable) {
  super(prepare, context, catalogReader, catalogReader.getTypeFactory(),
      schema, EnumerableRel.Prefer.ANY, cluster, BindableConvention.INSTANCE,
      convertletTable);
}
 
Example 6
Source Project: calcite   Source File: Frameworks.java    License: Apache License 2.0 5 votes vote down vote up
StdFrameworkConfig(Context context,
    SqlRexConvertletTable convertletTable,
    SqlOperatorTable operatorTable,
    ImmutableList<Program> programs,
    ImmutableList<RelTraitDef> traitDefs,
    SqlParser.Config parserConfig,
    SqlValidator.Config sqlValidatorConfig,
    SqlToRelConverter.Config sqlToRelConverterConfig,
    SchemaPlus defaultSchema,
    RelOptCostFactory costFactory,
    RelDataTypeSystem typeSystem,
    RexExecutor executor,
    boolean evolveLattice,
    SqlStatisticProvider statisticProvider,
    RelOptTable.ViewExpander viewExpander) {
  this.context = context;
  this.convertletTable = convertletTable;
  this.operatorTable = operatorTable;
  this.programs = programs;
  this.traitDefs = traitDefs;
  this.parserConfig = parserConfig;
  this.sqlValidatorConfig = sqlValidatorConfig;
  this.sqlToRelConverterConfig = sqlToRelConverterConfig;
  this.defaultSchema = defaultSchema;
  this.costFactory = costFactory;
  this.typeSystem = typeSystem;
  this.executor = executor;
  this.evolveLattice = evolveLattice;
  this.statisticProvider = statisticProvider;
  this.viewExpander = viewExpander;
}
 
Example 7
Source Project: marble   Source File: TableConfig.java    License: Apache License 2.0 4 votes vote down vote up
public SqlRexConvertletTable getConvertletTable() {
  return convertletTable;
}
 
Example 8
Source Project: marble   Source File: TableConfig.java    License: Apache License 2.0 4 votes vote down vote up
public void setConvertletTable(
    SqlRexConvertletTable convertletTable) {
  this.convertletTable = convertletTable;
}
 
Example 9
Source Project: marble   Source File: TableEnv.java    License: Apache License 2.0 4 votes vote down vote up
public TableEnv(TableConfig tableConfig) {
  try {
    this.tableConfig = tableConfig;
    SqlParser.Config sqlParserConfig = tableConfig.getSqlParserConfig()
        != null ? tableConfig.getSqlParserConfig() : SqlParser
        .configBuilder().setCaseSensitive(false)
        .build();
    SqlOperatorTable sqlStdOperatorTable = tableConfig
        .getSqlOperatorTable()
        != null
        ? tableConfig.getSqlOperatorTable()
        : ChainedSqlOperatorTable.of(SqlStdOperatorTable.instance());
    CalciteConnectionConfig calciteConnectionConfig = tableConfig
        .getCalciteConnectionConfig()
        != null
        ? tableConfig.getCalciteConnectionConfig()
        : createDefaultConnectionConfig(sqlParserConfig);
    RelDataTypeSystem typeSystem = tableConfig.getRelDataTypeSystem() != null
        ? tableConfig.getRelDataTypeSystem()
        : calciteConnectionConfig.typeSystem(RelDataTypeSystem.class,
            RelDataTypeSystem.DEFAULT);
    SqlRexConvertletTable convertletTable = tableConfig
        .getConvertletTable()
        != null
        ? tableConfig
        .getConvertletTable()
        : StandardConvertletTable.INSTANCE;
    RexExecutor rexExecutor = tableConfig.getRexExecutor() != null
        ? tableConfig.getRexExecutor()
        : RexUtil.EXECUTOR;
    this.calciteCatalogReader = new CalciteCatalogReader(
        CalciteSchema.from(rootSchema),
        CalciteSchema.from(rootSchema).path(null),
        new JavaTypeFactoryImpl(typeSystem),
        calciteConnectionConfig);
    this.frameworkConfig = createFrameworkConfig(sqlParserConfig,
        ChainedSqlOperatorTable.of(sqlStdOperatorTable,
            calciteCatalogReader), convertletTable,
        calciteConnectionConfig, typeSystem, rexExecutor);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example 10
@Override
public SqlRexConvertletTable getConvertletTable() {
    return MycatCalciteSupport.INSTANCE.config.getConvertletTable();
}
 
Example 11
public ReflectionAllowedMonitoringConvertletTable(SqlRexConvertletTable delegate) {
  super();
  this.delegate = delegate;
}
 
Example 12
Source Project: calcite   Source File: CalcitePrepareImpl.java    License: Apache License 2.0 4 votes vote down vote up
/** Factory method for default convertlet table. */
protected SqlRexConvertletTable createConvertletTable() {
  return StandardConvertletTable.INSTANCE;
}
 
Example 13
Source Project: calcite   Source File: Frameworks.java    License: Apache License 2.0 4 votes vote down vote up
public SqlRexConvertletTable getConvertletTable() {
  return convertletTable;
}
 
Example 14
Source Project: Bats   Source File: FrameworkConfig.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the convertlet table that should be used when converting from SQL
 * to row expressions
 */
SqlRexConvertletTable getConvertletTable();
 
Example 15
Source Project: calcite   Source File: FrameworkConfig.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the convertlet table that should be used when converting from SQL
 * to row expressions
 */
SqlRexConvertletTable getConvertletTable();