forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-47094][SQL] SPJ : Dynamically rebalance number of buckets when…
… they are not equal ### What changes were proposed in this pull request? -- Allow SPJ between 'compatible' bucket funtions -- Add a mechanism to define 'reducible' functions, one function whose output can be 'reduced' to another for all inputs. ### Why are the changes needed? -- SPJ currently applies only if the partition transform expressions on both sides are identifical. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added new tests in KeyGroupedPartitioningSuite ### Was this patch authored or co-authored using generative AI tooling? No
- Loading branch information
Showing
9 changed files
with
531 additions
and
22 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/functions/Reducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.apache.spark.sql.connector.catalog.functions; | ||
|
||
import org.apache.spark.annotation.Evolving; | ||
|
||
/** | ||
* A 'reducer' for output of user-defined functions. | ||
* | ||
* A user_defined function f_source(x) is 'reducible' on another user_defined function f_target(x), | ||
* if there exists a 'reducer' r(x) such that r(f_source(x)) = f_target(x) for all input x. | ||
* @param <T> function output type | ||
* @since 4.0.0 | ||
*/ | ||
@Evolving | ||
public interface Reducer<T> { | ||
T reduce(T arg1); | ||
} |
25 changes: 25 additions & 0 deletions
25
...yst/src/main/java/org/apache/spark/sql/connector/catalog/functions/ReducibleFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.apache.spark.sql.connector.catalog.functions; | ||
|
||
import org.apache.spark.annotation.Evolving; | ||
import scala.Option; | ||
|
||
/** | ||
* Base class for user-defined functions that can be 'reduced' on another function. | ||
* | ||
* A function f_source(x) is 'reducible' on another function f_target(x) if | ||
* there exists a reducer function r(x) such that r(f_source(x)) = f_target(x) for all input x. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
@Evolving | ||
public interface ReducibleFunction<T, A> extends ScalarFunction<T> { | ||
|
||
/** | ||
* If this function is 'reducible' on another function, return the {@link Reducer} function. | ||
* @param other other function | ||
* @param thisArgument argument for this function instance | ||
* @param otherArgument argument for other function instance | ||
* @return a reduction function if it is reducible, none if not | ||
*/ | ||
Option<Reducer<A>> reducer(ReducibleFunction<?, ?> other, Option<?> thisArgument, Option<?> otherArgument); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.