Jit B
Jit B

Reputation: 1246

Getting the schema of the query output in Hive

I am using Apache Hive to create and execute some queries, but before the query is executed I need to report the structure of the resultset. The queries may involve joins and projections so it will be quite difficult to parse the query. The current solution that we are working on involves parsing the output of explain command but its quite complex itself.

My question is whether there is some simpler way by setting some properties in hive or some query parameters that don't select any data (the map/reduce tasks are not started) but creates a table that I can query via metastore to get the schema?

Upvotes: 4

Views: 3991

Answers (2)

Marcus
Marcus

Reputation: 2238

While not something you can do before the query is returned, if you enable

set hive.cli.print.header=true;

then it will show the schema right before the results.

Upvotes: 1

gbharat
gbharat

Reputation: 276

Unfortunately there is no simpler way other than using EXPLAIN or DESCRIBE commands to get query schema and table schema.

Upvotes: 1

Related Questions