0

I created an cube in Apache kylin where 'ft' is my facttable and 'ls' is one of the dimensiontables. Both are joint on the column 'lid'. My query

select ft.sid, ls.lid, ls.pos
from(
    select sid, lid
    from ft
    where lid = '1500221'
    group by lid, sid
) as ft inner join (
    select lid, pos
    from ls
    where pos = '14'
) as ls on (ft.lid = ls.lid)

returns one row like

1500 1500221 14

So far, so good. Leaving out the first where-condition, my result is also one row, but this time another...

select ft.sid, ls.lid, ls.pos
from(
    select sid, lid
    from ft
    group by lid, sid
) as ft inner join (
    select lid, pos
    from ls
    where pos = '14'
) as ls on (ft.lid = ls.lid)

returns

0140 0140110 14

Both are correct results, but the second query should return more than just one row and at least the result of the first query also.

Does anyone knows what is going wrong here?

Thanks in advance, Søren

Søren
  • 31
  • 3

1 Answers1

0

You might have hit a defeat of Kylin dealing with sub-queries.

However, why use sub-query where it is not required? The below simple query should give what you need.

select sid, lid, pos
from ft
inner join ls on ft.lid = ls.lid
where pos = '14'
group by lid, sid, pos
Li Yang
  • 284
  • 1
  • 6
  • Tried to cut down the join by pre grouping ft first and was wondering about the behavior. Your query works fine. Thanks – Søren Aug 23 '16 at 07:59