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

ORDER BY caluse of INSERT INTO statement is unexpectantly eliminated #22422

Closed
liuyehcf opened this issue Jun 18, 2024 · 1 comment
Closed

ORDER BY caluse of INSERT INTO statement is unexpectantly eliminated #22422

liuyehcf opened this issue Jun 18, 2024 · 1 comment

Comments

@liuyehcf
Copy link

liuyehcf commented Jun 18, 2024

In version 427

The following insert into statement works fine.

INSERT INTO reason (
  r_reason_sk,
  r_reason_id,
  r_reason_desc
) SELECT
  r_reason_sk,
  r_reason_id,
  r_reason_desc
FROM tpcds.sf1.reason
ORDER BY r_reason_sk;

In version 449, the order by is eliminated

INSERT INTO reason (
  r_reason_sk,
  r_reason_id,
  r_reason_desc
) SELECT
  r_reason_sk,
  r_reason_id,
  r_reason_desc
FROM tpcds.sf1.reason
ORDER BY r_reason_sk;

img_v3_02bv_dc290cc3-e9d9-4f01-a33f-bc1cd2c06fhu

I think this is a bug? the order by is meaningful, cannot be simply eliminated.

@liuyehcf liuyehcf changed the title Question: ORDER BY in subquery may have no effect [Bug]: ORDER BY caluse of INSERT INTO statement is unexpectantly eliminated Jun 19, 2024
@liuyehcf liuyehcf changed the title [Bug]: ORDER BY caluse of INSERT INTO statement is unexpectantly eliminated ORDER BY caluse of INSERT INTO statement is unexpectantly eliminated Jun 19, 2024
@raunaqmorarka
Copy link
Member

This is by design
See
#19547
#18159
#818
#759 (comment)

You need to use sorted_by table property in the relevant connector to enforce an ordered physical layout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants