Skip to content

All tables support the _table virtual column - #63665

Merged
alexey-milovidov merged 20 commits into
ClickHouse:masterfrom
wudidapaopao:all_tables_support_table_virtual_column
Jul 29, 2025
Merged

alexey-milovidov merged 20 commits into
ClickHouse:masterfrom
wudidapaopao:all_tables_support_table_virtual_column

Conversation

@wudidapaopao

@wudidapaopao wudidapaopao commented May 11, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #60300

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Not only for Merge tables, but all tables support the _table virtual column

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

Modify your CI run

NOTE: If your merge the PR with modified CI you MUST KNOW what you are doing
NOTE: Checked options will be applied if set before CI RunConfig/PrepareRunConfig step

Include tests (required builds will be added automatically):

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with Analyzer
  • All with Azure
  • Add your option here

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All with Aarch64
  • Add your option here

Extra options:

  • do not test (only style check)
  • disable merge-commit (no merge from master before tests)
  • disable CI cache (job reuse)

Only specified batches in multi-batch jobs:

  • 1
  • 2
  • 3
  • 4
Details

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch from 8ee3e19 to ea30421 Compare May 11, 2024 20:39
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 11, 2024
@robot-ch-test-poll robot-ch-test-poll added the pr-feature Pull request with new product feature label May 11, 2024
@robot-ch-test-poll

robot-ch-test-poll commented May 11, 2024 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit d0a272e with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS⏳ pending
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests❌ failure
Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
BuzzHouse (asan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (debug)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (msan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (tsan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (ubsan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns ClickBench with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch 3 times, most recently from a4b8d09 to c9cbc27 Compare May 15, 2024 10:21
@wudidapaopao

Copy link
Copy Markdown
Contributor Author

Hi @alexey-milovidov
I've submitted a PR(63665) that has passed most tests. However, it seems that there are some failing tests, but they might not be related to this submission. Could you please take a look and provide your review?
Thanks!

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch from c9cbc27 to 85fc5ac Compare May 17, 2024 05:50
@clickhouse-ci

clickhouse-ci Bot commented May 17, 2024

Copy link
Copy Markdown

This is an automatic comment. The PR descriptions does not match the template.

Please, edit it accordingly.

The error is: More than one changelog category specified: 'New Feature', 'Fixes #60300'

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch from 85fc5ac to a6f74aa Compare May 21, 2024 19:08
@wudidapaopao wudidapaopao reopened this May 24, 2024
@divanik divanik self-assigned this Jun 5, 2024
@divanik

divanik commented Jun 5, 2024

Copy link
Copy Markdown
Contributor

Hi, @wudidapaopao. I would be glad to review your feature. Could you, please, merge master?

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch from a6f74aa to ae287c2 Compare June 5, 2024 19:00
@wudidapaopao

Copy link
Copy Markdown
Contributor Author

Hi, @wudidapaopao. I would be glad to review your feature. Could you, please, merge master?

Hi, @divanik. I have refreshed the code and I would like to express my sincere gratitude for your thorough review.

Comment on lines 25 to 28

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.

Could you, please, explain why this behavior is a desired one and we do not want to see m1 here?

@wudidapaopao wudidapaopao Jun 9, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently, the _table virtual column is only supported for tables with the Merge engine.
The behavior is such that when querying a table using the Merge engine, the _table virtual column returns the actual names of the underlying tables that the Merge table aggregates data from, rather than returning the name of the Merge table itself. And this PR extends this virtual column to all tables.
https://clickhouse.com/docs/en/engines/table-engines/special/merge#virtual-columns

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 make it always to be the inner-most table.

It will break the current behavior when a Merge table is created on top of more Merge tables, but it will be ok.

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.

I'd like if the breaking change is a separate PR.

Comment thread src/Planner/PlannerJoinTree.cpp Outdated

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.

Name should reflect connection with _table column

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've relocated this logic to the common AddingTableNameVirtualColumnStep.cpp file and add "TableName" to the function's name to elucidate its functionality.

Comment thread src/Planner/PlannerJoinTree.cpp Outdated

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.

Here as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rename "extractRequiredColumnsFromStorage" to "extractRequiredNonTableColumnsFromStorage"

Comment thread src/Planner/PlannerJoinTree.cpp Outdated

@divanik divanik Jun 7, 2024 •

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.

return true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For distributed tables, it's special as the table name needed for projection has been transformed into a constant column. Therefore, there's no requirement to add an AddingTableNameVirtualColumnStep subsequently, which is why the return value here is false.

@divanik divanik left a comment •

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.

I asked several questions, answer them, please. Also this PR lacks documentation about new virtual column

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch from 41ffaff to 497aa2f Compare June 9, 2024 17:01
@wudidapaopao

wudidapaopao commented Jun 9, 2024 •

Copy link
Copy Markdown
Contributor Author

I asked several questions, answer them, please. Also this PR lacks documentation about new virtual column

Hi, @divanik. I greatly appreciate the review feedback provided. I have incorporated documentation within the "Documentation entry for user-facing changes" subsection. Is there a necessity to add documentation in any other sections?

@wudidapaopao
wudidapaopao force-pushed the all_tables_support_table_virtual_column branch 3 times, most recently from ee19f35 to bdabc6d Compare June 12, 2024 15:01
@divanik

divanik commented Jun 17, 2024 •

Copy link
Copy Markdown
Contributor

I think, that you can put the content from Documentation entry for user-facing changes as you can write. Could you please remove it from this PR (I think that CI thinks that documentation is not written because there is no change in docs/ folder)?

@wudidapaopao

Copy link
Copy Markdown
Contributor Author

Hi, @divanik. I moved the content of the document in PR to docs/en/engines/table-engines/index.md.

@wudidapaopao

Copy link
Copy Markdown
Contributor Author

Hi @divanik @KochetovNicolai, based on the previous feedback, I have added tests for VIEW, MATERIALIZED VIEW, and Buffer types. For MATERIALIZED VIEW and Buffer tables, it directly returns the MATERIALIZED VIEW table name and Buffer table name, respectively. For VIEW, it returns the initial table name. Please let me know if there are any inaccuracies, and I will make the necessary adjustments promptly.

@divanik

divanik commented Jan 27, 2025

Copy link
Copy Markdown
Contributor

Hi @wudidapaopao,

I’ve decided to implement this feature myself to address our design discussions internally. I plan to make the PR it within this or next week and will invite you to review the pull request once it's ready.

@clickhouse-gh

clickhouse-gh Bot commented Mar 4, 2025

Copy link
Copy Markdown
Contributor

Dear @divanik, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@clickhouse-gh

clickhouse-gh Bot commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2dd0076]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan, distributed plan, sequential) failure
00002_log_and_exception_messages_formatting FAIL
Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) failure
Logical error thrown (see clickhouse-server.log or logical_errors.txt) FAIL
Stateless tests (arm_binary, parallel) failure
01825_new_type_json_ghdata_insert_select FAIL

@alexey-milovidov alexey-milovidov self-assigned this Jul 26, 2025
@alexey-milovidov
alexey-milovidov merged commit 25915fd into ClickHouse:master Jul 29, 2025
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 29, 2025
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @wudidapaopao @alexey-milovidov — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

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

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature 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.

The _table virtual column can work not only for Merge tables.

7 participants