Hi!
I have simple problem but I have no idea what's happening. I'm trying to load table s_kontrachenci from table przelewy_zrodlo using hive. I'm useing such query:
insert owerwrite table s_kontrachenci
select distinct kontrachenci.klucz, kontrachenci.nazwa, kontrachenci.typ from (
select
concat('key_', nazwa_zleceniodawcy) AS klucz,
nazwa_zleceniodawcy AS nazwa,
case when substr(nr_rach_zleceniodawcy, 1, 1) < 5 then 'WEW' else 'ZEW' AS typ
from przelewy_zrodlo
UNION ALL
select
concat('key_', nazwa_zleceniodawcy) AS klucz,
nazwa_zleceniodawcy AS nazwa,
case when substr(nr_rach_zleceniodawcy, 1, 1) < 5 then 'WEW' else 'ZEW' AS typ
from przelewy_zrodlo
) kontrachenci;
After I load data to table s_kontrachenci I execute query:
select count(*) from s_kontrachenci;
and I get result 1987 rows.
But when I execute such query:
select count(*) from (
select distinct kontrachenci.klucz, kontrachenci.nazwa, kontrachenci.typ from (
select
concat('key_', nazwa_zleceniodawcy) AS klucz,
nazwa_zleceniodawcy AS nazwa,
case when substr(nr_rach_zleceniodawcy, 1, 1) < 5 then 'WEW' else 'ZEW' AS typ
from przelewy_zrodlo
UNION ALL
select
concat('key_', nazwa_zleceniodawcy) AS klucz,
nazwa_zleceniodawcy AS nazwa,
case when substr(nr_rach_zleceniodawcy, 1, 1) < 5 then 'WEW' else 'ZEW' AS typ
from przelewy_zrodlo
) kontrachenci
) kontr;
I get 1991 rows. And now I'm very confused because in my opinion both queries should return same number of rows. Any ideas why number of rows are diffrent for those queries?
I should add information that i use such structure:
select distinct ... from (
select ... from ...
UNION ALL
select ... from) ...;
Because there is no UNION in hive and in my opinion this should work as UNION.
Any help would be appreciate!
Thanks in advance!
