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-unsubscr...@pinot.apache.org

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


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

Reply via email to