DonnyZone commented on a change in pull request #1881: [CALCITE-3216]
ClassCastException when running aggregate function and window function over
Union
URL: https://github.com/apache/calcite/pull/1881#discussion_r407344927
##########
File path:
linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java
##########
@@ -3650,6 +3668,68 @@ public void close() {
}
}
+ /** Extended casting Enumerator that casts each value.
+ * This Enumerator is the extension of CastingEnumerator.
+ * As for sql type, most of the numeric types are compatible, and are
assignable from other
+ * numeric types. But after these sql types have been translated to Java
types, the original
+ * compatible types cannot cast directly. This Enumerator can help these
compatible types cast.
+ *
+ * @param <T> element type */
+ static class ExtendedCastingEnumerator<T> implements Enumerator<T> {
+ private final Enumerator<?> enumerator;
+ private final Class<T> clazz;
+
+ ExtendedCastingEnumerator(Enumerator<?> enumerator, Class<T> clazz) {
+ this.enumerator = enumerator;
+ this.clazz = clazz;
+ }
+
+ public T current() {
+ return extendedCast(enumerator.current());
+ }
+
+ public boolean moveNext() {
+ return enumerator.moveNext();
+ }
+
+ public void reset() {
+ enumerator.reset();
+ }
+
+ public void close() {
+ enumerator.close();
+ }
+
+ public T extendedCast(Object obj) {
Review comment:
According to the cast logic, I think we can achieve the same goal in
`EnumUtils.convert`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services