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

Compiler Panic with multiple group transforms #3870

Open
2 tasks done
richb-hanover opened this issue Nov 30, 2023 · 7 comments · Fixed by #4037
Open
2 tasks done

Compiler Panic with multiple group transforms #3870

richb-hanover opened this issue Nov 30, 2023 · 7 comments · Fixed by #4037
Labels
bug Invalid compiler output or panic

Comments

@richb-hanover
Copy link
Contributor

richb-hanover commented Nov 30, 2023

What happened?

Using a recent Playground from main 9cc5bc8 in a Dev Container (not the deployed Playground) the PRQL compiler generates an error. PR #3864 now displays an attractive error message when a panic is encountered.

Can I provide any further diagnostic info? Thanks.

PRQL input

from inv=invoices
join item=invoice_items (==invoice_id)

group { inv.billing_city } (

  group { item.name } (
    aggregate {
      ct1 = count inv.name,
    }
  )
)

SQL output

N/A

Expected SQL output

N/A

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

No response

@richb-hanover richb-hanover added the bug Invalid compiler output or panic label Nov 30, 2023
@vanillajonathan
Copy link
Collaborator

I've investigated this a bit using a breakpoint in the browser dev tools.

The PRQL query gets passed (as the variable named value) to the prql.compile method on line 71:

sql = prql.compile(value);

However, no exception gets thrown because the compiler successfully compiles the query (I can compile this query with prqlc too) and returns the SQL query:

SELECT
  item.name,
  COUNT(*) AS ct1
FROM
  invoices AS inv
  JOIN invoice_items AS item ON inv.invoice_id = item.invoice_id
GROUP BY
  item.name

-- Generated by PRQL compiler version:0.10.1 (https://prql-lang.org)

It then passes the SQL query to DuckDB through the c.query method on line 121.

arrow = await c.query(sql);

which throws an Error with the message:

Binder Error: Table "item" does not have a column named "name"
LINE 8:   item.name
          ^

which gets caught and sets the React state duckdbError which is shown if you change tab to the "Query Results" tab.

@aljazerzen
Copy link
Member

That's right @vanillajonathan, this is not a compiler panic, but bad PRQL program.

@max-sixty
Copy link
Member

@vanillajonathan great debugging!

So the issue is that the old version of the compiler didn't have a panic, so the playground doesn't panic. Only the new version of the compiler panics.

So we're all good on #3864 — that works great. Thanks @vanillajonathan .

The remaining piece here is the panic from the compiler.


The error messages Binder Error: Table "item" does not have a column named "name" are because we try and run every query on the duckdb backend. We could adjust that to only run queries when the "Query Results" tab is displayed...

@richb-hanover
Copy link
Contributor Author

I ask more about the "bad program" in #3832 (comment)

@richb-hanover
Copy link
Contributor Author

Here's a screenshot showing the error in main:

image

@haydenflinner
Copy link

I managed to recreate this with this query:

from experiment
select started
append (from experiment | sort started | take 5 | select started)

@kgutwin
Copy link
Collaborator

kgutwin commented Jun 10, 2024

With PR #4582, @haydenflinner 's query returns the error message:

Error:
   ╭─[:3:32]
   │
 3 │ append (from experiment | sort started | take 5 | select started)
   │                                ───┬───
   │                                   ╰───── internal compiler error; tracked at https://github.com/PRQL/prql/issues/3870
───╯

Which makes me think it's related to the sort issue identified in #4063 (which is of course related to this issue somehow as well...)

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

Successfully merging a pull request may close this issue.

6 participants