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

Cleanup of TPC handling #32891

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Cleanup of TPC handling #32891

merged 1 commit into from
Jan 24, 2024

Conversation

roji
Copy link
Member

@roji roji commented Jan 22, 2024

Our current TPC design uses a special TableExpressionBase - TpcTablesExpression - to represent the potential set of table queries that will be needed. In postprocessing, TpcTablesExpressionRemovingExpressionVisitor reduces TpcTablesExpression to actual unioned subqueries, based on the concrete entity types that are actually needed.

This refactor does two main things:

  • It removes _tpcDiscriminatorValues from SelectExpression. This was private state which specified - for each TpcTablesExpression contained in the SelectExpression - the discriminator column and actual needed discriminator values. This information was moved onto TpcTablesExpression itself.
  • Make TpcTablesExpressionRemovingExpressionVisitor a fully immutable visitor, rather than mutating the tree.

@roji roji requested a review from a team January 22, 2024 23:24
if (newList.Count > 0)
{
_tpcDiscriminatorValues[leftTpc] = (leftColumn, newList);
tpcExpression.DiscriminatorValues = newList;
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is mutation, but it occurs in ApplyPredicate, when the whole SelectExpression is still in mutable state. If we end up making SelectExpression fully mutable always, we'll change this to produce a copy.

@@ -47,8 +47,8 @@ SELECT COUNT(*)
UNION ALL
SELECT [k].[CountryId]
FROM [Kiwi] AS [k]
) AS [t]
WHERE [t].[CountryId] = 1 AND [c].[Id] = [t].[CountryId] AND [t].[CountryId] > 0) > 0
) AS [u]
Copy link
Member Author

Choose a reason for hiding this comment

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

Test baselines are only alias changes from t to u (i.e. union).

@roji roji merged commit 8b95f6a into dotnet:main Jan 24, 2024
7 checks passed
@roji roji deleted the TpcDiscriminatorValues branch January 24, 2024 07:48
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