Hi everyone, I want to ask about the performance w...
# troubleshooting
h
Hi everyone, I want to ask about the performance when using WITH and UNION statements when ETL streaming uses Flink SQL. For example:
INSERT INTO
AGG_ACCT_STATEMENT
WITH
FT_DETAIL AS (
-- complex queries
)
SELECT
TRAN.*,
TRAN_TYPE_ORG AS TRAN_TYPE,
TRAN_TYPE_DTL_ORG AS TRAN_TYPE_DTL
FROM FT_DETAIL TRAN
WHERE COALESCE(DEBIT_AMT_ORG, CREDIT_AMT_ORG) IS NOT NULL
UNION ALL
SELECT
FEE.*,
'fee' AS TRAN_TYPE,
CASE
WHEN TRANSACTION_TYPE = 'ACFE' AND DEBIT_ACCT_NO LIKE 'PL52%' THEN 'fee_reve'
ELSE 'fee'
END AS TRAN_TYPE_DTL
FROM FT_DETAIL FEE
WHERE FEE_AMT_ORG IS NOT NULL
AND (CUSTOMER_ID IS NOT NULL OR INT_TYPE = 'Y')
UNION ALL
SELECT
TAX.*,
'tax' AS TRAN_TYPE,
'tax' AS TRAN_TYPE_DTL
FROM FT_DETAIL TAX
WHERE TAX_AMT_ORG IS NOT NULL
AND CUSTOMER_ID IS NOT NULL
Currently, I see Flink processing the
FT_DETAIL AS()
query cluster 3 times. Is there a way to make Flink process
FT_DETAIL AS()
only once and then do UNION ALL? Previously when batch processing, I created a temporary table
FT_DETAIL
and truncate them after each run.