Copilot commented on code in PR #16808:
URL: https://github.com/apache/pinot/pull/16808#discussion_r2345754629


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/invertedindex/JsonIndexHandler.java:
##########
@@ -134,7 +134,7 @@ private void 
createJsonIndexForColumn(SegmentDirectory.Writer segmentWriter, Col
     // Create new json index for the column.
     LOGGER.info("Creating new json index for segment: {}, column: {}", 
segmentName, columnName);
     Preconditions.checkState(columnMetadata.isSingleValue() && 
(columnMetadata.getDataType() == DataType.STRING
-            || columnMetadata.getDataType() == DataType.JSON),
+            || columnMetadata.getDataType() == DataType.JSON || 
columnMetadata.getDataType() == DataType.MAP),
         "Json index can only be applied to single-value STRING or JSON 
columns");

Review Comment:
   The error message is outdated and doesn't reflect that MAP columns are now 
supported. It should be updated to include MAP in the list of supported column 
types.
   ```suggestion
           "Json index can only be applied to single-value STRING, JSON, or MAP 
columns");
   ```



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/MapFilterOperator.java:
##########
@@ -70,6 +73,14 @@ public MapFilterOperator(IndexSegment indexSegment, 
Predicate predicate, QueryCo
       DataSource dataSource = indexSegment.getDataSourceNullable(_columnName);
       if (dataSource != null) {
         jsonIndex = dataSource.getJsonIndex();
+        if (jsonIndex == null) {
+          // Fallback to Composite JSON Index if standard JSON index is not 
available
+          Optional<IndexType<?, ?, ?>> compositeIndex =
+              IndexService.getInstance().getOptional("composite_json_index");
+          if (compositeIndex.isPresent()) {
+            jsonIndex = (JsonIndexReader) 
dataSource.getIndex(compositeIndex.get());

Review Comment:
   The unchecked cast to JsonIndexReader on line 81 could cause a 
ClassCastException if the composite index doesn't implement JsonIndexReader. 
Consider adding type checking or using instanceof before casting.
   ```suggestion
               Object compositeIndexReader = 
dataSource.getIndex(compositeIndex.get());
               if (compositeIndexReader instanceof JsonIndexReader) {
                 jsonIndex = (JsonIndexReader) compositeIndexReader;
               }
   ```



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