Zou created FLINK-22120:
---------------------------
Summary: Bug when generate code for map get
Key: FLINK-22120
URL: https://issues.apache.org/jira/browse/FLINK-22120
Project: Flink
Issue Type: Improvement
Components: Table SQL / Planner
Reporter: Zou
There is a bug when we get values from a map with a complex expression key.
The reason is the `key.code` in ScalarOperatorGens#generateMapGet will be
called twice.
This is a test case:
{code:java}
CREATE TABLE T (
`name` VARCHAR,
`map` MAP<VARCHAR, INT>
) WITH (
...
);
SELECT `map`[coalesce(name, '')] FROM T;
{code}
An exception will be thrown while running this query:
{code:java}
Caused by: java.lang.RuntimeException: Could not instantiate generated class
'StreamExecCalc$21'
at
org.apache.flink.table.runtime.generated.GeneratedClass.newInstance(GeneratedClass.java:67)
at
org.apache.flink.table.runtime.operators.CodeGenOperatorFactory.createStreamOperator(CodeGenOperatorFactory.java:40)
at
org.apache.flink.streaming.api.operators.StreamOperatorFactoryUtil.createOperator(StreamOperatorFactoryUtil.java:70)
at
org.apache.flink.streaming.runtime.tasks.OperatorChain.<init>(OperatorChain.java:167)
at
org.apache.flink.streaming.runtime.tasks.StreamTask.beforeInvoke(StreamTask.java:458)
at
org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:527)
at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:725)
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.flink.util.FlinkRuntimeException:
org.apache.flink.api.common.InvalidProgramException: Table program cannot be
compiled. This is a bug. Please file an issue.
at
org.apache.flink.table.runtime.generated.CompileUtils.compile(CompileUtils.java:68)
at
org.apache.flink.table.runtime.generated.GeneratedClass.compile(GeneratedClass.java:78)
at
org.apache.flink.table.runtime.generated.GeneratedClass.newInstance(GeneratedClass.java:65)
... 8 more
Caused by:
org.apache.flink.shaded.guava18.com.google.common.util.concurrent.UncheckedExecutionException:
org.apache.flink.api.common.InvalidProgramException: Table program cannot be
compiled. This is a bug. Please file an issue.
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2203)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache.get(LocalCache.java:3937)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4739)
at
org.apache.flink.table.runtime.generated.CompileUtils.compile(CompileUtils.java:66)
... 10 more
Caused by: org.apache.flink.api.common.InvalidProgramException: Table program
cannot be compiled. This is a bug. Please file an issue.
at
org.apache.flink.table.runtime.generated.CompileUtils.doCompile(CompileUtils.java:81)
at
org.apache.flink.table.runtime.generated.CompileUtils.lambda$compile$1(CompileUtils.java:66)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4742)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at
org.apache.flink.shaded.guava18.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
... 13 more
Caused by: org.codehaus.commons.compiler.CompileException: Line 121, Column
27: Redefinition of local variable "result$6"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:12124)
at
org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:3662)
at org.codehaus.janino.UnitCompiler.access$5800(UnitCompiler.java:215)
at
org.codehaus.janino.UnitCompiler$12.visitLocalVariableDeclarationStatement(UnitCompiler.java:3543)
at
org.codehaus.janino.UnitCompiler$12.visitLocalVariableDeclarationStatement(UnitCompiler.java:3511)
at
org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:3511)
at
org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:3510)
at
org.codehaus.janino.UnitCompiler.buildLocalVariableMap(UnitCompiler.java:3567)
at org.codehaus.janino.UnitCompiler.access$4700(UnitCompiler.java:215)
at org.codehaus.janino.UnitCompiler$12.visitBlock(UnitCompiler.java:3529)
at org.codehaus.janino.UnitCompiler$12.visitBlock(UnitCompiler.java:3511)
at org.codehaus.janino.Java$Block.accept(Java.java:2776)
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)