Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create a Database in Spark SQL

How do I create a database or multiple databases in sparkSQL. I am executing the SQL from spark-sql CLI. The query like in hive create database sample_db does not work here. I have Hadoop 2.7 and Spark 1.6 installed on my system.

like image 269
Lokesh Yadav Avatar asked Jul 04 '16 14:07

Lokesh Yadav


2 Answers

spark.sql("create database test")

//fetch metadata data from the catalog. your database name will be listed here
spark.catalog.listDatabases.show(false)
like image 158
user6858809 Avatar answered Jan 04 '23 12:01

user6858809


CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] db_name  
    [COMMENT comment_text]  
    [LOCATION path]  
    [WITH DBPROPERTIES (key1=val1, key2=val2, ...)]  

Link for your reference

like image 31
Nagesh Singh Chauhan Avatar answered Jan 04 '23 11:01

Nagesh Singh Chauhan