]
Johnathon Lee updated TEIID-5330:
---------------------------------
Fix Version/s: 8.12.13.6_4
FIRST_VALUE/LAST_VALUE/LEAD/LAG functions always try to return
integer
----------------------------------------------------------------------
Key: TEIID-5330
URL:
https://issues.jboss.org/browse/TEIID-5330
Project: Teiid
Issue Type: Bug
Components: Query Engine
Affects Versions: 8.12.13.6_4
Reporter: Jan Martiska
Assignee: Steven Hawkins
Priority: Blocker
Fix For: 10.3, 8.12.13.6_4, 10.1.4, 10.2.2
The FIRST_VALUE/LAST_VALUE/LEAD/LAG functions always try to return integer, no matter
what the type of the column is.
If integer can be cast to the target type, the query will successfully return, but the
return type will be integer instead of the expected one. If integer cannot be cast to the
requested type, the query will fail.
For example, when running this against a CSV source and a string column:
{noformat}
SELECT FIRST_VALUE(stringkey) OVER (ORDER BY stringkey) FROM BQT1.smallA
{noformat}
This fails with:
{noformat}
14:54:49,328 ERROR [org.teiid.TRANSPORT] (New I/O worker #2) TEIID40113 Unhandled
exception, aborting operation: org.teiid.transport.ObjectEncoder$FailedWriteException:
org.teiid.core.TeiidRuntimeException: TEIID20001 The modeled datatype integer for column 0
doesn't match the runtime type "java.lang.String". Please ensure that the
column's modeled datatype matches the expected data.
at org.teiid.transport.ObjectEncoder.handleDownstream(ObjectEncoder.java:136)
[teiid-runtime-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.jboss.netty.channel.Channels.write(Channels.java:704)
[netty-3.6.10.Final-redhat-1.jar:3.6.10.Final-redhat-1]
at org.jboss.netty.channel.Channels.write(Channels.java:671)
[netty-3.6.10.Final-redhat-1.jar:3.6.10.Final-redhat-1]
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248)
[netty-3.6.10.Final-redhat-1.jar:3.6.10.Final-redhat-1]
at
org.teiid.transport.SSLAwareChannelHandler$ObjectChannelImpl.write(SSLAwareChannelHandler.java:94)
[teiid-runtime-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.transport.SocketClientInstance.send(SocketClientInstance.java:94)
[teiid-runtime-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.transport.ServerWorkItem.sendResult(ServerWorkItem.java:135)
[teiid-runtime-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.transport.ServerWorkItem$1.onCompletion(ServerWorkItem.java:105)
[teiid-runtime-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.client.util.ResultsFuture.done(ResultsFuture.java:135)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.client.util.ResultsFuture.access$200(ResultsFuture.java:40)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.client.util.ResultsFuture$1.receiveResults(ResultsFuture.java:79)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at
org.teiid.dqp.internal.process.RequestWorkItem.sendResultsIfNeeded(RequestWorkItem.java:996)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at
org.teiid.dqp.internal.process.RequestWorkItem$1.flushBatchDirect(RequestWorkItem.java:676)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.query.processor.BatchCollector.flushBatch(BatchCollector.java:223)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.query.processor.BatchCollector.collectTuples(BatchCollector.java:194)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.query.processor.BatchCollector.collectTuples(BatchCollector.java:146)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.dqp.internal.process.RequestWorkItem.processMore(RequestWorkItem.java:472)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.dqp.internal.process.RequestWorkItem.process(RequestWorkItem.java:348)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.dqp.internal.process.AbstractWorkItem.run(AbstractWorkItem.java:51)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.dqp.internal.process.RequestWorkItem.run(RequestWorkItem.java:274)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:284)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:210)
[teiid-engine-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[rt.jar:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[rt.jar:1.8.0_151]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_151]
Caused by: org.teiid.core.TeiidRuntimeException: TEIID20001 The modeled datatype integer
for column 0 doesn't match the runtime type "java.lang.String". Please
ensure that the column's modeled datatype matches the expected data.
at org.teiid.client.BatchSerializer.writeBatch(BatchSerializer.java:878)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.client.ResultsMessage.writeExternal(ResultsMessage.java:319)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
[rt.jar:1.8.0_151]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
[rt.jar:1.8.0_151]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[rt.jar:1.8.0_151]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[rt.jar:1.8.0_151]
at org.teiid.net.socket.Message.writeExternal(Message.java:61)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
[rt.jar:1.8.0_151]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
[rt.jar:1.8.0_151]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[rt.jar:1.8.0_151]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[rt.jar:1.8.0_151]
at org.teiid.transport.ObjectEncoder.handleDownstream(ObjectEncoder.java:131)
[teiid-runtime-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
... 25 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Integer
at
org.teiid.client.BatchSerializer$IntColumnSerializer.writeObject(BatchSerializer.java:563)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at
org.teiid.client.BatchSerializer$ColumnSerializer.writeColumn(BatchSerializer.java:534)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
at org.teiid.client.BatchSerializer.writeBatch(BatchSerializer.java:867)
[teiid-client-8.12.13.6_4-redhat-64-1.jar:8.12.13.6_4-redhat-64-1]
... 36 more
{noformat}