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/10/12 06:20:20 UTC

[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #9569: Fix time validation when data type needs to be converted

Jackie-Jiang commented on code in PR #9569:
URL: https://github.com/apache/pinot/pull/9569#discussion_r993039017


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/recordtransformer/TimeValidationTransformer.java:
##########
@@ -0,0 +1,108 @@
+/**
+ * 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.segment.local.recordtransformer;
+
+import com.google.common.base.Preconditions;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.ingestion.IngestionConfig;
+import org.apache.pinot.spi.data.DateTimeFieldSpec;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.utils.TimeUtils;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The {@code TimeValidationTransformer} class will validate the time column value.
+ * <p>NOTE: should put this after the {@link DataTypeTransformer} so that all values follow the data types in
+ * {@link FieldSpec}, and before the {@link NullValueTransformer} so that the invalidated value can be filled.
+ */
+public class TimeValidationTransformer implements RecordTransformer {
+  private static final Logger LOGGER = LoggerFactory.getLogger(TimeValidationTransformer.class);
+
+  private final String _timeColumnName;
+  private final DateTimeFormatSpec _timeFormatSpec;
+  private final boolean _skipTimeValueCheck;
+  private final boolean _continueOnError;
+
+  public TimeValidationTransformer(TableConfig tableConfig, Schema schema) {
+    _timeColumnName = tableConfig.getValidationConfig().getTimeColumnName();
+    if (_timeColumnName != null) {
+      DateTimeFieldSpec dateTimeFieldSpec = schema.getSpecForTimeColumn(_timeColumnName);
+      Preconditions.checkState(dateTimeFieldSpec != null, "Failed to find spec for time column: %s from schema: %s",
+          _timeColumnName, schema.getSchemaName());
+      _timeFormatSpec = dateTimeFieldSpec.getFormatSpec();
+      IngestionConfig ingestionConfig = tableConfig.getIngestionConfig();
+      if (ingestionConfig != null) {
+        _skipTimeValueCheck = !ingestionConfig.isRowTimeValueCheck();

Review Comment:
   I'm debating a little bit on having the default value as `true`, but checked with @xiangfu0 and I believe the default behavior of having row value check on is by mistake (different from the existing behavior), so I'll change it to use the original flag



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