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

[Coral-Trino] Migrate UNNEST From RelToTrinoConverter to SqlCallConverter layer #428

Merged
merged 5 commits into from
Jun 22, 2023

Conversation

aastha25
Copy link
Contributor

@aastha25 aastha25 commented Jun 21, 2023

What changes are proposed in this pull request, and why are they necessary?

Prior to this PR, transformations related to the UNNEST() function were applied in RelToTrinoConverter for translations from Coral IR -> Trino SQL.
In an attempt to standardize Coral intermediate representation and converge RelToTrinoConverter with CoralRelToSqlNodeConverter, the related transformations are extracted out as SqlCallTransformers over 3 transformations: JoinSqlCallTransformer, AsOperatorTransformer and UnnestOperatorTransformer. Also, the corresponding code from CoralRelToSqlNodeConverter is copied over to RelToTrinoConverter. In a separate PR, RelToTrinoConverter will be removed.
Other changes:
(1) Unused config SUPPORT_LEGACY_UNNEST_ARRAY_OF_STRUCT has been deleted and the corresponding unit tests, testLegacyOuterUnnestArrayOfStruct and testLegacyUnnestArrayOfStruct from HiveToTrinoConverterTest have been removed.
(2) Several unit tests in TrinoToRelConverterTest have been marked as unsupported as their SqlNode representations do not align with Coral IR at present.

Most of the code changes are part of the previous effort of extracting UNNEST operator in PR #315 .

How was this patch tested?

./gradlew spotlessApply
./gradlew build
modified UTs
i-tested with production views

Copy link
Contributor

@yiqiangin yiqiangin left a comment

Choose a reason for hiding this comment

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

LGTM


// Transform UNNEST(fieldName) to UNNEST(TRANSFORM(fieldName, x -> ROW(x)))
if (operator.getRelDataType() != null) {
String fieldName = "empty";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the initial value of fieldName is "empty"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified it to String fieldName = unnestOperand.toSqlString(TrinoSqlDialect.INSTANCE).getSql();
Probably the if - else if section below it can be removed but I'll get to that in a follow-up PR after i-testing again. Thanks for bringing it up.

@aastha25 aastha25 merged commit 3e6c039 into linkedin:master Jun 22, 2023
@aastha25 aastha25 deleted the migrate-unnest branch June 22, 2023 23:20
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