PRQL / prql

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement
https://prql-lang.org
Apache License 2.0
9.58k stars 208 forks source link

feat: prqlc compile --debug-log #4646

Closed aljazerzen closed 1 week ago

aljazerzen commented 1 week ago

Adds a framework for capturing debug information during the compilation process.

First stab at #4636

The result can be serialized into JSON or rendered into HTML (image below). Current display is not much better than plain terminal output, but this has potential for better visualization of what is going on in the compiler.

image

aljazerzen commented 1 week ago

Actually, this PR is combination of the two things you've suggested.

  1. --debug-log=my_log.json will create a JSON file with all of the AST reprs emitted. This file could probably be read back and rendered to the HTML output,
  2. the debug log should contain basically all intermediate information that compiler has. The idea is to replace various commands we have with these "debug log entries", so a normal compile invocation produces all that you need. ATM, we are 80% there.
max-sixty commented 1 week ago

Actually, this PR is combination of the two things you've suggested.

Yes! My musing was whether splitting it up made sense (but really just a musing and maybe not that useful..)

aljazerzen commented 1 week ago

More refinement: image

max-sixty commented 1 week ago

I tried this out — really really cool! Very impressive you could pull together a UI so quickly!


FWIW when I try I don't get the highlights across the different stages (like in your query) unless I select the whole query, but possibly that's because the spans aren't serialized yet.


Other small thoughts (obv you are the owner and so only consider these if they're useful, am strongly not trying to say these are necessarily good)

aljazerzen commented 1 week ago

integrate with playground? Maybe that's more work than it saves though. Mostly similar goals (would want a check-box to show / hide, similar to what we have with outputting PL & RQ now)

Yes, this is possible to do. We just need to expose the --debug-log argument to JS bindings somehow. We'd probably change the type signature, so the debug log is returned instead of written into a file.


minor but it would be v nice to have the stages in each column, so we can see across them — i.e. "what RQ comes from this expression"

This is easy to do! Newer versions are somewhat easier to parse visually, so it might not even be needed, but yes, can be done.