Copilot commented on code in PR #6675:
URL: https://github.com/apache/hive/pull/6675#discussion_r3854385383
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java:
##########
@@ -146,12 +146,18 @@ public void flattenUnionSubdirectories(Path sourcePath)
throws HiveException {
Path path = i.next().getPath();
Path parent = path.getParent();
if (parent.getName().startsWith(prefix)) {
- // We do rename by including the name of parent directory into the
filename so that there are no clashes
- // when we move the files to the parent directory. Ex.
HIVE_UNION_SUBDIR_1/000000_0 -> 1_000000_0
+ // Fold the subdir index into the filename so there are no clashes
when the files
+ // are moved to the parent directory, and so that the resulting
name still matches
+ // the "original data file" convention that both the ACID reader
(AcidUtils.
+ // ORIGINAL_PATTERN_COPY) and the metastore's non-ACID→ACID
validator (Transactional
+ // ValidationListener.ORIGINAL_PATTERN_COPY) recognize:
+ // HIVE_UNION_SUBDIR_1/000000_0 -> 000000_0_copy_1
+ // See Utilities.COPY_KEYWORD.
String parentOfParent = parent.getParent().toString();
String parentNameSuffix =
parent.getName().substring(prefix.length());
- fs.rename(path, new Path(parentOfParent + "/" + parentNameSuffix +
"_" + path.getName()));
+ fs.rename(path,
+ new Path(parentOfParent + "/" + path.getName() +
Utilities.COPY_KEYWORD + parentNameSuffix));
Review Comment:
This new name already contains a `_copy_<N>` suffix, but the subsequent
`Hive.loadTable` move still treats it as an ordinary basename. On non-atomic
filesystems, `Hive.pickDestFilePath` unconditionally appends its per-query
suffix, producing names such as `000000_0_copy_1_copy_<tag>`; on atomic
filesystems the same happens whenever a prior flattened insert has already
created `000000_0_copy_1`. Those names do not match `ORIGINAL_PATTERN_COPY`, so
flattening can still make later inserts unreadable or cause ACID conversion
validation to fail. Please coordinate the destination-name handling to preserve
a single valid copy suffix (and add a flatten-on repeated-insert/non-atomic
regression test).
--
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]