Skip to content

Support subcolumns in default and materialized expressions#74403

Merged
Avogar merged 11 commits intoClickHouse:masterfrom
Avogar:subcolumns-in-default
Feb 10, 2025
Merged

Support subcolumns in default and materialized expressions#74403
Avogar merged 11 commits intoClickHouse:masterfrom
Avogar:subcolumns-in-default

Conversation

@Avogar
Copy link
Copy Markdown
Member

@Avogar Avogar commented Jan 9, 2025

Changelog category (leave one):

  • Improvement

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

Support subcolumns in default and materialized expressions

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/

CI Settings (Only check the boxes if you know what you are doing)

All builds in Builds_1 and Builds_2 stages are always mandatory
and will run independently of the checks below:

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64
  • Exclude: All with release
  • Exclude: All with debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, BuzzHouse, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

@Avogar Avogar requested a review from KochetovNicolai January 9, 2025 18:26
@Avogar Avogar mentioned this pull request Jan 9, 2025
56 tasks
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-improvement Pull request with some product improvements label Jan 9, 2025
@robot-ch-test-poll1
Copy link
Copy Markdown
Contributor

robot-ch-test-poll1 commented Jan 9, 2025

This is an automated comment for commit d16da86 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
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
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ 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
Install packagesChecks that the built packages are installable in a clear environment✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ 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


/// Create an alias for getSubcolumn function so it has the name of the subcolumn.
const auto & alias_node = extract_subcolumns_dag.addAlias(function_node, input->result_name);
extract_subcolumns_dag.addOrReplaceInOutputs(alias_node);
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.

I think it is safer to support the map with added output names. In this case, we can skip adding unused getSubcolumn, and replace this line to extract_subcolumns_dag.getOutputs().push_back(alias_node)

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.

I think it is safer to support the map with added output names.

But how it's possible to add the same name as output twice here? Each added output corresponds to a different subcolumn. Using extract_subcolumns_dag.getOutputs().push_back(alias_node) should be enough.

TBH I used addOrReplaceInOutputs not because I was afraid of duplicates but because I didn't thinking about getOutputs().push_back :)

Copy link
Copy Markdown
Member

@KochetovNicolai KochetovNicolai left a comment

Choose a reason for hiding this comment

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

Overall looks good!

@Avogar Avogar force-pushed the subcolumns-in-default branch from a17dc26 to 4916e3c Compare January 30, 2025 19:39
@Avogar Avogar force-pushed the subcolumns-in-default branch from 4916e3c to b97d8c0 Compare January 30, 2025 19:42
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 7, 2025

Workflow [PR], commit [a17c45c]

@Avogar Avogar added this pull request to the merge queue Feb 10, 2025
Merged via the queue into ClickHouse:master with commit ece0003 Feb 10, 2025
115 of 116 checks passed
@Avogar Avogar deleted the subcolumns-in-default branch February 10, 2025 12:41
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 10, 2025
@handgunman
Copy link
Copy Markdown
Contributor

This fix depends on the setting allow_experimental_analyzer=1;
Is that how it should be?

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 12, 2025

This fix depends on the setting allow_experimental_analyzer=1;
Is that how it should be?

Do ypu have an example when it doesn't work without analyzer?

BTW, analyzer is not experimental anymore and enabled by default since 24.3. There is an alias enable_analyzer.

@handgunman
Copy link
Copy Markdown
Contributor

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 12, 2025

I see, it is indeed a problem with old analyzer. But I don't think we want to fix such things with old analyzer, it's better to switch to the new one.

@handgunman
Copy link
Copy Markdown
Contributor

It is not clear why this fix depends on this setting.

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 12, 2025

The problem is in TreeRewriter implmentation when we read a subcolumn of a materialized column. TreeRewriter is used only in old analyzer.

@handgunman
Copy link
Copy Markdown
Contributor

Okay, I'll wait for the full implementation.

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 12, 2025

What do you mean by full implementation?
It works in new analyzer, so just use new analyzer.

@handgunman
Copy link
Copy Markdown
Contributor

The allow_experimental_analyzer setting is disabled in the cloud service. For this reason, it doesn't work without setting in queries or profiles. Without this, accessibility will only be possible after removing the dependency on this setting.

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 12, 2025

The allow_experimental_analyzer setting is disabled in the cloud service.

It is disabled for old services for compatibility. You can test if enabling it doesn't break your queries and enable it by default for your profile or ask the support to enable it by default for the whole service.

@handgunman
Copy link
Copy Markdown
Contributor

I have already asked the service a question. Their position is unequivocal: experimental setting is disabled. I know about the profile and will use it in some cases. Thanks!

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 12, 2025

Their position is unequivocal: experimental setting is disabled.

That is strange, analyzer is not expiremental anymore for long time already. Maybe they were confused by the setting name allow_experimental_analyzer, you can ask about enable_analyzer setting

@handgunman
Copy link
Copy Markdown
Contributor

if the analyzer is turned on and the experimental one is turned off, the error is reproduced.
https://fiddle.clickhouse.com/4dc3617c-c416-47b4-931a-064d6189ef49

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented May 13, 2025

There is no experimental analyzer. enable_analyzer is just an alias to allow_experimental_analyzer that was added when the analyzer became non experimental. The old setting is left for compatibility. In your example you just enabled analyzer and then disabled it just via another setting.

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

Labels

pr-improvement Pull request with some product improvements 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.

5 participants