Reader small image

You're reading from  Modern Data Architectures with Python

Product typeBook
Published inSep 2023
Reading LevelExpert
PublisherPackt
ISBN-139781801070492
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Brian Lipp
Brian Lipp
author image
Brian Lipp

Brian Lipp is a Technology Polyglot, Engineer, and Solution Architect with a wide skillset in many technology domains. His programming background has ranged from R, Python, and Scala, to Go and Rust development. He has worked on Big Data systems, Data Lakes, data warehouses, and backend software engineering. Brian earned a Master of Science, CSIS from Pace University in 2009. He is currently a Sr. Data Engineer working with large Tech firms to build Data Ecosystems.
Read more about Brian Lipp

Right arrow

Solution

We will get started as follows:

  1. First, we will import our libraries. Also, note that you must install confluent_kafka first using pip:
    from confluent_kafka.schema_registry import SchemaRegistryClient
    import ssl
    from pyspark.sql.functions import from_json
    from pyspark.sql.functions  import udf, col, expr
    from pyspark.sql.types import StringType
  2. Here, we set up our variables for our initial Kafka connection:
    kafka_cluster = "see confluent website"
    kafka_api_key = "see confluent website"
    kafka_api_secret = "see confluent website"
    kafka_topic = "chapter_5"
    boostrap_server = "see confluent website"
    schema_reg_url = "see confluent website"
    schema_api_key = "see confluent website"
    schema_api_secret = "see confluent website"
  3. We will create a UDF to convert the value into a string:
    binary_to_string = udf(lambda x: str(int.from_bytes(x, byteorder='big')), StringType())
  4. Now, we will...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Modern Data Architectures with Python
Published in: Sep 2023Publisher: PacktISBN-13: 9781801070492

Author (1)

author image
Brian Lipp

Brian Lipp is a Technology Polyglot, Engineer, and Solution Architect with a wide skillset in many technology domains. His programming background has ranged from R, Python, and Scala, to Go and Rust development. He has worked on Big Data systems, Data Lakes, data warehouses, and backend software engineering. Brian earned a Master of Science, CSIS from Pace University in 2009. He is currently a Sr. Data Engineer working with large Tech firms to build Data Ecosystems.
Read more about Brian Lipp