-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow read old parquet file which is maked by old api with old avro version which allow wrong default value in schema #1140
base: master
Are you sure you want to change the base?
Conversation
…ersion which allow wrong default value in schema
Thanks @wwang-talend for opening the PR! Could you create a JIRA issue for this? |
@@ -129,10 +129,10 @@ public RecordMaterializer<T> prepareForRead( | |||
avroSchema = new Schema.Parser().parse(metadata.get(AVRO_READ_SCHEMA_METADATA_KEY)); | |||
} else if (keyValueMetaData.get(AVRO_SCHEMA_METADATA_KEY) != null) { | |||
// use the Avro schema from the file metadata if present | |||
avroSchema = new Schema.Parser().parse(keyValueMetaData.get(AVRO_SCHEMA_METADATA_KEY)); | |||
avroSchema = new Schema.Parser().setValidateDefaults(false).parse(keyValueMetaData.get(AVRO_SCHEMA_METADATA_KEY)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this issue exist with both AVRO_SCHEMA_METADATA_KEY
and OLD_AVRO_SCHEMA_METADATA_KEY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blindly disabling validation at all times may introduce new issues silently. Is it safer to add a flag to work around this? In the default case, we should always enable validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc Avro experts @Fokko @gszadovszky @clairemcginty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does seem potentially scary - maybe it would be safest to make this a Configuration option that the user can opt into?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 with option to enable this or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 making it a config option
Please consider if user call this api to write a parquet file with avro schema string in file metadata:
that "avroSchema" have wrong default value(as before avro 1.9, avro api not validate default value when construct avro schema).
Now user use new parquet-avro jar with avro 1.11.x, and do read action to read that old parquet file with avro schema string in file metadata, then will check the default value by parse avro schema in parquet AvroReadSupport, then issue will appear. That is why do this change here.
exception stack is this: