[
https://issues.apache.org/jira/browse/CALCITE-2752?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16727790#comment-16727790
]
Marc Prud'hommeaux commented on CALCITE-2752:
---------------------------------------------
As an aside, it would be nice if RelJsonWriter & RelJsonReader were generally
better tested; adding a round-tripping-via-JSON-retains-fidelity stage to some
of the tests would help shake out a lot of bugs. Being able to serialize
RelNodes to JSON could be a very powerful feature, enabling tools that
manipulate RelNodes directly and communicate with Calcite via the externalized
JSON forms.
> Round-tripping RelNode via RelJson corrupts decimal literals
> ------------------------------------------------------------
>
> Key: CALCITE-2752
> URL: https://issues.apache.org/jira/browse/CALCITE-2752
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.17.0
> Reporter: Marc Prud'hommeaux
> Assignee: Julian Hyde
> Priority: Major
>
> The SQL statement "VALUES 1.23" when parsed and converted into a RelNode is
> explained as "1:LogicalValues(tuples=[[\{ 1.23 }]])". So far so good.
>
> Then writing it out with a RelJsonWriter yields:
>
> {code:java}
> {
> "rels": [
> {
> "id": "0",
> "relOp": "LogicalValues",
> "type": [
> {
> "type": "DECIMAL",
> "nullable": false,
> "precision": 3,
> "scale": 2,
> "name": "EXPR$0"
> }
> ],
> "tuples": [
> [
> 123
> ]
> ],
> "inputs": []
> }
> ]
> }
> {code}
>
> When it is read back in with a RelJsonReader, the new RelNode is explained as
> "2:LogicalValues(tuples=[[\{ 123 }]])" and the re-built SQL from
> RelToSqlConverter is: SELECT * FROM (VALUES (123)) AS "t" ("EXPR$0").
>
> I can't quite tell if the fault lies with the RelJsonWriter (for writing out
> "123") or the RelJsonReader (for not re-building the decimal using the
> "precision" and "scale" arguments).
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)