lukasz-antoniak commented on code in PR #174:
URL:
https://github.com/apache/cassandra-analytics/pull/174#discussion_r2889193145
##########
cassandra-analytics-common/src/main/java/org/apache/cassandra/spark/data/CqlTable.java:
##########
@@ -275,6 +275,55 @@ public boolean containsUdt(String fieldName)
return columnsWithUdts.contains(fieldName);
}
+ /**
+ * Checks if a type is a tuple type (possibly wrapped in frozen)
+ * @param type the CQL type to check
+ * @return true if the type is a tuple or tuple inside a frozen
+ */
+ public static boolean isTupleType(CqlField.CqlType type)
+ {
+ return unwrapFrozen(type) instanceof CqlField.CqlTuple;
+ }
+
+ /**
+ * Checks if a collection type contains tuples
+ * @param type the CQL type to check
+ * @return true if the type is a collection containing tuples
+ */
+ public static boolean containsTuples(CqlField.CqlType type)
+ {
+ CqlField.CqlType unwrapped = unwrapFrozen(type);
+
+ if (unwrapped instanceof CqlField.CqlList || unwrapped instanceof
CqlField.CqlSet)
+ {
+ CqlField.CqlCollection collection = (CqlField.CqlCollection)
unwrapped;
+ return isTupleType(collection.type()) ||
containsTuples(collection.type());
+ }
+
+ if (unwrapped instanceof CqlField.CqlMap)
+ {
+ CqlField.CqlMap map = (CqlField.CqlMap) unwrapped;
+ return isTupleType(map.keyType()) || containsTuples(map.keyType())
+ || isTupleType(map.valueType()) ||
containsTuples(map.valueType());
+ }
+
+ return false;
+ }
+
+ /**
+ * Unwraps frozen wrapper if present
+ * @param type the type to unwrap
+ * @return the inner type if frozen, otherwise the original type
+ */
+ public static CqlField.CqlType unwrapFrozen(CqlField.CqlType type)
Review Comment:
NIT: `unwrapIfFrozen` sounds better.
--
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]