Skip to content

Commit

Permalink
[CALCITE-6295] Support IS NOT NULL in Arrow adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
timgrein authored and asolimando committed Jul 20, 2024
1 parent f44ed0a commit f47ca1c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private String translateMatch2(RexNode node) {
return translateBinary("greater_than_or_equal_to", "<=", (RexCall) node);
case IS_NULL:
return translateUnary("isnull", (RexCall) node);
case IS_NOT_NULL:
return translateUnary("isnotnull", (RexCall) node);
default:
throw new UnsupportedOperationException("Unsupported operator " + node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,34 +294,39 @@ static void initializeArrowState(@TempDir Path sharedTempDir) throws IOException
.explainContains(plan);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6295">[CALCITE-6295]
* Support IS NOT NULL in Arrow adapter</a>. */
@Test void testArrowProjectFieldsWithIsNotNullFilter() {
String sql = "select \"intField\", \"stringField\"\n"
+ "from arrowdata\n"
+ "where \"intField\" is not null\n"
+ "order by \"intField\"\n"
+ "limit 1";
String plan;
if (Bug.CALCITE_6295_FIXED) {
plan = "PLAN=EnumerableLimit(fetch=[1])\n"
+ " EnumerableSort(sort0=[$0], dir0=[ASC])\n"
+ " ArrowToEnumerableConverter\n"
+ " ArrowProject(intField=[$0], stringField=[$1])\n"
+ " ArrowFilter(condition=[IS NOT NULL($0)])\n"
+ " ArrowTableScan(table=[[ARROW, ARROWDATA]], fields=[[0, 1, 2, 3]])\n\n";
} else {
plan = "PLAN=EnumerableCalc(expr#0..3=[{inputs}], proj#0..1=[{exprs}])\n"
+ " EnumerableLimit(fetch=[1])\n"
+ " EnumerableSort(sort0=[$0], dir0=[ASC])\n"
+ " EnumerableCalc(expr#0..3=[{inputs}], expr#4=[IS NOT NULL($t0)], proj#0..3=[{exprs}], $condition=[$t4])\n"
+ " ArrowToEnumerableConverter\n"
+ " ArrowTableScan(table=[[ARROW, ARROWDATA]], fields=[[0, 1, 2, 3]])\n\n";
}
String result = "intField=0; stringField=0\n";
+ "where \"intField\" is not null\n";
String plan = "PLAN=ArrowToEnumerableConverter\n"
+ " ArrowProject(intField=[$0], stringField=[$1])\n"
+ " ArrowFilter(condition=[IS NOT NULL($0)])\n"
+ " ArrowTableScan(table=[[ARROW, ARROWDATA]], fields=[[0, 1, 2, 3]])\n\n";

CalciteAssert.that()
.with(arrow)
.query(sql)
.returns(result)
.returnsCount(50)
.explainContains(plan);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6295">[CALCITE-6295]
* Support IS NOT NULL in Arrow adapter</a>. */
@Test void testConjunctiveIsNotNullFilters() {
String sql = "select * from arrowdata\n"
+ "where \"intField\" is not null and \"stringField\" is not null";
String plan = "PLAN=ArrowToEnumerableConverter\n"
+ " ArrowFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])\n"
+ " ArrowTableScan(table=[[ARROW, ARROWDATA]], fields=[[0, 1, 2, 3]])\n\n";

CalciteAssert.that()
.with(arrow)
.query(sql)
.returnsCount(50)
.explainContains(plan);
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/main/java/org/apache/calcite/util/Bug.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ public abstract class Bug {
* [CALCITE-6294] Support IN filter in Arrow adapter</a> is fixed. */
public static final boolean CALCITE_6294_FIXED = false;

/** Whether
* <a href="https://issues.apache.org/jira/browse/CALCITE/issues/CALCITE-6295">
* [CALCITE-6295] Support IS NOT NULL in Arrow adapter</a> is fixed. */
public static final boolean CALCITE_6295_FIXED = false;

/**
* Use this to flag temporary code.
*/
Expand Down

0 comments on commit f47ca1c

Please sign in to comment.