Skip to content

[CALCITE-7575] Parser can not parse unparsed polymorphic table functions with several table args#4984

Merged
snuyanzin merged 1 commit into
apache:mainfrom
snuyanzin:calcite7575
Jun 7, 2026
Merged

[CALCITE-7575] Parser can not parse unparsed polymorphic table functions with several table args#4984
snuyanzin merged 1 commit into
apache:mainfrom
snuyanzin:calcite7575

Conversation

@snuyanzin

Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7575

Changes Proposed

The PR is to support parsing of queries with PTF (polymorphic table functions) with several table args like

SELECT * FROM TABLE(MY_PTF(
(SELECT * FROM table1) PARTITION BY a,
(SELECT * FROM table2) PARTITION BY b))

e = LambdaExpression()
|
e = Expression(exprContext)
// A set-semantics table argument may be a partitioned sub-query, e.g.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part of the language reference does this correspond to?

@snuyanzin snuyanzin Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is SQL:2016 Polymorphic Table Functions (ISO/IEC 9075-2:2016)

the problem with current implementation is that it covers only first arg of table function and doesn't cover any other arg.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, in the reference.md file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, then this line

* A polymorphic table function may have multiple input tables. However,
at most one input table could have row semantics.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for PARTITION BY in the grammar, but no place seemed to match what you are not parsing

@snuyanzin snuyanzin Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, seems it is missing details for PTF in reference.md
It was solved (for the first arg) in CALCITE-6944, also a number of references in this comment https://issues.apache.org/jira/browse/CALCITE-6944?focusedCommentId=17945242&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17945242
here I'm following the same approach for other(non-first) args

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you then please update the grammar as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, added

Comment thread site/_docs/reference.md
A PTF may have more than one table argument, each with its own semantics,
partitioning and ordering; at most one of them may have row semantics.

| Operator syntax | Description

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a table needed for a single row?
Or is this for symmetry with other operators?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it is optional
here in reference just because of symmetry

@sonarqubecloud

sonarqubecloud Bot commented Jun 6, 2026

Copy link
Copy Markdown

@snuyanzin

Copy link
Copy Markdown
Contributor Author

squashed and rebased before merging

@snuyanzin snuyanzin merged commit 8741cdc into apache:main Jun 7, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants