use of org.apache.hadoop.hive.ql.optimizer.calcite.translator.RexNodeConverter in project hive by apache.
the class HiveRexExecutorImpl method reduce.
@Override
public void reduce(RexBuilder rexBuilder, List<RexNode> constExps, List<RexNode> reducedValues) {
RexNodeConverter rexNodeConverter = new RexNodeConverter(cluster);
for (RexNode rexNode : constExps) {
// initialize the converter
ExprNodeConverter converter = new ExprNodeConverter("", null, null, null, new HashSet<Integer>(), cluster.getTypeFactory());
// convert RexNode to ExprNodeGenericFuncDesc
ExprNodeDesc expr = rexNode.accept(converter);
if (expr instanceof ExprNodeGenericFuncDesc) {
// folding the constant
ExprNodeDesc constant = ConstantPropagateProcFactory.foldExpr((ExprNodeGenericFuncDesc) expr);
if (constant != null) {
try {
// convert constant back to RexNode
reducedValues.add(rexNodeConverter.convert((ExprNodeConstantDesc) constant));
} catch (Exception e) {
LOG.warn(e.getMessage());
reducedValues.add(rexNode);
}
} else {
reducedValues.add(rexNode);
}
} else {
reducedValues.add(rexNode);
}
}
}
Aggregations