Dear experts,
today i did experience a behaviour of hana that i cannot understand.
In order to enable you to reenact the phenomenon i created the following demo code:
######################### PREPERATION
-- creating a copy of a sap demo content table
create column table "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST"
like "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses" with data;
-- set two columns to null
Update "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST"
set CITY = NULL;
Update "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST"
set POSTALCODE = NULL;
######################### / PREPERATION
######################### INITIAL
-- returns an empty resultset (initial version)
select col from (
select 'CITY' as col, count(*) i from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" where CITY is not NULL union all
select 'POSTALCODE', count(*) from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" where POSTALCODE is not NULL
) where i = 0;
######################### / INITIAL
######################### ALTERED VERSIONS
-- returns the expected resultset (outer select contains i)
select col, i from (
select 'CITY' as col, count(*) i from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" where CITY is not NULL union all
select 'POSTALCODE', count(*) from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" where POSTALCODE is not NULL
) where i = 0;
-- returns the expected resultset (check for "is null")
select col from (
select 'CITY' as col, count(*) i from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" where CITY is NULL union all
select 'POSTALCODE', count(*) from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" where POSTALCODE is NULL
) where i = (select count(*) from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST");
-- returns the expected resultset (now without where)
select col from (
select 'CITY' as col, count(CITY) i from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST" union all
select 'POSTALCODE', count(POSTALCODE) from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses_TEST"
) where i = 0
######################### ALTERED VERSIONS
The question is why does the initial statement return an empty resultset?
And please consider that the initial version works just fine under rev68 (resultset is not empty), but returns an empty resultset when being executed on a rev70 system.
Many thanks in advance for your feedback.