Skip to content

Add table metadata changes for statistics information in table metadata - #5450

Merged
rdblue merged 1 commit into
apache:masterfrom
findepi:findepi/stats-table-metadata
Aug 24, 2022
Merged

rdblue merged 1 commit into
apache:masterfrom
findepi:findepi/stats-table-metadata

Conversation

@findepi

@findepi findepi commented Aug 5, 2022

Copy link
Copy Markdown
Member

Extracted from #5021

#5021 (comment)

Comment thread .palantir/revapi.yml Resolved
@findepi
findepi force-pushed the findepi/stats-table-metadata branch 2 times, most recently from 30f6308 to 6b6ca9e Compare August 8, 2022 10:00
@findepi

findepi commented Aug 8, 2022

Copy link
Copy Markdown
Member Author

Thanks @rdblue for a thorough review. Comments applied, please take another look if you want.

@findepi
findepi force-pushed the findepi/stats-table-metadata branch 3 times, most recently from 76d0743 to c00b965 Compare August 11, 2022 13:02
@findepi

findepi commented Aug 11, 2022

Copy link
Copy Markdown
Member Author

Per #5450 (comment), i have rebased this off of #5021.

@rdblue please take another look when you want

}
}

class RemoveStatistics implements MetadataUpdate {

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.

When is this going to be used? Should we have a single ReplaceStatistics operation that is idempotent instead?

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.

When working on Trino stats support in Hive and Delta we found out that ability to remove stats is useful. We need a way to remove statistics from a table, for example if we detect that application that wrote stats did it incorrectly, or when stats are correct, but a query engine makes wrong conclusions using those stats and plans are bad in practice.

@rdblue how would you want to model this?

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.

That sounds good to me. Is SetStatistics intended to be idempotent? That would make sense so that we don't need both remove and set if we want to replace.

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.

Yes, SetStatistics should be idempotent and also should allow replacing an existing stat file, so we don't need remove when we want to set.

@findepi
findepi force-pushed the findepi/stats-table-metadata branch from c00b965 to c5ad62f Compare August 23, 2022 12:33
@findepi

findepi commented Aug 23, 2022

Copy link
Copy Markdown
Member Author

Thanks @rdblue for your review. Updated the PR thanks to your suggestions.
Open questions: #5450 (comment) and optionally #5450 (comment)

private long currentSnapshotId;
private List<Snapshot> snapshots;
private final Map<String, SnapshotRef> refs;
private final Map<Long, List<StatisticsFile>> statisticsFiles;

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.

Why use a multimap? Shouldn't setStatistics replace the previous file? I think that's the behavior that is currently implemented, so I think this should just be a regular map to ensure there aren't somehow multiple files for a snapshot ID.

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.

Why use a multimap?

This is so per #5021 (comment)

Please clarify where I can use a Map and where I should not, the lifecycle of these metadata objects is still not crystal clear to me

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.

Okay, so the idea is to simply preserve cases where there are multiple stats files? I guess I'm okay with that. I'd also be fine with discarding one of them.

@findepi
findepi force-pushed the findepi/stats-table-metadata branch from c5ad62f to ad6c355 Compare August 24, 2022 20:37
@rdblue

rdblue commented Aug 24, 2022

Copy link
Copy Markdown
Contributor

Looks good. I'll merge when tests are passing.

@findepi

findepi commented Aug 24, 2022

Copy link
Copy Markdown
Member Author

Looks good. I'll merge when tests are passing.

thanks for all the review comments!

@rdblue
rdblue merged commit 007ef6e into apache:master Aug 24, 2022
@rdblue

rdblue commented Aug 24, 2022

Copy link
Copy Markdown
Contributor

Thanks, @findepi!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants