egalpin commented on code in PR #10234:
URL: https://github.com/apache/pinot/pull/10234#discussion_r1120629885


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImpl.java:
##########
@@ -558,15 +560,39 @@ private RecordInfo getRecordInfo(GenericRow row, int 
docId) {
     PrimaryKey primaryKey = row.getPrimaryKey(_schema.getPrimaryKeyColumns());
 
     if (isUpsertEnabled()) {
-      Object upsertComparisonValue = row.getValue(_upsertComparisonColumn);
-      Preconditions.checkState(upsertComparisonValue instanceof Comparable,
-          "Upsert comparison column: %s must be comparable", 
_upsertComparisonColumn);
-      return new RecordInfo(primaryKey, docId, (Comparable) 
upsertComparisonValue);
+      if (_upsertComparisonColumns.size() > 1) {
+        return multiComparisonRecordInfo(primaryKey, docId, row);
+      }
+      Comparable comparisonValue = (Comparable) 
row.getValue(_upsertComparisonColumns.get(0));
+      return new RecordInfo(primaryKey, docId, comparisonValue);
     }
 
     return new RecordInfo(primaryKey, docId, null);
   }
 
+  private RecordInfo multiComparisonRecordInfo(PrimaryKey primaryKey, int 
docId, GenericRow row) {
+    Comparable[] comparisonColumns = new 
Comparable[_upsertComparisonColumns.size()];
+
+    int i = -1;
+    for (String columnName : _upsertComparisonColumns) {
+      i++;
+      Object comparisonValue = row.getValue(columnName);
+
+      Preconditions.checkState(comparisonValue instanceof Comparable,
+          "Upsert comparison column: %s must be comparable", columnName);
+
+      if (row.isNullValue(columnName)) {
+        // Inbound records may only have exactly 1 non-null value in one of 
the comparison column i.e. comparison

Review Comment:
   I had intended to enforce this so as to avoid highly complex comparison 
logic.  But we could potentially support all values being non-null if there's 
an agreeable way to perform the comparison.
   
   Ex. Do all values for a new/inbound doc need to be greater than 
corresponding prior values? Or should it be "if any value is higher than 
corresponding prior value, perform the upsert?" 



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

Reply via email to