-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-21127] [SQL] Update statistics after data changing commands #18334
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -437,7 +437,20 @@ case class AlterTableAddPartitionCommand( | |
| } | ||
| catalog.createPartitions(table.identifier, parts, ignoreIfExists = ifNotExists) | ||
|
|
||
| CommandUtils.updateTableStats(sparkSession, table) | ||
| if (table.stats.nonEmpty) { | ||
| if (sparkSession.sessionState.conf.autoUpdateSize) { | ||
| val addedSize = parts.map { part => | ||
| CommandUtils.calculateLocationSize(sparkSession.sessionState, table.identifier, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the function
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, shall we log in info level or debug level?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. INFO should be fine, because it should not be a lot, right? |
||
| part.storage.locationUri) | ||
| }.sum | ||
| if (addedSize > 0) { | ||
| val newStats = CatalogStatistics(sizeInBytes = table.stats.get.sizeInBytes + addedSize) | ||
| catalog.alterTableStats(table.identifier, Some(newStats)) | ||
| } | ||
| } else { | ||
| catalog.alterTableStats(table.identifier, None) | ||
| } | ||
| } | ||
| Seq.empty[Row] | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the log message contains the timestamp. It does not need to calculate the total time, but I think it is fine here.