cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using from_avro function

MaximeGendre
New Contributor III

Hello everyone,
I need your help with a topic that has been preoccupying me for a few days.

"from_avro" function gives me a strange result when I pass it the json schema of a Kafka topic.

====================================================================

lastVersion = schema_registry_client.get_latest_version(topic_name +"-value")
print(f"last schema structure is {lastVersion.schema.schema_str}")
 
MaximeGendre_2-1717533967736.png

The schema looks pretty simple.

====================================================================

schema_json = """{
  "namespace": "aaa.kafkaday.planedemo",
  "type": "record",
  "name": "PlaneDemo",
  "fields": [
    {"name": "FlightNumber", "type": "string"},
    {"name": "PositionTime", "type": "long"},
    {"name": "Lat", "type": "double"},
    {"name": "Long", "type": "double"},
    {"name": "Alt", "type": "double"}
  ]
}"""

display(df.select(
  from_avro( col("value"),
            schema_json, from_avro_options)
))

MaximeGendre_0-1717533089570.png

Using from_avro on the same dataset with SchemaRegistry information it works well.

====================================================================

 
display(df.select(
  from_avro(data = F.col("value"),
            subject = topic_name +"-value",
            schemaRegistryAddress = schema_registry_address,
            options = schema_registry_options).alias("value")
    ).selectExpr("*"))

MaximeGendre_1-1717533556219.png

A suggestion on where I'm going wrong ?

Thank you.

 

 

 

 

0 REPLIES 0

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now