Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-02-03 Thread Julian Hyde
These kinds of roll ups are very common. They have simple mathematical properties. There is a simplifying abstraction to be found here. Please find it and use it. Julian > On Feb 2, 2022, at 7:47 PM, Thomas D'Silva wrote: > > Hi Stamatis, > > Thanks for your response. Your suggestion of

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-02-02 Thread Thomas D'Silva
Hi Stamatis, Thanks for your response. Your suggestion of having use case specific rules that translate time ranges that align on the rollup of the materialized view makes sense. However if the time range doesn't align for eg. if we have a view that rolls up to the minute and the query predicate

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-02-02 Thread Stamatis Zampetakis
Hi Thomas, I haven't looked into the implementation details of the rule but I assume the rewriting does not kick in because there is no easy way to relate the "ts" column that is used in the query with the "floor(ts to minute)" column that is materialized. I assume that if your query is/was

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-01-28 Thread Thomas D'Silva
Xurenhe, Thank you for the detailed response and pointers. The use case you describe for OLAP streaming queries is similar to what our team is trying to accomplish. We use calcite to query data stored in kudu [1]. We use kafka streams to maintain materialized views that contain pre-aggregated

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-01-28 Thread 徐仁和
It’s useful in OLAP. Time ’s prediction bottom `Aggregate` could be pulled-up, because of Time’s granularity in Aggregate’s group. By the way, the query can be rewritten by mv, when the query's granularity is coarser than mv’s. eg: -- mv: SELECT eventid, floor(ts TO minute), count(*) as cnt

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-01-27 Thread Thomas D'Silva
Stamatis, For the materialized view and query that I had mentioned in the earlier email, I got the following final plan that used the table : EnumerableCalc(expr#0..2=[{inputs}], EXPR$0=[$t1], EXPR$1=[$t2]) EnumerableAggregate(group=[{0, 1}], EXPR$1=[COUNT()])

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-01-27 Thread Stamatis Zampetakis
Hey Thomas, Can you post the plan/query that you were expecting after the rewriting? Is the behavior you observed specific to timestamps? Best, Stamatis On Thu, Jan 27, 2022 at 4:07 AM Thomas D'Silva wrote: > Justin, > > Thanks for your response. If I change the query predicate to "floor(ts

Re: MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-01-26 Thread Thomas D'Silva
Justin, Thanks for your response. If I change the query predicate to "floor(ts to minute) >= timestamp'2018-01-01 00:01:00' AND floor(ts to minute) < timestamp'2018-01-01 00:05:00'" it does end up querying the view. However I want to be able to query an arbitrary time range and have the union

MaterializedViewRule is not applied for queries on aggregate views that truncate timestamp

2022-01-26 Thread Thomas D'Silva
Hi, The existing MaterializedViewRule is not applied when the materialized view does not have a view predicate but the query contains a predicate. For eg for the following materialized view SELECT eventid, floor(ts to minute), count(*) as cnt FROM events GROUP BY eventid, floor(ts TO