You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "xiangfu0 (via GitHub)" <gi...@apache.org> on 2023/07/26 23:57:34 UTC

[GitHub] [pinot] xiangfu0 opened a new pull request, #11191: Adding Geometry support in multi-stage

xiangfu0 opened a new pull request, #11191:
URL: https://github.com/apache/pinot/pull/11191

   - support st-* functions in multi-stage engine


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on a diff in pull request #11191: [multistage] Support Geometry queries

Posted by "walterddr (via GitHub)" <gi...@apache.org>.
walterddr commented on code in PR #11191:
URL: https://github.com/apache/pinot/pull/11191#discussion_r1276641683


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/GeoSpatialClusterIntegrationTest.java:
##########
@@ -0,0 +1,249 @@
+/**
+ * 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.pinot.integration.tests;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.ImmutableList;
+import java.io.File;
+import java.nio.ByteBuffer;
+import org.apache.avro.file.DataFileWriter;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericDatumWriter;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.segment.local.utils.GeometrySerializer;
+import org.apache.pinot.segment.local.utils.GeometryUtils;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.BytesUtils;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.apache.pinot.util.TestUtils;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Point;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+
+public class GeoSpatialClusterIntegrationTest extends BaseClusterIntegrationTest {
+
+  private static final int NUM_TOTAL_DOCS = 1000;
+  private static final String DIM_NAME = "dimName";
+  private static final String ST_POINT = "st_point";
+
+  private static final String ST_X_NAME = "st_x";
+  private static final String ST_Y_NAME = "st_y";
+  private static final String WKT_1 = "wkt1";
+  private static final String WKT_2 = "wkt2";
+
+  @BeforeClass
+  public void setUp()
+      throws Exception {
+    TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir, _tarDir);
+
+    // Start the Pinot cluster
+    startZk();
+    startController();
+    startBroker();
+    startServer();
+
+    // create & upload schema AND table config
+    Schema schema = new Schema.SchemaBuilder().setSchemaName(DEFAULT_SCHEMA_NAME)
+        .addSingleValueDimension(DIM_NAME, FieldSpec.DataType.STRING)
+        .addSingleValueDimension(ST_POINT, FieldSpec.DataType.BYTES)
+        .addSingleValueDimension(ST_X_NAME, FieldSpec.DataType.DOUBLE)
+        .addSingleValueDimension(ST_Y_NAME, FieldSpec.DataType.DOUBLE)
+        .build();
+    addSchema(schema);
+    TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName(DEFAULT_TABLE_NAME).build();
+    addTableConfig(tableConfig);
+
+    // create & upload segments
+    File avroFile = createAvroFile();
+    ClusterIntegrationTestUtils.buildSegmentFromAvro(avroFile, tableConfig, schema, 0, _segmentDir, _tarDir);
+    uploadSegments(DEFAULT_TABLE_NAME, _tarDir);
+
+    waitForAllDocsLoaded(60_000);
+  }
+
+  @Override
+  protected long getCountStarResult() {
+    return NUM_TOTAL_DOCS;
+  }
+
+  private File createAvroFile()
+      throws Exception {
+
+    // create avro schema
+    org.apache.avro.Schema avroSchema = org.apache.avro.Schema.createRecord("myRecord", null, null, false);
+    avroSchema.setFields(ImmutableList.of(
+        new org.apache.avro.Schema.Field(DIM_NAME, org.apache.avro.Schema.create(org.apache.avro.Schema.Type.STRING),
+            null, null),
+        new org.apache.avro.Schema.Field(ST_X_NAME, org.apache.avro.Schema.create(org.apache.avro.Schema.Type.DOUBLE),
+            null, null),
+        new org.apache.avro.Schema.Field(ST_Y_NAME, org.apache.avro.Schema.create(org.apache.avro.Schema.Type.DOUBLE),
+            null, null),
+        new org.apache.avro.Schema.Field(ST_POINT,
+            org.apache.avro.Schema.create(org.apache.avro.Schema.Type.BYTES), null, null)));
+
+    File avroFile = new File(_tempDir, "data.avro");
+    try (DataFileWriter<GenericData.Record> fileWriter = new DataFileWriter<>(new GenericDatumWriter<>(avroSchema))) {
+      fileWriter.create(avroSchema, avroFile);
+      for (int i = 0; i < NUM_TOTAL_DOCS; i++) {
+        GenericData.Record record = new GenericData.Record(avroSchema);
+        record.put(DIM_NAME, "dim" + i);
+        Point point =
+            GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(RANDOM.nextDouble(), RANDOM.nextDouble()));
+        record.put(ST_X_NAME, point.getX());
+        record.put(ST_Y_NAME, point.getY());
+        record.put(ST_POINT, ByteBuffer.wrap(GeometrySerializer.serialize(point)));
+        fileWriter.append(record);
+      }
+    }
+
+    return avroFile;
+  }
+
+  @AfterClass
+  public void tearDown()
+      throws Exception {
+    dropOfflineTable(getTableName());
+
+    stopServer();
+    stopBroker();
+    stopController();
+    stopZk();
+
+    FileUtils.deleteDirectory(_tempDir);
+  }
+
+  @Test(dataProvider = "useBothQueryEngines")
+  public void testGetHexagonAddress(boolean useMultiStageQueryEngine)
+      throws Exception {
+    setUseMultiStageQueryEngine(useMultiStageQueryEngine);
+
+    String query = "Select geoToH3(20,102,5) from " + DEFAULT_TABLE_NAME;

Review Comment:
   let's add unit-tests in pinot-query-runtime



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on a diff in pull request #11191: [multistage] Support Geometry queries

Posted by "walterddr (via GitHub)" <gi...@apache.org>.
walterddr commented on code in PR #11191:
URL: https://github.com/apache/pinot/pull/11191#discussion_r1276640980


##########
pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java:
##########
@@ -173,29 +173,37 @@ public enum TransformFunctionType {
   SCALAR("scalar"),
 
   // Geo constructors
-  ST_GEOG_FROM_TEXT("ST_GeogFromText"),
-  ST_GEOM_FROM_TEXT("ST_GeomFromText"),
-  ST_GEOG_FROM_WKB("ST_GeogFromWKB"),
-  ST_GEOM_FROM_WKB("ST_GeomFromWKB"),
-  ST_POINT("ST_Point"),
-  ST_POLYGON("ST_Polygon"),
+  ST_GEOG_FROM_TEXT("ST_GeogFromText", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),
+  ST_GEOM_FROM_TEXT("ST_GeomFromText", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),
+  ST_GEOG_FROM_WKB("ST_GeogFromWKB", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY),
+  ST_GEOM_FROM_WKB("ST_GeomFromWKB", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY),
+  ST_POINT("ST_Point", ReturnTypes.explicit(SqlTypeName.VARBINARY),
+      OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
+          ordinal -> ordinal > 1 && ordinal < 4)),
+  ST_POLYGON("ST_Polygon", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),
 
   // Geo measurements
-  ST_AREA("ST_Area"),
-  ST_DISTANCE("ST_Distance"),
-  ST_GEOMETRY_TYPE("ST_GeometryType"),
+  ST_AREA("ST_Area", ReturnTypes.DOUBLE_NULLABLE, OperandTypes.BINARY),
+  ST_DISTANCE("ST_Distance", ReturnTypes.DOUBLE_NULLABLE,
+      OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY))),
+  ST_GEOMETRY_TYPE("ST_GeometryType", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.BINARY),
 
   // Geo outputs
-  ST_AS_BINARY("ST_AsBinary"),
-  ST_AS_TEXT("ST_AsText"),
+  ST_AS_BINARY("ST_AsBinary", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY),
+  ST_AS_TEXT("ST_AsText", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.BINARY),
 
   // Geo relationship
-  ST_CONTAINS("ST_Contains"),
-  ST_EQUALS("ST_Equals"),
-  ST_WITHIN("ST_Within"),
+  ST_CONTAINS("ST_Contains", ReturnTypes.INTEGER,

Review Comment:
   shouldn't these return boolean?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] xiangfu0 merged pull request #11191: [multistage] Support Geometry queries

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 merged PR #11191:
URL: https://github.com/apache/pinot/pull/11191


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on a diff in pull request #11191: [multistage] Support Geometry queries

Posted by "walterddr (via GitHub)" <gi...@apache.org>.
walterddr commented on code in PR #11191:
URL: https://github.com/apache/pinot/pull/11191#discussion_r1276640521


##########
pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java:
##########
@@ -173,29 +173,37 @@ public enum TransformFunctionType {
   SCALAR("scalar"),
 
   // Geo constructors
-  ST_GEOG_FROM_TEXT("ST_GeogFromText"),
-  ST_GEOM_FROM_TEXT("ST_GeomFromText"),
-  ST_GEOG_FROM_WKB("ST_GeogFromWKB"),
-  ST_GEOM_FROM_WKB("ST_GeomFromWKB"),
-  ST_POINT("ST_Point"),
-  ST_POLYGON("ST_Polygon"),
+  ST_GEOG_FROM_TEXT("ST_GeogFromText", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),

Review Comment:
   can we add some test for the auto function name variance generated? (e.g. `ST_GEOG_FROM_TEXT` and the `ST_GeogFromText`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [multistage] Support Geometry queries [pinot]

Posted by "walterddr (via GitHub)" <gi...@apache.org>.
walterddr commented on code in PR #11191:
URL: https://github.com/apache/pinot/pull/11191#discussion_r1342971813


##########
pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java:
##########
@@ -173,29 +173,37 @@ public enum TransformFunctionType {
   SCALAR("scalar"),
 
   // Geo constructors
-  ST_GEOG_FROM_TEXT("ST_GeogFromText"),
-  ST_GEOM_FROM_TEXT("ST_GeomFromText"),
-  ST_GEOG_FROM_WKB("ST_GeogFromWKB"),
-  ST_GEOM_FROM_WKB("ST_GeomFromWKB"),
-  ST_POINT("ST_Point"),
-  ST_POLYGON("ST_Polygon"),
+  ST_GEOG_FROM_TEXT("ST_GeogFromText", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),
+  ST_GEOM_FROM_TEXT("ST_GeomFromText", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),
+  ST_GEOG_FROM_WKB("ST_GeogFromWKB", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY),
+  ST_GEOM_FROM_WKB("ST_GeomFromWKB", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY),
+  ST_POINT("ST_Point", ReturnTypes.explicit(SqlTypeName.VARBINARY),
+      OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
+          ordinal -> ordinal > 1 && ordinal < 4)),
+  ST_POLYGON("ST_Polygon", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING),
 
   // Geo measurements
-  ST_AREA("ST_Area"),
-  ST_DISTANCE("ST_Distance"),
-  ST_GEOMETRY_TYPE("ST_GeometryType"),
+  ST_AREA("ST_Area", ReturnTypes.DOUBLE_NULLABLE, OperandTypes.BINARY),
+  ST_DISTANCE("ST_Distance", ReturnTypes.DOUBLE_NULLABLE,

Review Comment:
   Looks like `ST_DISTANCE` `ST_GEOMETRY_TYPE` `ST_POLYGON` `ST_AS_BINARY` `ST_AS_TEXT`, ST_CONTAINS` are not tested. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] codecov-commenter commented on pull request #11191: [multistage] Support Geometry queries

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #11191:
URL: https://github.com/apache/pinot/pull/11191#issuecomment-1652747586

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/11191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#11191](https://app.codecov.io/gh/apache/pinot/pull/11191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (734ef18) into [master](https://app.codecov.io/gh/apache/pinot/commit/d83d1e87133d151da4fbfade35815d1098803e44?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (d83d1e8) will **decrease** coverage by `0.01%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #11191      +/-   ##
   ==========================================
   - Coverage    0.11%    0.11%   -0.01%     
   ==========================================
     Files        2219     2219              
     Lines      119191   119199       +8     
     Branches    18031    18031              
   ==========================================
     Hits          137      137              
   - Misses     119034   119042       +8     
     Partials       20       20              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | integration1temurin11 | `?` | |
   | integration1temurin17 | `?` | |
   | integration1temurin20 | `0.00% <0.00%> (ø)` | |
   | integration2temurin11 | `?` | |
   | integration2temurin20 | `?` | |
   | unittests1temurin11 | `?` | |
   | unittests1temurin17 | `0.00% <0.00%> (ø)` | |
   | unittests1temurin20 | `0.00% <0.00%> (ø)` | |
   | unittests2temurin11 | `0.11% <0.00%> (-0.01%)` | :arrow_down: |
   | unittests2temurin17 | `0.11% <0.00%> (-0.01%)` | :arrow_down: |
   | unittests2temurin20 | `0.11% <0.00%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files Changed](https://app.codecov.io/gh/apache/pinot/pull/11191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...e/pinot/common/function/TransformFunctionType.java](https://app.codecov.io/gh/apache/pinot/pull/11191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vVHJhbnNmb3JtRnVuY3Rpb25UeXBlLmphdmE=) | `0.00% <0.00%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org