prql icon indicating copy to clipboard operation
prql copied to clipboard

Suprising errors on small examples

Open snth opened this issue 2 years ago • 1 comments

What's up?

Empty table literal

❯ echo "from [{}]" | prqlc compile
Error: invalid RQ: table ref without columns

wat?

❯ echo "[{}]" | prqlc compile
Error: invalid RQ: table ref without columns

wat?

❯ echo "[]" | prqlc compile
The application panicked (crashed).
Message:  called `Option::unwrap()` on a `None` value
Location: /home/tobias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prql-compiler-0.9.4/src/semantic/lowering.rs:325

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

wat wat?

NULL rows or columns

❯ echo "from tbl|filter false==true" | prqlc compile
SELECT
  *
FROM
  tbl
WHERE
  false = true

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

ok

❯ echo "from tbl|select {}|filter false==true" | prqlc compile
Error:
   ╭─[:1:27]
   │
 1 │ from tbl|select {}|filter false==true
   │                           ──┬──
   │                             ╰──── Unknown name
───╯

wat?

❯ echo "from playlists.csv|take 3|filter false==true" | prqlc compile | duckdb
┌─────────────┬─────────┐
│ playlist_id │  name   │
│    int64    │ varchar │
├───────────────────────┤
│        0 rows         │
└───────────────────────┘

ok

❯ echo "from playlists.csv|take 3|filter false==true|select {}" | prqlc compile | duckdb
┌────────┐
│  NULL  │
│ int32  │
├────────┤
│ 0 rows │
└────────┘
ok

❯ echo "from playlists.csv|take 3|select {}|filter false==true" | prqlc compile | duckdb
Error:
   ╭─[:1:44]
   │
 1 │ from playlists.csv|take 3|select {}|filter false==true
   │                                            ──┬──
   │                                              ╰──── Unknown name
───╯

wat?

Background

I'm trying to create an empty result set for nefarious purposes in the least amount of code necessary and found these along the way.

snth avatar Sep 13 '23 15:09 snth

Great, these are good! (I renamed to make it a bit clearer. Though I appreciate the "wat" reference!)

max-sixty avatar Sep 13 '23 20:09 max-sixty