[CALCITE-6555] RelBuilder.aggregateRex wrongly thinks aggregate functions of "GROUP BY ()" queries are NOT NULL In RelBuilder, the aggregateRex method (added in CALCITE-5802) wrongly thinks that aggregate functions in a `GROUP BY ()` query are NOT NULL. Consider the query SELECT SUM(empno) AS s, COUNT(empno) AS c FROM emp GROUP BY () `SUM(empno)` should be nullable, even though `empno` has type `SMALLINT NOT NULL`, because `GROUP BY ()` will return one row even if `emp` has no rows, and therefore `SUM` will be evaluated over the empty set. A RelBuilder test that attempts to build an equivalent query gets the following error stack: java.lang.AssertionError: type mismatch: ref: SMALLINT NOT NULL input: SMALLINT We add a test case for measure queries, because measures are the only code path that uses `aggregateRex` at present.
Apache Calcite is a dynamic data management framework.
It contains many of the pieces that comprise a typical database management system but omits the storage primitives. It provides an industry standard SQL parser and validator, a customisable optimizer with pluggable rules and cost functions, logical and physical algebraic operators, various transformation algorithms from SQL to algebra (and the opposite), and many adapters for executing SQL queries over Cassandra, Druid, Elasticsearch, MongoDB, Kafka, and others, with minimal configuration.
For more details, see the home page.
The project uses JIRA for issue tracking. For further information, please see the JIRA accounts guide.