Skip to content

[CALCITE-4366] LatticeSuggester should treat UNION and VALUES sub-expressions as tables#2248

Draft
julianhyde wants to merge 5 commits into
apache:mainfrom
julianhyde:4366-lattice-union
Draft

[CALCITE-4366] LatticeSuggester should treat UNION and VALUES sub-expressions as tables#2248
julianhyde wants to merge 5 commits into
apache:mainfrom
julianhyde:4366-lattice-union

Conversation

@julianhyde

Copy link
Copy Markdown
Contributor

No description provided.

…ressions as tables

We achieve this by adding a wrapper table function in the
RelNode tree above any UNION or VALUES after sql-to-rel but
before calling LatticeSuggester.

If the UNION or VALUES expression is a common-table expression
(i.e. in the WITH clause), use the name of the WITH clause
table and columns for the dummy table. That allows use to
generate a nicer model later.

Add SqlToRelConverter.Config.postStep(), to apply a
user-specified transform to a RelNode after sql-to-rel
conversion. (We could make decorrelation use this hook.)

Implement getCursorOperand(int) in RexCallBinding, so that
when you call RelBuilder.tableFunctionScan the row-type can
be deduced in terms of the relational input(s).

Refactor LatticeSuggesterTest to make it easier to write
tests with custom config.
@vlsi

vlsi commented Nov 6, 2020

Copy link
Copy Markdown
Contributor

@julianhyde , Could you please refrain from adding @Nonnull?
It should be a default mode, so there's no point in adding @Nonnull.

It would be nice if you could annotate nullable (e.g. in case you expect something to receive or return null)

return new BaseColRef(tableRef, offset);
}
};
} else if (r instanceof TableFunctionScan) {

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 missed that this is checking for TableFunctionScan and that my wrapper extended TableScan. Should I rework my wrapper to be a TFS or should this be checking for TableScan?

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.

Ideally, you would throw away your code and move the logic into LatticeSuggester.

But failing that, use a TableFunctionScan that calls the WRAP function. Calls to any other table function will not be treated as wrappers.

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.

3 participants