@Nullable
private static DruidJsonFilter toIsNullKindDruidFilter(RexNode rexNode, RelDataType rowType,
DruidQuery druidQuery) {
if (rexNode.getKind() != SqlKind.IS_NULL && rexNode.getKind() != SqlKind.IS_NOT_NULL) {
throw new AssertionError(
DruidQuery.format("Expecting IS_NULL or IS_NOT_NULL but got [%s]", rexNode.getKind()));
}
final RexCall rexCall = (RexCall) rexNode;
final RexNode refNode = rexCall.getOperands().get(0);
Pair<String, ExtractionFunction> druidColumn = DruidQuery
.toDruidColumn(refNode, rowType, druidQuery);
final String columnName = druidColumn.left;
final ExtractionFunction extractionFunction = druidColumn.right;
if (columnName == null) {
return null;
}
if (rexNode.getKind() == SqlKind.IS_NOT_NULL) {
return toNotDruidFilter(new JsonSelector(columnName, null, extractionFunction));
}
return new JsonSelector(columnName, null, extractionFunction);
}