caicancai commented on code in PR #4032:
URL: https://github.com/apache/calcite/pull/4032#discussion_r1829691098
##########
arrow/src/test/java/org/apache/calcite/adapter/arrow/ArrowAdapterDataTypesTest.java:
##########
@@ -176,4 +176,94 @@ static void initializeArrowState(@TempDir Path
sharedTempDir)
.returns(result)
.explainContains(plan);
}
+
+ @Test void testBooleanProject() {
+ String sql = "select \"booleanField\" from arrowdatatype";
+ String plan = "PLAN=ArrowToEnumerableConverter\n"
+ + " ArrowProject(booleanField=[$7])\n"
+ + " ArrowTableScan(table=[[ARROW, ARROWDATATYPE]], fields=[[0, 1,
2, 3, 4, 5, 6, 7, 8, 9]])\n\n";
+ String result =
"booleanField=null\nbooleanField=true\nbooleanField=false\n";
+ CalciteAssert.that()
+ .with(arrow)
+ .query(sql)
+ .limit(3)
+ .returns(result)
+ .explainContains(plan);
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6638">[CALCITE-6638]
+ * Arrow adapter should support IS FALSE Operator and IS TRUE Operator</a>.
*/
+ @Test void testArrowProjectWithIsTrueFilter() {
+ String sql = "select \"booleanField\"\n"
+ + "from arrowdatatype\n"
+ + "where \"booleanField\" is true";
+ String plan = "PLAN=ArrowToEnumerableConverter\n"
+ + " ArrowProject(booleanField=[$7])\n"
+ + " ArrowFilter(condition=[$7])\n"
+ + " ArrowTableScan(table=[[ARROW, ARROWDATATYPE]], fields=[[0, 1,
2, 3, 4, 5, 6, 7, 8, 9]])\n\n";
+ String result = "booleanField=true\nbooleanField=true\n";
+
+ CalciteAssert.that()
+ .with(arrow)
+ .query(sql)
+ .limit(2)
+ .returns(result)
+ .explainContains(plan);
+ }
+
+ @Test void testArrowProjectFieldsWithNotFilter() {
+ String sql = "select \"booleanField\"\n"
+ + "from arrowdatatype\n"
+ + "where \"booleanField\" is false";
+ String plan = "PLAN=ArrowToEnumerableConverter\n"
+ + " ArrowProject(booleanField=[$7])\n"
+ + " ArrowFilter(condition=[NOT($7)])\n"
+ + " ArrowTableScan(table=[[ARROW, ARROWDATATYPE]], fields=[[0, 1,
2, 3, 4, 5, 6, 7, 8, 9]])\n\n";
+ String result = "booleanField=false\nbooleanField=false\n";
Review Comment:
No, there are 20 rows of data in total. rowCount is 20
```
private void booleanField(FieldVector fieldVector, int rowCount) {
BitVector bitVector = (BitVector) fieldVector;
bitVector.setInitialCapacity(rowCount);
bitVector.allocateNew();
for (int i = 0; i < rowCount; i++) {
if (i % 3 == 0) {
bitVector.setNull(i);
} else {
bitVector.set(i, this.booleanValue ? 1 : 0);
}
this.booleanValue = !this.booleanValue;
}
fieldVector.setValueCount(rowCount);
}
```
It's just that the field content is distributed regularly according to the
three types of content: null, true, and false.
I set limit(2) on the final result, so it only shows two rows, but there are
actually more than two rows.
example
```
booleanfield
null
true
false
null
true
false
...
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]