I want join t.archer_fact_metrics_results table with b.lkp_nonpercentagekri table and derive a column derived_january when t,January value is between those threshold values assign b.colour_indicator's corresponding value of b.proxy_percentage_value to
derived_january else keep t.january value as is to derived_january column
select
(case
when (Format = 'Monetary Amount' or Format = 'Number')
then case when (t.January >= green_threshold_min and t.January <=green_threshold_max) then b.proxy_percentage_value and b.colour_indicator='Green'
when (t.January >= amber_threshold_min and t.January <= amber_threshold_max) then b.proxy_percentage_value and b.colour_indicator = 'Amber'
when (t.January >= red_threshold_min and t.January <= red_threshold_max)then b.proxy_percentage_value and b.colour_indicator = 'Red'
else t.January end
end) as derived_january
from kri.archer_fact_metrics_results t
join kri.lkp_nonpercentagekri b on t.p2g_status = b.colour_indicator
Getting error:
SQL Error [40000] [42000]: Error while compiling statement: FAILED: ClassCastException org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableDoubleObjectInspector cannot be cast to org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector
Input values
b.proxy_percentage_value b.colour_indicator t.January t.green_threshold_min t.green_threshold_max
55.0 Green 34 25 60
34.0 Amber 25 20 50
45.0 Red 25 35 45
similar data for amber_threshold_min and amber_threshold_max and red_threshold_min and red_threshold_max
Expected:
derived_january
55.0
34.0
25