skoppu22 commented on code in PR #220:
URL: 
https://github.com/apache/cassandra-analytics/pull/220#discussion_r3530505903


##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/TableSchema.java:
##########
@@ -308,6 +300,47 @@ private static void 
validateDataframeFieldsInTable(TableInfoProvider tableInfo,
         Preconditions.checkArgument(unknownFields.isEmpty(), "Unknown fields 
in data frame => " + unknownFields);
     }
 
+    /**
+     * Validates secondary index constraints for bulk write operations.
+     * <p>
+     * When the cluster is Cassandra 5.0+ and ALL indexes are SAI, the write 
is allowed because
+     * SAI index components are generated alongside SSTables and are 
immediately queryable after import.
+     * <p>
+     * When any index is non-SAI (legacy 2i), the write is blocked unless 
SKIP_SECONDARY_INDEX_CHECK is set.
+     *
+     * @param tableInfo               the table info provider
+     * @param skipSecondaryIndexCheck  whether the user explicitly opted out 
of the check
+     * @param indexStatements          the CREATE INDEX statements for the 
table
+     * @param lowestCassandraVersion   the lowest Cassandra version in the 
cluster
+     */
+    static void validateSecondaryIndexes(TableInfoProvider tableInfo,
+                                         boolean skipSecondaryIndexCheck,
+                                         Set<String> indexStatements,
+                                         String lowestCassandraVersion)
+    {
+        if (!tableInfo.hasSecondaryIndex())
+        {
+            return; // No indexes — nothing to validate
+        }
+
+        if (isSaiWrite(indexStatements, lowestCassandraVersion))
+        {
+            LOGGER.info("Table has SAI indexes on Cassandra 5.0+. SAI index 
components will be generated "
+                      + "alongside SSTables. indexCount={}", 
indexStatements.size());
+            return;
+        }
+
+        if (skipSecondaryIndexCheck)
+        {
+            LOGGER.warn("Bulk writing to tables with SecondaryIndexes will 
have an asynchronous index rebuild "
+                      + "take place automatically after writing. Reads against 
the index during this time "
+                      + "window will produce inconsistent or stale results 
until index rebuild is complete.");
+            return;
+        }
+
+        throw new UnsupportedAnalyticsOperationException("Bulkwriter doesn't 
support secondary indexes");

Review Comment:
   Done



##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/TableSchema.java:
##########
@@ -308,6 +300,47 @@ private static void 
validateDataframeFieldsInTable(TableInfoProvider tableInfo,
         Preconditions.checkArgument(unknownFields.isEmpty(), "Unknown fields 
in data frame => " + unknownFields);
     }
 
+    /**
+     * Validates secondary index constraints for bulk write operations.
+     * <p>
+     * When the cluster is Cassandra 5.0+ and ALL indexes are SAI, the write 
is allowed because
+     * SAI index components are generated alongside SSTables and are 
immediately queryable after import.
+     * <p>
+     * When any index is non-SAI (legacy 2i), the write is blocked unless 
SKIP_SECONDARY_INDEX_CHECK is set.
+     *
+     * @param tableInfo               the table info provider
+     * @param skipSecondaryIndexCheck  whether the user explicitly opted out 
of the check
+     * @param indexStatements          the CREATE INDEX statements for the 
table
+     * @param lowestCassandraVersion   the lowest Cassandra version in the 
cluster
+     */
+    static void validateSecondaryIndexes(TableInfoProvider tableInfo,

Review Comment:
   Done



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