moomindani opened a new pull request #27690: [WIP][SPARK-21514][SQL] Added a new option to use non-blobstore storage when writing into blobstore storage URL: https://github.com/apache/spark/pull/27690 <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html 2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'. 4. Be sure to keep the PR description updated to reflect all changes. 5. Please write your PR title to summarize what this PR proposes. 6. If possible, provide a concise example to reproduce the issue for a faster review. 7. If you want to add a new configuration, please read the guideline first for naming configurations in 'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'. --> ### What changes were proposed in this pull request? <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below. 1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers. 2. If you fix some SQL features, you can provide some references of other DBMSes. 3. If there is design documentation, please add the link. 4. If there is a discussion in the mailing list, please add the link. --> I added config parameters; (the same parameter names used in Hive) spark.hadoop.hive.blobstore.supported.schemes (= s3a, s3, s3n) spark.hadoop.hive.blobstore.use.blobstore.as.scratchdir (= true) If the target table's schema is included in hive.blobstore.supported.schemes AND hive.blobstore.use.blobstore.as.scratchdir = false, then HDFS (MRTempDir) is used. Major benefits of this patch are; - Increase performance to write data to blob storage - Reduce costs for blob storage I/O - Reduce the effect of eventual consistency ### Why are the changes needed? <!-- Please clarify why the changes are needed. For instance, 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. --> Currently Spark writes temporary data into blob storage such as S3, and it affects performance and costs for customers. This pull request is raised to enhance a feature to change temporary data location from blob storage to HDFS. ### Does this PR introduce any user-facing change? <!-- If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If no, write 'No'. --> Yes - When `spark.hadoop.hive.blobstore.use.blobstore.as.scratchdir=true`, there is no change. - When `spark.hadoop.hive.blobstore.use.blobstore.as.scratchdir=false`, HDFS is used for temporal storage instead of blob storage. ### How was this patch tested? <!-- If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> #### Unit test I added two new unit tests; - SaveAsHiveFileSuite: Test the temp path for both blob storage and non-blob storage ``` $ build/sbt > project hive > testOnly *SaveAsHiveFileSuite ... [info] ScalaTest [info] Run completed in 14 seconds, 779 milliseconds. [info] Total number of tests run: 2 [info] Suites: completed 1, aborted 0 [info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0 [info] All tests passed. [info] Passed: Total 2, Failed 0, Errors 0, Passed 2 [success] Total time: 310 s, completed Feb 19, 2020 2:09:58 AM ``` - BlobStorageUtilsSuite: Test utility functions for managing configurations ``` > testOnly *BlobStorageUtilsSuite [info] ScalaTest [info] Run completed in 12 seconds, 922 milliseconds. [info] Total number of tests run: 6 [info] Suites: completed 1, aborted 0 [info] Tests: succeeded 6, failed 0, canceled 0, ignored 0, pending 0 [info] All tests passed. [info] Passed: Total 6, Failed 0, Errors 0, Passed 6 [success] Total time: 18 s, completed Feb 19, 2020 2:11:46 AM ``` #### Integration test In this integration test, I used the same data, the same EMR cluster with different configurations in `spark.hadoop.hive.blobstore.use.blobstore.as.scratchdir`. ##### Data Tables ``` CREATE EXTERNAL TABLE plain_cf ( Date DATE, Time STRING, Location STRING, Bytes INT, RequestIP STRING, Method STRING, Host STRING, Uri STRING, Status INT, Referrer STRING, os STRING, Browser STRING, BrowserVersion STRING ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' WITH SERDEPROPERTIES ( "input.regex" = "^(?!#)([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+[^\(]+[\(]([^\;]+).*\%20([^\/]+)[\/](.*)$" ) LOCATION 's3a://athena-examples/cloudfront/plaintext/'; CREATE TABLE spark_cf_txt1 ( Date DATE, Time STRING, Location STRING) STORED AS TEXTFILE LOCATION 's3a://sekiyama-bucket/spark/dev/SPARK21514/spark_cf_txt1'; CREATE TABLE spark_cf_txt2 ( Date DATE, Time STRING, Location STRING) STORED AS TEXTFILE LOCATION 's3a://sekiyama-bucket/spark/dev/SPARK21514/spark_cf_txt2'; ``` ##### Scenario 1 (spark.hadoop.hive.blobstore.use.blobstore.as.scratchdir=true) ``` spark-sql> INSERT OVERWRITE TABLE spark_cf_txt1 SELECT Date,Time,Location FROM plain_cf; ``` Here's the duration per trial (10 trials in total) - Time taken: 21.197 seconds - Time taken: 27.524 seconds - Time taken: 21.385 seconds - Time taken: 19.313 seconds - Time taken: 20.545 seconds - Time taken: 22.509 seconds - Time taken: 21.377 seconds - Time taken: 20.134 seconds - Time taken: 20.632 seconds - Time taken: 20.242 seconds **Average duration: 21.4858 seconds** ##### Scenario 2 (spark.hadoop.hive.blobstore.use.blobstore.as.scratchdir=false) ``` spark-sql> INSERT OVERWRITE TABLE spark_cf_txt2 SELECT Date,Time,Location FROM plain_cf; ``` Here's the duration per trial (10 trials in total) - Time taken: 19.624 seconds - Time taken: 15.178 seconds - Time taken: 15.645 seconds - Time taken: 20.185 seconds - Time taken: 15.821 seconds - Time taken: 15.545 seconds - Time taken: 15.612 seconds - Time taken: 14.925 seconds - Time taken: 15.691 seconds - Time taken: 15.747 seconds **Average duration: 16.3973 seconds**
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
