Search code examples
impala

How to check if a column exists in Impala table?


I have created an external table in Impala. I am writing a shell script which checks whether a particular column exists in that table.

We can do this in MySql using the following query.

SELECT * 
FROM information_schema.COLUMNS 
WHERE 
    TABLE_SCHEMA = 'db_name' 
    AND TABLE_NAME = 'table_name' 
    AND COLUMN_NAME = 'column_name'

But, in Impala, how can we achieve this?


Solution

  • Unfortunately you cannot query the schema metadata in Impala. You can use describe table (see the documentation) and check the output.