JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

[BUG] JSQLParser 5.4-SNAPSHOT : PostgreSQL : XMLTable function not supported

Open tomershay opened this issue 4 months ago • 0 comments

PostgreSQL official documentation:

https://www.postgresql.org/docs/current/functions-xml.html#FUNCTIONS-XML-PROCESSING-XMLTABLE

Error trying to parse:

Image

Steps to reproduce:

CREATE TABLE xmldata (
    id SERIAL PRIMARY KEY,      -- optional, just for uniqueness
    data XML NOT NULL           -- the XML column
);

-- Optional: Insert some dummy XML for testing
INSERT INTO xmldata (data) VALUES
(
    '<ROWS>
        <ROW id="1">
            <COUNTRY_NAME>Canada</COUNTRY_NAME>
            <COUNTRY_ID>CA</COUNTRY_ID>
            <SIZE unit="sq_km">9984670</SIZE>
            <PREMIER_NAME>Justin Trudeau</PREMIER_NAME>
        </ROW>
        <ROW id="2">
            <COUNTRY_NAME>France</COUNTRY_NAME>
            <COUNTRY_ID>FR</COUNTRY_ID>
            <SIZE unit="sq_mi">248573</SIZE>
        </ROW>
    </ROWS>'
);

SELECT xmltable.*
  FROM xmldata,
       XMLTABLE('//ROWS/ROW'
                PASSING data
                COLUMNS id int PATH '@id',
                        ordinality FOR ORDINALITY,
                        "COUNTRY_NAME" text,
                        country_id text PATH 'COUNTRY_ID',
                        size_sq_km float PATH 'SIZE[@unit = "sq_km"]',
                        size_other text PATH
                             'concat(SIZE[@unit!="sq_km"], " ", SIZE[@unit!="sq_km"]/@unit)',
                        premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified');```

tomershay avatar Oct 12 '25 17:10 tomershay