Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-42557][CONNECT] Add Broadcast to functions #40275

Closed
wants to merge 5 commits into from

Conversation

beliefer
Copy link
Contributor

@beliefer beliefer commented Mar 4, 2023

What changes were proposed in this pull request?

Currently, the connect functions missing the broadcast API. This PR want add this API to connect's functions.

Why are the changes needed?

Add the broadcast function to connect's functions.scala.

Does this PR introduce any user-facing change?

'No'.
New feature.

How was this patch tested?

New test cases.

* @since 3.4.0
*/
def broadcast[T](df: Dataset[T]): Dataset[T] = {
df.hint("broadcast")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enough? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

val left = spark.range(100).select(col("id"), rand(10).as("a"))
val right = spark.range(100).select(col("id"), rand(12).as("a"))
val joined =
left.join(broadcast(right), left("id") === right("id")).select(left("id"), right("a"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check if we actually broadcast the right table?

Copy link
Contributor

@hvanhovell hvanhovell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you add an check if actually broadcasting

val joined =
left.join(broadcast(right), left("id") === right("id")).select(left("id"), right("a"))
assert(joined.schema.catalogString === "struct<id:bigint,a:double>")
testCapturedStdOut(joined.explain(), "BroadcastHashJoin")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For later: we should have a better way to get the plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.

left.join(broadcast(right), left("id") === right("id")).select(left("id"), right("a"))
assert(joined.schema.catalogString === "struct<id:bigint,a:double>")
testCapturedStdOut(joined.explain(), "BroadcastHashJoin")
spark.conf.set("spark.sql.autoBroadcastJoinThreshold", "10MB")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to use try.. finally .. when you are resetting confs. That way failing tests do not start influencing others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we copy SQLHelper to client module later? withSQLConf and other functions are more useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuciferYang It's good idea. Let's do it later.

Copy link
Contributor

@hvanhovell hvanhovell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@LuciferYang LuciferYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM

@beliefer
Copy link
Contributor Author

beliefer commented Mar 5, 2023

@LuciferYang I want support the similar withSQLConf.

@beliefer
Copy link
Contributor Author

beliefer commented Mar 5, 2023

@LuciferYang Thank you.

@beliefer
Copy link
Contributor Author

beliefer commented Mar 6, 2023

@hvanhovell
Copy link
Contributor

Merging.

@hvanhovell hvanhovell closed this in 94b50e0 Mar 6, 2023
hvanhovell pushed a commit that referenced this pull request Mar 6, 2023
### What changes were proposed in this pull request?
Currently, the connect functions missing the broadcast API. This PR want add this API to connect's functions.

### Why are the changes needed?
Add the broadcast function to connect's functions.scala.

### Does this PR introduce _any_ user-facing change?
 'No'.
New feature.

### How was this patch tested?
New test cases.

Closes #40275 from beliefer/SPARK-42557.

Authored-by: Jiaan Geng <beliefer@163.com>
Signed-off-by: Herman van Hovell <herman@databricks.com>
(cherry picked from commit 94b50e0)
Signed-off-by: Herman van Hovell <herman@databricks.com>
@beliefer
Copy link
Contributor Author

beliefer commented Mar 6, 2023

@hvanhovell @LuciferYang Thank you.

hvanhovell pushed a commit that referenced this pull request Mar 20, 2023
…xclude` rule from mima check

### What changes were proposed in this pull request?
#40275 has implemented the `functions#broadcast`, so this pr remove the corresponding `ProblemFilters.exclude` rule from `CheckConnectJvmClientCompatibility`

### Why are the changes needed?
Remove `unnecessary` `ProblemFilters.exclude` rule.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Manual check `dev/connect-jvm-client-mima-check` passed

Closes #40463 from LuciferYang/SPARK-42557-FOLLOWUP.

Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Herman van Hovell <herman@databricks.com>
hvanhovell pushed a commit that referenced this pull request Mar 20, 2023
…xclude` rule from mima check

### What changes were proposed in this pull request?
#40275 has implemented the `functions#broadcast`, so this pr remove the corresponding `ProblemFilters.exclude` rule from `CheckConnectJvmClientCompatibility`

### Why are the changes needed?
Remove `unnecessary` `ProblemFilters.exclude` rule.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Manual check `dev/connect-jvm-client-mima-check` passed

Closes #40463 from LuciferYang/SPARK-42557-FOLLOWUP.

Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Herman van Hovell <herman@databricks.com>
(cherry picked from commit 6ad8bf4)
Signed-off-by: Herman van Hovell <herman@databricks.com>
snmvaughan pushed a commit to snmvaughan/spark that referenced this pull request Jun 20, 2023
### What changes were proposed in this pull request?
Currently, the connect functions missing the broadcast API. This PR want add this API to connect's functions.

### Why are the changes needed?
Add the broadcast function to connect's functions.scala.

### Does this PR introduce _any_ user-facing change?
 'No'.
New feature.

### How was this patch tested?
New test cases.

Closes apache#40275 from beliefer/SPARK-42557.

Authored-by: Jiaan Geng <beliefer@163.com>
Signed-off-by: Herman van Hovell <herman@databricks.com>
(cherry picked from commit 94b50e0)
Signed-off-by: Herman van Hovell <herman@databricks.com>
snmvaughan pushed a commit to snmvaughan/spark that referenced this pull request Jun 20, 2023
…xclude` rule from mima check

### What changes were proposed in this pull request?
apache#40275 has implemented the `functions#broadcast`, so this pr remove the corresponding `ProblemFilters.exclude` rule from `CheckConnectJvmClientCompatibility`

### Why are the changes needed?
Remove `unnecessary` `ProblemFilters.exclude` rule.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Manual check `dev/connect-jvm-client-mima-check` passed

Closes apache#40463 from LuciferYang/SPARK-42557-FOLLOWUP.

Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Herman van Hovell <herman@databricks.com>
(cherry picked from commit 6ad8bf4)
Signed-off-by: Herman van Hovell <herman@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants