Cast char fields, if necessary, to varchar type in Hive view translations#19275
Merged
findepi merged 1 commit intotrinodb:masterfrom Oct 27, 2023
Merged
Conversation
9300f57 to
5435e80
Compare
Bump coral to 2.2.14 to support Hive view translation cnsisting of a UNION between a char and a varchar field. Due to wrong coercion between `varchar` and `char` in Trino, as described in trinodb#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.
5435e80 to
33f1bc6
Compare
findepi
approved these changes
Oct 26, 2023
|
|
||
| @Test(groups = HIVE_VIEWS) | ||
| @Flaky(issue = RETRYABLE_FAILURES_ISSUES, match = RETRYABLE_FAILURES_MATCH) | ||
| public void testUnionBetweenCharAndVarchar() |
Member
There was a problem hiding this comment.
should this go to AbstractTestHiveViews?
Contributor
Author
There was a problem hiding this comment.
Probably not.
testing/bin/ptl test run --environment multinode --config config-default -- -t io.trino.tests.product.hive.TestHiveViewsLegacy.testUnionBetweenCharAndVarchar
Caused by: io.trino.spi.TrinoException: line 1:15: View 'hive.default.union_char_varchar_view' is stale or in invalid state: column [col] of type char(1024) projected from query view at position 0 cannot be coerced to column [col] of type varchar stored in view definition
tests | at io.trino.sql.analyzer.SemanticExceptions.semanticException(SemanticExceptions.java:48)
tests | at io.trino.sql.analyzer.SemanticExceptions.semanticException(SemanticExceptions.java:43)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.lambda$createScopeForView$56(StatementAnalyzer.java:2493)
tests | at java.base/java.util.Optional.ifPresent(Optional.java:178)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.createScopeForView(StatementAnalyzer.java:2493)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.createScopeForView(StatementAnalyzer.java:2446)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitTable(StatementAnalyzer.java:2238)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitTable(StatementAnalyzer.java:493)
tests | at io.trino.sql.tree.Table.accept(Table.java:60)
tests | at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:512)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.analyzeFrom(StatementAnalyzer.java:4560)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuerySpecification(StatementAnalyzer.java:3020)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuerySpecification(StatementAnalyzer.java:493)
tests | at io.trino.sql.tree.QuerySpecification.accept(QuerySpecification.java:155)
tests | at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:512)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:520)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuery(StatementAnalyzer.java:1521)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuery(StatementAnalyzer.java:493)
tests | at io.trino.sql.tree.Query.accept(Query.java:107)
tests | at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
tests | at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:512)
tests | at io.trino.sql.analyzer.StatementAnalyzer.analyze(StatementAnalyzer.java:472)
tests | at io.trino.sql.analyzer.StatementAnalyzer.analyze(StatementAnalyzer.java:461)
tests | at io.trino.sql.analyzer.Analyzer.analyze(Analyzer.java:97)
tests | at io.trino.sql.analyzer.Analyzer.analyze(Analyzer.java:86)
tests | at io.trino.execution.SqlQueryExecution.analyze(SqlQueryExecution.java:274)
tests | at io.trino.execution.SqlQueryExecution.<init>(SqlQueryExecution.java:209)
tests | at io.trino.execution.SqlQueryExecution$SqlQueryExecutionFactory.createQueryExecution(SqlQueryExecution.java:850)
tests | at io.trino.dispatcher.LocalDispatchQueryFactory.lambda$createDispatchQuery$0(LocalDispatchQueryFactory.java:153)
tests | at io.trino.$gen.Trino_426_726_g33f1bc6_dirty____20231026_151108_2.call(Unknown Source)
ebyhr
approved these changes
Oct 26, 2023
findepi
approved these changes
Oct 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bump coral to 2.2.14 to support Hive view translation cnsisting of a UNION between a char and a varchar field.
Due to wrong coercion between
varcharandcharin Trino, as described in #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.
Fixes #18337
Additional context and related issues
linkedin/coral#442
trinodb/trino-coral#2
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: