代码
object Spark04_SparkSQL_Hive {
def main(args: Array[String]): Unit = {
//TODO 创建SparkSQL的运行环境
val spark = SparkSession.builder().appName("sparksql").master("local[*]")
.config("spark.sql.shuffle.partitions","4")
.config("spark.sql.warehouse.dir","hdfs://centos01:9000/user/hive/warehouse")
.config("hive.metastore.uris","thrift://centos01:9083")
.enableHiveSupport()
.getOrCreate()
val sc = spark.sparkContext
sc.setLogLevel("WARN")
import spark.implicits._
spark.sql("show databases").show
//TODO 关闭环境
spark.stop()
}
运行结果