Skip to content

runningDifference WRONG RESULT with enable_optimize_predicate_expression #3885

@den-crane

Description

@den-crane

Connected to ClickHouse server version 18.16.0 revision 54412.

set enable_optimize_predicate_expression = 1

select n, z, changed from (
   select n, z, runningDifferenceStartingWithFirstValue(n) as changed from (
       select ts, n,z from system.one array join [1,3,4,5,6] as ts, 
          [1,2,2,2,1] as n, ['a', 'a', 'b', 'a', 'b'] as z 
    order by n, ts DESC)
) where changed = 0

┌─n─┬─z─┬─changed─┐
│ 2 │ b │       0 │
└───┴───┴─────────┘

set enable_optimize_predicate_expression = 0
The same query

┌─n─┬─z─┬─changed─┐
│ 1 │ a │       0 │
│ 2 │ b │       0 │
│ 2 │ a │       0 │
└───┴───┴─────────┘

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-query-optimizerQuery plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions