You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backward compatibility problem --> DB::Exception: Parameters to aggregate functions must be literals. Got parameter 'assumeNotNull(identity(_CAST(0.9, 'Nullable(Float64)')) AS _subquery14) AS TUNING'.
#59154
Closed
gervarela opened this issue
Jan 24, 2024
· 4 comments
· Fixed by #62185
As we were evaluating an upgrade from 22.11 to a 23.X stable version we have encountered a posible, and unexpected, 'backwards incompatible' change.
We have a quite complex query that uses CTEs. It works well in our production database with version 22.11, but gives an exception in 23.8.x and 23.12.x.
The problem seems to be related the evaluation of constant expressions as literals when using CTEs/Subqueries as parameters to aggregate functions.
This is a much simplified version of the query, but it exhibits the same behaviour and problems.
SELECT *
FROM
(
WITH
assumeNotNull((
SELECT 0.9
)) AS TUNING,
ELEMENT_QUERY AS
(
SELECT quantiles(TUNING)(1)
)
SELECT *
FROM ELEMENT_QUERY
)
Gives the exception:
Received exception from server (version 23.12.2):
Code: 134. DB::Exception: Received from localhost:9000. DB::Exception: Parameters to aggregate functions must be literals. Got parameter 'assumeNotNull(identity(_CAST(0.9, 'Nullable(Float64)')) AS _subquery14) AS TUNING'. (PARAMETERS_TO
_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS)
We have also tested (previously) on 23.8.X with same results.
Nonetheless, in 22.11 it works perfectly:
SELECT *
FROM
(
WITH
assumeNotNull((
SELECT 0.9
)) AS TUNING,
ELEMENT_QUERY AS
(
SELECT quantiles(TUNING)(1)
)
SELECT *
FROM ELEMENT_QUERY
)
Query id: 5d142c59-59fb-4b8c-9581-e491fa9f355f
┌─quantiles(TUNING)(1)─┐
│ [1] │
└──────────────────────┘
1 row in set. Elapsed: 0.005 sec.
The problem seems to be particularly related to the usage of CTEs, because a very similar construction like the one below, works well in all versions:
The current behaviour is bad but it's unlikely that it will get fixed in the current interpreter. The new analyzer (allow_experimental_analyzer) that will replace it in the short term already fixes the problem.
The problem with the old interpreter did most of the changes on top of the AST which led to lots complications like this one, where a fix somewhere breaks other parts of the query. That being said, if somebody sends a simple fix for it can be accepted; it's just that the effort is being put in the new infrastructure.
As we were evaluating an upgrade from 22.11 to a 23.X stable version we have encountered a posible, and unexpected, 'backwards incompatible' change.
We have a quite complex query that uses CTEs. It works well in our production database with version 22.11, but gives an exception in 23.8.x and 23.12.x.
The problem seems to be related the evaluation of constant expressions as literals when using CTEs/Subqueries as parameters to aggregate functions.
This is a much simplified version of the query, but it exhibits the same behaviour and problems.
Gives the exception:
We have also tested (previously) on 23.8.X with same results.
Nonetheless, in 22.11 it works perfectly:
The problem seems to be particularly related to the usage of CTEs, because a very similar construction like the one below, works well in all versions:
The text was updated successfully, but these errors were encountered: