-
Notifications
You must be signed in to change notification settings - Fork 3k
Flink: use correct metric config for position deletes #6313
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
Changes from 4 commits
cbb3fb9
205638d
5d63141
c44d036
d75c3d4
4b885c3
0a9337f
a762972
4de6115
f43000b
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 |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
| import org.apache.iceberg.PartitionSpec; | ||
| import org.apache.iceberg.Schema; | ||
| import org.apache.iceberg.StructLike; | ||
| import org.apache.iceberg.Table; | ||
| import org.apache.iceberg.avro.Avro; | ||
| import org.apache.iceberg.deletes.EqualityDeleteWriter; | ||
| import org.apache.iceberg.deletes.PositionDeleteWriter; | ||
|
|
@@ -55,13 +56,14 @@ public class FlinkAppenderFactory implements FileAppenderFactory<RowData>, Seria | |
| private final int[] equalityFieldIds; | ||
| private final Schema eqDeleteRowSchema; | ||
| private final Schema posDeleteRowSchema; | ||
| private final Table table; | ||
|
|
||
| private RowType eqDeleteFlinkSchema = null; | ||
| private RowType posDeleteFlinkSchema = null; | ||
|
|
||
| public FlinkAppenderFactory( | ||
| Schema schema, RowType flinkSchema, Map<String, String> props, PartitionSpec spec) { | ||
| this(schema, flinkSchema, props, spec, null, null, null); | ||
| this(null, schema, flinkSchema, props, spec, null, null, null); | ||
| } | ||
|
|
||
| public FlinkAppenderFactory( | ||
|
|
@@ -72,6 +74,27 @@ public FlinkAppenderFactory( | |
| int[] equalityFieldIds, | ||
| Schema eqDeleteRowSchema, | ||
| Schema posDeleteRowSchema) { | ||
| this( | ||
| null, | ||
| schema, | ||
| flinkSchema, | ||
| props, | ||
| spec, | ||
| equalityFieldIds, | ||
| eqDeleteRowSchema, | ||
| posDeleteRowSchema); | ||
| } | ||
|
|
||
| public FlinkAppenderFactory( | ||
| Table table, | ||
| Schema schema, | ||
| RowType flinkSchema, | ||
| Map<String, String> props, | ||
| PartitionSpec spec, | ||
| int[] equalityFieldIds, | ||
| Schema eqDeleteRowSchema, | ||
| Schema posDeleteRowSchema) { | ||
| this.table = table; | ||
| this.schema = schema; | ||
| this.flinkSchema = flinkSchema; | ||
| this.props = props; | ||
|
|
@@ -99,7 +122,8 @@ private RowType lazyPosDeleteFlinkSchema() { | |
|
|
||
| @Override | ||
| public FileAppender<RowData> newAppender(OutputFile outputFile, FileFormat format) { | ||
| MetricsConfig metricsConfig = MetricsConfig.fromProperties(props); | ||
| MetricsConfig metricsConfig = | ||
| table != null ? MetricsConfig.forTable(table) : MetricsConfig.fromProperties(props); | ||
|
||
| try { | ||
| switch (format) { | ||
| case AVRO: | ||
|
|
@@ -160,7 +184,8 @@ public EqualityDeleteWriter<RowData> newEqDeleteWriter( | |
| eqDeleteRowSchema, | ||
| "Equality delete row schema shouldn't be null when creating equality-delete writer"); | ||
|
|
||
| MetricsConfig metricsConfig = MetricsConfig.fromProperties(props); | ||
| MetricsConfig metricsConfig = | ||
| table != null ? MetricsConfig.forTable(table) : MetricsConfig.fromProperties(props); | ||
| try { | ||
| switch (format) { | ||
| case AVRO: | ||
|
|
@@ -216,7 +241,8 @@ public EqualityDeleteWriter<RowData> newEqDeleteWriter( | |
| @Override | ||
| public PositionDeleteWriter<RowData> newPosDeleteWriter( | ||
| EncryptedOutputFile outputFile, FileFormat format, StructLike partition) { | ||
| MetricsConfig metricsConfig = MetricsConfig.fromProperties(props); | ||
| MetricsConfig metricsConfig = | ||
| table != null ? MetricsConfig.forTable(table) : MetricsConfig.fromProperties(props); | ||
|
||
| try { | ||
| switch (format) { | ||
| case AVRO: | ||
|
|
||
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.
The data row in equality delete should share the same metrics config as the table, so I change this as well.
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 actually makes a stronger case that we should pass in a valid
Tableobject to theFlinkAppenderFactoryas I mentioned in the other comment. we should also useforTablefor position delete although it doesn't need schema or SortOrder as you said.