feat(dataframe): add join, joinOn, and JoinType#72
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Joins are the largest missing piece of the DataFrame API today; without them, Java callers cannot programmatically express even simple star-join queries that DataFusion's Rust API has supported for years.
What changes are included in this PR?
This PR ships Phase 1 : column-name
joinplusjoinOnwith String-form predicates. By committing to SQL-string predicates here, it also closes the Phase-2 design question. A typedExprbuilder is deliberately deferred.New public Java enum
org.apache.datafusion.JoinTypemirroring upstream's 10-variant enum (INNER,LEFT,RIGHT,FULL,LEFT_SEMI,RIGHT_SEMI,LEFT_ANTI,RIGHT_ANTI,LEFT_MARK,RIGHT_MARK). Crosses JNI as abytecode, mirroring the existingVolatilityprecedent for UDFs.Three new methods on
DataFrame:DataFrame.join(right, type, leftCols, rightCols)— equi-join on named columns, no residual filter.DataFrame.join(right, type, leftCols, rightCols, filter)— equi-join with a residual SQL filter parsed against the combined schema of left + right.DataFrame.joinOn(right, type, predicates...)— arbitrary join predicates, each parsed as a SQL expression against the combined schema. Predicates may be qualified with the relation alias when ambiguous (e.g."l.id = r.id","left.x < right.y").All three are non-consuming on the Java side: both
left(the receiver) andrightremain usable and must still be closed independently. Upstream's Rustjoin/join_onconsume both, but the JNI layer clones the underlyingArc-backedDataFramelike every other transformation method (select/filter/withColumn/unnestColumns). This matches the established Java-side convention and supports the natural star-join pattern where the same fact table is joined to multiple dimensions:Out of scope (for follow-ups):
Exprbuilder (Phase 2 option 2). Andy's issue explicitly cautions against the maintenance burden. The String-form predicate channel covers everything DataFusion's parser supports.filter(String)already does.Are these changes tested?
Yes, 18 new tests in
core/src/test/java/org/apache/datafusion/DataFrameJoinTest.javaAre there any user-facing changes?
Yes, purely additive. New public API:
org.apache.datafusion.JoinType(enum)DataFrame.join(DataFrame, JoinType, String[], String[])DataFrame.join(DataFrame, JoinType, String[], String[], String)DataFrame.joinOn(DataFrame, JoinType, String...)No API removals, no deprecations, no behavior change for existing callers. The native binary is unchanged in size (no new Cargo features or dependencies).