Search in sources :

Example 21 with FrameworkConfig

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.tools.FrameworkConfig in project calcite by apache.

the class CalciteMetaImpl method toQuery.

/**
 * Wraps the SQL string in a
 * {@link org.apache.calcite.jdbc.CalcitePrepare.Query} object, giving the
 * {@link Hook#STRING_TO_QUERY} hook chance to override.
 */
private CalcitePrepare.Query<Object> toQuery(Context context, String sql) {
    final Holder<CalcitePrepare.Query<Object>> queryHolder = Holder.of(CalcitePrepare.Query.of(sql));
    final FrameworkConfig config = Frameworks.newConfigBuilder().parserConfig(SqlParser.Config.DEFAULT).defaultSchema(context.getRootSchema().plus()).build();
    Hook.STRING_TO_QUERY.run(Pair.of(config, queryHolder));
    return queryHolder.get();
}
Also used : FrameworkConfig(org.apache.calcite.tools.FrameworkConfig)

Example 22 with FrameworkConfig

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.tools.FrameworkConfig in project calcite by apache.

the class RelMetadataTest method testGetPredicatesForJoin.

@Test
public void testGetPredicatesForJoin() throws Exception {
    final FrameworkConfig config = RelBuilderTest.config().build();
    final RelBuilder builder = RelBuilder.create(config);
    RelNode join = builder.scan("EMP").scan("DEPT").join(JoinRelType.INNER, builder.call(NONDETERMINISTIC_OP)).build();
    RelMetadataQuery mq = RelMetadataQuery.instance();
    assertTrue(mq.getPulledUpPredicates(join).pulledUpPredicates.isEmpty());
    RelNode join1 = builder.scan("EMP").scan("DEPT").join(JoinRelType.INNER, builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, 0, 0), builder.field(2, 1, 0))).build();
    assertEquals("=($0, $8)", mq.getPulledUpPredicates(join1).pulledUpPredicates.get(0).toString());
}
Also used : RelMetadataQuery(org.apache.calcite.rel.metadata.RelMetadataQuery) RelBuilder(org.apache.calcite.tools.RelBuilder) RelNode(org.apache.calcite.rel.RelNode) FrameworkConfig(org.apache.calcite.tools.FrameworkConfig) Test(org.junit.Test)

Example 23 with FrameworkConfig

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.tools.FrameworkConfig in project calcite by apache.

the class RelMetadataTest method testGetPredicatesForFilter.

@Test
public void testGetPredicatesForFilter() throws Exception {
    final FrameworkConfig config = RelBuilderTest.config().build();
    final RelBuilder builder = RelBuilder.create(config);
    RelNode filter = builder.scan("EMP").filter(builder.call(NONDETERMINISTIC_OP)).build();
    RelMetadataQuery mq = RelMetadataQuery.instance();
    assertTrue(mq.getPulledUpPredicates(filter).pulledUpPredicates.isEmpty());
    RelNode filter1 = builder.scan("EMP").filter(builder.call(SqlStdOperatorTable.EQUALS, builder.field(1, 0, 0), builder.field(1, 0, 1))).build();
    assertEquals("=($0, $1)", mq.getPulledUpPredicates(filter1).pulledUpPredicates.get(0).toString());
}
Also used : RelMetadataQuery(org.apache.calcite.rel.metadata.RelMetadataQuery) RelBuilder(org.apache.calcite.tools.RelBuilder) RelNode(org.apache.calcite.rel.RelNode) FrameworkConfig(org.apache.calcite.tools.FrameworkConfig) Test(org.junit.Test)

Example 24 with FrameworkConfig

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.tools.FrameworkConfig in project calcite by apache.

the class InterpreterTest method setUp.

@Before
public void setUp() {
    rootSchema = Frameworks.createRootSchema(true);
    final FrameworkConfig config = Frameworks.newConfigBuilder().parserConfig(SqlParser.Config.DEFAULT).defaultSchema(CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR)).build();
    planner = Frameworks.getPlanner(config);
    dataContext = new MyDataContext(planner);
}
Also used : FrameworkConfig(org.apache.calcite.tools.FrameworkConfig) Before(org.junit.Before)

Example 25 with FrameworkConfig

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.tools.FrameworkConfig in project calcite by apache.

the class LexCaseSensitiveTest method getPlanner.

private static Planner getPlanner(List<RelTraitDef> traitDefs, SqlParser.Config parserConfig, Program... programs) {
    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
    final FrameworkConfig config = Frameworks.newConfigBuilder().parserConfig(parserConfig).defaultSchema(CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR)).traitDefs(traitDefs).programs(programs).build();
    return Frameworks.getPlanner(config);
}
Also used : SchemaPlus(org.apache.calcite.schema.SchemaPlus) FrameworkConfig(org.apache.calcite.tools.FrameworkConfig)

Aggregations

FrameworkConfig (org.apache.calcite.tools.FrameworkConfig)24 Planner (org.apache.calcite.tools.Planner)14 RelNode (org.apache.calcite.rel.RelNode)12 SqlNode (org.apache.calcite.sql.SqlNode)12 SchemaPlus (org.apache.calcite.schema.SchemaPlus)10 ArrayList (java.util.ArrayList)6 JavaTypeFactory (org.apache.calcite.adapter.java.JavaTypeFactory)6 CalciteCatalogReader (org.apache.calcite.prepare.CalciteCatalogReader)5 SqlOperatorTable (org.apache.calcite.sql.SqlOperatorTable)5 ChainedSqlOperatorTable (org.apache.calcite.sql.util.ChainedSqlOperatorTable)5 JavaTypeFactoryImpl (org.apache.calcite.jdbc.JavaTypeFactoryImpl)4 StreamableTable (org.apache.calcite.schema.StreamableTable)4 Table (org.apache.calcite.schema.Table)4 SqlStdOperatorTable (org.apache.calcite.sql.fun.SqlStdOperatorTable)4 Test (org.junit.Test)4 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 SchemaPlus (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus)3 RelBuilder (org.apache.calcite.tools.RelBuilder)3 HashMap (java.util.HashMap)2