Skip to content

Analyzer: compute ALIAS columns right after reading#59595

Merged
vdimir merged 3 commits intomasterfrom
vdimir/analyzer/comute_alias_columns
Feb 29, 2024
Merged

Analyzer: compute ALIAS columns right after reading#59595
vdimir merged 3 commits intomasterfrom
vdimir/analyzer/comute_alias_columns

Conversation

@vdimir
Copy link
Copy Markdown
Member

@vdimir vdimir commented Feb 5, 2024

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

...

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/

@vdimir vdimir added the analyzer Issues and pull-requests related to new analyzer label Feb 5, 2024
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-not-for-changelog This PR should not be mentioned in the changelog label Feb 5, 2024
@robot-ch-test-poll1
Copy link
Copy Markdown
Contributor

robot-ch-test-poll1 commented Feb 5, 2024

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

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

Successful checks
Check nameDescriptionStatus
A SyncThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
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
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ 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. Integrational 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
Mergeable CheckChecks if all other necessary checks are successful✅ 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
SQLTestThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool✅ success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed✅ 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
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
Check nameDescriptionStatus
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR⏳ pending
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests❌ failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure

@novikd novikd self-assigned this Feb 6, 2024
@novikd
Copy link
Copy Markdown
Member

novikd commented Feb 6, 2024

I need this PR for #50894

@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Feb 6, 2024

Integration tests (asan, analyzer) [2/6] — fail: 5, passed: 358 Details

fixing row policy ...
UPD: also doesn't work with PREWHERE and moveToPrewhere.

@vdimir vdimir force-pushed the vdimir/analyzer/comute_alias_columns branch 2 times, most recently from 9383704 to fa7abfb Compare February 14, 2024 13:31
@vdimir vdimir marked this pull request as ready for review February 14, 2024 13:41
@vdimir vdimir force-pushed the vdimir/analyzer/comute_alias_columns branch 2 times, most recently from 7cfd7db to 8462f3a Compare February 14, 2024 17:10
@vdimir vdimir requested a review from novikd February 15, 2024 14:12
const auto & column_source = column_node->getColumnSourceOrNull();
if (column_source && (column_source->getNodeType() == QueryTreeNodeType::ARRAY_JOIN || column_source->getNodeType() == QueryTreeNodeType::JOIN))
return;
node = column_node->getExpression();
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.

maybe it's a good idea to also save alias here?

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.

Do you mean to set node->setAlias(column_node->getColumnName()) for replaced node? Added, let's see if it changes anything

/// Replace ALIAS columns with their expressions or register them in table expression data.
/// Usually we can replace them when we build some "local" actions DAG
/// (for example Row Policy or PREWHERE) that is applied on right top of table expression.
bool keep_alias_columns = true;
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.

When can not we do it?

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.

In other cases, when we keep ColumnNode with expression and compute after read. Added it to comment

@novikd
Copy link
Copy Markdown
Member

novikd commented Feb 20, 2024

Is it possible to remove alias columns computation in StorageMerge?

@vdimir vdimir force-pushed the vdimir/analyzer/comute_alias_columns branch from 8462f3a to e69aa4f Compare February 21, 2024 11:17
@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Feb 21, 2024

Is it possible to remove alias columns computation in StorageMerge?

I'm afraid there's not straightforward way to remove it, because planning of reading from source tables for Merge is hidden inside read method. But for Planner it's a blackbox and we could compute alias columns if StorageMerge itself had them. So, planner is not aware about underlying ALIAS columns and we still have to keep code to handle them in StorageMerge

@vdimir vdimir force-pushed the vdimir/analyzer/comute_alias_columns branch 2 times, most recently from 1075ef0 to cdd88c4 Compare February 23, 2024 16:24
@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Feb 26, 2024

Test failures @ cdd88c4 related to #60373

@vdimir vdimir force-pushed the vdimir/analyzer/comute_alias_columns branch from cdd88c4 to e67b0be Compare February 26, 2024 12:12
@vdimir vdimir force-pushed the vdimir/analyzer/comute_alias_columns branch from e67b0be to 9f1a073 Compare February 26, 2024 16:15
@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Feb 29, 2024

Stress test (ubsan) — Killed by signal (in clickhouse-server.log) Details

#60538

Integration tests (asan, analyzer) [2/6] — fail: 4, passed: 373 Details

test_kafka_bad_messages #58321

test_passing_max_partitions_to_read_remotely/test.py::test_default_database_on_cluster:

E               ERROR: for schema-registry  Cannot start service schema-registry: driver failed programming external connectivity on endpoint roottestkafkabadmessages_schema-registry_1 (e06efdc64c628f5a985bd465ddf2e8a4deb10d73ae86fad450477ff5032eabfc): Bind for 0.0.0.0:53539 failed: port is already allocated

Integration tests (tsan) [2/6] — fail: 1, passed: 379 Details

#60539

@vdimir vdimir merged commit 5dd81f3 into master Feb 29, 2024
@vdimir vdimir deleted the vdimir/analyzer/comute_alias_columns branch February 29, 2024 09:28
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 29, 2024
@vdimir vdimir restored the vdimir/analyzer/comute_alias_columns branch March 1, 2024 12:03
ActionsDAGPtr merged_alias_columns_actions_dag = std::make_shared<ActionsDAG>(query_plan.getCurrentDataStream().header.getColumnsWithTypeAndName());
ActionsDAG::NodeRawConstPtrs action_dag_outputs = merged_alias_columns_actions_dag->getInputs();

for (const auto & [column_name, alias_column_actions_dag] : alias_column_expressions)
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.

iteration over unordered map here. It makes the order of column in the resulting header unstable, and leads to columns swapping in the distributed queries.

Fixed in #94644

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

Labels

analyzer Issues and pull-requests related to new analyzer 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.

5 participants