Harish
Harish

Reputation: 11

Create hive Views using scala /spark

How do I create multiple table views in Hive programmatically using spark and scala?

  1. Drop if a view exists
  2. create a view from the table located in the hive.

Upvotes: 1

Views: 2048

Answers (1)

Ged
Ged

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

Related Questions