xuzifu666 commented on code in PR #4915:
URL: https://github.com/apache/calcite/pull/4915#discussion_r3188832704
##########
arrow/src/test/java/org/apache/calcite/adapter/arrow/ArrowAdapterTest.java:
##########
@@ -94,6 +102,70 @@ static void initializeArrowState(@TempDir Path
sharedTempDir)
isListOf("intField", "stringField", "floatField", "longField"));
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6291">[CALCITE-6291]
+ * Support converting ArrowTable to Queryable</a>.
+ */
+ @Test void testArrowTableAsQueryable() {
+ ArrowSchema arrowSchema = new ArrowSchema(arrowDataDirectory);
+ Map<String, Table> tableMap = arrowSchema.getTableMap();
+ ArrowTable arrowTable = (ArrowTable) tableMap.get("ARROWDATA");
+
+ // asQueryable can accept null QueryProvider and SchemaPlus for testing
+ Queryable<?> queryable = arrowTable.asQueryable(null, null, "ARROWDATA");
+
+ // Verify that asQueryable returns a non-null Queryable
+ assert queryable != null : "asQueryable should return a non-null
Queryable";
+
+ // Verify that the Queryable is an instance of ArrowQueryable
+ assert queryable instanceof ArrowTable.ArrowQueryable
+ : "asQueryable should return an instance of ArrowQueryable";
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6291">[CALCITE-6291]
+ * Support converting ArrowTable to Queryable</a>.
+ */
+ @Test void testArrowQueryableQueryWithData() {
+ ArrowSchema arrowSchema = new ArrowSchema(arrowDataDirectory);
+ Map<String, Table> tableMap = arrowSchema.getTableMap();
+ ArrowTable arrowTable = (ArrowTable) tableMap.get("ARROWDATA");
+
+ @SuppressWarnings("unchecked")
+ ArrowTable.ArrowQueryable<Object> queryable =
+ (ArrowTable.ArrowQueryable<Object>) arrowTable.asQueryable(null, null,
"ARROWDATA");
+
+ // Query with projection on all fields (0, 1, 2, 3) and no filter
conditions
+ List<Integer> fields = Arrays.asList(0, 1, 2, 3);
+ List<List<List<String>>> conditions = Collections.emptyList();
+
+ Enumerable<Object> enumerable = queryable.query(fields, conditions);
+
+ // Fetch the first 6 rows using enumerator
+ List<Object> results = new ArrayList<>();
+ Enumerator<Object> enumerator = enumerable.enumerator();
+ int count = 0;
+ while (enumerator.moveNext() && count < 6) {
+ results.add(enumerator.current());
+ count++;
+ }
+ enumerator.close();
+
+ // Verify we got 6 rows
Review Comment:
There's no need to add a comment here; I deleted it.
--
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]