Skip to content

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 👨‍🍳 👌


/// 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
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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