[Spark][Hive][Python][SQL]Spark 读取Hive表的小例子$ cat customers.txt 1 Ali us 2 Bsb ca 3 Carls mx $ hive hive> > CREATE TABLE IF NOT EXISTS customers( > cust_id string, > name string, > country string > ) > ROW FORMAT DELIMITED FIELDS TERMI
spark 2.4.3 spark读取hive表,步骤: 1)hive-site.xml hive-site.xml放到$SPARK_HOME/conf下 2)enableHiveSupport SparkSession.builder.enableHiveSupport().getOrCreate() 3) 测试代码 val sparkConf = new SparkConf().setAppName(getName) val sc = new SparkContext(sparkConf)
背景:根据业务需要需要把60张主子表批量入库到hive表. 创建测试数据: def createBatchTestFile(): Unit = { to ) { val sWriter = new PrintWriter(new File("D:\\server_" + layer + ".txt")) val nWriter = new PrintWriter(new File("D:\\neighour_" + layer + ".