Created
April 19, 2023 04:55
-
-
Save nfarah86/2f1e8d4d6ba64d5fe81e58478cec09f5 to your computer and use it in GitHub Desktop.
This file contains 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
import org.apache.spark.sql.SaveMode._ | |
val basePath = "/tmp/hudi/stocks" | |
val stocksDF1 = spark.read.json("docker/demo/data/batch_1.json") | |
val stocksDF2 = spark.read.option("multiline", "true").json("docker/demo/data/batch_2.json").limit(1) | |
stocksDF1.write.format("hudi"). | |
option("hoodie.datasource.write.recordkey.field", "symbol"). | |
option("hoodie.datasource.write.partitionpath.field", "date"). | |
option("hoodie.datasource.write.precombine.field", "ts"). | |
option("hoodie.table.name", "stocks"). | |
mode(Overwrite). | |
save(basePath) | |
stocksDF2.write.format("hudi"). | |
option("hoodie.datasource.write.recordkey.field", "symbol"). | |
option("hoodie.datasource.write.partitionpath.field", "date"). | |
option("hoodie.datasource.write.precombine.field", "ts"). | |
mode(Append). | |
save(basePath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment