yashmayya commented on code in PR #16431:
URL: https://github.com/apache/pinot/pull/16431#discussion_r2238942855
##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArrayFunctions.java:
##########
@@ -136,11 +136,17 @@ public static boolean arrayContainsString(String[]
values, String valueToFind) {
@ScalarFunction
public static int[] arraySliceInt(int[] values, int start, int end) {
+ if (start < 0 || end > values.length || start >= end) {
Review Comment:
This is a behavioral change right? For instance the result of
`arraySliceInt([1, 2, 3, 4, 5], 1, 10)` would be `[2, 3, 4, 5, 0, 0, 0, 0, 0]`
before this change but `[]` after?
##########
pinot-udf-test/src/main/java/org/apache/pinot/udf/test/UdfTestFramework.java:
##########
@@ -278,11 +282,38 @@ private static Object canonizeObject(@Nullable Object
value) {
list.add(f);
}
return list;
+ } else if (componentType == byte.class) {
+ // Convert byte array to List<Byte> for consistency
+ byte[] byteArray = (byte[]) value;
+ ArrayList<Byte> list = new ArrayList<>(byteArray.length);
+ for (byte b : byteArray) {
+ list.add(b);
+ }
+ return list;
} else {
return Arrays.asList((Object[]) value);
}
}
return value;
}
}
+
+ private static int doubleCompare(double d1, double d2) {
+ double epsilon = 0.0001d;
+ if (d1 > d2) {
+ if (d1 * (1 - epsilon) > d2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ if (d2 > d1) {
Review Comment:
Is this a standard double comparison algorithm? Can't we simply use
something like `DoubleMath#fuzzyEquals` / `DoubleMath#fuzzyCompare` from Guava
instead?
##########
pinot-common/src/main/java/org/apache/pinot/common/function/FunctionInfo.java:
##########
@@ -43,4 +44,11 @@ public Class<?> getClazz() {
public boolean hasNullableParameters() {
return _nullableParameters;
}
+
+ public static FunctionInfo fromMethod(Method method) {
Review Comment:
Where is this being used?
##########
pinot-udf-test/src/main/java/org/apache/pinot/udf/test/UdfTestFramework.java:
##########
@@ -278,6 +278,14 @@ private static Object canonizeObject(@Nullable Object
value) {
list.add(f);
}
return list;
+ } else if (componentType == byte.class) {
Review Comment:
Why do only float arrays and byte arrays need to be converted like this?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]