egalpin commented on code in PR #10234:
URL: https://github.com/apache/pinot/pull/10234#discussion_r1122438790
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImpl.java:
##########
@@ -558,15 +560,40 @@ 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) {
+ int numComparisonColumns = _upsertComparisonColumns.size();
+ Comparable[] comparisonValues = new Comparable[numComparisonColumns];
+
+ int numNonNull = 0;
+ for (int i = 0; i < numComparisonColumns; i++) {
+ String columnName = _upsertComparisonColumns.get(i);
+
+ if (!row.isNullValue(columnName)) {
+ // Inbound records may only have exactly 1 non-null value in one of
the comparison column i.e. comparison
+ // columns are mutually exclusive
+ numNonNull++;
+
+ Object comparisonValue = row.getValue(columnName);
+ Preconditions.checkState(comparisonValue instanceof Comparable,
+ "Upsert comparison column: %s must be comparable", columnName);
+ comparisonValues[i] = (Comparable) comparisonValue;
+ }
+ }
+ Preconditions.checkState(numNonNull == 1 || numNonNull == 0,
Review Comment:
Done as part of
https://github.com/apache/pinot/pull/10234/commits/45066e94007f5c9aac237c14061b7107a8180092
--
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]