Skip to content

how do I call AvroSchemaUtils.toAvroSchema from python? #305

Answered by kothapet
kothapet asked this question in Q&A
Discussion options

You must be logged in to vote

I figured it out. This will work.
Looks like to convert from python dataframe to java dataframe you have to do df._jdf

LINK

Create a Python wrapper method
Similarly create other Python wrapper methods for the toAvroSchema variations

def toAvroSchema(dataFrame, columnName, recordName="defaultName", nameSpace ="defaultNameSpace"):

    jvm_gateway = SparkContext._active_spark_context._gateway.jvm

    return jvm_gateway.za.co.absa.abris.avro.parsing.utils.AvroSchemaUtils.toAvroSchema(dataFrame._jdf, columnName, recordName, nameSpace ).toString()


keyAvroSchema = toAvroSchema(df, "key")

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kothapet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants