Skip to content

Conversation

@apilloud
Copy link
Member

@apilloud apilloud commented Feb 8, 2021

This is removing logical type optimizations broken by #11074 and removes the passthrough Beam types as Object optimization. After this change, inputs are always converted to Calcite types except for one special case of Row (which will be fixed in the next PR).


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status --- Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status Build Status Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status --- --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@apilloud apilloud changed the title Complex Type Passthrough Test [BEAM-9379] Fix Complex Type Passthrough in BeamCalcRel Apr 6, 2021
@apilloud apilloud changed the title [BEAM-9379] Fix Complex Type Passthrough in BeamCalcRel [BEAM-9379] Simplify BeamCalcRel inputs Apr 7, 2021
value = Expressions.call(expression, "getArray", Expressions.constant(index));
if (storageType == Object.class
&& TypeName.ROW.equals(fieldType.getCollectionElementType().getTypeName())) {
// Workaround for missing row output support
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the one special case that remains, it requires rewriting the output code to support rows. That is the next PR.

@apilloud
Copy link
Member Author

apilloud commented Apr 7, 2021

R: @ibzib
cc: @robinyqiu
I've rewritten BeamCalcRel's code generator for reading inputs from Beam Schema to be more strict around inputs. (There were cases were we weren't converting to Calcite types before.)

Copy link

@ibzib ibzib left a comment

Choose a reason for hiding this comment

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

LGTM. But I think this would be a good time to add some comments and rename some methods to make this class easier to follow.

if (value.getType() == java.sql.Time.class) {
valueDateTime = Expressions.call(BuiltInMethod.TIME_TO_INT.method, valueDateTime);
} else if (value.getType() == Long.class) {
} else if (value.getType() == Integer.class || value.getType() == Long.class) {
Copy link

Choose a reason for hiding this comment

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

Why does this need to include Integer now?

Copy link
Member Author

Choose a reason for hiding this comment

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

The internal type is actually suppose to be int. We've been passing Calcite a Long instead and the compiler just happily upconverts when doing math between the two types. We are still doing math somewhere (window functions?) that turns this into a Long sometimes. I think even before this change we were at risk of receiving a Integer here. (In the next CL I'm switching this to the java Number interface so we are permissive on outputs.)
https://github.com/apache/calcite-avatica/blob/89e0deb510311b85b8c8bacde6d2ff70c309930e/core/src/main/java/org/apache/calcite/avatica/SqlType.java#L306

private static Expression value(Expression value, FieldType fieldType) {
switch (fieldType.getTypeName()) {
case BYTE:
return Expressions.convert_(value, Byte.class);
Copy link

Choose a reason for hiding this comment

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

Why are these conversions necessary? e.g. doesn't getByte already return Byte?

Copy link
Member Author

Choose a reason for hiding this comment

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

These may be coming out of a Map or List as an Object. This isn't strictly necessary, I'm doing it to ensure types are what we expect. It generates a cast which results in a ClassCastException if it isn't the type we expected.

@apilloud apilloud merged commit 567cf8b into apache:master Apr 8, 2021
@apilloud apilloud deleted the passthrough branch April 8, 2021 22:39
@apilloud apilloud mentioned this pull request Sep 7, 2021
4 tasks
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