You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/11/04 01:10:31 UTC

[GitHub] [pinot] Jackie-Jiang opened a new pull request, #9725: Clean up the TIMESTAMP index logic to always update table config and schema together

Jackie-Jiang opened a new pull request, #9725:
URL: https://github.com/apache/pinot/pull/9725

   Currently the table config and schema update for TIMESTAMP index are managed separately, and the expression transformer has hard-coded transformers from table config. It is quite error prune, and the logic is quite hard to follow.
   This PR cleans up the logic, and always update the table config and schema at the same time.


-- 
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] Jackie-Jiang merged pull request #9725: Clean up the TIMESTAMP index logic to always update table config and schema together

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged PR #9725:
URL: https://github.com/apache/pinot/pull/9725


-- 
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] siddharthteotia commented on a diff in pull request #9725: Clean up the TIMESTAMP index logic to always update table config and schema together

Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on code in PR #9725:
URL: https://github.com/apache/pinot/pull/9725#discussion_r1014722476


##########
pinot-spi/src/test/java/org/apache/pinot/spi/utils/TimestampIndexUtilsTest.java:
##########
@@ -0,0 +1,129 @@
+/**
+ * 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.spi.utils;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.pinot.spi.config.table.FieldConfig;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.config.table.TimestampConfig;
+import org.apache.pinot.spi.config.table.TimestampIndexGranularity;
+import org.apache.pinot.spi.config.table.ingestion.TransformConfig;
+import org.apache.pinot.spi.data.DateTimeFieldSpec;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+
+public class TimestampIndexUtilsTest {
+
+  @Test
+  public void testTimestampIndexGranularity() {
+    assertTrue(TimestampIndexUtils.isValidGranularity("DAY"));
+    assertFalse(TimestampIndexUtils.isValidGranularity("day"));
+
+    String timestampColumn = "testTs";
+    TimestampIndexGranularity granularity = TimestampIndexGranularity.DAY;
+    assertEquals(TimestampIndexUtils.getColumnWithGranularity(timestampColumn, granularity), "$testTs$DAY");
+    assertTrue(TimestampIndexUtils.isValidColumnWithGranularity("$testTs$DAY"));
+    assertFalse(TimestampIndexUtils.isValidColumnWithGranularity(timestampColumn));
+    assertFalse(TimestampIndexUtils.isValidColumnWithGranularity("$docId"));
+    assertFalse(TimestampIndexUtils.isValidColumnWithGranularity("$ts$"));
+  }
+
+  @Test
+  public void testExtractColumnsWithGranularity() {
+    TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("testTable").setFieldConfigList(
+        Arrays.asList(
+            new FieldConfig("ts1", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.TIMESTAMP, null, null,
+                new TimestampConfig(Arrays.asList(TimestampIndexGranularity.SECOND, TimestampIndexGranularity.MINUTE,
+                    TimestampIndexGranularity.HOUR)), null),
+            new FieldConfig("ts2", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.TIMESTAMP, null, null,
+                new TimestampConfig(Arrays.asList(TimestampIndexGranularity.HOUR, TimestampIndexGranularity.DAY,
+                    TimestampIndexGranularity.WEEK)), null),
+            new FieldConfig("ts3", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.TIMESTAMP, null, null,
+                new TimestampConfig(Arrays.asList(TimestampIndexGranularity.WEEK, TimestampIndexGranularity.MONTH,
+                    TimestampIndexGranularity.YEAR)), null))).build();
+    Set<String> columnsWithGranularity = TimestampIndexUtils.extractColumnsWithGranularity(tableConfig);
+    assertEquals(columnsWithGranularity, new HashSet<>(
+        Arrays.asList("$ts1$SECOND", "$ts1$MINUTE", "$ts1$HOUR", "$ts2$HOUR", "$ts2$DAY", "$ts2$WEEK", "$ts3$WEEK",
+            "$ts3$MONTH", "$ts3$YEAR")));
+  }
+
+  @Test
+  public void testApplyTimestampIndex() {
+    TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("testTable").setFieldConfigList(
+        Arrays.asList(
+            new FieldConfig("ts1", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.TIMESTAMP, null, null,
+                new TimestampConfig(Arrays.asList(TimestampIndexGranularity.SECOND, TimestampIndexGranularity.MINUTE,
+                    TimestampIndexGranularity.HOUR)), null),
+            new FieldConfig("ts2", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.TIMESTAMP, null, null,

Review Comment:
   Do we support this on raw columns ? If so, may be add a test for that as well



-- 
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