Skip to content

Add testcases for default columns - #100048

Merged
rienath merged 7 commits into
masterfrom
vdimir/followup_94615
Aug 25, 2026
Merged

rienath merged 7 commits into
masterfrom
vdimir/followup_94615

Conversation

@vdimir

@vdimir vdimir commented Mar 19, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Followup for #94615


Workflow [PR]
Sync PR [sync-upstream/pr/100048]

@clickhouse-gh

clickhouse-gh Bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2befe2e]

Summary: ✅


AI Review

Summary

This PR adds stateless coverage around default-expression dependency ordering, tuple subcolumn references, cyclic defaults, and long dependency chains as a follow-up to #94615. The broad shape is fine, but one test still records a known-bad subcolumn result as the passing contract, so I would keep this in changes-requested state until that case stops locking the bug into the suite.

Missing context / blind spots
  • ⚠️ As of 2026-08-25, Fast test, Style check, and Build profile diff had completed, while the remaining build jobs were still pending. That does not affect the finding below, but it leaves the non-fast build surface unverified in this review pass.
Findings

⚠️ Majors

  • [tests/queries/0_stateless/04040_defaults_dependency_order.sql:70] [dismissed by author -- https://github.com/Add testcases for default columns #100048#discussion_r3420608952] test_tuple_elem2 still codifies the buggy a.x / a.y behavior as expected output: after inserting a = (5, 6), the reference keeps b = (10, 20) instead of the semantically correct b = (50, 60). The implementation mismatch is still real in current code: AddingDefaultsTransform builds its dependency order from raw RequiredSourceColumnsVisitor names (src/Processors/Transforms/AddingDefaultsTransform.cpp:195-209), so a.x never matches the top-level a column being defaulted, while sibling defaults machinery explicitly normalizes subcolumns back to the parent column before dependency analysis (src/Interpreters/MaterializedColumnDependencies.cpp:67-73). That makes the passing stateless suite protect the bug instead of the default-expression contract fixed by #94615. Either normalize subcolumn references in AddingDefaultsTransform and update the reference to (50,60), or move this case out of the passing contract until that behavior is intentionally fixed.
Final Verdict

⚠️ Changes requested.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 19, 2026
@vdimir
vdimir force-pushed the vdimir/followup_94615 branch 3 times, most recently from 5102aa7 to 681237e Compare March 23, 2026 10:26

@rienath rienath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add no-tsan/no-asan/no-msan to 04041 and no-old-analyzer to 04040

SELECT * FROM test_tuple_elem ORDER BY a;
DROP TABLE test_tuple_elem;

SELECT 'test_tuple_elem2: Bug, expected to have same result as test_tuple_elem, but missed dependency of b on a subcolumn:';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This test records the wrong result as expected. The previous test_tuple_elem case proves that an inserted a = (5, 6) should make b = (50, 60), but this case labels the a.x path as a bug and the reference asserts b = (10, 20) for the same inserted a.

That means CI will keep accepting the missing subcolumn dependency in AddingDefaultsTransform instead of protecting the default-expression contract fixed by #94615. Please either fix dependency extraction for subcolumns and expect (5,6) (50,60), or move this to a disabled/issue-linked known-bug test so the passing stateless suite does not encode the wrong semantics.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug is acknowledged in the test and when it's fixed test can be changed

@vdimir
vdimir added this pull request to the merge queue Jun 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 17, 2026

@rienath rienath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #88043,

CREATE TABLE t (
    a Tuple(x Int32, y Int32) DEFAULT (b.x, b.x),
    b Tuple(x Int32, y Int32) DEFAULT (c.x, 2),
    c Tuple(x Int32, y Int32) DEFAULT (a.x, 2)
) ENGINE = Memory;

no longer throws (fiddle) even though there's a cycle

{%- for i in range(1, 1000) %},
c{{ i }} UInt64 DEFAULT c{{ i - 1 }} + 1
{%- endfor %}
) ENGINE = Memory; -- { serverError TOO_DEEP_RECURSION }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it depends on build whether it fails or not, perhaps we should introduce some guard rather then relying on stack exhaustion

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed

#if !defined(THREAD_SANITIZER)
    /// It's overkill to use more then half of stack.
    static constexpr double STACK_SIZE_FREE_RATIO = 0.5;
#else
    /// Under TSan recursion eats too much RAM, so half of stack is too much.
    /// So under TSan only 5% of a stack is allowed (this is ~400K)
    static constexpr double STACK_SIZE_FREE_RATIO = 0.05;
#endif

We could alternatively add #no-flaky-check s.t. we don't run the test under thread sanitiser. Might be slightly easier

@vdimir
vdimir force-pushed the vdimir/followup_94615 branch from 455d242 to 0627b4e Compare June 25, 2026 15:12
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 456 line(s), 22 function(s) across 138 file(s) · Details

Top files
  • src/IO/S3/copyS3File.cpp: 78 line(s), 4 function(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 21 line(s)
  • src/Backups/registerBackupEngineS3.cpp: 14 line(s), 1 function(s)
  • src/IO/S3/deleteFileFromS3.cpp: 13 line(s)
  • src/Interpreters/HashJoin/HashJoin.cpp: 10 line(s)

Full report

@@ -0,0 +1,30 @@
-- Tags: long

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is too heavy for our instrumented and debug builds in CI. We either need to add no-asan, no-tsan, no-msan, no-ubsan, no-debug or reduce the chain size

@clickhouse-gh

clickhouse-gh Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing dd6c29b9e with master a3e34c2ea (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 694.45 MiB 691.45 MiB -3.00 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

7 translation units recompiled, 27 s compile time in total, 7 of them have a recent master baseline.

Job report

@rienath
rienath added this pull request to the merge queue Aug 25, 2026
Merged via the queue into master with commit 01156aa Aug 25, 2026
178 checks passed
@rienath
rienath deleted the vdimir/followup_94615 branch August 25, 2026 17:08
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants