Skip to content

fix: Fix panic in filter predicate#7126

Merged
viirya merged 1 commit intoapache:mainfrom
alamb:alamb/cpsolver
Jul 29, 2023
Merged

fix: Fix panic in filter predicate#7126
viirya merged 1 commit intoapache:mainfrom
alamb:alamb/cpsolver

Conversation

@alamb
Copy link
Copy Markdown
Contributor

@alamb alamb commented Jul 28, 2023

Which issue does this PR close?

Closes #7125

Rationale for this change

Panic in query isn't good

What changes are included in this PR?

Fix the check if a predicate is supported for range analysis

Are these changes tested?

yes

I also verified this PR passes the IOx tests in https://github.com/influxdata/influxdb_iox/pull/8355

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jul 28, 2023
if !is_operator_supported(binary.op()) || columns.is_empty() {
return Statistics::default();
}
if !check_support(predicate) {
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.

There is an existing function that does the correctly recursive check

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.

Do we need to keep columns.is_empty() check?

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 don't know its purpose -- given that all the tests still pass I think the answer is no, but it would be good to get a second opinion on that

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 guess it means if the predicate doesn't involve any column, we cannot do selectivity check so just return default?

@alamb alamb changed the title Fix panic in filter predicate fix: Fix panic in filter predicate Jul 28, 2023
@alamb alamb marked this pull request as ready for review July 28, 2023 15:27
@alamb
Copy link
Copy Markdown
Contributor Author

alamb commented Jul 28, 2023

@berkaysynnada do you perhaps have time to review this PR?

Copy link
Copy Markdown
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@berkaysynnada
Copy link
Copy Markdown
Contributor

@berkaysynnada do you perhaps have time to review this PR?

LGTM, thank you for the fix. Actually, it's good that you've removed the default return in the case that there is no column in the predicate. We don't need to provide a default return for those with 0 selective deterministic filters. Now, the calculations will yield a 0 selectivity result for these cases, instead of returning a default (as in the instance of 1>2).

@viirya viirya merged commit 2cf5f5b into apache:main Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panicked at 'internal error: entered unreachable code' in cp_solver

3 participants