Bug in MAX Function with MergeTree Engine

Open
#403 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
sql
Domain
databases

Research direction

Begin by running the supplied CREATE TABLE, INSERT, and SELECT sequence on the stated environment and compare repeated results with the expected value. Trace the MergeTree partition path and MAX/MIN handling for NaN-related values; done means repeated queries consistently return 766544500 and a regression test covers the reproduction.

Written by the indexing model from the issue text.

Description

bug environment needs-info

Dear CK Team, I have a bug that I need to report to you.

Description:
While using the MAX/MIN function on a column with MergeTree table engine, the query produces inconsistent results. Specifically, this bug is triggered when a specific partition key is selected and the corresponding column contains NaN values

Steps to Reproduce:

CREATE TABLE t1 (c0 Int32) 
ENGINE = MergeTree() 
ORDER BY c0
PARTITION BY (toUInt64 (c0))

INSERT INTO t1 (c0) 
VALUES (-766544500), (2052205600), (2064494500), (824848640), (0)

SELECT MAX(-(c0/c0/c0+c0)) 
FROM t1

Expected Behavior:
The result should be consistent and return the unique positive value 766544500.

Actual Behavior:
Different values are returned across multiple queries, including all values in c0 execpt NaN ( -766544500, 2052205600, 2064494500, 824848640, 0).

Environment
OS:Ubuntu Server 22.04 LTS 64bit
TDengine Version:24.5.1.1010 (official build)

Dominant language
C
Stars
388
Forks
220
Avg merge
1d 25m
Merged PRs (30d)
16

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ClickHouse/clickhouse-cpp

All issues in ClickHouse/clickhouse-cpp

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.