How to use a SQL template for creating a hive table?

If there is a SQL template, how do i use this template for creating a Hive table?

Any suggestions would be highly appreciated.

1 Like

What do you mean by SQL Template? Is it a tool or are you looking to convert existing create statement for hive?

Let’s say if there is a SQL file/template with a name of text.sql. and i am asked to create a hive table base on this text.sql file and save it to HDFS. What would be the possible ways i can do?

Thank you!

i Understand where you are going :wink: .
but yes it is a valid question .

i dint use the template rather i copied the template and used it in hive shell. but yes i would like to know this answer too.
@JinSui @itversity

lol not bad…
Do you mean you copied the content from the sql file and paste the information in Hive scrip:“create external table xxx”? please advise if you can make this works…

Thanks

yes ,
i was also not aware what to do here , so instead of using the sql file , i executed the entire external table query in the Hive shell.

You can create file with all hive scripts and run it using hive -f command - eg: hive -f script.hql

It should contain all valid hive statements or queries.

1 Like

Thanks Mate,

by copying the content from SQL file and paste to Hive shell, will it run directly without any other editing?

yes , the template is just the same hive queries that we run in our hive CLI.
for example the create external table query will be written in the .sql file .
so you either run that or just copy the queries and run it in HIVE CLI.

OK, thank you. that is helpful!

you can use velocity template.It will be much much easier and you can control all the scenarios and use cases for the same,We are using the same thing for creating hive tables based on template.
Single template will be used for multiple things.
just understand a bit more on velocity engine