Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5962

Add function STAsJSON to extend GIS support

    Details

      Description

      Add function as wrapper to ESRI's `asJson`

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user ChrisSandison opened a pull request:

          https://github.com/apache/drill/pull/1036

          Adding ST_AsJSON functionality

          Fixes #DRILL-5962

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/ChrisSandison/drill DRILL-5962

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/drill/pull/1036.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #1036


          commit fe633ab7282d69b8eca30a255f84ec68f2bafb3b
          Author: chris <chris@thinkdataworks.com>
          Date: 2017-11-14T21:26:21Z

          Adding ST_AsJSON functionality

          Fixes #DRILL-5962


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user ChrisSandison opened a pull request: https://github.com/apache/drill/pull/1036 Adding ST_AsJSON functionality Fixes # DRILL-5962 You can merge this pull request into a Git repository by running: $ git pull https://github.com/ChrisSandison/drill DRILL-5962 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/drill/pull/1036.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1036 commit fe633ab7282d69b8eca30a255f84ec68f2bafb3b Author: chris <chris@thinkdataworks.com> Date: 2017-11-14T21:26:21Z Adding ST_AsJSON functionality Fixes # DRILL-5962
          Hide
          ChrisSandison Chris Sandison added a comment -
          Show
          ChrisSandison Chris Sandison added a comment - PR created https://github.com/apache/drill/pull/1036
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user paul-rogers commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r150999524

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE,
          + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
          +public class STAsJSON 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 json = geom1.asJson();
          +
          + int outputSize = json.getBytes().length;
          — End diff –

          Better to cache the bytes, and use it twice, rather than converting the string from UTF-16 to UTF-8 twice.

          Show
          githubbot ASF GitHub Bot added a comment - Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r150999524 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) +public class STAsJSON 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 json = geom1.asJson(); + + int outputSize = json.getBytes().length; — End diff – Better to cache the bytes, and use it twice, rather than converting the string from UTF-16 to UTF-8 twice.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user ChrisSandison commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151142574

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE,
          + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
          +public class STAsJSON 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 json = geom1.asJson();
          +
          + int outputSize = json.getBytes().length;
          — End diff –

          Good call, I'm going to make that same change in #1034

          Show
          githubbot ASF GitHub Bot added a comment - Github user ChrisSandison commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151142574 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) +public class STAsJSON 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 json = geom1.asJson(); + + int outputSize = json.getBytes().length; — End diff – Good call, I'm going to make that same change in #1034
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151143439

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java —
          @@ -0,0 +1,58 @@
          +/**
          — End diff –

          @ChrisSandison Apache header should be in a from of comment. Please here and in other PR.

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151143439 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java — @@ -0,0 +1,58 @@ +/** — End diff – @ChrisSandison Apache header should be in a from of comment. Please here and in other PR.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151184263

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java —
          @@ -0,0 +1,59 @@
          +/*
          + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE,
          + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
          +public class STAsJSON implements DrillSimpleFunc {
          — End diff –

          `StAsJson`

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151184263 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java — @@ -0,0 +1,59 @@ +/* + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) +public class STAsJSON implements DrillSimpleFunc { — End diff – `StAsJson`
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151184397

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java —
          @@ -0,0 +1,59 @@
          +/*
          + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE,
          + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
          +public class STAsJSON implements DrillSimpleFunc {
          + @Param
          + VarBinaryHolder geom1Param;
          — End diff –

          `geomParam`

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151184397 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java — @@ -0,0 +1,59 @@ +/* + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) +public class STAsJSON implements DrillSimpleFunc { + @Param + VarBinaryHolder geom1Param; — End diff – `geomParam`
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151184326

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java —
          @@ -0,0 +1,59 @@
          +/*
          + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE,
          + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
          +public class STAsJSON 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
          — End diff –

          `geom`

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151184326 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java — @@ -0,0 +1,59 @@ +/* + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) +public class STAsJSON 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 — End diff – `geom`
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151184182

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java —
          @@ -0,0 +1,59 @@
          +/*
          + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE,
          — End diff –

          1. `st_as_json` (more sql like way)
          2. Please add description of the function in the java doc?

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151184182 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJSON.java — @@ -0,0 +1,59 @@ +/* + * 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_asjson", scope = FunctionTemplate.FunctionScope.SIMPLE, — End diff – 1. `st_as_json` (more sql like way) 2. Please add description of the function in the java doc?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151184679

          — Diff: contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java —
          @@ -49,6 +50,28 @@ public void testGeometryPointCreation() throws Exception {
          }

          @Test
          + public void testJSONFromPointCreation() throws Exception {
          + testBuilder()
          + .sqlQuery("select ST_AsJSON(ST_Point(-121.895, 37.339)) "
          + + "from cp.`/sample-data/CA-cities.csv` limit 1")
          + .ordered().baselineColumns("EXPR$0")
          — End diff –

          Please put `baselineColumns("EXPR$0")` to the new line.

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151184679 — Diff: contrib/gis/src/test/java/org/apache/drill/exec/expr/fn/impl/gis/TestGeometryFunctions.java — @@ -49,6 +50,28 @@ public void testGeometryPointCreation() throws Exception { } @Test + public void testJSONFromPointCreation() throws Exception { + testBuilder() + .sqlQuery("select ST_AsJSON(ST_Point(-121.895, 37.339)) " + + "from cp.`/sample-data/CA-cities.csv` limit 1") + .ordered().baselineColumns("EXPR$0") — End diff – Please put `baselineColumns("EXPR$0")` to the new line.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user brendanstennett commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r151267136

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJson.java —
          @@ -0,0 +1,64 @@
          +/*
          + * 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.
          + */
          +
          +/*
          + * Wrapper for ESRI ST_AsJson to convert geometry into REST Json.
          + * Emulates functionality from spatial-framework-for-hadoop.
          + */
          +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_as_json", scope = FunctionTemplate.FunctionScope.SIMPLE,
          + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
          +public class STAsJson implements DrillSimpleFunc {
          — End diff –

          @ChrisSandison I would suggest naming this `ST_AsGeoJSON` to stay in line with the conventions set forth in PostGIS.

          http://www.postgis.net/docs/ST_AsGeoJSON.html

          Show
          githubbot ASF GitHub Bot added a comment - Github user brendanstennett commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r151267136 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJson.java — @@ -0,0 +1,64 @@ +/* + * 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. + */ + +/* + * Wrapper for ESRI ST_AsJson to convert geometry into REST Json. + * Emulates functionality from spatial-framework-for-hadoop. + */ +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_as_json", scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) +public class STAsJson implements DrillSimpleFunc { — End diff – @ChrisSandison I would suggest naming this `ST_AsGeoJSON` to stay in line with the conventions set forth in PostGIS. http://www.postgis.net/docs/ST_AsGeoJSON.html
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on a diff in the pull request:

          https://github.com/apache/drill/pull/1036#discussion_r152032716

          — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJson.java —
          @@ -0,0 +1,64 @@
          +/*
          + * 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.
          + */
          +
          +/*
          + * Wrapper for ESRI ST_AsJson to convert geometry into REST Json.
          + * Emulates functionality from spatial-framework-for-hadoop.
          + */
          +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_as_json", scope = FunctionTemplate.FunctionScope.SIMPLE,
          — End diff –

          Please revert function name and squash the commits.

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/1036#discussion_r152032716 — Diff: contrib/gis/src/main/java/org/apache/drill/exec/expr/fn/impl/gis/STAsJson.java — @@ -0,0 +1,64 @@ +/* + * 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. + */ + +/* + * Wrapper for ESRI ST_AsJson to convert geometry into REST Json. + * Emulates functionality from spatial-framework-for-hadoop. + */ +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_as_json", scope = FunctionTemplate.FunctionScope.SIMPLE, — End diff – Please revert function name and squash the commits.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user arina-ielchiieva commented on the issue:

          https://github.com/apache/drill/pull/1036

          Please update commit message. +1, LGTM.

          Show
          githubbot ASF GitHub Bot added a comment - Github user arina-ielchiieva commented on the issue: https://github.com/apache/drill/pull/1036 Please update commit message. +1, LGTM.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/drill/pull/1036

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/drill/pull/1036

            People

            • Assignee:
              ChrisSandison Chris Sandison
              Reporter:
              ChrisSandison Chris Sandison
              Reviewer:
              Arina Ielchiieva
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 3h
                3h
                Remaining:
                Remaining Estimate - 3h
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development