MEASURE type and AGGREGATE aggregate function

2022-11-09 Thread Julian Hyde
Can I get a review for https://github.com/apache/calcite/pull/2965 /
https://issues.apache.org/jira/browse/CALCITE-5105?

It's the first change in what is - in my opinion - a major extension
to SQL, namely being able to define expressions in queries and views
and have those expressions 'expand' in the context where they are
used. It's something that BI tools and multidimensional databases do,
but it is not allowed by the conventional rules of SQL.

This change is fairly modest, adding a MEASURE type so that we can
represent measures internally. I believe that I have added sufficient
switches so that people who don't want these extensions in their SQL
dialect don't get them.

A later case, https://issues.apache.org/jira/browse/CALCITE-4496, will
allow you to define measures as part of a query and have them inlined
when you use them in an enclosing query. That case is quite a long way
from completion.

Julian


[jira] [Created] (CALCITE-5105) Add MEASURE type and AGGREGATE aggregate function

2022-04-20 Thread Julian Hyde (Jira)
Julian Hyde created CALCITE-5105:


 Summary: Add MEASURE type and AGGREGATE aggregate function
 Key: CALCITE-5105
 URL: https://issues.apache.org/jira/browse/CALCITE-5105
 Project: Calcite
  Issue Type: Bug
Reporter: Julian Hyde


In CALCITE-4496 we propose adding measures to SQL, and an "AS MEASURE" 
sub-clause to the SELECT clause so that you can define measures. This change is 
a first step in that direction: namely the ability to define the columns are 
measures and use validate queries that use measures.

This change adds a {{MEASURE}} type, which is parameterized with the value 
type, so that in RelNode-and-RexNode-land a measure column whose value is of 
type {{INTEGER}} would have type {{MEASURE}}. (In SqlNode-land its 
type would be {{INTEGER}} and we would tell that it was a measure by some other 
means.)

This change also adds an aggregate function called {{AGGREGATE}} that evaluates 
measures in the current {{GROUP BY}} context. (You can think of this as letting 
the measures roll themselves up as only they know how. For example, if the 
{{sum_price}} measure is defined as {{SUM(price)}} then if I write 
{{AGGREGATE(sum_price)}} in my query it's as if I wrote {{SUM(price)}}. But we 
also support measures that have more complex formulas.)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)