Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

(SPARK-12823) Cannot create UDF with StructType input -

avatar
Rising Star

Hi, I am trying create a UDF and use it in dataframe select something like

val selected = jsonRxMap.select(parsePatient($"Patient") ,parseProvider($"Provider"),parsePharmacy($"Pharmacy"))

$"Patient" is StuctureType and I searched google find this SPARK-12823 and I am not sure is there any work around to solve the problem. The goal is that by passing the StructuredType ( struct<FirstName:string,Address1:string,Address2:string,AltID:string,Beeper:string,..) to parsePatient function which returns a unique value to that patient and I can store the patient in a dimention table in hive with ORC format.

Can any one help.

thanks

Ram

1 ACCEPTED SOLUTION

avatar
Rising Star

Hi All, I further researched this issue and found an alternative solution. if you define the function as follows

val parsePatientfun = udf { (thestruct: Row) => thestruct.getAs[String]("City") }

you can get to the fields from StuctureType.

Thanks

Ram

View solution in original post

1 REPLY 1

avatar
Rising Star

Hi All, I further researched this issue and found an alternative solution. if you define the function as follows

val parsePatientfun = udf { (thestruct: Row) => thestruct.getAs[String]("City") }

you can get to the fields from StuctureType.

Thanks

Ram