Skip to content

Incorrect value for constant-foldable CASE for types where value equality is not binary-equality #31081

Description

@findepi

https://trysql.io/wlhkZ_velGY2

SELECT
  TIMESTAMP '1970-01-01 00:00:00 UTC' = TIMESTAMP '1970-01-01 01:00:00 Europe/Warsaw' AS they_equal,
  CASE TIMESTAMP '1970-01-01 00:00:00 UTC' 
    WHEN IF(rand() < 42, current_date, null) THEN 'impossible'
    WHEN TIMESTAMP '1970-01-01 01:00:00 Europe/Warsaw' THEN 'match' 
    ELSE 'no match'
  END
FROM tpch.tiny.region;
they_equalboolean _col1varchar(10)
true no match

this is also reproducible for other types where value equality is not binary-equality

  • Double 0 and -0 values
  • composite values backed by Block (ROW, MAP, ARRAY), where Objects.equals is reference equality

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions