skoppu22 commented on code in PR #109: URL: https://github.com/apache/cassandra-analytics/pull/109#discussion_r2081801395
########## cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/RecordWriter.java: ########## @@ -389,19 +391,52 @@ private Map<String, Object> getBindValuesForColumns(Map<String, Object> map, Str private Object maybeConvertUdt(Object value) { + if (value instanceof List) + { + List<Object> resultList = new ArrayList<>(); + for (Object entry : (List<?>) value) + { + resultList.add(maybeConvertUdt(entry)); + } + + return resultList; + } + + if (value instanceof Set) + { + Set<Object> resultList = new HashSet<>(); + for (Object entry : (Set<?>) value) + { + resultList.add(maybeConvertUdt(entry)); + } + + return resultList; + } + + if (value instanceof Map) + { + Map<Object, Object> resultMap = new HashMap<>(); + for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) + { + resultMap.put(maybeConvertUdt(entry.getKey()), maybeConvertUdt(entry.getValue())); + } + + return resultMap; + } Review Comment: - Updated CqlTable to maintain columns with UDTs and check it before calling maybeConvertUdt - There’s still a chance of creating unnecessary lists, sets, or maps, like udt<list<udt<set<map>>>>. We create new sets and maps without knowing if there are more UDTs inside. I tried counting UDTs in a column (inside determineColumnsWithUdts) to avoid this, but it may not work for all cases. It doesn’t differentiate when the same UDT type is used multiple times, like in map<udtType1, udtType1>, where the UDT count is 1 instead of 2. This is fine for Maps, but it could break things in non-Map cases. -- 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...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org