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

Check arg type against Py UDF signature at query compile time #5254

Merged
merged 10 commits into from
Mar 25, 2024

Conversation

jmao-denver
Copy link
Contributor

@jmao-denver jmao-denver commented Mar 15, 2024

Fixes #5221

@jmao-denver jmao-denver added this to the 1. March 2024 milestone Mar 15, 2024
@jmao-denver jmao-denver self-assigned this Mar 15, 2024
@jmao-denver jmao-denver changed the title WIP check arg type against defs at parsing time Check arg type against Py UDF signature at query compile time Mar 18, 2024
@jmao-denver jmao-denver marked this pull request as ready for review March 18, 2024 19:46
@jmao-denver jmao-denver marked this pull request as draft March 18, 2024 19:46
@@ -1968,6 +1968,39 @@ static boolean isWideningPrimitiveConversion(Class<?> original, Class<?> target)
return false;
}

public static boolean isLosslessWideningPrimitiveConversion(Class<?> original, Class<?> target) {
Copy link
Member

Choose a reason for hiding this comment

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

This is interesting. Historically we've allowed widening from Long to Float. I see how this is lossy.

Is this used to disable vectorization? Or is it used to disable lossy widening?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See 5.1.2 on https://docs.oracle.com/javase/specs/jls/se9/html/jls-5.html. The intention here is to ensure lossless conversion.

@jmao-denver jmao-denver marked this pull request as ready for review March 19, 2024 20:50
return false;
}

public static boolean isLosslessWideningPrimitiveConversion(Class<?> original, Class<?> target) {
Copy link
Member

Choose a reason for hiding this comment

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

A unit test for this would be a good addition.

Copy link
Contributor Author

@jmao-denver jmao-denver Mar 25, 2024

Choose a reason for hiding this comment

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

  1. This particular class is not being tested in the JUnit tests probably due to the fact that it needs a non-trivial amount of work to properly wire everything up to test it in Java.
  2. The Python unit tests indirectly test this method in a pretty comprehensive way. Maybe we can do a bit more from the Python side.

Copy link
Member

Choose a reason for hiding this comment

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

  1. This is a static method that takes Class parameters. It should be very easy to unit test in Java.
  2. Unit tests like this should happen in Java when possible. That way things like coverage can be assessed.
  3. Additional Python tests should support the Java testing and not replace it.
  4. I suspect the lack of unit tests resulted from a lack of diligence at some point in the last 15 years. Now we are at a point where it looks like a lot of work to test everything. This is why I suggested testing a single static function.

py/server/deephaven/_udf.py Show resolved Hide resolved
py/server/deephaven/_udf.py Show resolved Hide resolved
Copy link
Member

@chipkent chipkent left a comment

Choose a reason for hiding this comment

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

I'm approving but still think there should be a Java unit test as noted.

@jmao-denver jmao-denver merged commit bcbeff7 into deephaven:main Mar 25, 2024
15 checks passed
@jmao-denver jmao-denver deleted the 5221-compile-time-arg-check branch March 25, 2024 14:34
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2024
@deephaven-internal
Copy link
Contributor

Labels indicate documentation is required. Issues for documentation have been opened:

Community: deephaven/deephaven-docs-community#179

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move arg type check for Py UDF to query compile time
4 participants