Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First attempt at supporting functionCall in FROM #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

FrigoEU
Copy link
Contributor

@FrigoEU FrigoEU commented Mar 23, 2021

Hi,

As mentioned in #123, this is my first attempt at supporting function calls in FROM clauses.

I changed the infer module a bit to support both SourceColumn and VirtualField in a bunch of places. I think this will kinda work, but it definitely has some limitations:

  • Only functions that return (arrays of) a single value are supported. Functions that return records aren't supported.
  • Overloaded functions probably aren't handled correctly either.

Very first try, so I'm happy to get any feedback at all!

@akheron
Copy link
Owner

akheron commented Mar 23, 2021

Thanks for the PR!

I think we should first add support for just unnest with one literal parameter, i.e. to just support your use case. Otherwise this rabbit hole is going to be too deep for one PR or even two 😄

In this case, you could just return an array of one column from getSourceColumnsForTableExpr, and there would be no need to call inferExpressionNullability at all. Calling it doesn't really make sense in this case, because the function call evaluates to a table.

I think using SourceColumn would be more appropriate than VirtualField, which is really meant for output columns. You could change the type of tableAlias to string | undefined and see which parts break. This would also avoid the uglyish hack of isSourceColumn type guard.

@akheron
Copy link
Owner

akheron commented Mar 27, 2021

@FrigoEU do you plan to work on this or wanna me to take over?

@FrigoEU
Copy link
Contributor Author

FrigoEU commented Mar 27, 2021 via email

@akheron
Copy link
Owner

akheron commented Mar 27, 2021

Well, I don’t have a very strong opinion. I just noticed all the SourceColumn | VirtualField in the diff and thought that it’s not optimal.

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