[ https://issues.apache.org/jira/browse/CALCITE-5048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17509234#comment-17509234 ]
Jiajun Xie edited comment on CALCITE-5048 at 4/4/22 9:05 AM: ------------------------------------------------------------- Hi, [~rubenql]. I found all the code that takes int value from fetch. - Three lines of code have been fixed in CALCITE-2061 {code:java} RelMdRowCount:160 final int limit = RexLiteral.intValue(rel.fetch); PruneEmptyRules.SortFetchZeroRuleConfig:459 && RexLiteral.intValue(sort.fetch) == 0) { RelFieldTrimmer:661 sort.fetch == null ? -1 : RexLiteral.intValue(sort.fetch);{code} - Seven lines of code that may have problems {code:java} EnumerableMergeUnionRule:89 RexLiteral.intValue(sort.fetch) + RexLiteral.intValue(sort.offset)); RelMdMaxRowCount:116 final int limit = RexLiteral.intValue(rel.fetch); RelMdMaxRowCount:213 return (double) RexLiteral.intValue(sort.fetch); RelMdMinRowCount:115 final int limit = RexLiteral.intValue(rel.fetch); RelMdMinRowCount:173 return (double) RexLiteral.intValue(sort.fetch); RelDecorrelator:481 final int fetch = rel.fetch == null ? -1 : RexLiteral.intValue(rel.fetch); DruidQuery:697 fetch = sort.fetch != null ? RexLiteral.intValue(sort.fetch) : null; {code} I'm interested in completely fixing them, Would you please assign the issue to me? was (Author: jiajunbernoulli): Hi, [~rubenql]. I found all the code that takes int value from fetch. - Two lines of code have been fixed in CALCITE-2061 {code:java} RelMdRowCount:160 final int limit = RexLiteral.intValue(rel.fetch); PruneEmptyRules.SortFetchZeroRuleConfig:459 && RexLiteral.intValue(sort.fetch) == 0) { {code} - Eight lines of code that may have problems {code:java} EnumerableMergeUnionRule:89 RexLiteral.intValue(sort.fetch) + RexLiteral.intValue(sort.offset)); RelMdMaxRowCount:116 final int limit = RexLiteral.intValue(rel.fetch); RelMdMaxRowCount:213 return (double) RexLiteral.intValue(sort.fetch); RelMdMinRowCount:115 final int limit = RexLiteral.intValue(rel.fetch); RelMdMinRowCount:173 return (double) RexLiteral.intValue(sort.fetch); RelDecorrelator:481 final int fetch = rel.fetch == null ? -1 : RexLiteral.intValue(rel.fetch); RelDecorrelator:661 sort.fetch == null ? -1 : RexLiteral.intValue(sort.fetch); DruidQuery:697 fetch = sort.fetch != null ? RexLiteral.intValue(sort.fetch) : null; {code} I'm interested in completely fixing them, Would you please assign the issue to me? > Query with parameterized LIMIT and correlated sub-query throws AssertionError > "not a literal" > --------------------------------------------------------------------------------------------- > > Key: CALCITE-5048 > URL: https://issues.apache.org/jira/browse/CALCITE-5048 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.29.0 > Reporter: Corvin Kuebler > Priority: Major > > This query: > {code:java} > // Does not run > @Test void testDynamicParameterLimit() { > CalciteAssert.hr() > .query("SELECT * FROM \"hr\".\"emps\" AS a " + > "WHERE \"deptno\" = " + > "(SELECT MAX(\"deptno\") " + > "FROM \"hr\".\"emps\" AS b " + > "WHERE a.\"empid\" = b.\"empid\"" + > ") LIMIT ?") > .runs(); > }{code} > results in the following exception: > {code:java} > not a literal: ?0 > java.lang.AssertionError: not a literal: ?0 > at org.apache.calcite.rex.RexLiteral.findValue(RexLiteral.java:1208) > at org.apache.calcite.rex.RexLiteral.intValue(RexLiteral.java:1183) > at > org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(RelDecorrelator.java:481) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:568) > at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:531) > at > org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:711) > at > org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:306) > at > org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:230) > at > org.apache.calcite.tools.Programs$DecorrelateProgram.run(Programs.java:361) > at > org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:336) > at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:177) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:312) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:220){code} -- This message was sent by Atlassian Jira (v8.20.1#820001)