feat: add support for the XMLTABLE table function - #2458
Open
fudianchn wants to merge 2 commits into
Open
Conversation
XMLTABLE (SQL/XML standard, supported by PostgreSQL and Oracle) turns an XML document into a relational row set. It is the XML counterpart of JSON_TABLE and shares its PASSING/COLUMNS structure, so it mirrors the existing JsonTableFunction without the JSON-specific clauses. Adds an XmlTableFunction AST node plus a grammar branch in the TableFunction dispatch covering: - a row XPath expression - an optional PASSING clause (value [AS name], ...) - an optional COLUMNS clause with FOR ORDINALITY, data type, PATH and DEFAULT per column Round-trips through parse/deparse and is wired into the expression visitor, deparser, table-names finder and validator. Fixes JSQLParser#2326 Signed-off-by: 付典 <fudianchn@gmail.com>
fudianchn
force-pushed
the
feat/xmltable-2326
branch
from
August 8, 2026 19:13
ad1d746 to
6752cc6
Compare
Each inner class declared an empty public no-arg constructor as its only constructor, which is redundant — the compiler generates an equivalent default constructor (Codacy PMD UnnecessaryConstructor). Removed both; the grammar and tests that instantiate them with `new ...Clause()` are unaffected. Verified locally: full build + XmlTableTest pass on JDK 17; javap confirms the default constructor is still synthesized. Refs JSQLParser#2326 Signed-off-by: 付典 <fudianchn@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2326.
XMLTABLE(SQL/XML standard, supported by PostgreSQL and Oracle) projects an XML document into a relational row set. JSQLParser currently fails to parse it, e.g. the PostgreSQL manual example:It is the XML counterpart of
JSON_TABLEand shares itsPASSING/COLUMNSstructure, so this mirrors the existingJsonTableFunction:XmlTableFunctionAST node: a row XPath expression, an optionalPASSING value [AS name], ...clause, and an optionalCOLUMNSclause withname FOR ORDINALITYorname <type> [PATH expr] [DEFAULT expr]per column;XmlTableBodybranch in theTableFunctiondispatch;ExpressionVisitor,ExpressionDeParser,ExpressionVisitorAdapter,TablesNamesFinderandExpressionValidator.The JSON-specific clauses (wrapper, error/empty handling, plan, NESTED) are intentionally out of scope, and
XMLNAMESPACESwould be a natural follow-up.Testing
XmlTableTestwith parameterised parse/deparse round-trips (incl. the issue example, quoted column names, bracket XPath,DEFAULT, multiplePASSINGarguments) plus AST assertions on the column structure../gradlew test --tests net.sf.jsqlparser.expression.XmlTableTestis green; the full suite shows no new failures vs.master../gradlew spotlessCheckpasses.