As I read here I have to create a table first and name all columns and after to write on it.
Create newTable:
val hive = com.hortonworks.spark.sql.hive.llap.HiveWarehouseBuilder.session(spark).build()
hive.createTable("newTable")
.ifNotExists()
.column("ws_sold_time_sk", "bigint")
.column("ws_ship_date_sk", "bigint")
.create()
Write to NewTable:
df.write.format(HIVE_WAREHOUSE_CONNECTOR)
.option("table", "newTable")
.save()
How to create a table with the same columns of the dataframe automatically. I have a dataframe with many columns and I can't write every column one by one. Is there anyway?
I tried:
//Read df from a path
var df = (spark
.read
.format("parquet")
.option("inferSchema", "true")
.option("header", "true")
.load(dataPath))
//Write df into a newTable but it doesn't create the table
df.write.format(HIVE_WAREHOUSE_CONNECTOR)
.option("table", "newTable")
.save()