-
Notifications
You must be signed in to change notification settings - Fork 4.7k
AddFiles: Add dry_run #40167
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
base: master
Are you sure you want to change the base?
AddFiles: Add dry_run #40167
Changes from all commits
2d2d5de
118fc01
bddfb6f
bd67e96
15ed933
6fafab8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run.", | ||
| "modification": 7 | ||
| "modification": 8 | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -120,7 +120,8 @@ public static Builder builder() { | |||||
| public abstract @Nullable List<String> getSortFields(); | ||||||
|
|
||||||
| @SchemaFieldDescription( | ||||||
| "Lets the transform change the table schema so that every file's columns are covered." | ||||||
| "Lets the transform change the table schema so that the table has a column for every" | ||||||
| + " column the files have." | ||||||
| + " Values: ALLOW_FIELD_ADDITION (columns a file has and the table lacks are added, as" | ||||||
| + " optional), ALLOW_FIELD_RELAXATION (a required table column becomes optional when a" | ||||||
| + " file lacks it or may hold nulls in it), ALLOW_TYPE_PROMOTION (a column type is" | ||||||
|
|
@@ -145,6 +146,19 @@ public static Builder builder() { | |||||
| + " Requires schema_evolution_options.") | ||||||
| public abstract @Nullable List<String> getRequiredColumns(); | ||||||
|
|
||||||
| @SchemaFieldDescription( | ||||||
| "When true, nothing is committed or registered: the transform reads the files' schemas" | ||||||
| + " and emits a dry_run_report output with one row that describes what a real run" | ||||||
| + " would do. Its allowed field is true when every file schema can be merged and the" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| + " configuration raises no problem; otherwise its reason field says what a real run" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| + " would do about it (fail, or route the files to the error output). Its schemas" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| + " field lists each distinct file schema with the changes a real run would make for" | ||||||
| + " it and, when it cannot be merged, why. The output only exists when this is set;" | ||||||
| + " consume it as input: <this transform's name>.dry_run_report. Against a missing" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| + " table, a REST catalog needs table-create permission even though no table is" | ||||||
| + " created.") | ||||||
| public abstract @Nullable Boolean getDryRun(); | ||||||
|
|
||||||
| @SchemaFieldDescription( | ||||||
| "What happens when a file's schema cannot be made to fit the table: it needs a change" | ||||||
| + " that is not allowed, or it conflicts with the table or with another file." | ||||||
|
|
@@ -158,8 +172,9 @@ public static Builder builder() { | |||||
| + " Parquet footers only), or a Parquet file with no null-count statistics for a" | ||||||
| + " required column (statistics disabled by the writer, or a column under a list or" | ||||||
| + " map). REJECT (the default) sends the file to the error output (see" | ||||||
| + " error_handling). ACCEPT registers it without checks, counted and logged. A file" | ||||||
| + " that fails a check is always sent to the error output. An accepted file that" | ||||||
| + " error_handling). ACCEPT registers it without the checks; such files are counted" | ||||||
| + " and logged. A file that fails a check is always sent to the error output. An" | ||||||
| + " accepted file that" | ||||||
| + " lacks a required column, or holds nulls in it, makes reads of the table fail.") | ||||||
| public abstract @Nullable String getUnverifiableFileHandling(); | ||||||
|
|
||||||
|
|
@@ -198,6 +213,8 @@ public abstract static class Builder { | |||||
|
|
||||||
| public abstract Builder setUnverifiableFileHandling(String handling); | ||||||
|
|
||||||
| public abstract Builder setDryRun(Boolean dryRun); | ||||||
|
|
||||||
| public abstract Configuration build(); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -207,19 +224,21 @@ public abstract static class Builder { | |||||
| List<String> pins = getRequiredColumns(); | ||||||
| String handlingName = getIncompatibleSchemaHandling(); | ||||||
| String unverifiableName = getUnverifiableFileHandling(); | ||||||
| boolean dryRun = Boolean.TRUE.equals(getDryRun()); | ||||||
| boolean nothingSet = | ||||||
| (optionNames == null || optionNames.isEmpty()) | ||||||
| && (pins == null || pins.isEmpty()) | ||||||
| && handlingName == null | ||||||
| && unverifiableName == null; | ||||||
| && unverifiableName == null | ||||||
| && !dryRun; | ||||||
| if (nothingSet) { | ||||||
| return null; | ||||||
| } | ||||||
| // SchemaEvolutionConfig.build() checks this too; this copy names the YAML keys | ||||||
| Preconditions.checkArgument( | ||||||
| optionNames != null && !optionNames.isEmpty(), | ||||||
| "required_columns, incompatible_schema_handling and unverifiable_file_handling need at" | ||||||
| + " least one schema_evolution_options entry"); | ||||||
| "required_columns, incompatible_schema_handling, unverifiable_file_handling and" | ||||||
| + " dry_run need at least one schema_evolution_options entry"); | ||||||
| Set<SchemaEvolutionOption> options = EnumSet.noneOf(SchemaEvolutionOption.class); | ||||||
| for (String name : checkStateNotNull(optionNames)) { | ||||||
| options.add(parseEnum(SchemaEvolutionOption.class, name, "schema_evolution_options")); | ||||||
|
|
@@ -228,6 +247,7 @@ public abstract static class Builder { | |||||
| if (pins != null) { | ||||||
| builder = builder.setRequiredColumns(new LinkedHashSet<>(pins)); | ||||||
| } | ||||||
| builder = builder.setDryRun(dryRun); | ||||||
| if (handlingName != null) { | ||||||
| SchemaEvolutionConfig.IncompatibleSchemaHandling handling = | ||||||
| parseEnum( | ||||||
|
|
@@ -316,6 +336,9 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) { | |||||
| if (errorHandling != null) { | ||||||
| output = output.and(errorHandling.getOutput(), result.get(ERROR_TAG)); | ||||||
| } | ||||||
| if (Boolean.TRUE.equals(configuration.getDryRun())) { | ||||||
| output = output.and(AddFiles.DRY_RUN_TAG, result.get(AddFiles.DRY_RUN_TAG)); | ||||||
| } | ||||||
| return output; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
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.