Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible error Invalid column type for ColumnUnique::insertRangeFrom ... #39716

Merged

Conversation

arthurpassos
Copy link
Contributor

@arthurpassos arthurpassos commented Jul 29, 2022

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in official stable or prestable release)

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

Fix possible error Invalid column type for ColumnUnique::insertRangeFrom. Expected String, got ColumnLowCardinality
Fixes #38460

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

@robot-ch-test-poll robot-ch-test-poll added the pr-bugfix Pull request with bugfix, not backported by default label Jul 29, 2022
@@ -285,6 +285,8 @@ ColumnPtr IExecutableFunction::executeWithoutSparseColumns(const ColumnsWithType
? res->cloneResized(1)->convertToFullColumnIfConst()
: res;

keys = keys->convertToFullColumnIfLowCardinality();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A couple of lines above IFunction::executeWithoutLowCardinalityColumns is called with columns_without_low_cardinality. columns_without_low_cardinality indeed contains unwrapped columns (as in not LC), but the value returned by IFunction::executeWithoutLowCardinalityColumns is Const(ColumnLowCardinality), which begs the question if that's the expected behavior. Doesn't seem like.

res is then used to create the keys, which is passed to res_mut_dictionary->uniqueInsertRangeFrom that expects an unwrapped LC column.

Calling keys->convertToFullColumnIfLowCardinality fixes the problem, but I wonder if that's the right way to fix it. My instinct tells me executeWithoutLowCardinalityColumns is the actual problem, but unfortunately my debugger won't allow me to properly debug this file. Hence, I am posting this comment as a quesiton.

What is the expected behavior/ return value of executeWithoutLowCardinalityColumns?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @Avogar, since you are an assignee, could you please clarify ^^ ?

Copy link
Member

@Avogar Avogar Aug 2, 2022

Choose a reason for hiding this comment

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

Yes, you are right, it's not an expected behaviour of executeWithoutLowCardinalityColumns. The problem is in function __getScalar here it should not use default implementation for LC columns. So we should add

bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }

@arthurpassos arthurpassos marked this pull request as ready for review July 29, 2022 15:29
@Felixoid Felixoid added the can be tested Allows running workflows for external contributors label Jul 29, 2022
@Avogar Avogar self-assigned this Aug 1, 2022
@Avogar
Copy link
Member

Avogar commented Aug 2, 2022

There is no need to create an integration tests for such simple test case. It would be much better to create simple stateless test. See examples in tests/queries/0_stateless. You will need to create two files, .sql with a queries you want to test and .reference file with expected queries output.

@arthurpassos
Copy link
Contributor Author

Hi @Avogar. Is there anything missing for the merge?

@Avogar
Copy link
Member

Avogar commented Aug 3, 2022

Everything is perfect, let's merge it

@Avogar Avogar merged commit b84e65b into ClickHouse:master Aug 3, 2022
@Avogar Avogar changed the title Unwrap LC column in IExecutablefunction::executeWithoutSparseColumns Fix possible error Invalid column type for ColumnUnique::insertRangeFrom ... Aug 4, 2022
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-bugfix Pull request with bugfix, not backported by default
Projects
None yet
5 participants