Re: [BUGS] Invalid YAML output from EXPLAIN - Mailing list pgsql-hackers

From Florian Weimer
Subject Re: [BUGS] Invalid YAML output from EXPLAIN
Date
Msg-id 82sk4yneb3.fsf@mid.bfk.de
Whole thread Raw
In response to Re: [BUGS] Invalid YAML output from EXPLAIN  (Greg Smith <greg@2ndquadrant.com>)
Responses Re: [BUGS] Invalid YAML output from EXPLAIN  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-hackers
* Greg Smith:

> Florian Weimer wrote:
>> It has been claimed before that YAML is a superset of JSON, so why
>> can't the YAML folks use the existing JSON output instead?
>>
>
> Because JSON just crosses the line where it feels like there's so much
> markup that people expect a tool is necessary to read it, which has
> always been the issue with XML too--bad human readability.

But YAML is not human-readable.  There are human-readable subsets of
it, but the general serializers do not produce them, and specific
serializers are difficult to get right (as we've seen).

> EXPLAIN (FORMAT YAML) SELECT * FROM customers WHERE customerid>1000
> ORDER BY zip;
>             QUERY PLAN
> -------------------------------------
> - Plan:                            +
>     Node Type: Sort                +
>     Startup Cost: 4449.30          +
>     Total Cost: 4496.80            +
>     Plan Rows: 19000               +
>     Plan Width: 268                +
>     Sort Key:                      +
>       - zip                        +
>     Plans:                         +
>       - Node Type: Seq Scan        +
>         Parent Relationship: Outer +
>         Relation Name: customers   +
>         Alias: customers           +
>         Startup Cost: 0.00         +
>         Total Cost: 726.00         +
>         Plan Rows: 19000           +
>         Plan Width: 268            +
>         Filter: (customerid > 1000)

What does your parser do with this (equivalent but shorter) YAML
output?

- Plan: !!map   &0 Node Type: Sort   &1 Startup Cost: 4449.30   &2 Total Cost: 4496.80   &3 Plan Rows: &5 19000   &4
PlanWidth: &6 268   Sort Key: ["zip"]   Plans: !!seq     - *0: Seq Scan       Parent Relationship: Outer       Relation
Name:&7 customers       Alias: *7       *1: 0.00       *2: 726.00       *3: *5       *4: *6       Filter: (customerid >
1000)

Looking at the spec, it's rather difficult to come up with a readable
subset which can parsed easily and is general in the sense that it can
express empty strings, strings with embedded newlines, and so on.
YAML's rules for dealing with whitespace are fairly complex, but are
probably needed to get a more compact notation than JSON.

--
Florian Weimer                <fweimer@bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Functional dependencies and GROUP BY
Next
From: Peter Eisentraut
Date:
Subject: Re: Functional dependencies and GROUP BY