You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by li...@apache.org on 2024/10/31 02:30:48 UTC
(doris) branch branch-2.1 updated: [improvement](statistics)Add log for estimating hive table row count logic. (#42921) (#42931)
This is an automated email from the ASF dual-hosted git repository.
lijibing pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new d67007c72d9 [improvement](statistics)Add log for estimating hive table row count logic. (#42921) (#42931)
d67007c72d9 is described below
commit d67007c72d99f63d5d3d32140f724479c358400f
Author: Jibing-Li <64...@users.noreply.github.com>
AuthorDate: Thu Oct 31 10:30:41 2024 +0800
[improvement](statistics)Add log for estimating hive table row count logic. (#42921) (#42931)
backport: https://github.com/apache/doris/pull/42921
---
.../doris/datasource/ExternalRowCountCache.java | 1 +
.../doris/datasource/hive/HMSExternalTable.java | 28 ++++++++++++++++++----
.../doris/datasource/iceberg/IcebergUtils.java | 6 ++++-
.../doris/statistics/util/StatisticsUtil.java | 7 +++++-
4 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
index 44aecbca1d5..faf01a49384 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
@@ -108,6 +108,7 @@ public class ExternalRowCountCache {
if (f.isDone()) {
return f.get().orElse(0L);
}
+ LOG.info("Row count for table {}.{}.{} is still processing.", catalogId, dbId, tableId);
} catch (Exception e) {
LOG.warn("Unexpected exception while returning row count", e);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
index 8f10af4bc24..06f1635e2fb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
@@ -526,7 +526,7 @@ public class HMSExternalTable extends ExternalTable implements MTMVRelatedTableI
long rowCount = getRowCountFromExternalSource();
// Only hive table supports estimate row count by listing file.
if (rowCount == -1 && dlaType.equals(DLAType.HIVE)) {
- LOG.debug("Will estimate row count from file list.");
+ LOG.info("Will estimate row count for table {} from file list.", name);
rowCount = getRowCountFromFileList();
}
return rowCount;
@@ -839,14 +839,16 @@ public class HMSExternalTable extends ExternalTable implements MTMVRelatedTableI
return -1;
}
if (isView()) {
+ LOG.info("Table {} is view, return 0.", name);
return 0;
}
HiveMetaStoreCache.HivePartitionValues partitionValues = getAllPartitionValues();
// Get files for all partitions.
int samplePartitionSize = Config.hive_stats_partition_sample_size;
- List<HiveMetaStoreCache.FileCacheValue> filesByPartitions = getFilesForPartitions(partitionValues,
- samplePartitionSize);
+ List<HiveMetaStoreCache.FileCacheValue> filesByPartitions =
+ getFilesForPartitions(partitionValues, samplePartitionSize);
+ LOG.info("Number of files selected for hive table {} is {}", name, filesByPartitions.size());
long totalSize = 0;
// Calculate the total file size.
for (HiveMetaStoreCache.FileCacheValue files : filesByPartitions) {
@@ -865,14 +867,20 @@ public class HMSExternalTable extends ExternalTable implements MTMVRelatedTableI
estimatedRowSize += column.getDataType().getSlotSize();
}
if (estimatedRowSize == 0) {
+ LOG.warn("Table {} estimated size is 0, return 0.", name);
return 0;
}
int totalPartitionSize = partitionValues == null ? 1 : partitionValues.getIdToPartitionItem().size();
if (samplePartitionSize != 0 && samplePartitionSize < totalPartitionSize) {
+ LOG.info("Table {} sampled {} of {} partitions, sampled size is {}",
+ name, samplePartitionSize, totalPartitionSize, totalSize);
totalSize = totalSize * totalPartitionSize / samplePartitionSize;
}
- return totalSize / estimatedRowSize;
+ long rows = totalSize / estimatedRowSize;
+ LOG.info("Table {} rows {}, total size is {}, estimatedRowSize is {}",
+ name, rows, totalSize, estimatedRowSize);
+ return rows;
}
// Get all partition values from cache.
@@ -890,6 +898,12 @@ public class HMSExternalTable extends ExternalTable implements MTMVRelatedTableI
// no need to worry that this call will invalid or refresh the cache.
// because it has enough space to keep partition info of all tables in cache.
partitionValues = cache.getPartitionValues(dbName, name, partitionColumnTypes);
+ if (partitionValues == null || partitionValues.getPartitionNameToIdMap() == null) {
+ LOG.warn("Partition values for hive table {} is null", name);
+ } else {
+ LOG.info("Partition values size for hive table {} is {}",
+ name, partitionValues.getPartitionNameToIdMap().size());
+ }
}
return partitionValues;
}
@@ -925,6 +939,7 @@ public class HMSExternalTable extends ExternalTable implements MTMVRelatedTableI
// get partitions without cache, so that it will not invalid the cache when executing
// non query request such as `show table status`
hivePartitions = cache.getAllPartitionsWithoutCache(dbName, name, partitionValuesList);
+ LOG.info("Partition list size for hive partition table {} is {}", name, hivePartitions.size());
} else {
hivePartitions.add(new HivePartition(dbName, name, true,
getRemoteTable().getSd().getInputFormat(),
@@ -932,6 +947,11 @@ public class HMSExternalTable extends ExternalTable implements MTMVRelatedTableI
}
// Get files for all partitions.
String bindBrokerName = catalog.bindBrokerName();
+ if (LOG.isDebugEnabled()) {
+ for (HivePartition partition : hivePartitions) {
+ LOG.debug("Chosen partition for table {}. [{}]", name, partition.toString());
+ }
+ }
return cache.getFilesByPartitionsWithoutCache(hivePartitions, bindBrokerName);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
index 2cedeeb2393..62d260dacaf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
@@ -602,11 +602,15 @@ public class IcebergUtils {
.getIcebergTable(catalog, dbName, tbName);
Snapshot snapshot = icebergTable.currentSnapshot();
if (snapshot == null) {
+ LOG.info("Iceberg table {}.{}.{} is empty, return row count 0.", catalog.getName(), dbName, tbName);
// empty table
return 0;
}
Map<String, String> summary = snapshot.summary();
- return Long.parseLong(summary.get(TOTAL_RECORDS)) - Long.parseLong(summary.get(TOTAL_POSITION_DELETES));
+ long rows = Long.parseLong(summary.get(TOTAL_RECORDS))
+ - Long.parseLong(summary.get(TOTAL_POSITION_DELETES));
+ LOG.info("Iceberg table {}.{}.{} row count in summary is {}", catalog.getName(), dbName, tbName, rows);
+ return rows;
} catch (Exception e) {
LOG.warn("Fail to collect row count for db {} table {}", dbName, tbName, e);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java
index 25563bf6c39..775138480d9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java
@@ -567,6 +567,7 @@ public class StatisticsUtil {
long rows = Long.parseLong(parameters.get(NUM_ROWS));
// Sometimes, the NUM_ROWS in hms is 0 but actually is not. Need to check TOTAL_SIZE if NUM_ROWS is 0.
if (rows != 0) {
+ LOG.info("Get row count {} for hive table {} in table parameters.", rows, table.getName());
return rows;
}
}
@@ -580,9 +581,13 @@ public class StatisticsUtil {
estimatedRowSize += column.getDataType().getSlotSize();
}
if (estimatedRowSize == 0) {
+ LOG.warn("Hive table {} estimated row size is invalid {}", table.getName(), estimatedRowSize);
return -1;
}
- return totalSize / estimatedRowSize;
+ long rows = totalSize / estimatedRowSize;
+ LOG.info("Get row count {} for hive table {} by total size {} and row size {}",
+ rows, table.getName(), totalSize, estimatedRowSize);
+ return rows;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org