zabetak commented on a change in pull request #2991:
URL: https://github.com/apache/hive/pull/2991#discussion_r801604148
##########
File path: ql/src/test/queries/clientpositive/stats_part_multi_insert.q
##########
@@ -0,0 +1,18 @@
+-- Test multi inserting to the same partition
+
+create table source(p int, key int,value string);
+insert into source(p, key, value) values (101,42,'string42');
+
+create table stats_part(key int,value string) partitioned by (p int);
+
+from source
+insert into stats_part select key, value, p
+insert into stats_part select key, value, p;
+
+select p, key, value from stats_part;
+desc formatted stats_part;
+select count(*) from stats_part;
Review comment:
To keep the test functional even if the default value of
`hive.compute.query.using.stats` changes in the future I would add an explicit
set to true just before the select query.
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/BasicStatsTask.java
##########
@@ -512,6 +513,8 @@ private String toString(Map<String, String> parameters) {
if (dpPartSpecs != null) {
// load the list of DP partitions and return the list of partition
specs
list.addAll(dpPartSpecs);
+ // Reload partition metadata because another BasicStatsTask instance
may have updated the stats.
+ list = db.getPartitionsByNames(table,
list.stream().map(Partition::getName).collect(Collectors.toList()));
Review comment:
Given that we are dealing with a correctness problem here, I would be
inclined to commit this fix as is right now and treat possible improvements if
any in a follow up keeping in mind that the performance overhead of
`getPartitionByNames` is not measured.
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/stats/BasicStatsTask.java
##########
@@ -512,6 +513,8 @@ private String toString(Map<String, String> parameters) {
if (dpPartSpecs != null) {
// load the list of DP partitions and return the list of partition
specs
list.addAll(dpPartSpecs);
+ // Reload partition metadata because another BasicStatsTask instance
may have updated the stats.
+ list = db.getPartitionsByNames(table,
list.stream().map(Partition::getName).collect(Collectors.toList()));
Review comment:
Maybe it would be slightly more readable like below:
```suggestion
// Reload partition metadata because another BasicStatsTask
instance may have updated the stats.
List<String> partNames =
dpPartSpecs.stream().map(Partition::getName).collect(Collectors.toList());
list.addAll(db.getPartitionsByNames(table, partNames));
```
--
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]