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 2015/10/26 18:42:51 UTC

[04/13] drill git commit: DRILL-3914: Gis contrib module with basic spatial queries functionality

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsText.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsText.java b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsText.java
new file mode 100644
index 0000000..aff1c07
--- /dev/null
+++ b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsText.java
@@ -0,0 +1,58 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import javax.inject.Inject;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.holders.VarBinaryHolder;
+import org.apache.drill.exec.expr.holders.VarCharHolder;
+
+import io.netty.buffer.DrillBuf;
+
+@FunctionTemplate(name = "st_astext", scope = FunctionTemplate.FunctionScope.SIMPLE,
+  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+public class STAsText implements DrillSimpleFunc {
+  @Param
+  VarBinaryHolder geom1Param;
+
+  @Output
+  VarCharHolder out;
+
+  @Inject
+  DrillBuf buffer;
+
+  public void setup() {
+  }
+
+  public void eval() {
+    com.esri.core.geometry.ogc.OGCGeometry geom1 = com.esri.core.geometry.ogc.OGCGeometry
+        .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start));
+
+    String geomWKT = geom1.asText();
+
+    int outputSize = geomWKT.getBytes().length;
+    buffer = out.buffer = buffer.reallocIfNeeded(outputSize);
+    out.start = 0;
+    out.end = outputSize;
+    buffer.setBytes(0, geomWKT.getBytes());
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STDWithin.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STDWithin.java b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STDWithin.java
new file mode 100644
index 0000000..c6927c8
--- /dev/null
+++ b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STDWithin.java
@@ -0,0 +1,68 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import javax.inject.Inject;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.holders.BitHolder;
+import org.apache.drill.exec.expr.holders.Float8Holder;
+import org.apache.drill.exec.expr.holders.VarBinaryHolder;
+
+import io.netty.buffer.DrillBuf;
+
+@FunctionTemplate(name = "st_dwithin", scope = FunctionTemplate.FunctionScope.SIMPLE,
+  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+public class STDWithin implements DrillSimpleFunc {
+  @Param
+  VarBinaryHolder geom1Param;
+
+  @Param
+  VarBinaryHolder geom2Param;
+
+  @Param(constant = true)
+  Float8Holder distanceParam;
+
+  @Output
+  BitHolder out;
+
+  @Inject
+  DrillBuf buffer;
+
+  public void setup() {
+  }
+
+  public void eval() {
+    double distance = distanceParam.value;
+
+    com.esri.core.geometry.ogc.OGCGeometry geom1;
+    com.esri.core.geometry.ogc.OGCGeometry geom2;
+
+    geom1 = com.esri.core.geometry.ogc.OGCGeometry
+        .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start));
+    geom2 = com.esri.core.geometry.ogc.OGCGeometry
+        .fromBinary(geom2Param.buffer.nioBuffer(geom2Param.start, geom2Param.end - geom2Param.start));
+
+    int isWithin = geom1.distance(geom2) <= distance ? 1 : 0;
+
+    out.value = isWithin;
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromText.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromText.java b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromText.java
new file mode 100644
index 0000000..98f22ba
--- /dev/null
+++ b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromText.java
@@ -0,0 +1,62 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import javax.inject.Inject;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
+import org.apache.drill.exec.expr.holders.VarBinaryHolder;
+
+import io.netty.buffer.DrillBuf;
+
+@FunctionTemplate(name = "st_geomfromtext", scope = FunctionTemplate.FunctionScope.SIMPLE,
+  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+public class STGeomFromText implements DrillSimpleFunc {
+  @Param
+  NullableVarCharHolder input;
+
+  @Output
+  VarBinaryHolder out;
+
+  @Inject
+  DrillBuf buffer;
+
+  public void setup() {
+  }
+
+  public void eval() {
+    String wktText = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end,
+        input.buffer);
+
+    com.esri.core.geometry.ogc.OGCGeometry geom;
+
+    geom = com.esri.core.geometry.ogc.OGCGeometry.fromText(wktText);
+
+    java.nio.ByteBuffer pointBytes = geom.asBinary();
+
+    int outputSize = pointBytes.remaining();
+    buffer = out.buffer = buffer.reallocIfNeeded(outputSize);
+    out.start = 0;
+    out.end = outputSize;
+    buffer.setBytes(0, pointBytes);
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromTextSrid.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromTextSrid.java b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromTextSrid.java
new file mode 100644
index 0000000..3da0744
--- /dev/null
+++ b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STGeomFromTextSrid.java
@@ -0,0 +1,68 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import javax.inject.Inject;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.holders.NullableIntHolder;
+import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
+import org.apache.drill.exec.expr.holders.VarBinaryHolder;
+
+import io.netty.buffer.DrillBuf;
+
+@FunctionTemplate(name = "st_geomfromtext", scope = FunctionTemplate.FunctionScope.SIMPLE,
+  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+public class STGeomFromTextSrid implements DrillSimpleFunc {
+  @Param
+  NullableVarCharHolder input;
+
+  @Param
+  NullableIntHolder sridParam;
+
+  @Output
+  VarBinaryHolder out;
+
+  @Inject
+  DrillBuf buffer;
+
+  public void setup() {
+  }
+
+  public void eval() {
+    int srid = sridParam.value;
+    String wktText = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end,
+        input.buffer);
+
+    com.esri.core.geometry.ogc.OGCGeometry geom;
+
+    geom = com.esri.core.geometry.ogc.OGCGeometry.fromText(wktText);
+    geom.setSpatialReference(com.esri.core.geometry.SpatialReference.create(srid));
+
+    java.nio.ByteBuffer pointBytes = geom.asBinary();
+
+    int outputSize = pointBytes.remaining();
+    buffer = out.buffer = buffer.reallocIfNeeded(outputSize);
+    out.start = 0;
+    out.end = outputSize;
+    buffer.setBytes(0, pointBytes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STPointFunc.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STPointFunc.java b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STPointFunc.java
new file mode 100644
index 0000000..731a392
--- /dev/null
+++ b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STPointFunc.java
@@ -0,0 +1,63 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import javax.inject.Inject;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.holders.Float8Holder;
+import org.apache.drill.exec.expr.holders.VarBinaryHolder;
+
+import io.netty.buffer.DrillBuf;
+
+@FunctionTemplate(name = "st_point", scope = FunctionTemplate.FunctionScope.SIMPLE,
+  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+public class STPointFunc implements DrillSimpleFunc {
+  @Param
+  Float8Holder lonParam;
+
+  @Param
+  Float8Holder latParam;
+
+  @Output
+  VarBinaryHolder out;
+
+  @Inject
+  DrillBuf buffer;
+
+  public void setup() {
+  }
+
+  public void eval() {
+
+    double lon = lonParam.value;
+    double lat = latParam.value;
+
+    com.esri.core.geometry.ogc.OGCPoint point = new com.esri.core.geometry.ogc.OGCPoint(
+        new com.esri.core.geometry.Point(lon, lat), com.esri.core.geometry.SpatialReference.create(4326));
+
+    java.nio.ByteBuffer pointBytes = point.asBinary();
+    out.buffer = buffer;
+    out.start = 0;
+    out.end = pointBytes.remaining();
+    buffer.setBytes(0, pointBytes);
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STWithin.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STWithin.java b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STWithin.java
new file mode 100644
index 0000000..615f2a7
--- /dev/null
+++ b/contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STWithin.java
@@ -0,0 +1,62 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import javax.inject.Inject;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.holders.BitHolder;
+import org.apache.drill.exec.expr.holders.VarBinaryHolder;
+
+import io.netty.buffer.DrillBuf;
+
+@FunctionTemplate(name = "st_within", scope = FunctionTemplate.FunctionScope.SIMPLE,
+  nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+public class STWithin implements DrillSimpleFunc {
+  @Param
+  VarBinaryHolder geom1Param;
+
+  @Param
+  VarBinaryHolder geom2Param;
+
+  @Output
+  BitHolder out;
+
+  @Inject
+  DrillBuf buffer;
+
+  public void setup() {
+  }
+
+  public void eval() {
+    com.esri.core.geometry.ogc.OGCGeometry geom1;
+    com.esri.core.geometry.ogc.OGCGeometry geom2;
+
+    geom1 = com.esri.core.geometry.ogc.OGCGeometry
+        .fromBinary(geom1Param.buffer.nioBuffer(geom1Param.start, geom1Param.end - geom1Param.start));
+    geom2 = com.esri.core.geometry.ogc.OGCGeometry
+        .fromBinary(geom2Param.buffer.nioBuffer(geom2Param.start, geom2Param.end - geom2Param.start));
+
+    int isWithin = geom1.within(geom2) ? 1 : 0;
+
+    out.value = isWithin;
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/main/resources/drill-module.conf
----------------------------------------------------------------------
diff --git a/contrib/gis/src/main/resources/drill-module.conf b/contrib/gis/src/main/resources/drill-module.conf
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/GISTestSuite.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/GISTestSuite.java b/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/GISTestSuite.java
new file mode 100644
index 0000000..70b6086
--- /dev/null
+++ b/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/GISTestSuite.java
@@ -0,0 +1,30 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(Suite.class)
+@SuiteClasses({ TestGeometryFunctions.class })
+public class GISTestSuite {
+  private static final Logger logger = LoggerFactory.getLogger(GISTestSuite.class);
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
----------------------------------------------------------------------
diff --git a/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java b/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
new file mode 100644
index 0000000..059fb36
--- /dev/null
+++ b/contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java
@@ -0,0 +1,75 @@
+/**
+ * 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.expr.fn.impl.gis;
+
+import org.apache.drill.BaseTestQuery;
+import org.junit.Test;
+
+public class TestGeometryFunctions extends BaseTestQuery {
+
+  String wktPoint = "POINT (-121.895 37.339)";
+
+  @Test
+  public void testGeometryFromTextCreation() throws Exception {
+
+    testBuilder()
+    .sqlQuery("select ST_AsText(ST_GeomFromText('" + wktPoint + "')) "
+        + "from cp.`/sample-data/CA-cities.csv` limit 1")
+    .ordered().baselineColumns("EXPR$0")
+    .baselineValues(wktPoint)
+    .build()
+    .run();
+  }
+
+  @Test
+  public void testGeometryPointCreation() throws Exception {
+
+    testBuilder()
+      .sqlQuery("select ST_AsText(ST_Point(-121.895, 37.339)) "
+          + "from cp.`/sample-data/CA-cities.csv` limit 1")
+      .ordered().baselineColumns("EXPR$0")
+      .baselineValues(wktPoint)
+      .build()
+      .run();
+  }
+
+  @Test
+  public void testSTWithinQuery() throws Exception {
+
+    testBuilder()
+      .sqlQuery("select ST_Within(ST_Point(columns[4], columns[3]),"
+          + "ST_GeomFromText('POLYGON((-121.95 37.28, -121.94 37.35, -121.84 37.35, -121.84 37.28, -121.95 37.28))')"
+          + ") "
+          + "from cp.`/sample-data/CA-cities.csv` where columns[2] = 'San Jose'")
+      .ordered().baselineColumns("EXPR$0")
+      .baselineValues(true)
+      .build()
+      .run();
+
+
+    testBuilder()
+    .sqlQuery("select ST_Within(" + "ST_Point(columns[4], columns[3]),"
+        + "ST_GeomFromText('POLYGON((-121.95 37.28, -121.94 37.35, -121.84 37.35, -121.84 37.28, -121.95 37.28))')"
+        + ") "
+        + "from cp.`/sample-data/CA-cities.csv` where columns[2] = 'San Francisco'")
+    .ordered().baselineColumns("EXPR$0")
+    .baselineValues(false)
+    .build()
+    .run();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/contrib/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/pom.xml b/contrib/pom.xml
index b351a51..2b08094 100644
--- a/contrib/pom.xml
+++ b/contrib/pom.xml
@@ -38,5 +38,6 @@
     <module>storage-jdbc</module>
     <module>sqlline</module>
     <module>data</module>
+    <module>gis</module>
   </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/distribution/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 76adb3a..4746106 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -167,6 +167,11 @@
           <artifactId>drill-storage-hive-core</artifactId>
           <version>${project.version}</version>
         </dependency>
+        <dependency>
+          <groupId>org.apache.drill.contrib</groupId>
+          <artifactId>drill-gis</artifactId>
+          <version>${project.version}</version>
+        </dependency>
       </dependencies>
     </profile>
 

http://git-wip-us.apache.org/repos/asf/drill/blob/6576123d/distribution/src/assemble/bin.xml
----------------------------------------------------------------------
diff --git a/distribution/src/assemble/bin.xml b/distribution/src/assemble/bin.xml
index bf80203..acdeefd 100644
--- a/distribution/src/assemble/bin.xml
+++ b/distribution/src/assemble/bin.xml
@@ -93,6 +93,7 @@
         <include>org.apache.drill.contrib:drill-mongo-storage</include>
         <include>org.apache.drill.contrib:drill-storage-hbase</include>
         <include>org.apache.drill.contrib:drill-jdbc-storage</include>
+        <include>org.apache.drill.contrib:drill-gis</include>
       </includes>
       <excludes>
         <exclude>org.apache.drill.contrib.storage-hive:drill-storage-hive-core:jar:tests</exclude>