[Calcite] Showcase bug related to JOIN expression#478
Draft
findinpath wants to merge 1 commit intolinkedin:masterfrom
Draft
[Calcite] Showcase bug related to JOIN expression#478findinpath wants to merge 1 commit intolinkedin:masterfrom
findinpath wants to merge 1 commit intolinkedin:masterfrom
Conversation
findinpath
commented
Nov 15, 2023
| @DataProvider(name = "viewTestCases") | ||
| public Object[][] viewTestCasesProvider() { | ||
| return new Object[][] { | ||
| return new Object[][] { { "test", "view_table_join_with_view_table_with_nested_columns", "..." }, |
Contributor
Author
There was a problem hiding this comment.
AssertionError happens in the translation of the view currently without reaching the point where the view translation gets compared with ....
Stacktrace:
java.lang.AssertionError: Field ordinal 3 is invalid for type 'RecordType:peek_no_expand(RecordType:peek_no_expand(VARCHAR(2147483647) idtype, VARCHAR(2147483647) id) studentid, RecordType:peek_no_expand(TIMESTAMP lastupdated, VARCHAR(2147483647) name, RecordType:peek_no_expand(DATE enrollmentdate, VARCHAR(2147483647) major) misc) details)'
at org.apache.calcite.rex.RexBuilder.makeFieldAccess(RexBuilder.java:197)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:3725)
at org.apache.calcite.sql2rel.SqlToRelConverter.access$2200(SqlToRelConverter.java:217)
at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4796)
at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4092)
at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:317)
at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4656)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectList(SqlToRelConverter.java:3939)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:670)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:627)
at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3181)
at com.linkedin.coral.hive.hive2rel.HiveSqlToRelConverter.convertQuery(HiveSqlToRelConverter.java:63)
at com.linkedin.coral.common.ToRelConverter.toRel(ToRelConverter.java:157)
at com.linkedin.coral.common.ToRelConverter.convertView(ToRelConverter.java:124)
at com.linkedin.coral.trino.rel2trino.HiveToTrinoConverterTest.testViews(HiveToTrinoConverterTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:701)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:893)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1218)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:758)
at org.testng.TestRunner.run(TestRunner.java:613)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
Contributor
|
Thanks for the PR. Could you simplify the table/view names in the test case? Also update the description to highlight the key reason why the test case fails (you could use the simplified names from the test). Right now, it is a bit hard to reverse engineer the problem from the test code alone. |
Contributor
Author
|
@wmoustafa AC |
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.
Consider the following scenario to translate via Coral:
When we have an function call in the
JOINexpression like in the example provided:we are then having a new
LogicalProject(different from the leafLogicalProjectcorresponding to the viewview_table_join_view_scenario_table_nested_columnsseeorg.apache.calcite.sql2rel.SqlToRelConverter#leaves) which includes the expressionCAST(concat('U', $0.id)):VARCHAR(2147483647)RexCall.This project is not considered a leaf.
In the flattening algorithm from
org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard#flattentherefore theLogicalProjectwith the expressionswill be flattened therefore again (because it is not a leaf) and we obtain therefore the
LogicalTableScancorresponding to the tabletable_join_view_scenario_table_nested_columnswhich contains only two fields:Therefore the type corresponding to the
LogicalTableScanhaving only two fields is being returned for usage inSqlToRelConverter.convertIdentifier.However,
details_last_updatedhas the index3in theLogicalProjectThis is why we stumble in an
AssertionErrorinRexBuilder.makeFieldAccess:org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard#flattensource code:This PR serves only for showcasing a potential unidentified bug in
calcite-coreStacktrace:
What changes are proposed in this pull request, and why are they necessary?
How was this patch tested?