use of org.apache.druid.sql.calcite.expression.DruidExpression in project druid by druid-io.
the class RegexpLikeOperatorConversion method toDruidFilter.
@Nullable
@Override
public DimFilter toDruidFilter(final PlannerContext plannerContext, final RowSignature rowSignature, @Nullable final VirtualColumnRegistry virtualColumnRegistry, final RexNode rexNode) {
final List<RexNode> operands = ((RexCall) rexNode).getOperands();
final DruidExpression druidExpression = Expressions.toDruidExpression(plannerContext, rowSignature, operands.get(0));
if (druidExpression == null) {
return null;
}
final String pattern = RexLiteral.stringValue(operands.get(1));
if (druidExpression.isSimpleExtraction()) {
return new RegexDimFilter(druidExpression.getSimpleExtraction().getColumn(), pattern, druidExpression.getSimpleExtraction().getExtractionFn(), null);
} else if (virtualColumnRegistry != null) {
String v = virtualColumnRegistry.getOrCreateVirtualColumnForExpression(druidExpression, operands.get(0).getType());
return new RegexDimFilter(v, pattern, null, null);
} else {
return null;
}
}
use of org.apache.druid.sql.calcite.expression.DruidExpression in project druid by druid-io.
the class RepeatOperatorConversion method toDruidExpression.
@Override
public DruidExpression toDruidExpression(final PlannerContext plannerContext, final RowSignature rowSignature, final RexNode rexNode) {
final RexCall call = (RexCall) rexNode;
final DruidExpression input = Expressions.toDruidExpression(plannerContext, rowSignature, call.getOperands().get(0));
if (input == null) {
return null;
}
if (call.getOperands().size() != 2) {
return null;
}
return OperatorConversions.convertDirectCall(plannerContext, rowSignature, rexNode, "repeat");
}
use of org.apache.druid.sql.calcite.expression.DruidExpression in project druid by druid-io.
the class RightOperatorConversion method toDruidExpression.
@Override
public DruidExpression toDruidExpression(final PlannerContext plannerContext, final RowSignature rowSignature, final RexNode rexNode) {
final RexCall call = (RexCall) rexNode;
final DruidExpression input = Expressions.toDruidExpression(plannerContext, rowSignature, call.getOperands().get(0));
if (input == null) {
return null;
}
if (call.getOperands().size() != 2) {
return null;
}
return OperatorConversions.convertDirectCall(plannerContext, rowSignature, rexNode, "right");
}
Aggregations