Skip to content

Analyzer: Fix resolving subcolumns in JOIN#49703

Merged
vdimir merged 3 commits intomasterfrom
vdimir/analyzer_join_resolve_nested
Jan 16, 2024
Merged

Analyzer: Fix resolving subcolumns in JOIN#49703
vdimir merged 3 commits intomasterfrom
vdimir/analyzer_join_resolve_nested

Conversation

@vdimir
Copy link
Copy Markdown
Member

@vdimir vdimir commented May 9, 2023

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):

...

TODO:

@robot-clickhouse robot-clickhouse added the pr-not-for-changelog This PR should not be mentioned in the changelog label May 9, 2023
@robot-clickhouse
Copy link
Copy Markdown
Member

robot-clickhouse commented May 9, 2023

This is an automated comment for commit e9ab8e8 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
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 image for serversThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkThere'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
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
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ 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
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
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure

@alexey-milovidov alexey-milovidov changed the title Fix resolving subcolumns in JOIN Analyzer: Fix resolving subcolumns in JOIN May 9, 2023
@novikd novikd self-assigned this May 11, 2023
@vdimir vdimir force-pushed the vdimir/analyzer_join_resolve_nested branch from ea7989f to 4b671f6 Compare May 15, 2023 15:05
@vdimir vdimir marked this pull request as draft May 15, 2023 16:48
@vdimir vdimir force-pushed the vdimir/analyzer_join_resolve_nested branch from 205e0b4 to acd9013 Compare June 1, 2023 10:10
@vdimir vdimir force-pushed the vdimir/analyzer_join_resolve_nested branch from acd9013 to b246070 Compare August 3, 2023 15:07
@qoega qoega added the analyzer Issues and pull-requests related to new analyzer label Jan 8, 2024
@vdimir vdimir force-pushed the vdimir/analyzer_join_resolve_nested branch from b246070 to 25268fb Compare January 9, 2024 19:05
@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Jan 10, 2024

AST fuzzer (debug) — Assertion `left_columns_count == result_sample_block.columns() - required_right_keys.columns() - sample_block_with_columns_to_add.columns... Details

#58652

@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Jan 10, 2024

Stateless tests (release, analyzer) — Some queries hung, fail: 0, passed: 5988, skipped: 6 Details

Looks like the same as should be fixed by #58213 , but for some reason is reproduced again

@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Jan 10, 2024

CREATE table ttta (x Int32, t Tuple(t Tuple(t UInt32, s String), s String)) ENGINE = MergeTree ORDER BY x;
INSERT INTO ttta VALUES (1, ((1, 's'), 's'));

CREATE table tttb (x Int32, t Tuple(t Tuple(t Int32, s String), s String)) ENGINE = MergeTree ORDER BY x;
INSERT INTO tttb VALUES (1, ((1, 's'), 's'));

t.t has super-type, while type of t remains the same:

-- ((1,'s'),'s')   (1,'s') Tuple(\n    t Tuple(\n        t UInt32,\n        s String),\n    s String)      Tuple(Int64, String)
SELECT t, t.t, toTypeName(t), toTypeName(t.t) FROM ttta AS a FULL OUTER JOIN tttb AS b USING t.t;

It's happening because we select t and t.t as just different columns from table. Perhaps we can check such case somehow and forbid it too?

While with subquery we resolve t.t.t into function getSubcolumn(t, 't.t') and do not allow it:

SELECT t.t.t FROM (
    SELECT ((1, 's'), 's') :: Tuple(t Tuple(t UInt32, s String), s String) as t
) t1 FULL JOIN (
    SELECT ((1, 's'), 's') :: Tuple(t Tuple(t Int32, s String), s String) as t
) t2 USING (t);

@vdimir vdimir force-pushed the vdimir/analyzer_join_resolve_nested branch from dfea151 to 2c68bde Compare January 10, 2024 13:35
@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Jan 10, 2024

Added comment to code, probably we can go with it, providing best-effort result while selecting sub/super-columns and having them in USING list. When an identifier is resolved into the function nested or getSubcolumn, and some column in its argument is in the USING list and its type has to be updated, we throw an error.

With current implementation, at least we do not have LOGICAL_ERRORS or type mismatches. (I added test with different subcolumn levels in select and using list, maybe it can be even more complex, e.g Tuples in Nested or several different columns in using list ? 😵‍💫)

@novikd you may check the PR

@vdimir vdimir marked this pull request as ready for review January 10, 2024 13:36
Copy link
Copy Markdown
Member

@novikd novikd left a comment

Choose a reason for hiding this comment

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

LGTM, let's see if CI finds any problem

@vdimir
Copy link
Copy Markdown
Member Author

vdimir commented Jan 16, 2024

Stateful tests (debug) — fail: 1, passed: 128, skipped: 2 Details

timeout 00165_jit_aggregate_functions ? It was recently updated with SET max_bytes_before_external_group_by='200M';, maybe it's still not enough ?

Stress test (tsan) — Sanitizer assert (in stderr.log) Details

#58437

@vdimir vdimir merged commit d2dccf9 into master Jan 16, 2024
@vdimir vdimir deleted the vdimir/analyzer_join_resolve_nested branch January 16, 2024 10:24
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants