|
16 | 16 | */ |
17 | 17 | package org.apache.auron |
18 | 18 |
|
| 19 | +import org.apache.spark.SparkEnv |
19 | 20 | import org.apache.spark.sql.{AuronQueryTest, Row} |
20 | 21 | import org.apache.spark.sql.execution.auron.plan.NativeBroadcastExchangeExec |
21 | 22 | import org.apache.spark.sql.execution.exchange.BroadcastExchangeExec |
22 | 23 |
|
23 | 24 | class AuronCheckConvertBroadcastExchangeSuite extends AuronQueryTest with BaseAuronSQLSuite { |
24 | 25 | import testImplicits._ |
25 | 26 |
|
| 27 | + test("do not serialize the broadcast relation with Spark tasks") { |
| 28 | + withSQLConf( |
| 29 | + "spark.auron.enable.broadcastExchange" -> "true", |
| 30 | + "spark.auron.enable.bhj" -> "false") { |
| 31 | + val payload = "x" * 4096 |
| 32 | + (0 until 256) |
| 33 | + .map(i => (i, s"$i$payload")) |
| 34 | + .toDF("key", "payload") |
| 35 | + .createOrReplaceTempView("broad_cast_table1") |
| 36 | + Seq(0, 255).toDF("key").createOrReplaceTempView("broad_cast_table2") |
| 37 | + |
| 38 | + val df = spark.sql( |
| 39 | + "select /*+ broadcast(a)*/ b.key from broad_cast_table1 a " + |
| 40 | + "inner join broad_cast_table2 b on a.key = b.key") |
| 41 | + |
| 42 | + checkAnswer(df, Seq(Row(0), Row(255))) |
| 43 | + val exchange = collectFirst(df.queryExecution.executedPlan) { |
| 44 | + case broadcastExchangeExec: NativeBroadcastExchangeExec => broadcastExchangeExec |
| 45 | + }.get |
| 46 | + val broadcast = exchange.executeBroadcast[Any]() |
| 47 | + try { |
| 48 | + val serialized = SparkEnv.get.closureSerializer.newInstance().serialize(broadcast) |
| 49 | + assert(serialized.remaining() < 64 * 1024) |
| 50 | + } finally { |
| 51 | + broadcast.destroy() |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
26 | 56 | test( |
27 | 57 | "test bhj broadcastExchange to native where spark.auron.enable.broadcastExchange is true") { |
28 | 58 | withSQLConf("spark.auron.enable.broadcastExchange" -> "true") { |
|
0 commit comments