You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2014/11/12 05:11:22 UTC
[05/16] incubator-drill git commit: DRILL-1656: Fix wildcard queries
to correctly determine selection root.
DRILL-1656: Fix wildcard queries to correctly determine selection root.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/abab3d31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/abab3d31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/abab3d31
Branch: refs/heads/master
Commit: abab3d31d703602219842580d5bd406944adf4df
Parents: 0cddfc2
Author: Jacques Nadeau <ja...@apache.org>
Authored: Mon Nov 10 12:01:17 2014 -0800
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Tue Nov 11 16:48:44 2014 -0800
----------------------------------------------------------------------
.../apache/drill/exec/store/dfs/FileSelection.java | 17 +++++++++++++++--
.../java/org/apache/drill/TestExampleQueries.java | 9 ++++++++-
2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/abab3d31/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
----------------------------------------------------------------------
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 36e7efe..edf5dbc 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
@@ -141,8 +141,21 @@ public class FileSelection {
return null;
}
String[] s = p.toUri().getPath().split("/");
- String newPath = StringUtils.join(ArrayUtils.subarray(s, 0, s.length - 1), "/");
- Preconditions.checkState(!newPath.contains("*") && !newPath.contains("?"), String.format("Unsupported selection path: %s", p));
+ int i = 0;
+
+ // get a selection root based on the portions of the selection path that don't contain a wildcard.
+ for(; i < s.length; i++){
+ if(s[i].contains("*") || s[i].contains("?")){
+ break;
+ }
+ }
+ String newPath;
+ if(i > 0){
+ newPath = StringUtils.join(ArrayUtils.subarray(s, 0, i), "/");
+ }else{
+ newPath = "/";
+ }
+
return new FileSelection(Lists.newArrayList(status), newPath);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/abab3d31/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
index e134a73..5b64d15 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
@@ -17,11 +17,12 @@
*/
package org.apache.drill;
+import static org.junit.Assert.assertEquals;
+
import org.apache.drill.common.util.FileUtils;
import org.apache.drill.exec.rpc.RpcException;
import org.junit.Ignore;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
public class TestExampleQueries extends BaseTestQuery{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestExampleQueries.class);
@@ -45,6 +46,12 @@ public class TestExampleQueries extends BaseTestQuery{
}
+ @Test
+ @Ignore("Can't be run on classpath since that fs doesn't support glob queries.")
+ public void testWildcard() throws Exception {
+ test("select * from dfs.`/tmp/xx/ab*/*.json`");
+ }
+
@Test // see DRILL-553
public void testQueryWithNullValues() throws Exception {
test("select count(*) from cp.`customer.json` limit 1");