I am trying to run a simple hive query,
select NULL as planned_date from abc_table union all select event_date as planned_date from xyz_table
where event_date's event type in xyz_table is timestamp. When I try to run this in Hive 1.2.1000.2.4.3.0-227, it successfully runs but when i try to run this in Hive 1.2.1000.2.5.3.0-37 it fails saying SemanticException 145:5 Schema of both sides of union should match: Column planned_date is of type void on first table and type timestamp on second table.
Any suggestion how to solve this?
This is a known issue issue (regression bug of Hive UNION logic in HDP 2.5.x)
The behaviour was introduced/changed by https://issues.apache.org/jira/browse/HIVE-14251, which was part of the HDP 2.5.x release
Workaround is to use 'cast' while running the query, for example:
select * from (select
case when browser_type is not null
end as action_code
cast(null as string) as action_code
from mcom.esp_responsys_complaint_stg_tmp) a limit 10;