Search in sources :

Example 1 with ProjectCorrelateTransposeRule

use of org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule in project calcite by apache.

the class RelOptRulesTest method testProjectCorrelateTransposeDynamic.

@Test
void testProjectCorrelateTransposeDynamic() {
    ProjectCorrelateTransposeRule customPCTrans = ProjectCorrelateTransposeRule.Config.DEFAULT.withPreserveExprCondition(RelOptRulesTest::skipItem).toRule();
    String sql = "select t1.c_nationkey, t2.a as fake_col2 " + "from SALES.CUSTOMER as t1, " + "unnest(t1.fake_col) as t2(a)";
    sql(sql).withDynamicTable().withRule(customPCTrans).checkUnchanged();
}
Also used : ProjectCorrelateTransposeRule(org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule) Test(org.junit.jupiter.api.Test)

Example 2 with ProjectCorrelateTransposeRule

use of org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule in project calcite by apache.

the class RelOptRulesTest method testProjectCorrelateTranspose.

@Test
void testProjectCorrelateTranspose() {
    ProjectCorrelateTransposeRule customPCTrans = ProjectCorrelateTransposeRule.Config.DEFAULT.withPreserveExprCondition(expr -> true).toRule();
    final String sql = "select t1.name, t2.ename\n" + "from DEPT_NESTED as t1,\n" + "unnest(t1.employees) as t2";
    sql(sql).withRule(customPCTrans).check();
}
Also used : AggregateProjectMergeRule(org.apache.calcite.rel.rules.AggregateProjectMergeRule) Programs(org.apache.calcite.tools.Programs) Arrays(java.util.Arrays) RelDistributions(org.apache.calcite.rel.RelDistributions) DateRangeRules(org.apache.calcite.rel.rules.DateRangeRules) Disabled(org.junit.jupiter.api.Disabled) Contexts(org.apache.calcite.plan.Contexts) Union(org.apache.calcite.rel.core.Union) CorrelationId(org.apache.calcite.rel.core.CorrelationId) EnumSet(java.util.EnumSet) RelTraitSet(org.apache.calcite.plan.RelTraitSet) ReduceExpressionsRule(org.apache.calcite.rel.rules.ReduceExpressionsRule) SqlOperatorBinding(org.apache.calcite.sql.SqlOperatorBinding) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) HepMatchOrder(org.apache.calcite.plan.hep.HepMatchOrder) EnumerableSort(org.apache.calcite.adapter.enumerable.EnumerableSort) SqlKind(org.apache.calcite.sql.SqlKind) Minus(org.apache.calcite.rel.core.Minus) RexExecutorImpl(org.apache.calcite.rex.RexExecutorImpl) RelFieldCollation(org.apache.calcite.rel.RelFieldCollation) DataContexts(org.apache.calcite.DataContexts) NL(org.apache.calcite.test.SqlToRelTestBase.NL) HintPredicates(org.apache.calcite.rel.hint.HintPredicates) AggregateProjectConstantToDummyJoinRule(org.apache.calcite.rel.rules.AggregateProjectConstantToDummyJoinRule) RelDataTypeSystemImpl(org.apache.calcite.rel.type.RelDataTypeSystemImpl) SqlStdOperatorTable(org.apache.calcite.sql.fun.SqlStdOperatorTable) RelCollation(org.apache.calcite.rel.RelCollation) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) JoinCommuteRule(org.apache.calcite.rel.rules.JoinCommuteRule) SqlConformanceEnum(org.apache.calcite.sql.validate.SqlConformanceEnum) RuleSet(org.apache.calcite.tools.RuleSet) EnumerableLimitSort(org.apache.calcite.adapter.enumerable.EnumerableLimitSort) AggregateExtractProjectRule(org.apache.calcite.rel.rules.AggregateExtractProjectRule) ProjectToWindowRule(org.apache.calcite.rel.rules.ProjectToWindowRule) RexCall(org.apache.calcite.rex.RexCall) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ProjectFilterTransposeRule(org.apache.calcite.rel.rules.ProjectFilterTransposeRule) ProjectReduceExpressionsRule(org.apache.calcite.rel.rules.ReduceExpressionsRule.ProjectReduceExpressionsRule) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AggregateProjectPullUpConstantsRule(org.apache.calcite.rel.rules.AggregateProjectPullUpConstantsRule) AggregateExpandWithinDistinctRule(org.apache.calcite.rel.rules.AggregateExpandWithinDistinctRule) ReturnTypes(org.apache.calcite.sql.type.ReturnTypes) Filter(org.apache.calcite.rel.core.Filter) Join(org.apache.calcite.rel.core.Join) RuleSets(org.apache.calcite.tools.RuleSets) RelDecorrelator(org.apache.calcite.sql2rel.RelDecorrelator) LogicalCorrelate(org.apache.calcite.rel.logical.LogicalCorrelate) JoinAssociateRule(org.apache.calcite.rel.rules.JoinAssociateRule) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MockCatalogReader(org.apache.calcite.test.catalog.MockCatalogReader) RelDataType(org.apache.calcite.rel.type.RelDataType) FilterProjectTransposeRule(org.apache.calcite.rel.rules.FilterProjectTransposeRule) SpatialRules(org.apache.calcite.rel.rules.SpatialRules) RelRule(org.apache.calcite.plan.RelRule) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) Aggregate(org.apache.calcite.rel.core.Aggregate) LogicalAggregate(org.apache.calcite.rel.logical.LogicalAggregate) SqlFunction(org.apache.calcite.sql.SqlFunction) EnumerableRules(org.apache.calcite.adapter.enumerable.EnumerableRules) JoinRelType(org.apache.calcite.rel.core.JoinRelType) ProjectMultiJoinMergeRule(org.apache.calcite.rel.rules.ProjectMultiJoinMergeRule) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) LogicalFilter(org.apache.calcite.rel.logical.LogicalFilter) FilterMultiJoinMergeRule(org.apache.calcite.rel.rules.FilterMultiJoinMergeRule) UnionMergeRule(org.apache.calcite.rel.rules.UnionMergeRule) LogicalTableModify(org.apache.calcite.rel.logical.LogicalTableModify) RexUtil(org.apache.calcite.rex.RexUtil) CalciteConnectionConfig(org.apache.calcite.config.CalciteConnectionConfig) FilterFlattenCorrelatedConditionRule(org.apache.calcite.rel.rules.FilterFlattenCorrelatedConditionRule) RexNode(org.apache.calcite.rex.RexNode) RelBuilder(org.apache.calcite.tools.RelBuilder) RelHint(org.apache.calcite.rel.hint.RelHint) Locale(java.util.Locale) Intersect(org.apache.calcite.rel.core.Intersect) HepProgram(org.apache.calcite.plan.hep.HepProgram) SqlTypeFactoryImpl(org.apache.calcite.sql.type.SqlTypeFactoryImpl) RelOptCluster(org.apache.calcite.plan.RelOptCluster) ValuesReduceRule(org.apache.calcite.rel.rules.ValuesReduceRule) Program(org.apache.calcite.tools.Program) Predicate(java.util.function.Predicate) RexLiteral(org.apache.calcite.rex.RexLiteral) DataContext(org.apache.calcite.DataContext) MultiJoin(org.apache.calcite.rel.rules.MultiJoin) CustomCorrelate(org.apache.calcite.test.SqlToRelTestBase.CustomCorrelate) RexInputRef(org.apache.calcite.rex.RexInputRef) Test(org.junit.jupiter.api.Test) List(java.util.List) FilterJoinRule(org.apache.calcite.rel.rules.FilterJoinRule) MockCatalogReaderExtended(org.apache.calcite.test.catalog.MockCatalogReaderExtended) OperandTypes(org.apache.calcite.sql.type.OperandTypes) RelOptPlanner(org.apache.calcite.plan.RelOptPlanner) RelTraitDef(org.apache.calcite.plan.RelTraitDef) SqlSpecialOperator(org.apache.calcite.sql.SqlSpecialOperator) Project(org.apache.calcite.rel.core.Project) RelDistributionTraitDef(org.apache.calcite.rel.RelDistributionTraitDef) RelOptUtil(org.apache.calcite.plan.RelOptUtil) Function(java.util.function.Function) EnumerableConvention(org.apache.calcite.adapter.enumerable.EnumerableConvention) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) HintStrategyTable(org.apache.calcite.rel.hint.HintStrategyTable) SqlLibrary(org.apache.calcite.sql.fun.SqlLibrary) SqlOperator(org.apache.calcite.sql.SqlOperator) CoreMatchers.sameInstance(org.hamcrest.CoreMatchers.sameInstance) RelCollations(org.apache.calcite.rel.RelCollations) SqlMonotonicity(org.apache.calcite.sql.validate.SqlMonotonicity) RelCollationTraitDef(org.apache.calcite.rel.RelCollationTraitDef) LogicalProject(org.apache.calcite.rel.logical.LogicalProject) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) RexBuilder(org.apache.calcite.rex.RexBuilder) SqlFunctionCategory(org.apache.calcite.sql.SqlFunctionCategory) ProjectJoinTransposeRule(org.apache.calcite.rel.rules.ProjectJoinTransposeRule) AggregateReduceFunctionsRule(org.apache.calcite.rel.rules.AggregateReduceFunctionsRule) PushProjector(org.apache.calcite.rel.rules.PushProjector) HepPlanner(org.apache.calcite.plan.hep.HepPlanner) RelNode(org.apache.calcite.rel.RelNode) SqlTestFactory(org.apache.calcite.sql.test.SqlTestFactory) EnumerableLimit(org.apache.calcite.adapter.enumerable.EnumerableLimit) RelOptRuleCall(org.apache.calcite.plan.RelOptRuleCall) CoerceInputsRule(org.apache.calcite.rel.rules.CoerceInputsRule) ProjectCorrelateTransposeRule(org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule) RelOptRule(org.apache.calcite.plan.RelOptRule) CoreRules(org.apache.calcite.rel.rules.CoreRules) Collections(java.util.Collections) PruneEmptyRules(org.apache.calcite.rel.rules.PruneEmptyRules) ProjectCorrelateTransposeRule(org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule) Test(org.junit.jupiter.api.Test)

Example 3 with ProjectCorrelateTransposeRule

use of org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule in project calcite by apache.

the class RelOptRulesTest method testProjectCorrelateTransposeWithExprCond.

@Test
void testProjectCorrelateTransposeWithExprCond() {
    ProjectCorrelateTransposeRule customPCTrans = ProjectCorrelateTransposeRule.Config.DEFAULT.withPreserveExprCondition(RelOptRulesTest::skipItem).toRule();
    final String sql = "select t1.name, t2.ename\n" + "from DEPT_NESTED as t1,\n" + "unnest(t1.employees) as t2";
    sql(sql).withRule(customPCTrans).check();
}
Also used : ProjectCorrelateTransposeRule(org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectCorrelateTransposeRule (org.apache.calcite.rel.rules.ProjectCorrelateTransposeRule)3 Test (org.junit.jupiter.api.Test)3 ImmutableList (com.google.common.collect.ImmutableList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 DataContext (org.apache.calcite.DataContext)1 DataContexts (org.apache.calcite.DataContexts)1 EnumerableConvention (org.apache.calcite.adapter.enumerable.EnumerableConvention)1 EnumerableLimit (org.apache.calcite.adapter.enumerable.EnumerableLimit)1 EnumerableLimitSort (org.apache.calcite.adapter.enumerable.EnumerableLimitSort)1 EnumerableRules (org.apache.calcite.adapter.enumerable.EnumerableRules)1 EnumerableSort (org.apache.calcite.adapter.enumerable.EnumerableSort)1 CalciteConnectionConfig (org.apache.calcite.config.CalciteConnectionConfig)1 Contexts (org.apache.calcite.plan.Contexts)1 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1