posit-dev / posit-dev/ggsql-duckdb

Parser rejects table-valued function column alias syntax (range(10) t(x))

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
32
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Hi, I was using this tool with DuckDB, but I ran into this issue. I tried various workarounds, and here's what I found. Thanks!

Environment

  • ggsql DuckDB extension version: v0.4.1
  • DuckDB version: v1.5.4
  • Installed via: INSTALL ggsql FROM community; LOAD ggsql;
  • OS: MacOS

Description

The README in posit-dev/ggsql-duckdb documents the following as a working example:

SELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line;

And via the scalar function:

SELECT ggsql('SELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line');

Both produce a parse error on v0.4.1:

memory D SELECT ggsql('SELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line');
Invalid Input Error:
ggsql: Parse error: Parse tree contains errors

Steps to reproduce

INSTALL ggsql FROM community;
LOAD ggsql;
SELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line;

Probable issue

ggsql parser does not handle DuckDB's table-valued function column alias syntax range(10) t(x)

Workaround

Using a CTE with unnest(range(10)) works correctly:

WITH nums AS (SELECT unnest(range(10)) AS x)
SELECT x, x*x AS y FROM nums
VISUALISE x, y
DRAW line;

The README example in posit-dev/ggsql-duckdb is broken and should be
updated to use the CTE workaround until this is fixed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the SQL reproduction from the issue against the documented README example, then compare it with the working CTE workaround. Trace how ggsql parses the table-valued function alias syntax range(10) t(x). Done means the documented query parses successfully, or the README is updated to use the CTE workaround until parser support is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.