Gustavo de Morais created FLINK-38731:
-----------------------------------------
Summary: Add support for MULTI_JOIN hint
Key: FLINK-38731
URL: https://issues.apache.org/jira/browse/FLINK-38731
Project: Flink
Issue Type: Sub-task
Components: Table SQL / Planner
Reporter: Gustavo de Morais
Assignee: Gustavo de Morais
Fix For: 2.3.0
We want to expose the MultiJoin operator via a hint so that users can control
which tables are merged into a MultiJoin and which ones should continue to use
the regular join operator. The user can then control wether only some tables or
all tables should be merged into the MultiJoin. The existing common join key
restrictions continue to apply. The hint can be used in combination with the
STATE_TTL hint as well.
These should be supported:
{code:java}
CREATE TABLE t1 (id BIGINT, name STRING, age INT) WITH (...);
CREATE TABLE t2 (id BIGINT, name STRING, age INT) WITH (...);
CREATE TABLE t3 (id BIGINT, name STRING, age INT) WITH (...);
{code}
{code:java}
-- Flink will use the MultiJoin operator for the three-way join.
SELECT /*+ MULTI_JOIN(t1, t2, t3) */ * FROM t1
JOIN t2 ON t1.id = t2.id
JOIN t3 ON t1.id = t3.id;{code}
{code:java}
-- Using table names instead of aliases.
SELECT /*+ MULTI_JOIN(Users, Orders, Payments) */ * FROM Users
INNER JOIN Orders ON Users.user_id = Orders.user_id
INNER JOIN Payments ON Users.user_id = Payments.user_id;
{code}
{code:java}
-- Partial match: only t1 and t2 will use MultiJoin, t3 will use regular join.
SELECT /*+ MULTI_JOIN(t1, t2) */ * FROM t1
JOIN t2 ON t1.id = t2.id
JOIN t3 ON t1.id = t3.id;
{code}
{code:java}
-- Combining MULTI_JOIN with STATE_TTL hint.
SELECT /*+ MULTI_JOIN(t1, t2, t3), STATE_TTL('t1'='1d', 't2'='2d', 't3'='12h')
*/ * FROM t1
JOIN t2 ON t1.id = t2.id
JOIN t3 ON t1.id = t3.id;{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)