Search in sources :

Example 11 with HiveJdbcConverter

use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter in project hive by apache.

the class JDBCJoinPushDownRule method matches.

@Override
public boolean matches(RelOptRuleCall call) {
    final HiveJoin join = call.rel(0);
    final RexNode cond = join.getCondition();
    final HiveJdbcConverter converter1 = call.rel(1);
    final HiveJdbcConverter converter2 = call.rel(2);
    // First we compare the convention
    if (!converter1.getJdbcConvention().getName().equals(converter2.getJdbcConvention().getName())) {
        return false;
    }
    // Second, we compare the connection string
    if (!converter1.getConnectionUrl().equals(converter2.getConnectionUrl())) {
        return false;
    }
    // Third, we compare the connection user
    if (!converter1.getConnectionUser().equals(converter2.getConnectionUser())) {
        return false;
    }
    // We do not push cross join
    if (cond.isAlwaysTrue()) {
        return false;
    }
    return JDBCRexCallValidator.isValidJdbcOperation(cond, converter1.getJdbcDialect());
}
Also used : HiveJdbcConverter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter) HiveJoin(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin) RexNode(org.apache.calcite.rex.RexNode)

Example 12 with HiveJdbcConverter

use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter in project hive by apache.

the class JDBCUnionPushDownRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    LOG.debug("JDBCUnionPushDown has been called");
    final HiveUnion union = call.rel(0);
    final HiveJdbcConverter converter1 = call.rel(1);
    final HiveJdbcConverter converter2 = call.rel(2);
    List<RelNode> unionInput = Arrays.asList(converter1.getInput(), converter2.getInput());
    JdbcUnion jdbcUnion = new JdbcUnion(union.getCluster(), union.getTraitSet().replace(converter1.getJdbcConvention()), unionInput, union.all);
    call.transformTo(converter1.copy(converter1.getTraitSet(), jdbcUnion));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) JdbcUnion(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcUnion) HiveJdbcConverter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter) HiveUnion(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveUnion)

Example 13 with HiveJdbcConverter

use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter in project hive by apache.

the class JDBCAggregationPushDownRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    LOG.debug("JDBCAggregationPushDownRule has been called");
    final HiveAggregate aggregate = call.rel(0);
    final HiveJdbcConverter converter = call.rel(1);
    JdbcAggregate jdbcAggregate;
    try {
        jdbcAggregate = new JdbcAggregate(aggregate.getCluster(), aggregate.getTraitSet().replace(converter.getJdbcConvention()), converter.getInput(), aggregate.indicator, aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList());
    } catch (InvalidRelException e) {
        LOG.warn(e.toString());
        return;
    }
    call.transformTo(converter.copy(converter.getTraitSet(), jdbcAggregate));
}
Also used : InvalidRelException(org.apache.calcite.rel.InvalidRelException) HiveAggregate(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveAggregate) HiveJdbcConverter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter) JdbcAggregate(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcAggregate)

Example 14 with HiveJdbcConverter

use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter in project hive by apache.

the class JDBCFilterPushDownRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    LOG.debug("JDBCFilterPushDown has been called");
    final HiveFilter filter = call.rel(0);
    final HiveJdbcConverter converter = call.rel(1);
    Filter newHiveFilter = filter.copy(filter.getTraitSet(), converter.getInput(), filter.getCondition());
    JdbcFilter newJdbcFilter = (JdbcFilter) JdbcFilterRule.create(converter.getJdbcConvention()).convert(newHiveFilter);
    if (newJdbcFilter != null) {
        RelNode converterRes = converter.copy(converter.getTraitSet(), Arrays.asList(newJdbcFilter));
        call.transformTo(converterRes);
    }
}
Also used : RelNode(org.apache.calcite.rel.RelNode) Filter(org.apache.calcite.rel.core.Filter) JdbcFilter(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter) HiveFilter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter) HiveJdbcConverter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter) JdbcFilter(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter) HiveFilter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter)

Example 15 with HiveJdbcConverter

use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter in project hive by apache.

the class JDBCProjectPushDownRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    LOG.debug("JDBCProjectPushDownRule has been called");
    final HiveProject project = call.rel(0);
    final HiveJdbcConverter converter = call.rel(1);
    JdbcProject jdbcProject = new JdbcProject(project.getCluster(), project.getTraitSet().replace(converter.getJdbcConvention()), converter.getInput(), project.getProjects(), project.getRowType());
    call.transformTo(converter.copy(converter.getTraitSet(), jdbcProject));
}
Also used : HiveProject(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject) JdbcProject(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcProject) HiveJdbcConverter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter)

Aggregations

HiveJdbcConverter (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter)16 RelNode (org.apache.calcite.rel.RelNode)5 RexNode (org.apache.calcite.rex.RexNode)4 HiveJoin (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin)4 Join (org.apache.calcite.rel.core.Join)3 HiveFilter (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter)3 DruidQuery (org.apache.calcite.adapter.druid.DruidQuery)2 JdbcFilter (org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter)2 JdbcSort (org.apache.calcite.adapter.jdbc.JdbcRules.JdbcSort)2 InvalidRelException (org.apache.calcite.rel.InvalidRelException)2 Filter (org.apache.calcite.rel.core.Filter)2 JoinRelType (org.apache.calcite.rel.core.JoinRelType)2 HiveAggregate (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveAggregate)2 HiveProject (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject)2 HiveTableScan (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan)2 HiveUnion (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveUnion)2 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)2 BigDecimal (java.math.BigDecimal)1 Collectors (java.util.stream.Collectors)1 JdbcAggregate (org.apache.calcite.adapter.jdbc.JdbcRules.JdbcAggregate)1