You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Will Yu (JIRA)" <ji...@apache.org> on 2019/03/30 18:27:01 UTC
[jira] [Comment Edited] (CALCITE-2900) RelStructuredTypeFlattener
generates wrong types on nested columns
[ https://issues.apache.org/jira/browse/CALCITE-2900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16805894#comment-16805894 ]
Will Yu edited comment on CALCITE-2900 at 3/30/19 6:26 PM:
-----------------------------------------------------------
[~zabetak] I think there is an existing issue with the current fix. Basically I double count 1 shift which will cause crash sometimes. I could open another PR to fix it or revert to fix it. Let me submit it right now. Sorry for that.
EDIT: I think the problem is that when we calculate offset, we check whether this type needs null indicator
if (SqlTypeUtil.needsNullIndicator(rowType)) {
// skip null indicator
++offset;
}
However, when we get the type, we directly use the fieldList which does not have null indicator in it.
We could either revert my fix, or fix forward. But I think this problem should be in other places too.
was (Author: my7ym):
[~zabetak] I think there is an existing issue with the current fix. Basically I double count 1 shift which will cause crash sometimes. I could open another PR to fix it or revert to fix it. Let me submit it right now. Sorry for that.
> RelStructuredTypeFlattener generates wrong types on nested columns
> ------------------------------------------------------------------
>
> Key: CALCITE-2900
> URL: https://issues.apache.org/jira/browse/CALCITE-2900
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.18.0
> Reporter: Will Yu
> Assignee: Will Yu
> Priority: Blocker
> Labels: pull-request-available
> Fix For: 1.20.0
>
> Time Spent: 5h 10m
> Remaining Estimate: 0h
>
> When we leverage Calcite to parse a SQL and generates a RelNode tree on top of a table with *structured* columns, Calcite throws an error about type mismatch shown at bottom.
> After a bit of debugging, the issue is suspected to happen in RewriteRexShuttle.visitFieldAccess. When the input is RexInputRef, such as $36.target_column, the newField type is calculated based on ONLY the index 36, WITHOUT considering the offset of target_column. The result is new field type is the type of the first sub-column of column $36, which causes the type mismatch.
>
> Error and stacktrace:
> java.lang.AssertionError: type mismatch:
> ref:
> INTEGER NOT NULL
> input:
> VARCHAR CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL
> at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
> at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:1832)
> at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:125)
> at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:57)
> at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
> at org.apache.calcite.rel.core.Project.isValid(Project.java:186)
> at org.apache.calcite.rel.core.Project.<init>(Project.java:83)
> at org.apache.calcite.rel.logical.LogicalProject.<init>(LogicalProject.java:62)
> at org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:112)
> at org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:100)
> at org.apache.calcite.rel.core.RelFactories$ProjectFactoryImpl.createProject(RelFactories.java:140)
> at org.apache.calcite.tools.RelBuilder.project(RelBuilder.java:1248)
> at org.apache.calcite.tools.RelBuilder.projectNamed(RelBuilder.java:1304)
> at org.apache.calcite.sql2rel.RelStructuredTypeFlattener.rewriteRel(RelStructuredTypeFlattener.java:506)
> 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.apache.calcite.util.ReflectUtil.invokeVisitorInternal(ReflectUtil.java:257)
> at org.apache.calcite.util.ReflectUtil.invokeVisitor(ReflectUtil.java:214)
> at org.apache.calcite.util.ReflectUtil$1.invokeVisitor(ReflectUtil.java:464)
> at org.apache.calcite.sql2rel.RelStructuredTypeFlattener$RewriteRelVisitor.visit(RelStructuredTypeFlattener.java:759)
> at org.apache.calcite.rel.SingleRel.childrenAccept(SingleRel.java:72)
> at org.apache.calcite.rel.RelVisitor.visit(RelVisitor.java:44)
> at org.apache.calcite.sql2rel.RelStructuredTypeFlattener$RewriteRelVisitor.visit(RelStructuredTypeFlattener.java:754)
> at org.apache.calcite.sql2rel.RelStructuredTypeFlattener.rewrite(RelStructuredTypeFlattener.java:194)
> at org.apache.calcite.sql2rel.SqlToRelConverter.flattenTypes(SqlToRelConverter.java:466)
> at org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:236)
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)