-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[format] Format prefix in option keys are processed in each format #4245
Conversation
|
||
public AvroFileFormat(FormatContext context) { | ||
super(IDENTIFIER); | ||
this.context = context; | ||
|
||
this.options = getIdentifierPrefixOptions(context.options(), false); |
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.
Can you also modify AVRO_OUTPUT_CODEC
and AVRO_ROW_NAME_MAPPING
to add prefix?
String prefix = formatIdentifier.toLowerCase() + "."; | ||
for (String key : options.keySet()) { | ||
if (key.toLowerCase().startsWith(prefix)) { | ||
String substr = key.substring(prefix.length()); |
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.
Change substr to another better name?
@@ -62,11 +62,14 @@ public class AvroFileFormat extends FileFormat { | |||
public static final ConfigOption<Map<String, String>> AVRO_ROW_NAME_MAPPING = |
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.
In AvroFileFormat, IDENTIFIER && AVRO_OUTPUT_CODEC && AVRO_ROW_NAME_MAPPING should be private.
public static FileFormat fromIdentifier(String identifier, Options options) { | ||
return fromIdentifier(identifier, new FormatContext(options, 1024, 1024)); | ||
return fromIdentifier( |
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 called method fromIdentifier should be private.
@@ -47,8 +47,8 @@ public void testAbsent() { | |||
@Test | |||
public void testPresent() { | |||
Options options = new Options(); | |||
options.setString("haha", "1"); | |||
options.setString("compress", "zlib"); | |||
options.setString("orc.haha", "1"); |
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.
Change haha to other normal orc option?
Good work! |
+1 |
Purpose
Currently, format prefix in option keys are removed before sending into the constructor of each format. However, most formats (orc, parquet) still recover these prefixes in their code, so it would be better to let the format itself deal with these prefixes.
Also, we're going to introduce a special
compacted changelog
format, which wraps other file formats. However with the current code, each format can only see the options related to itself. If option keys are processed in each format, we can see options for other formats and keep what we need.This PR process option keys in each format.
Tests
Existing tests should cover this change.
API and Format
No format changes.
Documentation
No new feature.