You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jiatao Tao (Jira)" <ji...@apache.org> on 2020/10/10 16:02:00 UTC
[jira] [Comment Edited] (CALCITE-4323) View with ORDER BY throws
AssertionError during view expansion
[ https://issues.apache.org/jira/browse/CALCITE-4323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17211719#comment-17211719 ]
Jiatao Tao edited comment on CALCITE-4323 at 10/10/20, 4:01 PM:
----------------------------------------------------------------
Hi [~julianhyde] , sorry for the previous comment here, it just a waste of time to read (I deleted that).
After debugging, I found the sort is removed cuz the "top" is false, so it recognized as sort in subquery.
You can do a quick verification, change SqlToRelConverter.Config#isRemoveSortInSubQuery to false, that will keep sort in sub-query. And your test can pass.
!image-2020-10-10-23-58-39-822.png|width=392,height=180!
No more "no collation assert error", the fail cuz the result is not equal.
!image-2020-10-10-23-59-22-297.png|width=737,height=290!
was (Author: aron.tao):
Hi [~julianhyde] , sorry for the previous comment, it just waste time cuz I do not dig the code(I deleted that).
After debugging, I found the sort is removed cuz the "top" is false, so it recognized as sort in subquery.
You can do a quick verification, change SqlToRelConverter.Config#isRemoveSortInSubQuery to false, that will keep sort in sub-query. And your test can pass.
!image-2020-10-10-23-58-39-822.png|width=392,height=180!
No more "no collation assert error", the fail cuz the result is not equal.
!image-2020-10-10-23-59-22-297.png|width=737,height=290!
> View with ORDER BY throws AssertionError during view expansion
> --------------------------------------------------------------
>
> Key: CALCITE-4323
> URL: https://issues.apache.org/jira/browse/CALCITE-4323
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Priority: Major
> Attachments: image-2020-10-10-23-58-39-822.png, image-2020-10-10-23-59-22-297.png
>
>
> If you have a view that has an ORDER BY clause, and try to execute a query on that view, SqlToRelConverter throws AssertionError during view expansion. For example,
> {noformat}
> create view v as select * from "EMPLOYEES" order by "deptno";
> select * from V;
> java.lang.AssertionError
> at org.apache.calcite.sql2rel.SqlToRelConverter.requiredCollation(SqlToRelConverter.java:634)
> at org.apache.calcite.sql2rel.SqlToRelConverter.requiredCollation(SqlToRelConverter.java:629)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:578)
> at org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.expandView(CalcitePrepareImpl.java:1072)
> at org.apache.calcite.plan.ViewExpanders$1.expandView(ViewExpanders.java:52)
> at org.apache.calcite.schema.impl.ViewTable.expandView(ViewTable.java:127)
> at org.apache.calcite.schema.impl.ViewTable.toRel(ViewTable.java:120)
> at org.apache.calcite.prepare.RelOptTableImpl.toRel(RelOptTableImpl.java:285)
> at org.apache.calcite.sql2rel.SqlToRelConverter.toRel(SqlToRelConverter.java:3605)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:2522)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2160)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2109)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2066)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:662)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:643)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3458)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:569)
> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:242)
> {noformat}
> I suspected that it would be a problem for when the view does not project the sort column(s), but it seems to be a problem even if the columns are projected.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)