Ai
1 Star 0 Fork 31

zhangxingrong/spark

forked from src-openEuler/spark
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-CommandResultExec-to-override-iterator-methods-to-avoid-triggering-multiple-jobs.patch 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
zhangxingrong 提交于 2024-08-16 17:45 +08:00 . add some upstream patchs
From 24f88b319c88bfe55e8b2b683193a85842bdad88 Mon Sep 17 00:00:00 2001
From: yorksity <yorksity@outlook.com>
Date: Tue, 10 Oct 2023 14:36:23 +0800
Subject: [PATCH] [SPARK-45205][SQL] CommandResultExec to override iterator
methods to avoid triggering multiple jobs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
### What changes were proposed in this pull request?
After SPARK-35378 was changed, the execution of statements such as ‘show parititions test' became slower. The change point is that the execution process changes from ExecutedCommandEnec to CommandResultExec, but ExecutedCommandExec originally implemented the following method
override def executeToIterator(): Iterator[InternalRow] = sideEffectResult.iterator
CommandResultExec is not rewritten, so when the hasNext method is executed, a job process is created, resulting in increased time-consuming
### Why are the changes needed?
Improve performance when show partitions/tables.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Existing tests should cover this.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #43270 from yorksity/SPARK-45205.
Authored-by: yorksity <yorksity@outlook.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit c9c99222e828d556552694dfb48c75bf0703a2c4)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
---
.../org/apache/spark/sql/execution/CommandResultExec.scala | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/CommandResultExec.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/CommandResultExec.scala
index 5f38278d2dc67..45e3e41ab053d 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/CommandResultExec.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/CommandResultExec.scala
@@ -81,6 +81,8 @@ case class CommandResultExec(
unsafeRows
}
+ override def executeToIterator(): Iterator[InternalRow] = unsafeRows.iterator
+
override def executeTake(limit: Int): Array[InternalRow] = {
val taken = unsafeRows.take(limit)
longMetric("numOutputRows").add(taken.size)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangxingrong/spark.git
git@gitee.com:zhangxingrong/spark.git
zhangxingrong
spark
spark
master

搜索帮助