raghavyadav01 commented on code in PR #19955:
URL: https://github.com/apache/pinot/pull/19955#discussion_r4368056265


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java:
##########
@@ -1238,12 +1240,21 @@ private class ValueReader implements Closeable {
       } else {
         _dictionary = null;
       }
-      _columnReader = new 
PinotSegmentColumnReader(columnMetadata.getColumnName(), _forwardIndexReader, 
_dictionary,
-          null, columnMetadata.getMaxNumberOfMultiValues());
+      // A null source value is stored as the column's default value. Read the 
null vector too, so the function sees
+      // null for those docs, as it does at ingestion, instead of deriving a 
non-null value from the placeholder.
+      String column = columnMetadata.getColumnName();
+      NullValueVectorReaderImpl nullValueVectorReader = null;
+      if (_segmentWriter.hasIndexFor(column, 
StandardIndexes.nullValueVector())) {
+        nullValueVectorReader =
+            new NullValueVectorReaderImpl(_segmentWriter.getIndexFor(column, 
StandardIndexes.nullValueVector()));
+      }
+      _columnReader = new PinotSegmentColumnReader(column, 
_forwardIndexReader, _dictionary, nullValueVectorReader,
+          columnMetadata.getMaxNumberOfMultiValues());
     }
 
+    @Nullable
     Object getValue(int docId) {
-      return _columnReader.getValue(docId);
+      return _columnReader.isNull(docId) ? null : 
_columnReader.getValue(docId);

Review Comment:
   Good call. I'll add a release-note line to the PR description: with null 
handling on, reloading a segment now keeps nulls from the source column in the 
derived column, instead of computing a value from the placeholder.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to