我想将 ORC 数据从 Spark 数据帧写入外部 Hive 表。当我将数据框另存为表时,数据会发送到现有的外部表,但是,当我尝试将 ORC 格式的数据保存到目录中,然后从外部表中读取此数据时,它不会显示。
第二种情况下数据缺失的原因可能是什么?
这个怎么运作:
val dataDir = "/tmp/avro_data"
sql("CREATE EXTERNAL TABLE avro_random(name string, age int, phone string, city string, country string) STORED AS ORC LOCATION '$dataDir'")
dataframe
.write
.mode(SaveMode.Overwrite)
.saveAsTable("avro_random")
sql("SELECT * FROM avro_random").show()
返回空外部表的代码:
val dataDir = "/tmp/avro_data"
sql("CREATE EXTERNAL TABLE avro_random(name string, age int, phone string, city string, country string) STORED AS ORC LOCATION '$dataDir'")
dataframe
.write
.mode(SaveMode.Overwrite)
.orc(dataDir)
sql("SELECT * FROM avro_random").show()