This is an automated email from the ASF dual-hosted git repository.
dzamo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new 1758029 DRILL-8064: Cannot query text files with names that contain a
backslash (#2392)
1758029 is described below
commit 1758029dc36980b06c0ef21cee6c20d07dc578d9
Author: James Turton <[email protected]>
AuthorDate: Sat Dec 4 06:23:26 2021 +0200
DRILL-8064: Cannot query text files with names that contain a backslash
(#2392)
* Unescape root path in dfs plugin.
* Fix a spelling mistake in a comment.
---
.../org/apache/drill/exec/store/dfs/FileSelection.java | 11 ++++++++---
.../java/org/apache/drill/exec/store/dfs/TestGlob.java | 16 ++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
index 6700114..ebe1a43 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
@@ -270,15 +270,20 @@ public class FileSelection {
Stopwatch timer = logger.isDebugEnabled() ? Stopwatch.createStarted() :
null;
boolean hasWildcard = path.contains(WILD_CARD);
- Path combined = new Path(parent,
DrillStringUtils.removeLeadingSlash(path));
+ String child = DrillStringUtils.removeLeadingSlash(path);
+ Path combined = new Path(parent, child);
+ // Unescape chars escaped with '\' for our root path to be consistent with
what
+ // fs.globStatus(...) below will do with them, c.f. DRILL-8064
+ Path root = new Path(parent, DrillStringUtils.unescapeJava(child));
+
if (!allowAccessOutsideWorkspace) {
checkBackPaths(new Path(parent).toUri().getPath(),
combined.toUri().getPath(), path);
}
- FileStatus[] statuses = fs.globStatus(combined); // note: this would
expand wildcards
+ FileStatus[] statuses = fs.globStatus(combined); // note: this will expand
wildcards
if (statuses == null) {
return null;
}
- FileSelection fileSel = create(Arrays.asList(statuses), null, combined);
+ FileSelection fileSel = create(Arrays.asList(statuses), null, root);
if (timer != null) {
logger.debug("FileSelection.create() took {} ms ",
timer.elapsed(TimeUnit.MILLISECONDS));
timer.stop();
diff --git
a/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestGlob.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestGlob.java
index 2ca2120..03fba37 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestGlob.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestGlob.java
@@ -31,6 +31,10 @@ public class TestGlob extends BaseTestQuery {
@BeforeClass
public static void setupTestFiles() {
dirTestWatcher.copyResourceToRoot(Paths.get("multilevel"));
+ dirTestWatcher.copyResourceToRoot(
+ Paths.get("emptyStrings.csv"),
+ Paths.get("globEscapeCharIsA\\Backslash.csv")
+ );
}
@Test
@@ -75,4 +79,16 @@ public class TestGlob extends BaseTestQuery {
.build()
.run();
}
+
+ @Test
+ // DRILL-8064
+ public void testGlobEscapeCharRootTextFile() throws Exception {
+ testBuilder()
+ .sqlQuery("select count(*) from
dfs.`globEscapeCharIsA\\\\Backslash.csv`")
+ .unOrdered()
+ .baselineColumns("EXPR$0")
+ .baselineValues(3L)
+ .build()
+ .run();
+ }
}