This repository was archived by the owner on Dec 20, 2018. It is now read-only.
Getting user defined types working#239
Open
jon-morra-zefr wants to merge 3 commits intodatabricks:masterfrom
Open
Getting user defined types working#239jon-morra-zefr wants to merge 3 commits intodatabricks:masterfrom
jon-morra-zefr wants to merge 3 commits intodatabricks:masterfrom
Conversation
jon-morra-zefr
commented
Jun 28, 2017
| */ | ||
|
|
||
| package com.databricks.spark.avro | ||
| package org.apache.spark.avro |
Author
There was a problem hiding this comment.
In order to reference UserDefinedType we have to change the package name.
| FloatType | DoubleType | StringType | BooleanType => identity | ||
| case _: DecimalType => (item: Any) => if (item == null) null else item.toString | ||
| FloatType | DoubleType | BooleanType => identity | ||
| case _: DecimalType | StringType => (item: Any) => if (item == null) null else item.toString |
Author
There was a problem hiding this comment.
My use case for this is serializing Enum[_] types. I'm doing this as strings on the backend. However, in my tests it was still presenting the native enum type to the native avro reader. By moving the StringType out and explicitly calling .toString on it I'm able to get around this issue assuming the UserDefinedType for my enums is StringType.
|
Question, some plan to merge this improve??? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As outlined in #235 it is desirable to get Avro serialization working with
UserDefinedTypes. This PR addresses that concern and allows serialization ofUserDefinedTypes. I wasn't able to write any tests, but I'm sure that can be done easily. This works on my local projects.