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

append is buggy with a bit of logic in tables #4947

Open
2 tasks done
PrettyWood opened this issue Oct 10, 2024 · 2 comments
Open
2 tasks done

append is buggy with a bit of logic in tables #4947

PrettyWood opened this issue Oct 10, 2024 · 2 comments
Labels
bug Invalid compiler output or panic

Comments

@PrettyWood
Copy link
Collaborator

What happened?

Still working on a query builder to convert transformation steps into SQL via PRQL
We have an issue with append that doesn't seem to work well with basic tables
I'm more than happy to help on debugging this

PRQL input

from `albums`
select { `album_id`, `title` }
sort {+`album_id`}
take 2
append (
  from `albums`
  select { `album_id`, `title` }
  sort {-`album_id`}
  take 2
)

SQL output

fails

Expected SQL output

WITH table_0 AS (
  SELECT
    album_id,
    title
  FROM
    albums
  ORDER BY
    album_id DESC
  LIMIT
    2
)
SELECT
  *
FROM
  (
    SELECT
      album_id,
      title
    FROM
      albums
    ORDER BY
      album_id
    LIMIT
      2
  ) AS table_1
UNION
ALL
SELECT
  *
FROM
  table_0

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

No response

@PrettyWood PrettyWood added the bug Invalid compiler output or panic label Oct 10, 2024
@PrettyWood PrettyWood changed the title append is buggy with subtables append is buggy with a bit of logic in tables Oct 10, 2024
@PrettyWood
Copy link
Collaborator Author

It may be the same bug as #4063. I'll start digging

@richb-hanover
Copy link
Contributor

Interesting serendipity (of timing). Just this morning, I was looking at this and #5055 which has a similar pattern. Rewriting the original query as follows works as expected in the current Playground.

I wonder if the fix from @lukapeshke will address #5055 as well...

# ==== from #4947 - rewritten
let a = (
from `albums`
select { `album_id`, `title` }
sort {+`album_id`}
take 2
)

let b = (
  from `albums`
  select { `album_id`, `title` }
  sort {-`album_id`}
  take 2
)
from a
append b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Invalid compiler output or panic
Projects
None yet
Development

No branches or pull requests

2 participants