]
Steven Hawkins resolved TEIID-5041.
-----------------------------------
Fix Version/s: 10.0
8.12.x-6.4
9.3.4
Resolution: Done
On the initial reading this seemed to only relate to the primary key type change. However
there existed a related issue (no exception thrown) even with non-primary key columns.
So there were several issues addressed with the commit:
1. we'll rewrite insert statements created from triggers to create as simple of insert
expression as possible - that by itself mostly addresses the observed issue.
2. the couchbase logic was missing an assertion error if an insert value is something
other than a literal/parameter. This is a limitation of the couchbase logic and the
assertion is needed so that we don't allow an insert to proceed without the expected
values.
3. changed the planning logic to detect when batched plans may push constructs not
supported by the translator. This was not the direct issue seen here, but was possible
given our initial planning treatment of reference/parameters as something that will
eventually evaluate to a literal - which is not necessarily the case with batching.
Couchbase documentID column enforced also in a view
---------------------------------------------------
Key: TEIID-5041
URL:
https://issues.jboss.org/browse/TEIID-5041
Project: Teiid
Issue Type: Bug
Components: Misc. Connectors
Affects Versions: 8.12.x-6.4
Reporter: Jan Stastny
Assignee: Steven Hawkins
Fix For: 10.0, 8.12.x-6.4, 9.3.4
{code:sql|query against view}
INSERT INTO SmallA_Direct (IntKey, StringKey, IntNum, StringNum) VALUES (4, '1',
1, '1');
{code}
results in
{code:|title=ERROR}
13:11:43,493 ERROR [org.teiid.CONNECTOR] (Worker30_QueryProcessorQueue146) Connector
worker process failed for atomic-request=ReyS5USI/FcT.7.0.26:
org.teiid.core.TeiidRuntimeException: TEIID29006 A documentID is necessary to
insert/update/delete nested array, INSERT INTO `dvqe_crud` (documentID, `type`,
`StringKey`, `IntNum`, `StringNum`) VALUES (convert(4, string), 'nullSmallA',
'1', 1, '1')
at org.teiid.translator.couchbase.N1QLUpdateVisitor.visit(N1QLUpdateVisitor.java:149)
[translator-couchbase-8.12.11.6_4-redhat-64-5.jar:8.12.11.6_4-redhat-64-5]
at org.teiid.language.Insert.acceptVisitor(Insert.java:57)
[teiid-api-8.12.11.6_4-redhat-64-5.jar:8.12.11.6_4-redhat-64-5]
at
org.teiid.language.visitor.AbstractLanguageVisitor.visitNode(AbstractLanguageVisitor.java:51)
[teiid-api-8.12.11.6_4-redhat-64-5.jar:8.12.11.6_4-redhat-64-5]
at org.teiid.language.visitor.SQLStringVisitor.append(SQLStringVisitor.java:91)
[teiid-api-8.12.11.6_4-redhat-64-5.jar:8.12.11.6_4-redhat-64-5]
at
org.teiid.translator.couchbase.CouchbaseUpdateExecution.execute(CouchbaseUpdateExecution.java:52)
[translator-couchbase-8.12.11.6_4-redhat-64-5.jar:8.12.11.6_4-redhat-64-5]
at
org.teiid.dqp.internal.datamgr.ConnectorWorkItem$1.execute(ConnectorWorkItem.java:401)
at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:363)
at sun.reflect.GeneratedMethodAccessor183.invoke(Unknown Source) [:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_121]
at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:211)
at com.sun.proxy.$Proxy91.execute(Unknown Source)
at
org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:306)
at
org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:112)
at
org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_121]
at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:65)
at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:280)
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:119)
at
org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:210)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[rt.jar:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[rt.jar:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
13:11:43,501 WARN [org.teiid.PROCESSOR] (Worker29_QueryProcessorQueue147) TEIID30020
Processing exception for request ReyS5USI/FcT.7 'TEIID30504 Source: TEIID29006 A
documentID is necessary to insert/update/delete nested array, INSERT INTO `dvqe_crud`
(documentID, `type`, `StringKey`, `IntNum`, `StringNum`) VALUES (convert(4, string),
'nullSmallA', '1', 1, '1')'. Originally
TeiidProcessingException N1QLUpdateVisitor.java:149. Enable more detailed logging to see
the entire stacktrace.
{code}
My take from the implementing code:
The actual source cmd contains documentID and it has no NAMEINSOURCE option (after which
the column is considered PK/documentID of couchbase document). But the name of the column
is probably being compared on the level of view, not resulting source command.
{code:sql|title=source model ddl}
CREATE FOREIGN TABLE SmallA (
documentID string PRIMARY KEY,
type string OPTIONS (NAMEINSOURCE '`type`'),
FloatNum float OPTIONS (NAMEINSOURCE '`FloatNum`'),
BigIntegerValue biginteger OPTIONS (NAMEINSOURCE '`BigIntegerValue`'),
StringKey string OPTIONS (NAMEINSOURCE '`StringKey`'),
CharValue string OPTIONS (NAMEINSOURCE '`CharValue`'),
LongNum long OPTIONS (NAMEINSOURCE '`LongNum`'),
DoubleNum double OPTIONS (NAMEINSOURCE '`DoubleNum`'),
ObjectValue string OPTIONS (NAMEINSOURCE '`ObjectValue`'),
ShortValue integer OPTIONS (NAMEINSOURCE '`ShortValue`'),
BigDecimalValue bigdecimal OPTIONS (NAMEINSOURCE '`BigDecimalValue`'),
DateValue string OPTIONS (NAMEINSOURCE '`DateValue`'),
BooleanValue boolean OPTIONS (NAMEINSOURCE '`BooleanValue`'),
TimestampValue string OPTIONS (NAMEINSOURCE '`TimestampValue`'),
ByteNum integer OPTIONS (NAMEINSOURCE '`ByteNum`'),
StringNum string OPTIONS (NAMEINSOURCE '`StringNum`'),
TimeValue string OPTIONS (NAMEINSOURCE '`TimeValue`'),
IntNum integer OPTIONS (NAMEINSOURCE '`IntNum`')
) OPTIONS (NAMEINSOURCE '`dvqe_crud`', UPDATABLE TRUE,
"teiid_couchbase:ISARRAYTABLE" 'false',
"teiid_couchbase:NAMEDTYPEPAIR"
'`type`:''nullSmallA''');
{code}
{code:sql|title=DDL of view}
CREATE VIEW SmallA_Direct (IntKey integer PRIMARY KEY,
StringKey string,
IntNum integer,
StringNum string)
OPTIONS (UPDATABLE 'TRUE')
AS
SELECT CONVERT(documentID,integer), StringKey, IntNum, StringNum FROM Source.SmallA;
CREATE TRIGGER ON SmallA_Direct INSTEAD OF INSERT AS FOR EACH ROW
BEGIN ATOMIC
INSERT INTO Source.SmallA(documentID, type, StringKey, IntNum, StringNum) VALUES
(NEW.IntKey, 'nullSmallA', NEW.StringKey, NEW.IntNum, NEW.StringNum);
END;
{code}