mariadb-IuriiGerzhedovich commented on PR #5332:
URL: https://github.com/apache/calcite/pull/5332#issuecomment-6210804877
> This PR ensures that MERGE can be compiled, but there is no proof that it
would produce the right results. Is there a runtime implementation of MERGE
that could be used to test the results end-to-end?
@mihaibudiu
Thanks for the review. I checked what can execute a MERGE in Calcite itself:
1. There is no Enumerable implementation: 'EnumerableTableModify' supports
only INSERT, UPDATE and DELETE and fails with 'unsupported operation: MERGE'.
2. The only end-to-end path is JDBC push-down ('JdbcTableModify' +
'RelToSqlConverter', executed by the external database), which
'JdbcAdapterTest.testMerge' uses with HSQLDB.
I tried the cases of this PR on that path (foodmart on HSQLDB):
- An uncorrelated sub-query in SET: the plan is now correct and fully pushed
to JDBC, but 'RelToSqlConverter' assumes that the input of the MERGE projection
is the join of the source and the target, and generates invalid SQL ('USING
(VALUES ...) AS "t" INNER JOIN "foodmart"."expense_fact" ON ... ON TRUE',
rejected by HSQLDB).
- A correlated sub-query: after decorrelation the 'SINGLE_VALUE' aggregate
is not pushed to JDBC, so the MERGE stays in Enumerable convention and fails
with `unsupported operation: MERGE`.
So, as far as I can see, these cases cannot be tested end-to-end in Calcite
without either an Enumerable implementation of MERGE or fixing
`RelToSqlConverter` for MERGE with sub-queries, which I think are separate
issues. I can log them in Jira. In this PR the tests check the plans: the field
references point to the correct source/target columns, and the existing
'JdbcAdapterTest.testMerge' keeps passing end-to-end.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]