1

I am attempting to stream from sql table using the following:

my_sales =  spark.read.jdbc(jdbcUrl, dbo.table)

static = spark.read.format("csv").load(my_sales)
dataSchema = static.schema

I am trying to read in the data from the table with the following:

rawdf = (spark.readStream 
      .format("csv") \
      .option("maxFilesPerTrigger", 1) \
      .schema(dataSchema) \
      .csv(dataPath)
           )

I am using the following to write the data to the following location

saveloc = '/mnt/raw/streaminglocation/'


streamingQuery = (
  rawdf
  .writeStream
  .format("csv")
  .outputMode("append")
  .option("checkpointLocation", f"{saveloc}/_checkpoints")
  .option("mergeSchema", "true")
  .start(saveloc)
)

However this failing.

Is it possible to stream from a SQL table?

1 Answer 1

1

This is not possible. JDBC sources are not supported for Spark Structured Streaming.

Not convinced of the upfront coding either.

Use CDC with Kafka, or materialized updateable views with CDC with KAFKA, or Debezium.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.