Reputation: 11
How do I create multiple table views in Hive programmatically using spark and scala?
Upvotes: 1
Views: 2048
Reputation: 18098
Since SPARK 2:
spark.sql("create or replace view viewSO as select f1.orig as f1_orig, f2.orig as f2_orig, f2.dest as f2_dest from facts f1, facts f2 ")
spark.table("viewSO").printSchema
root
|-- f1_orig: string (nullable = true)
|-- f2_orig: string (nullable = true)
|-- f2_dest: string (nullable = true)
I would do it in Hive, Impala, but anyway.
And:
spark.sql("drop view viewSO")
Upvotes: 1