[
https://issues.apache.org/jira/browse/IGNITE-19018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17706951#comment-17706951
]
Andrey Mashenkov commented on IGNITE-19018:
-------------------------------------------
The query logical plan:
{code:java}
LogicalTableModify(table=[[PUBLIC, T]], operation=[INSERT], flattened=[false])
LogicalProject(__p_key=[GEN_RANDOM_UUID()], VAL=[$0])
LogicalValues(tuples=[[{ 1 }, { 2 }, { 3 }]])
{code}
As of now, in physical plan we get Values with broadcast distribution and
TableModify with hash distribution. So, Calcite will add an Exchange in
between. Actually, it is TrimExchange to make broadcast-distribution fits
hash-distribution, which looks ok in general.
But here is a trick with Project that produce non-idenponent UUID.
So, we must either void requesting data from project more than once or make it
deterministic and rewindable.
Also there are another similar queries:
1. INSERT INTO t VALUES (1), (2), (3)
2. INSERT INTO t (key, val) VALUES (1, 1), (2, 2), (3, 3)
3. INSERT INTO t (SELECT (val) FROM T2)
4. INSERT INTO t (SELECT (key, val) FROM VALUES() WHERE ...)
All these queries have similar logical plans, 3 and 4 have table scans at the
very bottom.
The 4 has an additional filter, just as an example, that we may got different
subtrees.
{code:java}
LogicalTableModify(table=[[PUBLIC, T]], operation=[INSERT], flattened=[false])
LogicalProject(__p_key=[GEN_RANDOM_UUID()], VAL=[$0])
LogicalTableScan(T2)
{code}
Seems, for p.1 and p3. single-distribution is mandatory because we need
materialize Project values first, then send rows to other nodes.
For p.2 any distribution is acceptable. Single may be preffered for large
Values set.
In p4, TableModify with hash-distribution allows to pushdown TableModify and
avoid pulling data to a single node.
Summarizing, we need to allow TableModify nodes satisfy single-distribution and
hash-distribution in different cases. This can be achieved by having 2 rules
like TableModifyConverterRule.
But how to forbid TableModify with hash-distribution when there is Values
underneath ??
> Sql. Investigate AssertionError in ScanNode. ItCorrelatesTest fails when
> distribution of VALUES is changed from Broadcast to Single.
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: IGNITE-19018
> URL: https://issues.apache.org/jira/browse/IGNITE-19018
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Affects Versions: 3.0.0-beta2
> Reporter: Maksim Zhuravkov
> Assignee: Andrey Mashenkov
> Priority: Critical
> Labels: calcite3-required, ignite-3
> Fix For: 3.0.0-beta2
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The query in ItCorrelatesTest triggers AssertionError in ScanNode. This
> behaviour is observed in after modification operations were changed in
> https://issues.apache.org/jira/browse/IGNITE-18225 is implemented.
> {code:java}
> assertQuery("SELECT * FROM test1 WHERE "
> + "EXISTS(SELECT * FROM test2 WHERE (SELECT test1.a)=test2.a
> AND (SELECT test1.b)<>test2.c) "
> + "AND NOT EXISTS(SELECT * FROM test2 WHERE (SELECT
> test1.a)=test2.a AND (SELECT test1.b)<test2.c)")
> .returns(12, 2)
> .check();
> {code}
> AssertionError:
> {code:java}
> Caused by: java.lang.AssertionError: rowsCnt=512, requested=512
> at
> org.apache.ignite.internal.sql.engine.exec.rel.ScanNode.request(ScanNode.java:53)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.ProjectNode.request(ProjectNode.java:59)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.HashAggregateNode.request(HashAggregateNode.java:110)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Outbox.flush(Outbox.java:267)
> at
> org.apache.ignite.internal.sql.engine.exec.rel.Outbox.onRequest(Outbox.java:108)
> at
> org.apache.ignite.internal.sql.engine.exec.ExchangeServiceImpl.lambda$onMessage$3(ExchangeServiceImpl.java:178)
> at
> org.apache.ignite.internal.sql.engine.exec.ExchangeServiceImpl.onMessage(ExchangeServiceImpl.java:187)
> at
> org.apache.ignite.internal.sql.engine.exec.ExchangeServiceImpl.lambda$start$1(ExchangeServiceImpl.java:73)
> at
> org.apache.ignite.internal.sql.engine.message.MessageServiceImpl.onMessageInternal(MessageServiceImpl.java:164)
> at org.
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)