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


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImpl.java:
##########
@@ -966,16 +966,21 @@ public Set<String> getPhysicalColumnNames() {
   public DataSource getDataSource(String column) {
     FieldSpec fieldSpec = _schema.getFieldSpecFor(column);
     if (fieldSpec == null || fieldSpec.isVirtualColumn()) {
+      VirtualColumnContext virtualColumnContext = null;
       // Column is either added during ingestion, or was initiated with a 
virtual column provider
       if (fieldSpec == null) {
         // If the column was added during ingestion, we will construct the 
column provider based on its fieldSpec to
         // provide values
         fieldSpec = _newlyAddedColumnsFieldMap.get(column);
         Preconditions.checkNotNull(fieldSpec,
             "FieldSpec for " + column + " should not be null. " + "Potentially 
invalid column name specified.");
+        // newly added column shouldn't have any doc count?
+        virtualColumnContext = new VirtualColumnContext(fieldSpec, 0);

Review Comment:
   Why do we change this? I think the old code is correct



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/constant/ConstantMVForwardIndexReader.java:
##########
@@ -45,6 +45,9 @@ public DataType getStoredType() {
 
   @Override
   public int getDictIdMV(int docId, int[] dictIdBuffer, 
ForwardIndexReaderContext context) {
+    if (dictIdBuffer.length == 0) {

Review Comment:
   This is not needed when `maxNumberOfMultiValues` is properly set



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/column/DefaultNullValueVirtualColumnProvider.java:
##########
@@ -85,7 +85,13 @@ public InvertedIndexReader<?> 
buildInvertedIndex(VirtualColumnContext context) {
 
   @Override
   public ColumnMetadataImpl buildMetadata(VirtualColumnContext context) {
-    return 
getColumnMetadataBuilder(context).setCardinality(1).setSorted(context.getFieldSpec().isSingleValueField())
-        .setHasDictionary(true).build();
+    if (context.getFieldSpec().isSingleValueField()) {
+      return 
getColumnMetadataBuilder(context).setCardinality(1).setSorted(true)
+          .setTotalDocs(context.getTotalDocCount())
+          .setHasDictionary(true).build();
+    }
+    return 
getColumnMetadataBuilder(context).setSorted(false).setTotalDocs(context.getTotalDocCount())
+        .setHasDictionary(true).setMaxNumberOfMultiValues(0)
+        .build();

Review Comment:
   It should be set to 1
   ```suggestion
   
       ColumnMetadataImpl.Builder builder = 
getColumnMetadataBuilder(context).setCardinality(1).setHasDictionary(true);
       if (context.getFieldSpec().isSingleValueField()) {
         builder.setSorted(true);
       } else {
         builder.setMaxNumberOfMultiValues(1);
       }
       return builder.build();
   ```



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