drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject [2/7] drill git commit: DRILL-1757 Support for wildcards in repeated_contains()
Date Wed, 18 Mar 2015 21:18:47 GMT
DRILL-1757 Support for wildcards in repeated_contains()


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/bfbc0e01
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/bfbc0e01
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/bfbc0e01

Branch: refs/heads/master
Commit: bfbc0e01423ab85f362013a03ef0f00e95cd721b
Parents: 151b9be
Author: vsowrirajan <vsowrirajan@maprtech.com>
Authored: Thu Feb 19 12:04:52 2015 -0800
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Tue Mar 17 18:05:47 2015 -0700

----------------------------------------------------------------------
 .../expr/fn/impl/SimpleRepeatedFunctions.java   | 19 ++++----
 .../fn/impl/TestNewSimpleRepeatedFunctions.java | 49 ++++++++++++++++++++
 2 files changed, 59 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/bfbc0e01/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
index 1bfcb45..253c92a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
@@ -326,26 +326,27 @@ public class SimpleRepeatedFunctions {
     @Param RepeatedVarCharHolder listToSearch;
     @Param VarCharHolder targetValue;
     @Workspace VarCharHolder currVal;
+    @Workspace java.util.regex.Matcher matcher;
 
     @Output BitHolder out;
 
     public void setup() {
       currVal = new VarCharHolder();
+      matcher = java.util.regex.Pattern.compile(
+          org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(targetValue.start,
 targetValue.end,  targetValue.buffer)).matcher("");
     }
 
     public void eval() {
       for (int i = listToSearch.start; i < listToSearch.end; i++) {
         out.value = 0;
         listToSearch.vector.getAccessor().get(i, currVal);
-        if (org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(
-            currVal.buffer, currVal.start, currVal.end, targetValue.buffer, targetValue.start,
targetValue.end) == 0 ) {
-          out.value = 1;
-          break;
-        }
-      }
+        String in = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(currVal.start,
currVal.end, currVal.buffer);
+        matcher.reset(in);
+          if(matcher.find()) {
+             out.value = 1;
+             break;
+          }
+       }
     }
-
   }
-
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/bfbc0e01/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
new file mode 100644
index 0000000..05807d6
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.fn.impl;
+
+import org.apache.drill.BaseTestQuery;
+import org.junit.Test;
+
+public class TestNewSimpleRepeatedFunctions extends BaseTestQuery {
+  @Test
+  public void testRepeatedContainsForWildCards() throws Exception {
+     testBuilder().
+       sqlQuery("select repeated_contains(topping, 'Choc*') from cp.`testRepeatedWrite.json`")
+       .ordered()
+       .baselineColumns("EXPR$0")
+       .baselineValues(true)
+       .baselineValues(true)
+       .baselineValues(true)
+       .baselineValues(true)
+       .baselineValues(false)
+       .build().run();
+
+     testBuilder().
+       sqlQuery("select repeated_contains(topping, 'Pow*') from cp.`testRepeatedWrite.json`")
+       .ordered()
+       .baselineColumns("EXPR$0")
+       .baselineValues(true)
+       .baselineValues(false)
+       .baselineValues(false)
+       .baselineValues(true)
+       .baselineValues(false)
+       .build().run();
+
+  }
+}
\ No newline at end of file


Mime
View raw message