Spark: How can i create temp views in user defined database instead of default database?

0 votes

In spark SQL when I create temp views they get stored in default database.

It seems I can create a user-defined database as well

spark.sql("create database test")

How can I create temp views in the user-defined database instead of the default database, in above for example in "test" database?

Also, when I create a temp view and run command

spark.sql("show tables in default")

it lists all the tables in the database, here I see a column "isTemporary" is set to True. What is the significance of this column, and how can, for a particular view I can set it to "False" and if I do so, will this table be permanently stored in Spark?

Jul 14 in Apache Spark by Ashul
29 views

1 answer to this question.

0 votes

You can try the below code:

df.registerTempTable(“airports”)

sqlContext.sql(" create database New ")

sqlContext.sql(" use New ")

sqlContext.sql(" create table new123 as select * from airports")
answered Jul 14 by Ishan

Related Questions In Apache Spark

0 votes
2 answers

In a Spark DataFrame how can I flatten the struct?

// Collect data from input avro file ...READ MORE

answered Jul 4 in Apache Spark by Dhara dhruve
698 views
0 votes
1 answer

How can I write a text file in HDFS not from an RDD, in Spark program?

Yes, you can go ahead and write ...READ MORE

answered May 29, 2018 in Apache Spark by Shubham
• 13,290 points
1,044 views
0 votes
1 answer

How can I compare the elements of the RDD using MapReduce?

You have to use the comparison operator ...READ MORE

answered May 24, 2018 in Apache Spark by Shubham
• 13,290 points
275 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,510 points
2,408 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,510 points
246 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
12,237 views
0 votes
1 answer

Difference between cogroup and full outer join in spark

Please go through the below explanation : Full ...READ MORE

answered Jul 13 in Apache Spark by Kiran
87 views
0 votes
1 answer