metanil commented on code in PR #55885:
URL: https://github.com/apache/spark/pull/55885#discussion_r3547814330


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/functions/ReducibleFunction.java:
##########
@@ -60,6 +61,48 @@
 @Evolving
 public interface ReducibleFunction<I, O> {
 
+  /**
+   * Generic reducer for parameterized functions (bucket, truncate, etc.).
+   *
+   * If this function is 'reducible' on another function, return the {@link 
Reducer}.
+   * <p>
+   * Each parameter is a non-complex {@link Literal} carrying both its value 
and data type:
+   * array/map/struct/UDT-typed values are filtered out by Spark and not 
passed here, but other
+   * scalar values (e.g. bucket numBuckets, truncate width, or a
+   * {@code CalendarInterval}) may be. {@link Literal#value()} is Spark's 
internal representation
+   * (e.g. {@code UTF8String} for strings, {@code Decimal} for decimals); use
+   * {@link Literal#dataType()} to interpret it rather than assuming a JVM 
type.
+   * <p>
+   * {@code thisParams} and {@code otherParams} hold each side's own literal 
parameters and may have
+   * different lengths -- for example a zero-parameter transform reducing onto 
a one-parameter one.
+   * Implementations must check each array's length before indexing into it.
+   * <p>
+   * Returning {@code null} means "not reducible for these parameters". 
Throwing
+   * {@link UnsupportedOperationException} signals that this overload is not 
implemented (Spark then

Review Comment:
   @sunchao  thanks, this is fixed, but it prompted a larger change worth 
flagging: **the dispatch was reversed to generalized-first**, so a couple of 
the premises in this comment are now inverted. See more on my top level comment.



-- 
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]

Reply via email to