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

[CALCITE-6348] ARRAY_OVERLAP with a NULL argument crashes the compiler #3746

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

mihaibudiu
Copy link
Contributor

No description provided.

@@ -7126,6 +7126,9 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
"Cannot apply 'ARRAYS_OVERLAP' to arguments of type 'ARRAYS_OVERLAP\\("
+ "<INTEGER ARRAY>, <BOOLEAN>\\)'. Supported form\\(s\\): 'ARRAYS_OVERLAP\\("
+ "<EQUIVALENT_TYPE>, <EQUIVALENT_TYPE>\\)'", false);
f.checkNull("arrays_overlap(null, null)");
Copy link
Member

Choose a reason for hiding this comment

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

@mihaibudiu Are you sure spark supports this writing method? My test failed in spark 3.4.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure what you mean by that. This is a legal expression which shouldn't crash the compiler.

Copy link
Member

Choose a reason for hiding this comment

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

2024-04-03 08-20-47屏幕截图

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what you mean by that. This is a legal expression which shouldn't crash the compiler.

It seems to be a bug in spark. I can help you test it on the latest code branch of spark to see if it can be fixed.

Copy link
Member

@caicancai caicancai Apr 3, 2024

Choose a reason for hiding this comment

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

@mihaibudiu I tested it on the spark master branch. It seems that the parameters in arrays_overlap are not allowed to be null, which will fail at compile time

Is this a bug in spark sql?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

which program crashes?

Copy link
Member

@caicancai caicancai Apr 3, 2024

Choose a reason for hiding this comment

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

Sorry. There may be something wrong with my expression. It should not be said that the program crashed, but that the execution failed.

What do you think?
2024-04-03 09-04-51屏幕截图

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoever wrote that code is confusing the type "NULL" with the type "VOID". These are not the same thing at all. NULL is a type which has one value, whereas VOID has no values at all.
So there is at least one bug in their handling of types.
We can also reject this expression at compilation time in Calcite.
What happens if both arrays are NULL?

Copy link
Member

Choose a reason for hiding this comment

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

The situation of arrays_overlap(null, null) is as follows
2024-04-03 09-12-28屏幕截图

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then it's easy, we just reject arguments of type NULL for this function.
I will rework the implementation.

Copy link
Member

@caicancai caicancai left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

sonarcloud bot commented Apr 4, 2024

@mihaibudiu mihaibudiu merged commit 4c69588 into apache:main Apr 4, 2024
17 checks passed
@mihaibudiu mihaibudiu deleted the issue6348 branch April 4, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants