spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Segel <msegel_had...@hotmail.com>
Subject Re: schema change for structured spark streaming using jsonl files
Date Wed, 25 Apr 2018 15:35:36 GMT
Hi,

This is going to sound complicated.

Taken as an individual JSON document, because its a self contained schema doc, its structured.
 However there isn’t a persisting schema that has to be consistent across multiple documents.
 So you can consider it semi structured.

If you’re parsing the JSON document and storing different attributes in separate columns…
you will have a major issue because its possible for a JSON document to contain a new element
that isn’t in your Parquet schema.

If you are going from JSON to parquet… you will probably be better off storing a serialized
version of the JSON doc and then storing highlighted attributes in separate columns.

HTH

-Mike


> On Apr 23, 2018, at 1:46 PM, Lian Jiang <jiangok2006@gmail.com> wrote:
> 
> Hi,
> 
> I am using structured spark streaming which reads jsonl files and writes into parquet
files. I am wondering what's the process if jsonl files schema change.
> 
> Suppose jsonl files are generated in \jsonl folder and the old schema is { "field1":
String}. My proposal is:
> 
> 1. write the jsonl files with new schema (e.g. {"field1":String, "field2":Int}) into
another folder \jsonl2
> 2. let spark job complete handling all data in \jsonl, then stop the spark streaming
job.
> 3. use a spark script to convert the parquet files from old schema to new schema (e.g.
add a new column with some default value for "field2").
> 4. upgrade and start the spark streaming job for handling the new schema jsonl files
and parquet files.
> 
> Is this process correct (best)? Thanks for any clue.

Mime
View raw message