Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Spill is not open for merge into. #13930

Open
2 tasks done
JackTan25 opened this issue Dec 5, 2023 · 2 comments
Open
2 tasks done

bug: Spill is not open for merge into. #13930

JackTan25 opened this issue Dec 5, 2023 · 2 comments
Assignees
Labels
C-bug Category: something isn't working

Comments

@JackTan25
Copy link
Contributor

Search before asking

  • I had searched in the issues and found no similar issues.

Version

35f129c

What's Wrong?

in xsmall, when execute

MERGE INTO transactions USING (
    SELECT t.user_id, t.asset_type,
           SUM(t.quantity) AS total_quantity
    FROM transactions t
    GROUP BY t.user_id, t.asset_type
    UNION ALL
    SELECT t.user_id, 'NEW_TRANSACTION' AS asset_type,  -- New transaction type for insert
           30 AS quantity                                -- Example quantity
    FROM transactions t
    WHERE t.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY t.user_id
) AS combined_transactions ON transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.user_id, 'trade', combined_transactions.asset_type, combined_transactions.total_quantity, '2023-01-01');

MERGE INTO transactions USING (
  SELECT
    t.user_id,
    t.asset_type,
    SUM(t.quantity) AS total_quantity
  FROM
    transactions t
  GROUP BY
    t.user_id,
    t.asset_type
  UNION
  ALL
  SELECT
    t.user_id,
    'NEW_TRANSACTION' AS asset_type,
    30 AS quantity
  FROM
    transactions t
  WHERE
    t.user_id % 2 = 0
  GROUP BY
    t.user_id
) AS combined_transactions ON transactions.asset_type = combined_transactions.asset_type
WHEN MATCHED THEN
UPDATE
SET
  transactions.quantity = combined_transactions.total_quantity
  WHEN NOT MATCHED THEN
INSERT
  (
    user_id,
    transaction_type,
    asset_type,
    quantity,
    transaction_time
  )
VALUES
  (
    combined_transactions.user_id,
    'trade',
    combined_transactions.asset_type,
    combined_transactions.total_quantity,
    '2023-01-01'
  )

memory oversize.

How to Reproduce?

mergeinto> MERGE INTO transactions USING (
    SELECT t.user_id, t.asset_type,
           SUM(t.quantity) AS total_quantity
    FROM transactions t
    GROUP BY t.user_id, t.asset_type
    UNION ALL
    SELECT t.user_id, 'NEW_TRANSACTION' AS asset_type,  -- New transaction type for insert
           30 AS quantity                                -- Example quantity
    FROM transactions t
    WHERE t.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY t.user_id
) AS combined_transactions ON transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.user_id, 'trade', combined_transactions.asset_type, combined_transactions.total_quantity, '2023-01-01');

MERGE INTO transactions USING (
  SELECT
    t.user_id,
    t.asset_type,
    SUM(t.quantity) AS total_quantity
  FROM
    transactions t
  GROUP BY
    t.user_id,
    t.asset_type
  UNION
  ALL
  SELECT
    t.user_id,
    'NEW_TRANSACTION' AS asset_type,
    30 AS quantity
  FROM
    transactions t
  WHERE
    t.user_id % 2 = 0
  GROUP BY
    t.user_id
) AS combined_transactions ON transactions.asset_type = combined_transactions.asset_type
WHEN MATCHED THEN
UPDATE
SET
  transactions.quantity = combined_transactions.total_quantity
  WHEN NOT MATCHED THEN
INSERT
  (
    user_id,
    transaction_type,
    asset_type,
    quantity,
    transaction_time
  )
VALUES
  (
    combined_transactions.user_id,
    'trade',
    combined_transactions.asset_type,
    combined_transactions.total_quantity,
    '2023-01-01'
  )

error happens after fetched 0 rows: APIError: PageError with 1104: memory usage 25.8 GB(25770320620) exceeds limit 25.8 GB(25769803776)
0 row read in 14.572 sec. Processed 2.35 million row, 51.33 MiB (160.98 thousand row/s, 3.52 MiB/s)

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@JackTan25 JackTan25 added the C-bug Category: something isn't working label Dec 5, 2023
@JackTan25 JackTan25 self-assigned this Dec 5, 2023
@zenus
Copy link
Contributor

zenus commented Dec 6, 2023

/ assign me

@BohuTANG
Copy link
Member

BohuTANG commented Dec 6, 2023

@zenus Thanks for taking but this is a bit complex, @JackTan25 already working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants