-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-36579][CORE][SQL] Make spark source stagingDir can be customized #33828
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
Closed
Closed
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
2031f5b
[SPARK-36579][SQL] Make spark source stagingDir can use user defined
AngersZhuuuu c29f55e
Update SQLHadoopMapReduceCommitProtocol.scala
AngersZhuuuu 2604c9f
Update
AngersZhuuuu 71f6b17
fix ut
AngersZhuuuu 1947cbf
Merge branch 'master' into SPARK-36579
AngersZhuuuu 30113d2
Update SaveAsHiveFile.scala
AngersZhuuuu 6f405dc
update
AngersZhuuuu 361263b
update
AngersZhuuuu 9ee6ee5
update
AngersZhuuuu 7773fb2
update
AngersZhuuuu a3b3c51
Update PathOutputCommitProtocol.scala
AngersZhuuuu b4d60e4
Update PathOutputCommitProtocol.scala
AngersZhuuuu 2c41808
Update CommitterBindingSuite.scala
AngersZhuuuu 5926822
update
AngersZhuuuu 6cdee58
update
AngersZhuuuu 824ec04
Update FileCommitProtocol.scala
AngersZhuuuu 8c8a174
update
AngersZhuuuu 8d7ce6e
update
AngersZhuuuu da6a0b9
update
AngersZhuuuu 63e466c
update
AngersZhuuuu fd2ac5f
update
AngersZhuuuu e2951f1
fix UT
AngersZhuuuu c8d0c33
complicated
AngersZhuuuu eafb8dd
update
AngersZhuuuu ff2bfb8
revert API change
AngersZhuuuu c5a1d16
update
AngersZhuuuu 8b93bad
Update package.scala
AngersZhuuuu a0e0ec9
follow comment
AngersZhuuuu 872cd01
update
AngersZhuuuu d664932
update
AngersZhuuuu cf0cea8
Merge branch 'master' into SPARK-36579
AngersZhuuuu 997ba25
Update InsertSuite.scala
AngersZhuuuu 9e4a5a8
Merge branch 'SPARK-36579' of https://github.com/AngersZhuuuu/spark i…
AngersZhuuuu 44d63de
Update SQLHadoopMapReduceCommitProtocol.scala
AngersZhuuuu ed58884
Update SQLConf.scala
AngersZhuuuu 632d725
Update SQLConf.scala
AngersZhuuuu 10e029f
Merge branch 'master' into SPARK-36579
AngersZhuuuu db66beb
Merge branch 'master' into SPARK-36579
AngersZhuuuu b07e816
Merge branch 'master' into SPARK-36579
AngersZhuuuu cc8a4c3
Update SQLConf.scala
AngersZhuuuu 1c5a70a
Update FileCommitProtocol.scala
AngersZhuuuu 1e8424e
Update SQLHadoopMapReduceCommitProtocol.scala
AngersZhuuuu 3da83f1
Update SQLHadoopMapReduceCommitProtocol.scala
AngersZhuuuu 0a729f0
update
AngersZhuuuu 9392bdb
update
AngersZhuuuu 1178d1b
update
AngersZhuuuu 9dba590
update
AngersZhuuuu b998ec9
Update InsertSuite.scala
AngersZhuuuu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
81 changes: 81 additions & 0 deletions
81
sql/core/src/test/scala/org/apache/spark/sql/sources/CommitProtocolStagingDirSuite.scala
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.sources | ||
|
|
||
| import org.apache.spark.SparkConf | ||
| import org.apache.spark.sql.{QueryTest, Row} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.test.SharedSparkSession | ||
| import org.apache.spark.util.Utils | ||
|
|
||
|
|
||
| abstract class CommitProtocolStagingDirBaseSuite extends QueryTest with SharedSparkSession { | ||
| import testImplicits._ | ||
|
|
||
| def stagingDir: String | ||
| def cleanStagingDir(): Unit | ||
|
|
||
| override def sparkConf: SparkConf = | ||
| super.sparkConf.set(SQLConf.EXEC_STAGING_DIR, stagingDir) | ||
|
|
||
| override def beforeAll(): Unit = { | ||
| super.beforeAll() | ||
| cleanStagingDir() | ||
| } | ||
|
|
||
| override def afterAll(): Unit = { | ||
| try { | ||
| cleanStagingDir() | ||
| } finally { | ||
| super.afterAll() | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-36579: dynamic partition overwrite can use user defined staging dir") { | ||
| withSQLConf(SQLConf.PARTITION_OVERWRITE_MODE.key -> | ||
| SQLConf.PartitionOverwriteMode.DYNAMIC.toString) { | ||
| withTempDir { d => | ||
| withTable("t") { | ||
| sql( | ||
| s""" | ||
| |CREATE TABLE t(c1 int, p1 int) USING PARQUET PARTITIONED BY(p1) | ||
| |LOCATION '${d.getAbsolutePath}' | ||
| """.stripMargin) | ||
|
|
||
| val df = Seq((1, 2), (3, 4)).toDF("c1", "p1") | ||
| df.write | ||
| .partitionBy("p1") | ||
| .mode("overwrite") | ||
| .saveAsTable("t") | ||
| checkAnswer(sql("SELECT * FROM t"), df) | ||
| checkAnswer(sql("SELECT * FROM t WHERE p1 = 2"), Row(1, 2) :: Nil) | ||
| checkAnswer(sql("SELECT * FROM t WHERE p1 = 4"), Row(3, 4) :: Nil) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class LocalStagingDirSuite extends CommitProtocolStagingDirBaseSuite { | ||
| val stagingDirFile = Utils.createTempDir() | ||
| override val stagingDir = stagingDirFile.getAbsolutePath | ||
|
|
||
| override def cleanStagingDir(): Unit = { | ||
| Utils.deleteRecursively(stagingDirFile) | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always a bit brittle using the uri scheme. any way to avoid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't know why we need to handle viewfs separately and after searching origin pull request of this part, don't see the discussion, so I am not sure about this. And this part is just moved to here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably there to ensure you don't create staging dirs in a different fs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I remembered that hive will check tempLocation and targetOutputPath's FS and EZ when call HiveMetastore loadTable/loadPartition, Should move that logical to here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about current?