Copilot commented on code in PR #16027: URL: https://github.com/apache/pinot/pull/16027#discussion_r2132645013
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/RecordReaderSegmentCreationDataSource.java: ########## @@ -63,12 +64,17 @@ public SegmentPreIndexStatsCollector gatherStats(StatsCollectorConfig statsColle .getIngestionConfig().isContinueOnError(); GenericRow reuse = new GenericRow(); TransformPipeline.Result reusedResult = new TransformPipeline.Result(); + Set<String> notNullColumns = SegmentCreatorUtils.extractNotNullColumns(statsCollectorConfig.getSchema()); while (_recordReader.hasNext()) { reuse.clear(); try { reuse = _recordReader.next(reuse); transformPipeline.processRow(reuse, reusedResult); for (GenericRow row : reusedResult.getTransformedRows()) { + if (SegmentCreatorUtils.shouldSkipRowForNotNull(notNullColumns, row)) { + throw new IllegalStateException("Row contains null value in a not-null column, and " Review Comment: The exception for null in a not-null column is very generic. Consider defining or using a more specific exception type (e.g., `InvalidRowException`) and include the column name for clearer error reporting. ########## pinot-query-runtime/src/test/resources/queries/NullHandling.json: ########## @@ -271,7 +271,10 @@ ["bar", 2, 2, 2, "alice", "alice", "alice"], ["alice", 2, 2, 2, null, null, null], [null, 4, 4, 4, null, null, null], - ["bob", null, null, null, null, null, null] + ["bob", null, null, null, null, null, null], + ["alice", 2, 2, 2, null, null, "null"], + [null, 4, 4, 4, null, null, "null"], + ["bob", null, null, -2147483648, null, null, "null"] Review Comment: Using the string literal "null" for default null values may be misleading in tests. Consider using actual JSON null values or a clear placeholder to match production behavior. ```suggestion ["alice", 2, 2, 2, null, null, null], [null, 4, 4, 4, null, null, null], ["bob", null, null, -2147483648, null, null, null] ``` ########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/SegmentCreatorUtils.java: ########## @@ -0,0 +1,52 @@ +/** + * 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.segment.creator; + +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.pinot.spi.data.FieldSpec; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SegmentCreatorUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(SegmentCreatorUtils.class); + + private SegmentCreatorUtils() { + } + + public static boolean shouldSkipRowForNotNull(Set<String> notNullColumns, GenericRow row) { + for (String columnName : notNullColumns) { + if (row.getValue(columnName) == null) { + LOGGER.debug("Skipping Row due to null value for column {}, the whole row is {}", columnName, row); + return true; + } + } + return false; + } + + public static Set<String> extractNotNullColumns(Schema schema) { + return schema.getAllFieldSpecs().stream() + .filter(fieldSpec -> schema.isEnableColumnBasedNullHandling() && fieldSpec.isNotNull()) Review Comment: The check `schema.isEnableColumnBasedNullHandling()` is repeated for every field. Move this flag check outside the stream filter to avoid redundant evaluations. ```suggestion boolean isNullHandlingEnabled = schema.isEnableColumnBasedNullHandling(); return schema.getAllFieldSpecs().stream() .filter(fieldSpec -> isNullHandlingEnabled && fieldSpec.isNotNull()) ``` -- 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