kasakrisz commented on code in PR #4334:
URL: https://github.com/apache/hive/pull/4334#discussion_r1217912003
##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/desc/formatter/TextDescTableFormatter.java:
##########
@@ -248,27 +251,52 @@ private void getViewInfo(StringBuilder tableInfo, Table
table, boolean isOutputP
formatOutput("Original Query:", table.getViewOriginalText(), tableInfo);
formatOutput("Expanded Query:", table.getViewExpandedText(), tableInfo);
if (table.isMaterializedView()) {
- formatOutput("Rewrite Enabled:", table.isRewriteEnabled() ? "Yes" :
"No", tableInfo);
- formatOutput("Outdated for Rewriting:", table.isOutdatedForRewriting()
== null ? "Unknown"
- : table.isOutdatedForRewriting() ? "Yes" : "No", tableInfo);
- tableInfo.append(LINE_DELIM).append("# Materialized View Source table
information").append(LINE_DELIM);
- TextMetaDataTable metaDataTable = new TextMetaDataTable();
- metaDataTable.addRow("Table name", "I/U/D since last rebuild");
- List<SourceTable> sourceTableList = new
ArrayList<>(table.getMVMetadata().getSourceTables());
-
- sourceTableList.sort(Comparator.<SourceTable,
String>comparing(sourceTable -> sourceTable.getTable().getDbName())
- .thenComparing(sourceTable ->
sourceTable.getTable().getTableName()));
- for (SourceTable sourceTable : sourceTableList) {
- String qualifiedTableName = TableName.getQualified(
- sourceTable.getTable().getCatName(),
- sourceTable.getTable().getDbName(),
- sourceTable.getTable().getTableName());
- metaDataTable.addRow(qualifiedTableName,
- String.format("%d/%d/%d",
- sourceTable.getInsertedCount(),
sourceTable.getUpdatedCount(), sourceTable.getDeletedCount()));
- }
- tableInfo.append(metaDataTable.renderTable(isOutputPadded));
+ getMaterializedViewInfo(tableInfo, table, isOutputPadded);
+ }
+ }
+
+ private static void getMaterializedViewInfo(StringBuilder tableInfo, Table
table, boolean isOutputPadded) {
+ formatOutput("Rewrite Enabled:", table.isRewriteEnabled() ? "Yes" : "No",
tableInfo);
+ formatOutput("Outdated for Rewriting:", table.isOutdatedForRewriting() ==
null ? "Unknown"
+ : table.isOutdatedForRewriting() ? "Yes" : "No", tableInfo);
+ tableInfo.append(LINE_DELIM).append("# Materialized View Source table
information").append(LINE_DELIM);
+ TextMetaDataTable metaDataTable = new TextMetaDataTable();
+ metaDataTable.addRow("Table name", "Snapshot");
+ List<SourceTable> sourceTableList = new
ArrayList<>(table.getMVMetadata().getSourceTables());
+
+ sourceTableList.sort(Comparator.<SourceTable, String>comparing(sourceTable
-> sourceTable.getTable().getDbName())
+ .thenComparing(sourceTable ->
sourceTable.getTable().getTableName()));
+
+ MaterializationSnapshotFormatter snapshotFormatter =
+
createMaterializationSnapshotFormatter(table.getMVMetadata().getSnapshot());
+
+ for (SourceTable sourceTable : sourceTableList) {
+ String qualifiedTableName = TableName.getDbTable(
+ sourceTable.getTable().getDbName(),
+ sourceTable.getTable().getTableName());
+ metaDataTable.addRow(qualifiedTableName,
+ snapshotFormatter.getSnapshotOf(qualifiedTableName));
}
+ tableInfo.append(metaDataTable.renderTable(isOutputPadded));
+ }
+
+ private static MaterializationSnapshotFormatter
createMaterializationSnapshotFormatter(
+ MaterializationSnapshot snapshot) {
+ if (snapshot != null && snapshot.getTableSnapshots() != null &&
!snapshot.getTableSnapshots().isEmpty()) {
+ return qualifiedTableName ->
snapshot.getTableSnapshots().get(qualifiedTableName).toString();
Review Comment:
Changed to `Objects.toString()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]