[Coral-Trino] Cast char fields, if necessary, to varchar type in the set operation - RelToTrinoConverter#438
Conversation
coral-trino/src/test/java/com/linkedin/coral/trino/rel2trino/HiveToTrinoConverterTest.java
Outdated
Show resolved
Hide resolved
97b61be to
6eec47e
Compare
coral-trino/src/test/java/com/linkedin/coral/trino/rel2trino/HiveToTrinoConverterTest.java
Outdated
Show resolved
Hide resolved
|
@findinpath can you implement this transformation as a |
+1 since we are migrating all RelNode language specific transformations from the SqlNode layer, either on the Hive side or Trino side. |
|
Just discussed with @aastha25 after testing the queries natively on Trino. It sounds the SQL text is correct, but the |
fc9a8f1 to
782340e
Compare
|
@aastha25 / @wmoustafa AC . Could you please review again the PR? |
782340e to
ea1397b
Compare
char fields, if necessary, to varchar type in the set operation
char fields, if necessary, to varchar type in the set operationchar fields, if necessary, to varchar type in the set operation - RelToTrinoConverter
|
@aastha25 , @wmoustafa can we please proceed with the review for this PR? |
…set operation In case of dealing with Hive views which make use of set operation (e.g. UNION) ensure that the `char` fields from the inner SELECT statements have the same type as the output field types of the set operation. Due to wrong coercion between `varchar` and `char` in Trino, as described in trinodb/trino#9031 , a work-around needs to be applied in case of translating Hive views which contain a UNION dealing with char and varchar types. The work-around consists in the explicit cast of the field having char type towards varchar type corresponding of the set operation output type.
ea1397b to
a504411
Compare
|
@findinpath Thank you for filing #442. I still believe #442 is the way to go since:
@aastha25 mentioned she would be able to help you make more progress on #442 especially that she has seen the error before. So it could be a minor issue after all. |
Yes, this is true. This is why the change I'm suggesting is done in
Sure, if there a possibility to work with Also another point in going forward with #438 is the amount of code to be changed/maintained to address trinodb/trino#9031 use-cases is quite straight-forward. For the |
|
@findinpath, the place where you made the changes in this PR (438) is moving to The type derivation of |
Closing the current PR, because it doesn't have chances to land on |
What changes are proposed in this pull request, and why are they necessary?
In case of dealing with Hive views which make use of set operation (e.g. UNION) ensure that the fields from the inner SELECT statements have the same type as the field types of the set operation.
This patch adds the method
com.linkedin.coral.trino.rel2trino.RelToTrinoConverter#setOpToSqlwhich is used by all set operationsUNION,INTERSECT,MINUS.The proactive casting makes sure that Trino doesn't encounter anymore coercion issues while translating Hive views containing set statements.
Relates to trinodb/trino#18337
How was this patch tested?
This patch has unit test coverage.