mihaibudiu commented on code in PR #4259:
URL: https://github.com/apache/calcite/pull/4259#discussion_r2012519261
##########
core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java:
##########
@@ -737,25 +742,28 @@ private void checkOp(CalciteAssert.AssertThat with,
String fn) {
*
* @see CatchallSchema#enumerable
* @see CatchallSchema#list */
- @Test void testSchemaFieldHasBadType() {
+ @Test void testSchemaFieldHasBadAndProperType() {
final CalciteAssert.AssertThat with =
CalciteAssert.that().withSchema("s", CATCHALL);
// BitSet is not a valid relation type. It's as if "bitSet" field does
// not exist.
with.query("select * from \"s\".\"bitSet\"")
.throws_("Object 'bitSet' not found within 's'");
- // Enumerable field returns 3 records with 0 fields
- with.query("select * from \"s\".\"enumerable\"")
- .returns("\n"
- + "\n"
- + "\n"
- + "\n");
- // List is implicitly converted to Enumerable
- with.query("select * from \"s\".\"list\"")
- .returns("\n"
- + "\n"
- + "\n"
- + "\n");
+
+ final String employees = new StringBuilder()
Review Comment:
why is this result different?
was the previous result wrong?
##########
core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java:
##########
@@ -972,4 +980,48 @@ public static class DateColumnSchema {
assertNotNull(statistic);
assertThat(statistic.getRowCount(), is(2D));
}
+
+ public static final ReflectiveSchema COLLECTIONS_SCHEMA =
+ new ReflectiveSchema(new PetCollectionsSchema());
+
+ public static Stream<Arguments> collectionsSchemaFieldNames() {
+ return Stream.of(
+ Arguments.of("cats_array_list"),
+ Arguments.of("cats_linked_list"),
+ Arguments.of("cats_stack"),
+ Arguments.of("cats_vector"),
+ Arguments.of("cats_array_dequeue"),
+ Arguments.of("cats_hash_set"),
+ Arguments.of("cats_linked_hash_set"),
+ Arguments.of("cats_tree_set"));
+ }
+
+ /**
+ * Test that the Collections works as field of ReflectiveSchema.
Review Comment:
"Test that Collections can be used as field"
##########
core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java:
##########
@@ -972,4 +980,48 @@ public static class DateColumnSchema {
assertNotNull(statistic);
assertThat(statistic.getRowCount(), is(2D));
}
+
+ public static final ReflectiveSchema COLLECTIONS_SCHEMA =
+ new ReflectiveSchema(new PetCollectionsSchema());
+
+ public static Stream<Arguments> collectionsSchemaFieldNames() {
+ return Stream.of(
+ Arguments.of("cats_array_list"),
+ Arguments.of("cats_linked_list"),
+ Arguments.of("cats_stack"),
+ Arguments.of("cats_vector"),
+ Arguments.of("cats_array_dequeue"),
+ Arguments.of("cats_hash_set"),
+ Arguments.of("cats_linked_hash_set"),
+ Arguments.of("cats_tree_set"));
+ }
+
+ /**
+ * Test that the Collections works as field of ReflectiveSchema.
+ *
+ * @see <a
href="https://issues.apache.org/jira/browse/CALCITE-4708">[CALCITE-4708]</a>
+ */
+ @ParameterizedTest @MethodSource("collectionsSchemaFieldNames")
+ void testSelectCollectionsFieldsSchema(String fieldName) {
+ CalciteAssert.that()
+ .withSchema("s", COLLECTIONS_SCHEMA)
+ .query("select * from \"s\".\"" + fieldName + "\"")
+ .returns("name=Simba; age=2\nname=Luna; age=1\nname=Bella; age=3\n");
+ }
+
+ /**
+ * Test that the Collections works as field of ReflectiveSchema with corrects
Review Comment:
correct statistics
##########
core/src/main/java/org/apache/calcite/adapter/java/ReflectiveSchema.java:
##########
@@ -320,6 +326,8 @@ private static class ReflectiveTable
*
* Employee[] EMPS;
* Department[] DEPTS;
+ * List<Discount> DISCOUNTS;
Review Comment:
was this an omission?
--
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]