gr4ve commented on a change in pull request #1405: [CALCITE-2772] Support
varargs UDF for scalar function
URL: https://github.com/apache/calcite/pull/1405#discussion_r366125970
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumUtils.java
##########
@@ -191,24 +192,43 @@ static Expression fromInternal(Expression e, Class<?>
targetType) {
return e;
}
+ /**
+ * build expression list.
+ * if varArgs is true, the last targetType will replace by its Component
Type.
+ */
static List<Expression> fromInternal(Class<?>[] targetTypes,
- List<Expression> expressions) {
+ List<Expression> expressions, boolean varArgs) {
+
final List<Expression> list = new ArrayList<>();
- if (targetTypes.length == expressions.size()) {
+
+ if (varArgs) {
+ Class<?> varTargetType = targetTypes[targetTypes.length - 1];
+ Preconditions.checkArgument(varTargetType != null &&
varTargetType.isArray(),
+ "the var target type should not null and it must be an array.");
+
Review comment:
i think the ? is better in this place, the question mark represents an
unknown type.
----------------------------------------------------------------
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