Skip to content

fix: fixes trig function order by #11559

New issue

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

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

Already on GitHub? # to your account

Merged
merged 3 commits into from
Jul 21, 2024
Merged

fix: fixes trig function order by #11559

merged 3 commits into from
Jul 21, 2024

Conversation

tshauck
Copy link
Contributor

@tshauck tshauck commented Jul 20, 2024

Which issue does this PR close?

Closes #11552

Rationale for this change

The assert!(datatype.is_primitive()); is getting hit in new_negative_one, but as far as I can tell isn't needed. There's a match statement right below that handles the datatype.

Without the assert these functions seem to work properly. That said, I'm a little confused why it's working exactly. The datatypes coming through are Datatype::Null which caused the assertion error but seemingly isn't causing errors in the match statement.

I'm also working on a branch https://github.com/apache/datafusion/compare/main...tshauck:arrow-datafusion:add-unary-udf-bounds?expand=1 that I think is a more complete way to solve this problem because currently unary functions don't report their bounds which I think is what ordering relies on to get its data type and means nested trig functions can work for ordering.

What changes are included in this PR?

Removed datatype.is_primative() asserts where the datatype is immediately matched on. I think it'd generally be better to handle unexpected datatypes that way for the error propagation vs asserting, which can lead to panics at query time.

Are these changes tested?

I added tests from the ticket that were reported as panicking.

Are there any user-facing changes?

No

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Jul 20, 2024
@tshauck tshauck marked this pull request as ready for review July 20, 2024 02:07
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @tshauck 👨‍🍳 👌

@@ -1063,7 +1063,6 @@ impl ScalarValue {

/// Create an one value in the given type.
pub fn new_one(datatype: &DataType) -> Result<ScalarValue> {
assert!(datatype.is_primitive());
Copy link
Contributor

Choose a reason for hiding this comment

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

removing the assert (as any unhandled type will cause a runtime error) makes a lot of sense to me.

@alamb alamb merged commit 7df2bde into apache:main Jul 21, 2024
26 checks passed
@tshauck tshauck deleted the remove-assert branch July 21, 2024 13:34
Lordworms pushed a commit to Lordworms/arrow-datafusion that referenced this pull request Jul 23, 2024
* fix: remove assert

* tests: add tests from ticket

* tests: clean up table
wiedld pushed a commit to influxdata/arrow-datafusion that referenced this pull request Jul 31, 2024
* fix: remove assert

* tests: add tests from ticket

* tests: clean up table
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query with order by acos(sin(v1)) panic (SQLancer)
2 participants