Search in sources :

Example 16 with JavaTypeFactoryImpl

use of org.apache.calcite.jdbc.JavaTypeFactoryImpl in project hive by apache.

the class TestHiveReduceExpressionsWithStatsRule method before.

@Before
public void before() {
    HepProgramBuilder programBuilder = new HepProgramBuilder();
    programBuilder.addRuleInstance(HiveReduceExpressionsWithStatsRule.INSTANCE);
    planner = new HepPlanner(programBuilder.build());
    JavaTypeFactoryImpl typeFactory = new JavaTypeFactoryImpl();
    RexBuilder rexBuilder = new RexBuilder(typeFactory);
    final RelOptCluster optCluster = RelOptCluster.create(planner, rexBuilder);
    RelDataType rowTypeMock = typeFactory.createStructType(MyRecord.class);
    Mockito.doReturn(rowTypeMock).when(tableMock).getRowType();
    Mockito.doReturn(tableMock).when(schemaMock).getTableForMember(Matchers.any());
    statObj = new ColStatistics("_int", "int");
    Mockito.doReturn(Lists.newArrayList(statObj)).when(tableMock).getColStat(Matchers.anyListOf(Integer.class));
    Mockito.doReturn(hiveTableMDMock).when(tableMock).getHiveTableMD();
    Mockito.doReturn(tableParams).when(hiveTableMDMock).getParameters();
    builder = HiveRelFactories.HIVE_BUILDER.create(optCluster, schemaMock);
    StatsSetupConst.setStatsStateForCreateTable(tableParams, Lists.newArrayList("_int"), StatsSetupConst.TRUE);
    tableParams.put(StatsSetupConst.ROW_COUNT, "3");
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) JavaTypeFactoryImpl(org.apache.calcite.jdbc.JavaTypeFactoryImpl) ColStatistics(org.apache.hadoop.hive.ql.plan.ColStatistics) HepProgramBuilder(org.apache.calcite.plan.hep.HepProgramBuilder) RexBuilder(org.apache.calcite.rex.RexBuilder) RelDataType(org.apache.calcite.rel.type.RelDataType) HepPlanner(org.apache.calcite.plan.hep.HepPlanner) Before(org.junit.Before)

Aggregations

JavaTypeFactoryImpl (org.apache.calcite.jdbc.JavaTypeFactoryImpl)16 Table (org.apache.calcite.schema.Table)8 JavaTypeFactory (org.apache.calcite.adapter.java.JavaTypeFactory)7 RelDataType (org.apache.calcite.rel.type.RelDataType)6 RexBuilder (org.apache.calcite.rex.RexBuilder)6 SchemaPlus (org.apache.calcite.schema.SchemaPlus)6 StreamableTable (org.apache.calcite.schema.StreamableTable)6 RelNode (org.apache.calcite.rel.RelNode)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 RelOptCluster (org.apache.calcite.plan.RelOptCluster)4 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)4 QueryPlanner (org.apache.storm.sql.planner.trident.QueryPlanner)4 TridentRel (org.apache.storm.sql.planner.trident.rel.TridentRel)4 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)3 CompilerUtil (org.apache.storm.sql.compiler.CompilerUtil)3 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 DruidSchema (org.apache.calcite.adapter.druid.DruidSchema)2 DruidTable (org.apache.calcite.adapter.druid.DruidTable)2