-
Notifications
You must be signed in to change notification settings - Fork 922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow custom type converters to be utilized for collection types #1204
base: master
Are you sure you want to change the base?
allow custom type converters to be utilized for collection types #1204
Conversation
test this please |
test this please |
@RussellSpitzer I'm not sure why the automated testing isn't working on this branch |
@RussellSpitzer what steps would I need to go through to get this merged? |
@RussellSpitzer: sorry to bother, but wondering if it is possible to get this PR in? |
@aashishs101 Sorry about that, we only check the JIRA so I miss if people post PR's without an accompanying ticket. Please file one and we'll get to review and testing ASAP. |
test this please |
Only authorized users can start the tests :) |
Build against Scala 2.11 finished with failure |
|
Currently, the connector limits users' ability to create custom type converters for collection types. Instead, it only allows the use of the default collection converters, which just apply in-scope converters to the elements of a collection, while ignoring any user-defined converters for the collection type. This prevents use cases where a converter is being used to convert a non-collection type into a collection, or where a collection is being converted into another collection (for instance we want to only store the keys of a map as a list). Currently, when such a custom converter is specified, it will fail with the following exception:
[info] - should write to a table with HLLs *** FAILED *** [info] org.apache.spark.SparkException: Job aborted due to stage failure: Task 11 in stage 0.0 failed 1 times, most recent failure: Lost task 11.0 in stage 0.0 (TID 11, localhost, executor driver): com.datastax.spark.connector.types.TypeConversionException: Cannot convert object OurType(14,16384,0.7212525005219688) of type class com.us.commons.internal.util.fn.OurType to Map[AnyRef,AnyRef]. [info] at com.datastax.spark.connector.types.TypeConverter$$anonfun$convert$1.apply(TypeConverter.scala:45) [info] at com.datastax.spark.connector.types.TypeConverter$CollectionConverter$$anonfun$convertPF$35.applyOrElse(TypeConverter.scala:694) [info] at com.datastax.spark.connector.types.TypeConverter$class.convert(TypeConverter.scala:43) [info] at com.datastax.spark.connector.types.TypeConverter$CollectionConverter.convert(TypeConverter.scala:682)
This is because of lines like this one that don't try to look for the correct type converter in scope. The proposed change keeps the current functionality of using the default collection converters, but only when a custom one isn't also in scope.
JIRA Ticket: https://datastax-oss.atlassian.net/browse/SPARKC-556