Skip to content

Cleanup metadata manager#10091

Merged
dain merged 22 commits intotrinodb:masterfrom
dain:cleanup-metadata-manager
Dec 20, 2021
Merged

Cleanup metadata manager#10091
dain merged 22 commits intotrinodb:masterfrom
dain:cleanup-metadata-manager

Conversation

@dain
Copy link
Copy Markdown
Member

@dain dain commented Nov 28, 2021

Metadata is being used as a dumping ground for unrelated services, because it is present in all places in the analyzer and optimizer. This PR makes more parts of the analyzer injectable, and remove most unnecessary services from metadata manager.

@dain dain requested review from electrum and martint November 28, 2021 21:38
@cla-bot cla-bot bot added the cla-signed label Nov 28, 2021
@dain dain force-pushed the cleanup-metadata-manager branch from 01dfcf8 to 81b718c Compare December 4, 2021 20:51
@dain dain force-pushed the cleanup-metadata-manager branch 3 times, most recently from c307fab to a9d2a16 Compare December 5, 2021 22:06
@dain dain force-pushed the cleanup-metadata-manager branch 4 times, most recently from 7fa8be0 to 75c801b Compare December 18, 2021 03:54
Copy link
Copy Markdown
Member

@martint martint left a comment

Choose a reason for hiding this comment

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

Reviewed up to "Remove SessionPropertyManager from Metadata"

@dain dain force-pushed the cleanup-metadata-manager branch 3 times, most recently from 2987b03 to 4b6fdd2 Compare December 18, 2021 20:52
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could convert this to LoadingCache now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make sense to extract Metadata in the constructor for all of these, since that's the only field they use?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All of these tasks actually use the planner context. The downstream services need it.

@dain dain force-pushed the cleanup-metadata-manager branch from 4b6fdd2 to 17fa973 Compare December 20, 2021 00:47
@dain dain merged commit c13f952 into trinodb:master Dec 20, 2021
@dain dain deleted the cleanup-metadata-manager branch December 20, 2021 02:13
@github-actions github-actions bot added this to the 367 milestone Dec 20, 2021
.addAll(new UnwrapRowSubscript().rules())
.addAll(new PushCastIntoRow().rules())
.addAll(new UnwrapCastInComparison(metadata, typeOperators, typeAnalyzer).rules())
.addAll(new UnwrapCastInComparison(plannerContext, typeAnalyzer).rules())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any reason why planner context doesn't include the type analyzer?

new RemoveRedundantIdentityProjections(),
new PushDownProjectionsFromPatternRecognition())),
new MetadataQueryOptimizer(metadata),
new MetadataQueryOptimizer(plannerContext),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The choice which optimizers now take plannerContext and which continue to take metadata looks arbitrary. What's the rule?

Session session,
Expression predicate,
TypeProvider types)
public static ExtractionResult getExtractionResult(PlannerContext plannerContext, Session session, Expression predicate, TypeProvider types)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Update TestDomainTranslator.testFrom*Predicate* methods


@Inject
public TypeAnalyzer(SqlParser parser, Metadata metadata)
public TypeAnalyzer(PlannerContext plannerContext, StatementAnalyzerFactory statementAnalyzerFactory, AccessControl accessControl)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Previous TypeAnalyzer signature was: TypeAnalyzer(SqlParser parser, Metadata metadata).
That was kind of easy to understand.
Why does it need all these things now?
@martint can you perhaps explain this to me?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In particular, in a unit test i could create TypeAnalyzer like this

TypeAnalyzer typeAnalyzer = new TypeAnalyzer(new SqlParser(), createTestMetadataManager());

Now it seems this takes

Metadata metadata = createTestMetadataManager();
TypeOperators typeOperators = new TypeOperators();
InternalTypeManager typeManager = new InternalTypeManager(new TypeRegistry(typeOperators, new FeaturesConfig()));
PlannerContext plannerContext = new PlannerContext(
        metadata,
        typeOperators,
        new InternalBlockEncodingSerde(new BlockEncodingManager(), typeManager),
        TESTING_TYPE_MANAGER);
TypeAnalyzer typeAnalyzer = createTestingTypeAnalyzer(plannerContext);

to get same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants