V
V
Vitaly2018-07-05 12:58:11
big data
Vitaly, 2018-07-05 12:58:11

Is it possible to automate the creation of tables in HIVE?

Good afternoon, when creating tables in HIVE, we must immediately define all the fields of the table https://cwiki.apache.org/confluence/display/Hive/L...
But provided that we have a csv file with 600+ columns, it is possible it is possible to create a table based on this file with the required number of columns? NOT by hand.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yo!, 2018-07-16
@allposts_vitali

maybe spark. create a dataframe on the file, make createOrReplaceTempView and
spark.sql("create table my_table as select * from my_temp_table");

Y
Yuri, 2018-09-06
@kunter

You can do this (via spark)
1) Spread the csv line
2) Determine the number of columns in it.
3) Generate sql query in spark so that the final result would be
Create table YourTabel (col1 string,col2 string, ......) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\;' STORED AS TEXTFILE;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question