[Fix](outfile) FE check the hdfs URI of outfile (#38602)

bp: #38203

1. Previously, if the root path of the HDFS URI started with two
slashes, the outfile would be successfully exported without errors, but
the exported path would not be the expected path.
Currently, we will delete repeated '/' which specified by users in FE.

2. move the test case for outfile HDFS from p2 to p0.
This commit is contained in:
Tiewei Fang
2024-07-31 22:46:37 +08:00
committed by GitHub
parent ef8a1918c3
commit b21b906306
4 changed files with 169 additions and 118 deletions

View File

@ -55,6 +55,8 @@ import org.apache.hadoop.fs.Path;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -535,6 +537,12 @@ public class OutFileClause {
filePath = filePath.replace(HDFS_FILE_PREFIX, HDFS_FILE_PREFIX + dfsNameServices);
}
}
// delete repeated '/'
try {
filePath = new URI(filePath).normalize().toString();
} catch (URISyntaxException e) {
throw new AnalysisException("Can not normalize the URI, error: " + e.getMessage());
}
if (Strings.isNullOrEmpty(filePath)) {
throw new AnalysisException("Must specify file in OUTFILE clause");
}