pivot by 应该不会出现题主所出现的问题。
代码复现如下,不会出现数据为空的情况。
数据:
n=1000000: ID=rand(150, n) dates=2017.08.07..2017.08.11 date=rand(dates, n) x=rand(`a`b`c`d`e, n) t=table(ID, date, x) dbDate = database(, VALUE, 2017.08.07..2017.08.11) dbID = database(, RANGE, 0 50 100 150) db = database("dfs://compoDB", COMPO, [dbDate, dbID]) pt = db.createPartitionedTable(t, `pt, `date`ID) pt.append!(t);
pivot by 语句:
select x from loadTable("dfs://compoDB", "pt") where (ID = 48) and (date between date(2017.08.07):date(2017.08.11) ) pivot by date,ID,x