Prevent panic when using table functions in joins and subqueries #3299
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.
This prevents the panic seen in dolthub/dolt#10051
The join planner assumed that every instance of TableAlias wrapped an implementer of sql.TableNode.
Only tables that support lookups implement sql.TableNode. Table functions that are not backed by an actual table and don't support lookups do not implement this interface.
This panic is happening when testing to see whether we can optimize a join into a RightSemiJoin. The table needs to support lookups for this optimization to be allowed. So if it doesn't implement
sql.TableNode, it suffices to skip this join plan, since we wouldn't be able to produce it away.This does not fix the broader issue of dolthub/dolt#10051, which is that it is currently impossible for table functions that accept non-literal arguments to support efficient lookups. I'm not currently aware of any use cases where this is required, but I'll keep the issue open to track it in case we need to support that in the future.