prql icon indicating copy to clipboard operation
prql copied to clipboard

Playground does not display float/decimal results correctly

Open richb-hanover opened this issue 1 year ago • 1 comments

What happened?

Using the public Playground (version 0.12.2), the Playground displays incorrect results for the round function. It seems to be missing the decimal points in the output.

The generated SQL is correct, and pasting that SQL into SQLite shows the expected results.

PRQL input

from [ { a=1 } ]
select {
  math.round 1  1.23,
  math.round 1  4.56
}

SQL output

WITH table_0 AS (
  SELECT
    1 AS a
)
SELECT
  ROUND(1.23, 1),
  ROUND(4.56, 1)
FROM
  table_0

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

Expected SQL output

==== EXPECTED ====

ROUND(1.23, 1)	ROUND(4.56, 1)
1.2	4.6

==== ACTUAL ====

round(1.23, 1)	round(4.56, 1)
12	46         <-- Note the lack of decimal points

MVCE confirmation

  • [ ] Minimal example
  • [ ] New issue

Anything else?

No response

richb-hanover avatar Jul 10 '24 12:07 richb-hanover

This doesn't require math.round, as you can reproduce the missing decimals without it:

from [ { a=1.23 } ]
derive { b=4.56 }

When you select the "Query Results" tab and click "Copy to clipboard" you get this JSON:

[
  {"a": 123, "b": 456}
]

So the playground is just misbehaving when it comes to decimals.

kgutwin avatar Jul 10 '24 14:07 kgutwin