-
Notifications
You must be signed in to change notification settings - Fork 29k
SPARK-22833 [Improvement] in SparkHive Scala Examples #20018
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 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9d9b42b
SPARK-22833 [Improvement] in SparkHive Scala Examples
chetkhatri 0bbad8c
[SPARK-22833] [Improvement] Example code enabled for documentation
chetkhatri ee53208
SPARK-22833 [Improvement] in SparkHive Scala Example - DDL for partit…
chetkhatri 2f98a3c
SPARK-22833 [Improvement] - reverted mistake on on-off example
chetkhatri 69a4145
SPARK-22833 [Improvement] in SparkHive Scala example - change in comm…
chetkhatri b95587d
SPARK-22833 [Improvement] in SparkHive Scala example - DDL used in sql
chetkhatri 9b8d188
SPARK-22833 [Improvement] in SparkHive Scala example - location added…
chetkhatri c3dda1b
SPARK-22833 [Improvement] in SparkHive Scala Example - comments rephr…
chetkhatri 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
Prev
Previous commit
SPARK-22833 [Improvement] in SparkHive Scala Example - comments rephr…
…ased
- Loading branch information
commit c3dda1bd3445dc34e9c980d3f19ecd7abfc2ccc5
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,36 +102,36 @@ object SparkHiveExample { | |
| // | 5| val_5| 5| val_5| | ||
| // ... | ||
|
|
||
| // Create Hive managed table with parquet | ||
| // Create Hive managed table with Parquet | ||
| sql("CREATE TABLE records(key int, value string) STORED AS PARQUET") | ||
| // Save DataFrame to Hive Managed table as Parquet format | ||
| // Save DataFrame to Hive managed table as Parquet format | ||
| val hiveTableDF = sql("SELECT * FROM records") | ||
| hiveTableDF.write.mode(SaveMode.Overwrite).saveAsTable("database_name.records") | ||
| // Create External Hive table with parquet | ||
| // Create External Hive table with Parquet | ||
| sql("CREATE EXTERNAL TABLE records(key int, value string) " + | ||
| "STORED AS PARQUET LOCATION '/user/hive/warehouse/'") | ||
| // to make Hive parquet format compatible with spark parquet format | ||
| // to make Hive Parquet format compatible with Spark Parquet format | ||
| spark.sqlContext.setConf("spark.sql.parquet.writeLegacyFormat", "true") | ||
|
|
||
| // Multiple parquet files could be created accordingly to volume of data under directory given. | ||
| // Multiple Parquet files could be created accordingly to volume of data under directory given. | ||
| val hiveExternalTableLocation = "/user/hive/warehouse/database_name.db/records" | ||
|
|
||
| // Save DataFrame to Hive External table as compatible parquet format | ||
| // Save DataFrame to Hive External table as compatible Parquet format | ||
| hiveTableDF.write.mode(SaveMode.Overwrite).parquet(hiveExternalTableLocation) | ||
|
|
||
| // turn on flag for Dynamic Partitioning | ||
| // Turn on flag for Dynamic Partitioning | ||
| spark.sqlContext.setConf("hive.exec.dynamic.partition", "true") | ||
| spark.sqlContext.setConf("hive.exec.dynamic.partition.mode", "nonstrict") | ||
|
|
||
| // You can create partitions in Hive table, so downstream queries run much faster. | ||
| hiveTableDF.write.mode(SaveMode.Overwrite).partitionBy("key") | ||
| .parquet(hiveExternalTableLocation) | ||
|
|
||
| // reduce number of files for each partition by repartition | ||
| // Reduce number of files for each partition by repartition | ||
| hiveTableDF.repartition($"key").write.mode(SaveMode.Overwrite) | ||
| .partitionBy("key").parquet(hiveExternalTableLocation) | ||
|
|
||
| // Control number of files in each partition by coalesce | ||
| // Control the number of files in each partition by coalesce | ||
| hiveTableDF.coalesce(10).write.mode(SaveMode.Overwrite) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| .partitionBy("key").parquet(hiveExternalTableLocation) | ||
| // $example off:spark_hive$ | ||
|
|
||
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.
This is not a standard usage, let's not put it in the example.
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.
@cloud-fan removed all comments , as discussed with @srowen it does really make sense to have at docs with removed inconsitency.