Skip to content

universal query for place#249

Open
thomasp85 wants to merge 1 commit intoposit-dev:mainfrom
thomasp85:PLACE-AS
Open

universal query for place#249
thomasp85 wants to merge 1 commit intoposit-dev:mainfrom
thomasp85:PLACE-AS

Conversation

@thomasp85
Copy link
Collaborator

This PR fixes the query PLACE uses to create its data so that it is universal and works with the SQLite reader (and by extension in the wasm build)

@thomasp85 thomasp85 requested a review from georgestagg March 20, 2026 12:41
Copy link
Collaborator

@georgestagg georgestagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work, at least for this example:

Image

I can interact with it and the Wasm build updates the plot successfully.


However, there is an issue with the following example:

VISUALISE FROM ggsql:airquality
  PLACE rect SETTING
    xmin => '1973-06-01', 
    xmax => '1973-06-30',
    ymin => 50, 
    ymax => 100,
    colour => 'dodgerblue'
  DRAW line MAPPING Date AS x, Temp AS y
Execute error: ReaderError("Failed to prepare SQL: near \"'1970-01-01'\": syntax error in SELECT * FROM (WITH __ggsql_values__(\"pos1min\", \"pos2min\", \"pos1max\", \"pos2max\") AS (VALUES (CAST(DATE '1970-01-01' + INTERVAL 1247 DAY AS DATE), 50, CAST(DATE '1970-01-01' + INTERVAL 1276 DAY AS DATE), 100)) SELECT * FROM __ggsql_values__) AS __schema__ LIMIT 1 at offset 103")

There's a Quarto error in CI, and I don't think that CAST(DATE '1970-01-01' + INTERVAL 1276 DAY AS DATE) is ever going to work in sqlite, since AFAIK it doesn't have real DATE types. We might need to throw an error there instead when running under sqlite and avoid this example, or otherwise accept it will never be interactive even if we fix it :/

@georgestagg
Copy link
Collaborator

Then again, I guess we could convert the date to some Rust value and do the required calculation there, if it is just a fixed calculation that we don't need to delegate to the SQL engine to run over billions of rows?

@thomasp85
Copy link
Collaborator Author

Yeah, this is more an issue with SQLite than with place I think...

We can discuss next week, but I think perhaps the SqlDialect should have a temporal module or something. SQLite does have these facilities they are just horrible to look at...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants