Reply
New Contributor
Posts: 3
Registered: ‎02-05-2018

Check, if columns have the same data type

Hi All,

 

I am trying to automatise the testing of the data in Impala. Is there a way to check, if two columns from the different tables have the same data type? Currently we are doing this check manually, by

 

describe formatted a;

describe formatted b;

 

 

but I would like to see result in the way:

 

select 
case 
when a.type = b.type
then "TRUE"
else "FALSE"
end
from 
(describe formatted x.column1 as type) a,
(describe formatted y.column1 as type) b;

 

Can you please advise, if there is a way to implement second example? 

 

Thanks,

Anastasia

Highlighted
Posts: 504
Topics: 14
Kudos: 84
Solutions: 45
Registered: ‎09-02-2016

Re: Check, if columns have the same data type

@laanajar

 

Just a thought...

 

For your use case, instead of try that in impala, you login to your metadata database (ex: mysql, postgresql, etc) where all your table name, column name, datatypes are stored 

 

Ex:

>mysql –u root –p

>use hive;

>show tables; 

 

Get the Metadata for your table and compare the datatype easily

 

Cloudera Employee
Posts: 347
Registered: ‎07-29-2015

Re: Check, if columns have the same data type

There's no easy way to do this right now unfortunately. I agree it would be great if we exposed table metadata as system tables so you could use SQL to query metadata.

 

Announcements