I want to create a projection to sort the data with DESC mode, due to the projection (v7.2) doesn't support the DESC sorting. so I created a calculate field which based on the Dim_Reg_Date field. The logic is below:
datediff(day,Dim_Reg_Date,'9999-12-30') as sfRegDate
and then I create a new projection to apply sorting by the new calculated field:
create projection dMart.p_t_trade_info_us_regDate
(
Dim_Reg_Date ENCODING RLE
,sfRegDate ENCODING RLE
,DIM_CountryCode ENCODING RLE
)
AS
select
T_Trade_Info_US.dim_reg_date
,T_Trade_Info_US.sfRegDate
,T_Trade_Info_US.dim_countrycode
from dMart.T_Trade_Info_US
order by sfRegDate
UNSEGMENTED ALL NODES;
select refresh('dmart.t_trade_info_us');
after I done the preparation, I want to query the data with the following script:
select distinct Dim_Reg_Date,sfRegDate,DIM_CountryCode
from dMart.p_t_trade_info_us_regDate
limit 4;
the result still doesn't sorted. and the result data is randomly changed while I run the select query many times.
first time:
2016-02-29 2916035 US
2017-06-23 2915555 US
2017-06-04 2915574 US
2017-07-12 2915536 US
second time:
2016-03-14 2916021 US
2017-07-07 2915541 US
2017-06-18 2915560 US
2017-07-26 2915522 US
so I have to use the sort as below:
select distinct Dim_Reg_Date,sfRegDate,DIM_CountryCode
from dMart.p_t_trade_info_us_regDate
order by sfRegDate
limit 4;
the following result is correct.
2017-11-06 2915419 US
2017-11-05 2915420 US
2017-11-04 2915421 US
2017-11-03 2915422 US
(I need to waiting for 20+ sec while I appended order by clause, if not, just 1 second completed, so I won't to use the order by clause in my data query script.)
any one can help me on the issue?
thanks!
