Hi,
Suppose I have 3 tables , record different wallet event:
-deposit
-withdraw
-transfer
Because the schema are similar, I want to transform the three source tables into single destination table. If I create sqlx definitions and each config specific same table name:
-wallet_event_deposit.sqlx
config {
type: "table",
name: "wallet_event"
}
SELECT
user_id,
event_type,
balance,
..
FROM deposit
-wallet_event_withdraw.sqlx
config {
type: "table",
name: "wallet_event"
}
SELECT
user_id,
event_type,
balance,
..
FROM withdraw
-wallet_event_transfer.sqlx
config {
type: "table",
name: "wallet_event"
}
SELECT
user_id,
event_type,
balance,
..
FROM transfer
then the workspace will return error:
Duplicate action name detected. Names within a schema must be unique across tables, declarations, assertions, and operations.
So I have to write all source sql in same sqlx file and using UNION function to aggregator the result.
-wallet_event.sqlx
SELECT
..
FROM deposit ...
UNION ALL
SELECT
..
FROM withdraw ...
UNION ALL
SELECT
..
FROM transfer ...
I wonder
1. If there is a way to split source sqlx file and insert into same table?
2. Is UNION the best practice for this scenario?