Search in sources :

Example 1 with JdbcFilter

use of org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter in project hive by apache.

the class JDBCSortPushDownRule method onMatch.

@Override
public void onMatch(RelOptRuleCall call) {
    LOG.debug("JDBCSortPushDownRule has been called");
    final HiveSortLimit sort = call.rel(0);
    final HiveJdbcConverter converter = call.rel(1);
    RelNode node = (sort.fetch != null && RexLiteral.intValue(sort.fetch) == 0) ? new JdbcFilter(sort.getCluster(), sort.getTraitSet().replace(converter.getJdbcConvention()), converter.getInput(), call.builder().literal(false)) : new JdbcSort(sort.getCluster(), sort.getTraitSet().replace(converter.getJdbcConvention()), converter.getInput(), sort.getCollation(), sort.offset, sort.fetch);
    call.transformTo(converter.copy(converter.getTraitSet(), node));
}
Also used : JdbcSort(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcSort) RelNode(org.apache.calcite.rel.RelNode) HiveJdbcConverter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter) HiveSortLimit(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortLimit) JdbcFilter(org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter)

Example 2 with JdbcFilter

use of org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter 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)

Aggregations

JdbcFilter (org.apache.calcite.adapter.jdbc.JdbcRules.JdbcFilter)2 RelNode (org.apache.calcite.rel.RelNode)2 HiveJdbcConverter (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter)2 JdbcSort (org.apache.calcite.adapter.jdbc.JdbcRules.JdbcSort)1 Filter (org.apache.calcite.rel.core.Filter)1 HiveFilter (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter)1 HiveSortLimit (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortLimit)1