Reputation: 2807
I want to write a query such that it returns the table name (of the table I am querying) and some other values. Something like:
select table_name, col1, col2 from table_name;
I need to do this in Hive. Any idea how I can get the table name of the table I am querying?
Basically, I am creating a lookup table that stores the table name and some other information on a daily basis in Hive. Since Hive does not (at least the version we are using) support full-fledged INSERTs
, I am trying to use the workaround where we can INSERT
into a table with a SELECT
query that queries another table. Part of this involves actually storing the table name as well. How can this be achieved?
Upvotes: 1
Views: 3201
Reputation: 2807
For the purposes of my use case, this will suffice:
select 'table_name', col1, col2 from table_name;
It returns the table name with the other columns that I will require.
Upvotes: 2