Skip to content

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

Open
snuyanzin wants to merge 1 commit into
apache:mainfrom
snuyanzin:calcite7575
Open

[CALCITE-7575] Parser can not parse unparsed polymorphic table functions with several table args#4984
snuyanzin wants to merge 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?

Copy link
Copy Markdown
Contributor Author

@snuyanzin snuyanzin Jun 1, 2026

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

Copy link
Copy Markdown
Contributor Author

@snuyanzin snuyanzin Jun 1, 2026

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?

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

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