Skip to content

[Bug] COALESCE returns NaN during INSERT SELECT when right argument contains NaN #57883

@laixiong

Description

@laixiong

Search before asking

  • I had searched in the issues and found no similar issues.

Version

2.1.8

What's Wrong?

When using COALESCE(a, b), a simple SELECT query returns the correct value of a.
However, during INSERT INTO ... SELECT COALESCE(a, b), the result column may unexpectedly contain NaN values, especially when the dataset is large.
This issue is not always reproducible — it appears probabilistically depending on batch size and data distribution.

当使用 COALESCE(a, b) 表达式时,直接执行 SELECT 查询结果是正确的(返回 a 的值)。
但在执行 INSERT INTO ... SELECT COALESCE(a, b) 时,结果列中会出现 随机的 NaN 值,尤其是在数据量较大时。
该问题 并非必现,而是在一定规模的数据或特定执行路径下才出现。

This behavior occurs intermittently, especially with larger data sets or complex query plans.
在数据量较小或简单查询下通常正常,而在数据量大或复杂查询计划下更容易复现。

What You Expected?

When b contains NaN, the inserted results sometimes become NaN instead of a.
当 b 中包含 NaN 时,插入表的结果列有时变成 NaN,而不是 a 的值。

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions