You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "hubgeter (via GitHub)" <gi...@apache.org> on 2026/10/16 08:17:02 UTC

[PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

hubgeter opened a new pull request, #69188:
URL: https://github.com/apache/doris/pull/69188

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: N/A
   
   Problem Summary:
   
   Doris could not write an Iceberg partition by value when the identity partition field had been renamed away from its source column (`ALTER TABLE t ADD PARTITION KEY id AS id_identity`):
   
   - `INSERT OVERWRITE TABLE t PARTITION (id = 2) (value, metric) VALUES ('b', 2)` failed with `Unknown partition column 'id' in table 't'. Available partition columns: [id_identity]`, although `id` is the column Spark resolves for a static partition clause and the one `SHOW CREATE TABLE` renders for this table (`PARTITION BY LIST (\`id\`)`);
   - `... PARTITION (id_identity = 2) (value, metric) ...` passed the validation but then failed with `Column has no default value, column=id`: `id_identity` is a partition FIELD name, not a table column, so the static literal could not be materialized into any row column;
   - `... PARTITION (id_identity = 2) SELECT id, value, metric ...` (no column list) was accepted and wrote data files whose `id` column value disagreed with their own partition value.
   
   The two checks contradicted each other: the validation required a name that the binder then rejected, so there was no usable spelling.
   
   Fix:
   
   - resolve a `PARTITION (col = val)` name to the identity partition field's SOURCE column, case-insensitively — the identifier the binder can materialize (`PluginDrivenExternalTable#materializeStaticPartitionValues`);
   - reject a renamed partition FIELD name with the source column to use instead, and list the usable source columns for an unknown name; non-identity transforms keep their existing rejection;
   - rewrite the static partition spec keys to partition FIELD names before the BE sink (`static_partition_values`) and the commit row filter consume them, so the thrift contract, the overwrite row filter and the BE writer stay unchanged.
   
   Behavior is aligned with Spark:
   
   - Spark's `Analyzer.partitionColumnNames` takes the identity transform's field reference, so a static partition column is the SOURCE column (`PARTITION (id = 2)`), not the renamed field name;
   - `Analyzer.addStaticPartitionColumns` materializes that literal into the source column and rejects the same column in an explicit insert column list — Doris does the same after this change;
   - the resulting overwrite is an `OverwriteFiles.overwriteByRowFilter(id = 2)` (`Iceberg SparkWrite`), which is exactly what Doris builds once the spec is field-keyed.
   
   Effect after the fix: `PARTITION (id = 2)` overwrites only that partition, the new files carry `id = 2` next to partition value `2`, and Spark reads the same rows; `PARTITION (id_identity = 2)` now reports `'id_identity' ... is a partition field name, not a table column; write the identity partition by its source column 'id' instead.` instead of a contradictory error or a corrupted write. Tables whose partition field name already equals its source column are unaffected.
   
   ### Release note
   
   Fix `INSERT [OVERWRITE] ... PARTITION (col = val)` on Iceberg tables whose identity partition field was renamed with `ADD PARTITION KEY ... AS ...`: the static value is now written through the identity source column (`PARTITION (id = 2)`), matching Spark, instead of reporting contradictory errors or writing files whose data column disagreed with the partition value. Non-identity transforms and unpartitioned tables keep their existing rejection.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [x] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason
   - Manual test detail: full `fe-connector-iceberg` module unit tests (93 test classes) plus checkstyle pass locally with 0 failures on top of current master; the new regression case (TC39) needs the external docker Iceberg environment to run, so it is expected to be covered by the regression pipeline.
   - Behavior changed:
       - [ ] No.
       - [x] Yes.
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6282521177

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6265819165

   # FE Regression Coverage Report
   Increment line coverage `  0.00% (0/4)` :tada:
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/69188_bb7d6ab74c9a76e087ed16b356588936fa01d314_merge_fe/increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/69188_bb7d6ab74c9a76e087ed16b356588936fa01d314_merge_fe/report/index.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6282521603

   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6261498075

   /review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6212587584

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 151949 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit 6cf4d69938059e2e0d4eaa728692c18056428e5a, data reload: false
   
   query5	4317	614	443	443
   query6	427	227	197	197
   query7	4802	442	232	232
   query8	312	176	162	162
   query9	8770	3981	3965	3965
   query10	450	333	254	254
   query11	6020	3808	3554	3554
   query12	142	92	89	89
   query13	1258	431	309	309
   query14	6108	4035	3788	3788
   query14_1	3477	3500	3496	3496
   query15	210	196	173	173
   query16	935	483	440	440
   query17	830	637	510	510
   query18	2409	414	307	307
   query19	189	153	131	131
   query20	82	83	80	80
   query21	203	137	108	108
   query22	12886	13019	12750	12750
   query23	13621	12930	12528	12528
   query23_1	12647	12679	12562	12562
   query24	7100	838	453	453
   query24_1	467	454	465	454
   query25	509	384	333	333
   query26	1316	254	139	139
   query27	2775	440	268	268
   query28	4623	1938	1926	1926
   query29	1582	616	457	457
   query30	305	228	183	183
   query31	1009	930	813	813
   query32	139	93	98	93
   query33	524	312	263	263
   query34	897	864	525	525
   query35	746	761	684	684
   query36	820	805	753	753
   query37	123	95	85	85
   query38	1799	1736	1676	1676
   query39	801	793	755	755
   query39_1	737	733	738	733
   query40	221	112	91	91
   query41	65	62	62	62
   query42	86	85	81	81
   query43	368	373	317	317
   query44	1281	686	688	686
   query45	180	175	161	161
   query46	858	960	574	574
   query47	3000	2865	2917	2865
   query48	310	308	217	217
   query49	573	396	285	285
   query50	678	274	230	230
   query51	10300	10509	10097	10097
   query52	80	83	70	70
   query53	191	201	150	150
   query54	235	192	187	187
   query55	76	69	63	63
   query56	241	229	224	224
   query57	1617	1574	1583	1574
   query58	276	263	239	239
   query59	2118	2135	1975	1975
   query60	294	245	228	228
   query61	149	146	143	143
   query62	395	339	287	287
   query63	203	162	159	159
   query64	2757	985	785	785
   query65	3278	3263	3221	3221
   query66	1766	416	293	293
   query67	20424	20204	20219	20204
   query68	3038	989	617	617
   query69	379	270	245	245
   query70	883	790	786	786
   query71	300	224	207	207
   query72	2785	2557	2282	2282
   query73	512	519	293	293
   query74	4628	4459	4326	4326
   query75	2351	2313	1955	1955
   query76	2308	1016	596	596
   query77	342	388	296	296
   query78	9807	9613	9064	9064
   query79	889	843	524	524
   query80	472	415	377	377
   query81	530	321	275	275
   query82	220	133	111	111
   query83	199	193	176	176
   query84	291	112	96	96
   query85	760	419	369	369
   query86	260	239	245	239
   query87	2009	1975	1810	1810
   query88	3589	2699	2684	2684
   query89	330	295	259	259
   query90	2105	183	173	173
   query91	165	156	150	150
   query92	93	85	80	80
   query93	997	999	570	570
   query94	442	309	284	284
   query95	593	334	310	310
   query96	670	538	231	231
   query97	2461	2418	2313	2313
   query98	166	154	151	151
   query99	774	771	655	655
   Total cold run time: 233517 ms
   Total hot run time: 151949 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6261496462

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6211186466

   /review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6212044297

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6263143053

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 24.5 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit bb7d6ab74c9a76e087ed16b356588936fa01d314, data reload: false
   
   query1	0.01	0.00	0.01
   query2	0.10	0.05	0.05
   query3	0.26	0.12	0.12
   query4	1.61	0.11	0.12
   query5	0.24	0.24	0.25
   query6	1.18	0.70	0.68
   query7	0.03	0.01	0.00
   query8	0.05	0.04	0.04
   query9	0.41	0.35	0.35
   query10	0.59	0.60	0.58
   query11	0.20	0.15	0.14
   query12	0.18	0.14	0.14
   query13	0.50	0.50	0.48
   query14	1.04	1.01	1.01
   query15	0.64	0.61	0.61
   query16	0.31	0.36	0.34
   query17	1.16	1.17	1.12
   query18	0.23	0.21	0.21
   query19	2.08	1.99	1.96
   query20	0.02	0.01	0.01
   query21	15.45	0.25	0.15
   query22	4.49	0.06	0.05
   query23	16.26	0.32	0.13
   query24	3.32	0.69	0.38
   query25	0.11	0.06	0.06
   query26	1.35	0.26	0.16
   query27	0.03	0.04	0.04
   query28	1.67	0.59	0.36
   query29	12.55	4.11	3.32
   query30	0.28	0.14	0.13
   query31	2.78	0.56	0.33
   query32	3.23	0.61	0.52
   query33	3.15	3.28	3.14
   query34	15.56	3.94	3.41
   query35	3.36	3.34	3.34
   query36	0.55	0.43	0.46
   query37	0.09	0.07	0.06
   query38	0.05	0.04	0.04
   query39	0.03	0.04	0.03
   query40	0.18	0.14	0.14
   query41	0.09	0.03	0.02
   query42	0.03	0.04	0.05
   query43	0.05	0.03	0.04
   Total cold run time: 95.5 s
   Total hot run time: 24.5 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on code in PR #69188:
URL: https://github.com/apache/doris/pull/69188#discussion_r4292806162


##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergPartitionUtils.java:
##########
@@ -138,6 +139,46 @@ static List<String> getIdentityPartitionColumns(Table table) {
         return new ArrayList<>(partitionColumns);
     }
 
+    /**
+     * Rewrites a static-partition spec ({@code INSERT [OVERWRITE] ... PARTITION (col = val)}) so every key is the
+     * matching partition FIELD name, the identifier both downstream consumers address: the BE sink matches
+     * {@code static_partition_values} against {@code PartitionField#name()}, and the commit row filter resolves
+     * the field to its source column.
+     *
+     * <p>The engine's PARTITION clause names the identity partition's SOURCE column instead — the identifier Spark
+     * resolves for a static partition clause ({@code Analyzer.partitionColumnNames} takes the identity transform's
+     * field reference) and the one {@code SHOW CREATE TABLE} renders — so the two spellings must be bridged once,
+     * here, before either consumer sees the spec. A key that matches no field of the current spec is kept verbatim
+     * and left to the callers' fail-loud guards.</p>
+     */
+    static Map<String, String> toPartitionFieldKeys(Map<String, String> staticPartitions, Schema schema,
+            PartitionSpec spec) {
+        if (staticPartitions == null || staticPartitions.isEmpty() || spec == null) {
+            return staticPartitions;
+        }
+        Map<String, String> canonical = new HashMap<>(staticPartitions.size());
+        for (Map.Entry<String, String> entry : staticPartitions.entrySet()) {
+            canonical.put(toPartitionFieldName(schema, spec, entry.getKey()), entry.getValue());
+        }
+        return canonical;
+    }
+
+    /**
+     * The partition field a static-partition name addresses: its SOURCE column name, or the field name itself.
+     * Iceberg refuses to name a partition field after a column other than its own source
+     * ({@code PartitionSpec.Builder#checkAndAddPartitionName}), so the two lookups cannot disagree.
+     */
+    private static String toPartitionFieldName(Schema schema, PartitionSpec spec, String name) {
+        for (PartitionField field : spec.fields()) {
+            NestedField source = schema.findField(field.sourceId());
+            if ((source != null && source.name().equalsIgnoreCase(name))

Review Comment:
   Fixed in 1ff3d44d061. `toPartitionFieldName` now resolves the identity partition over the top-level SOURCE column first and only falls back to a field-name match, so the alias cannot capture the key. Your example is pinned by the new tests `validateStaticPartitionColumnsPrefersTheIdentitySourceOverACaseFoldedAlias` and `staticPartitionKeysPreferTheIdentitySourceOverACaseFoldedFieldAlias` (the spec builder does accept `identity(other, "ID")` next to `identity(id, "id_identity")`, as you noted).



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -1911,23 +1919,60 @@ public void validateStaticPartitionColumns(ConnectorSession session, ConnectorTa
             throw new DorisConnectorException(String.format(
                     "Table %s is not partitioned, cannot use static partition syntax", tableName));
         }
-        Map<String, PartitionField> partitionFieldMap = new HashMap<>();
+        for (String colName : staticPartitionColumnNames) {
+            validateStaticPartitionColumn(table.schema(), spec, colName, tableName);
+        }
+    }
+
+    /** The single-name rule of {@link #validateStaticPartitionColumns}. */
+    private static void validateStaticPartitionColumn(Schema schema, PartitionSpec spec, String colName,
+            String tableName) {
         for (PartitionField field : spec.fields()) {
-            partitionFieldMap.put(field.name(), field);
+            Types.NestedField source = schema.findField(field.sourceId());
+            if (source == null || !source.name().equalsIgnoreCase(colName)) {

Review Comment:
   Fixed in 1ff3d44d061. Static targets must now resolve to a TOP-LEVEL source column (`IcebergPartitionUtils#topLevelSourceColumnName`); `NestedField#name()` is no longer treated as a column name, so `PARTITION(id=2)` over `identity(payload.id)` reads as unknown and the field name itself reports "its source is a nested field ... the engine can only materialize the literal into a top-level column". Covered by `validateStaticPartitionColumnsRejectsNestedPartitionSources`.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -1911,23 +1919,60 @@ public void validateStaticPartitionColumns(ConnectorSession session, ConnectorTa
             throw new DorisConnectorException(String.format(
                     "Table %s is not partitioned, cannot use static partition syntax", tableName));
         }
-        Map<String, PartitionField> partitionFieldMap = new HashMap<>();
+        for (String colName : staticPartitionColumnNames) {
+            validateStaticPartitionColumn(table.schema(), spec, colName, tableName);
+        }
+    }
+
+    /** The single-name rule of {@link #validateStaticPartitionColumns}. */
+    private static void validateStaticPartitionColumn(Schema schema, PartitionSpec spec, String colName,
+            String tableName) {
         for (PartitionField field : spec.fields()) {
-            partitionFieldMap.put(field.name(), field);
+            Types.NestedField source = schema.findField(field.sourceId());
+            if (source == null || !source.name().equalsIgnoreCase(colName)) {
+                continue;
+            }
+            // The SOURCE column of a partition field: a legal static target only for an identity transform,
+            // because a transformed partition value is not the column value and cannot be written through it.
+            if (field.transform().isIdentity()) {
+                return;
+            }
+            throw new DorisConnectorException(String.format(

Review Comment:
   Fixed in 1ff3d44d061. The identity partition over the source is searched across ALL fields before any non-identity error is raised, and the key rewrite shares that lookup, so a spec that declares `bucket(8, id)` before `identity(id)` keeps its static writes. Pinned by `validateStaticPartitionColumnsFindsIdentityAfterANonIdentityFieldOnTheSameSource` and `staticPartitionKeysFindTheIdentityFieldRegardlessOfFieldOrder`.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -1911,23 +1919,60 @@ public void validateStaticPartitionColumns(ConnectorSession session, ConnectorTa
             throw new DorisConnectorException(String.format(
                     "Table %s is not partitioned, cannot use static partition syntax", tableName));
         }
-        Map<String, PartitionField> partitionFieldMap = new HashMap<>();
+        for (String colName : staticPartitionColumnNames) {
+            validateStaticPartitionColumn(table.schema(), spec, colName, tableName);

Review Comment:
   Fixed in 1ff3d44d061. Validation now uses the statement's pinned writer schema (`IcebergStatementScope.activeWriteSchema`) - the same copy binding, planning and the BE sink consume, registered by `pinConnectorWriteSchema` before analysis - and only falls back to the loaded table when no pin exists. `validateStaticPartitionColumnsUsesThePinnedBranchWriterSchema` pins your branch case: the pinned (`@branch(old)`) statement accepts `id`, while validating against the renamed current schema would reject it and advise `key`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6212409466

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 29333 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit 6cf4d69938059e2e0d4eaa728692c18056428e5a, data reload: false
   
   ------ Round 1 ----------------------------------
   ============================================
   q1	17620	5764	5580	5580
   q2	2114	321	265	265
   q3	10235	1403	846	846
   q4	4679	469	340	340
   q5	7423	800	530	530
   q6	186	187	154	154
   q7	769	817	639	639
   q8	9256	1356	1143	1143
   q9	5584	4257	4281	4257
   q10	6819	1296	1017	1017
   q11	428	258	237	237
   q12	631	395	280	280
   q13	18087	4067	2991	2991
   q14	282	276	247	247
   q15	q16	744	721	681	681
   q17	1205	756	584	584
   q18	7182	6249	6196	6196
   q19	1111	957	584	584
   q20	386	349	229	229
   q21	5389	2270	2368	2270
   q22	368	319	263	263
   Total cold run time: 100498 ms
   Total hot run time: 29333 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   ============================================
   q1	6201	6169	6146	6146
   q2	708	593	535	535
   q3	5205	5405	4977	4977
   q4	2006	2119	1564	1564
   q5	5290	5564	5977	5564
   q6	254	192	150	150
   q7	2371	2149	1888	1888
   q8	3376	3086	2794	2794
   q9	8254	8133	8129	8129
   q10	3708	3724	3358	3358
   q11	632	446	427	427
   q12	698	735	516	516
   q13	3555	4019	3208	3208
   q14	338	301	290	290
   q15	q16	694	734	648	648
   q17	8423	7529	7401	7401
   q18	13160	12324	13031	12324
   q19	900	785	783	783
   q20	2180	2166	1918	1918
   q21	5814	4728	4854	4728
   q22	500	485	394	394
   Total cold run time: 74267 ms
   Total hot run time: 67742 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6211184147

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6213852325

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 24.7 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit 1ff3d44d061b4403856095555af481ef9a89f926, data reload: false
   
   query1	0.00	0.01	0.00
   query2	0.10	0.05	0.04
   query3	0.27	0.12	0.11
   query4	1.60	0.13	0.12
   query5	0.27	0.26	0.25
   query6	1.16	0.68	0.68
   query7	0.03	0.01	0.00
   query8	0.06	0.04	0.04
   query9	0.40	0.35	0.33
   query10	0.61	0.58	0.57
   query11	0.20	0.15	0.15
   query12	0.18	0.15	0.15
   query13	0.50	0.49	0.49
   query14	1.02	1.01	1.02
   query15	0.64	0.60	0.60
   query16	0.36	0.35	0.34
   query17	1.19	1.16	1.12
   query18	0.22	0.21	0.21
   query19	2.10	2.04	2.00
   query20	0.02	0.01	0.02
   query21	15.52	0.27	0.14
   query22	4.50	0.05	0.05
   query23	16.21	0.32	0.13
   query24	3.15	0.58	0.50
   query25	0.11	0.06	0.05
   query26	1.41	0.25	0.15
   query27	0.05	0.04	0.03
   query28	2.27	0.62	0.39
   query29	12.51	4.20	3.33
   query30	0.28	0.13	0.13
   query31	2.77	0.58	0.33
   query32	3.22	0.62	0.52
   query33	3.23	3.35	3.25
   query34	15.50	3.99	3.37
   query35	3.34	3.32	3.33
   query36	0.57	0.44	0.46
   query37	0.09	0.06	0.06
   query38	0.04	0.04	0.03
   query39	0.04	0.04	0.03
   query40	0.18	0.15	0.15
   query41	0.09	0.04	0.03
   query42	0.04	0.02	0.03
   query43	0.04	0.03	0.03
   Total cold run time: 96.09 s
   Total hot run time: 24.7 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6263060752

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 152270 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit bb7d6ab74c9a76e087ed16b356588936fa01d314, data reload: false
   
   query5	4289	578	445	445
   query6	421	214	194	194
   query7	4812	444	229	229
   query8	318	167	153	153
   query9	8762	3950	3963	3950
   query10	491	307	261	261
   query11	5996	3799	3515	3515
   query12	149	88	84	84
   query13	1232	434	315	315
   query14	6077	4012	3767	3767
   query14_1	3521	3497	3480	3480
   query15	206	195	183	183
   query16	937	447	410	410
   query17	815	647	517	517
   query18	2420	446	295	295
   query19	184	164	144	144
   query20	85	84	84	84
   query21	209	131	107	107
   query22	12987	13040	12810	12810
   query23	13594	12905	12497	12497
   query23_1	12585	12694	12656	12656
   query24	7144	812	452	452
   query24_1	466	458	459	458
   query25	513	398	339	339
   query26	1316	258	135	135
   query27	2780	432	268	268
   query28	4674	1940	1913	1913
   query29	1548	584	465	465
   query30	304	220	191	191
   query31	1012	925	805	805
   query32	154	98	91	91
   query33	529	308	251	251
   query34	994	854	524	524
   query35	751	756	672	672
   query36	810	820	744	744
   query37	123	102	96	96
   query38	1806	1726	1670	1670
   query39	806	790	759	759
   query39_1	765	758	745	745
   query40	219	122	106	106
   query41	75	69	69	69
   query42	85	86	84	84
   query43	389	390	336	336
   query44	1287	707	714	707
   query45	189	182	165	165
   query46	843	959	568	568
   query47	2932	2958	2769	2769
   query48	303	314	219	219
   query49	609	403	303	303
   query50	694	277	219	219
   query51	10255	10383	10170	10170
   query52	84	81	80	80
   query53	188	209	160	160
   query54	267	224	193	193
   query55	74	69	72	69
   query56	249	227	235	227
   query57	1612	1587	1579	1579
   query58	304	278	272	272
   query59	2161	2262	1981	1981
   query60	307	254	245	245
   query61	169	170	172	170
   query62	407	342	289	289
   query63	210	173	168	168
   query64	2880	1040	893	893
   query65	3270	3253	3242	3242
   query66	1833	404	316	316
   query67	20126	20340	20129	20129
   query68	3000	988	618	618
   query69	391	278	247	247
   query70	861	787	769	769
   query71	286	218	201	201
   query72	2705	2608	2312	2312
   query73	515	542	294	294
   query74	4587	4464	4308	4308
   query75	2323	2287	1940	1940
   query76	2301	1011	609	609
   query77	339	370	261	261
   query78	9919	9754	9149	9149
   query79	1625	850	514	514
   query80	1242	434	342	342
   query81	594	324	268	268
   query82	739	130	109	109
   query83	298	193	181	181
   query84	314	121	104	104
   query85	860	438	376	376
   query86	394	236	228	228
   query87	2005	1953	1849	1849
   query88	3608	2683	2682	2682
   query89	337	297	261	261
   query90	1866	174	178	174
   query91	166	154	128	128
   query92	98	85	90	85
   query93	1115	1001	582	582
   query94	629	312	293	293
   query95	588	394	319	319
   query96	682	515	232	232
   query97	2462	2415	2308	2308
   query98	163	154	151	151
   query99	776	774	645	645
   Total cold run time: 236129 ms
   Total hot run time: 152270 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6263448481

   # FE UT Coverage Report
   Increment line coverage `` :tada:
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/69188_bb7d6ab74c9a76e087ed16b356588936fa01d314/fe_increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/69188_bb7d6ab74c9a76e087ed16b356588936fa01d314/fe_report/index.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hubgeter (via GitHub)" <gi...@apache.org>.
hubgeter commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6212046202

   /review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6262893678

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 29705 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit bb7d6ab74c9a76e087ed16b356588936fa01d314, data reload: false
   
   ------ Round 1 ----------------------------------
   ============================================
   q1	17603	5702	5527	5527
   q2	2111	322	268	268
   q3	10232	1412	860	860
   q4	4680	476	345	345
   q5	7440	797	540	540
   q6	195	192	155	155
   q7	771	808	616	616
   q8	9252	1407	1168	1168
   q9	5543	4313	4297	4297
   q10	6825	1309	1038	1038
   q11	454	257	251	251
   q12	646	400	294	294
   q13	18086	3578	3030	3030
   q14	277	263	240	240
   q15	q16	762	736	654	654
   q17	1213	759	596	596
   q18	7015	6226	6195	6195
   q19	1108	973	629	629
   q20	384	351	230	230
   q21	5596	2472	2630	2472
   q22	402	347	300	300
   Total cold run time: 100595 ms
   Total hot run time: 29705 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   ============================================
   q1	6566	6677	6534	6534
   q2	738	629	579	579
   q3	5595	5747	5366	5366
   q4	2043	2143	1596	1596
   q5	5692	5795	5572	5572
   q6	244	194	146	146
   q7	2303	2024	1794	1794
   q8	3087	2771	2796	2771
   q9	8112	7607	7563	7563
   q10	3664	3629	3242	3242
   q11	599	402	378	378
   q12	666	687	502	502
   q13	3227	3537	3008	3008
   q14	292	289	270	270
   q15	q16	665	686	614	614
   q17	7812	6996	6869	6869
   q18	13130	12259	13105	12259
   q19	938	805	825	805
   q20	2189	2177	1914	1914
   q21	5790	4714	4810	4714
   q22	499	445	438	438
   Total cold run time: 73851 ms
   Total hot run time: 66934 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "Gabriel39 (via GitHub)" <gi...@apache.org>.
Gabriel39 merged PR #69188:
URL: https://github.com/apache/doris/pull/69188


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6213600904

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 29383 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit 1ff3d44d061b4403856095555af481ef9a89f926, data reload: false
   
   ------ Round 1 ----------------------------------
   ============================================
   q1	17599	5727	5593	5593
   q2	2153	305	259	259
   q3	10209	1394	884	884
   q4	4686	470	351	351
   q5	7421	793	536	536
   q6	189	186	155	155
   q7	778	791	608	608
   q8	9263	1345	1098	1098
   q9	5538	4284	4259	4259
   q10	6816	1307	1019	1019
   q11	438	252	250	250
   q12	641	396	286	286
   q13	18067	3576	3026	3026
   q14	272	266	248	248
   q15	q16	755	725	670	670
   q17	1208	757	589	589
   q18	7155	6257	6193	6193
   q19	1252	971	595	595
   q20	389	345	234	234
   q21	4887	2262	2416	2262
   q22	386	323	268	268
   Total cold run time: 100102 ms
   Total hot run time: 29383 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   ============================================
   q1	6210	6286	6185	6185
   q2	689	572	562	562
   q3	5191	5412	4943	4943
   q4	2013	2123	1580	1580
   q5	5314	5458	6025	5458
   q6	268	199	152	152
   q7	2393	2185	1904	1904
   q8	3319	3008	2741	2741
   q9	8119	8065	8118	8065
   q10	3753	3722	3333	3333
   q11	645	430	413	413
   q12	690	730	517	517
   q13	3567	3837	3415	3415
   q14	325	318	282	282
   q15	q16	715	724	650	650
   q17	8418	7556	7399	7399
   q18	13058	12283	13196	12283
   q19	947	798	809	798
   q20	2208	2186	1921	1921
   q21	5924	4726	4877	4726
   q22	507	443	417	417
   Total cold run time: 74273 ms
   Total hot run time: 67744 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6211182941

   
   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your PR](https://doris.apache.org/community/how-to-contribute/review-and-ci).
   
   Please clearly describe your PR:
   1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
   2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
   3. What features were added. Why was this function added?
   4. Which code was refactored and why was this part of the code refactored?
   5. Which functions were optimized and what is the difference before and after the optimization?
       


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #69188:
URL: https://github.com/apache/doris/pull/69188#discussion_r4292649786


##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergPartitionUtils.java:
##########
@@ -138,6 +139,46 @@ static List<String> getIdentityPartitionColumns(Table table) {
         return new ArrayList<>(partitionColumns);
     }
 
+    /**
+     * Rewrites a static-partition spec ({@code INSERT [OVERWRITE] ... PARTITION (col = val)}) so every key is the
+     * matching partition FIELD name, the identifier both downstream consumers address: the BE sink matches
+     * {@code static_partition_values} against {@code PartitionField#name()}, and the commit row filter resolves
+     * the field to its source column.
+     *
+     * <p>The engine's PARTITION clause names the identity partition's SOURCE column instead — the identifier Spark
+     * resolves for a static partition clause ({@code Analyzer.partitionColumnNames} takes the identity transform's
+     * field reference) and the one {@code SHOW CREATE TABLE} renders — so the two spellings must be bridged once,
+     * here, before either consumer sees the spec. A key that matches no field of the current spec is kept verbatim
+     * and left to the callers' fail-loud guards.</p>
+     */
+    static Map<String, String> toPartitionFieldKeys(Map<String, String> staticPartitions, Schema schema,
+            PartitionSpec spec) {
+        if (staticPartitions == null || staticPartitions.isEmpty() || spec == null) {
+            return staticPartitions;
+        }
+        Map<String, String> canonical = new HashMap<>(staticPartitions.size());
+        for (Map.Entry<String, String> entry : staticPartitions.entrySet()) {
+            canonical.put(toPartitionFieldName(schema, spec, entry.getKey()), entry.getValue());
+        }
+        return canonical;
+    }
+
+    /**
+     * The partition field a static-partition name addresses: its SOURCE column name, or the field name itself.
+     * Iceberg refuses to name a partition field after a column other than its own source
+     * ({@code PartitionSpec.Builder#checkAndAddPartitionName}), so the two lookups cannot disagree.
+     */
+    private static String toPartitionFieldName(Schema schema, PartitionSpec spec, String name) {
+        for (PartitionField field : spec.fields()) {
+            NestedField source = schema.findField(field.sourceId());
+            if ((source != null && source.name().equalsIgnoreCase(name))

Review Comment:
   [P1] Resolve source columns before matching partition-field aliases
   
   The two lookups can disagree because [Iceberg's builder](https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/api/src/main/java/org/apache/iceberg/PartitionSpec.java#L358-L402) checks names case-sensitively by default. With schema `(id INT, other INT)` and spec `identity(other, "ID"), identity(id, "id_identity")`, `PARTITION(id=7)` validates against source `id`, but this loop returns the earlier field `ID`, whose source is `other`. An overwrite supplying `other=9` then writes row `(id=7, other=9)` while BE stamps `other`'s partition as 7; the commit also filters `other=7` instead of `id=7`. This can overwrite the wrong partitions and commit files whose rows contradict their partition metadata. Resolve the validated identity source first, and only consider field aliases as an unambiguous fallback.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -1911,23 +1919,60 @@ public void validateStaticPartitionColumns(ConnectorSession session, ConnectorTa
             throw new DorisConnectorException(String.format(
                     "Table %s is not partitioned, cannot use static partition syntax", tableName));
         }
-        Map<String, PartitionField> partitionFieldMap = new HashMap<>();
+        for (String colName : staticPartitionColumnNames) {
+            validateStaticPartitionColumn(table.schema(), spec, colName, tableName);
+        }
+    }
+
+    /** The single-name rule of {@link #validateStaticPartitionColumns}. */
+    private static void validateStaticPartitionColumn(Schema schema, PartitionSpec spec, String colName,
+            String tableName) {
         for (PartitionField field : spec.fields()) {
-            partitionFieldMap.put(field.name(), field);
+            Types.NestedField source = schema.findField(field.sourceId());
+            if (source == null || !source.name().equalsIgnoreCase(colName)) {

Review Comment:
   [P1] Keep nested source fields distinct from top-level columns
   
   `NestedField.name()` is only the leaf name. For a supported table `(id INT, payload STRUCT<id:INT>)` partitioned by `identity(payload.id)` as `nested_id`, this accepts `PARTITION(id=2)` even though the top-level `id` is not a partition source. `BindSink` materializes the literal into that top-level column, while `toPartitionFieldKeys` rewrites it to `nested_id`. An overwrite supplying `payload.id=9` therefore writes that value into the file but stamps its nested partition as 2 through BE's static override. Even an initially empty table can commit this inconsistent file; the overwrite path does not validate added files against the filter. Resolve the source's full path/field identity and reject nested static targets unless the binder can materialize that same source.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -1911,23 +1919,60 @@ public void validateStaticPartitionColumns(ConnectorSession session, ConnectorTa
             throw new DorisConnectorException(String.format(
                     "Table %s is not partitioned, cannot use static partition syntax", tableName));
         }
-        Map<String, PartitionField> partitionFieldMap = new HashMap<>();
+        for (String colName : staticPartitionColumnNames) {
+            validateStaticPartitionColumn(table.schema(), spec, colName, tableName);
+        }
+    }
+
+    /** The single-name rule of {@link #validateStaticPartitionColumns}. */
+    private static void validateStaticPartitionColumn(Schema schema, PartitionSpec spec, String colName,
+            String tableName) {
         for (PartitionField field : spec.fields()) {
-            partitionFieldMap.put(field.name(), field);
+            Types.NestedField source = schema.findField(field.sourceId());
+            if (source == null || !source.name().equalsIgnoreCase(colName)) {
+                continue;
+            }
+            // The SOURCE column of a partition field: a legal static target only for an identity transform,
+            // because a transformed partition value is not the column value and cannot be written through it.
+            if (field.transform().isIdentity()) {
+                return;
+            }
+            throw new DorisConnectorException(String.format(

Review Comment:
   [P2] Search all matching transforms before rejecting the source
   
   A valid Iceberg spec can contain `bucket("id", 8)` before `identity("id")`. `PARTITION(id=7)` previously resolved the identity field named `id`, but the new loop stops at the bucket field with the same source and throws, never reaching the identity field. This breaks static INSERT and OVERWRITE on such tables solely because of spec field order. Look for a matching identity source before reporting a non-identity error, and make `toPartitionFieldName` select that same identity field rather than the first source match.



##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -1911,23 +1919,60 @@ public void validateStaticPartitionColumns(ConnectorSession session, ConnectorTa
             throw new DorisConnectorException(String.format(
                     "Table %s is not partitioned, cannot use static partition syntax", tableName));
         }
-        Map<String, PartitionField> partitionFieldMap = new HashMap<>();
+        for (String colName : staticPartitionColumnNames) {
+            validateStaticPartitionColumn(table.schema(), spec, colName, tableName);

Review Comment:
   [P2] Validate static names against the pinned branch writer schema
   
   Create an identity-partitioned `t(id INT, value STRING)`, create branch `old` from a snapshot, then rename main's source column `id` to `key`. `INSERT INTO t@branch(old) PARTITION(id=2) (value) VALUES('x')` still binds to the branch's old `id` schema, but this call validates against current `table.schema()`: it misses source `key` and rejects partition field `id`, advising the user to use `key`, which is absent from that branch. The previous field-keyed validation accepted this ordinary INSERT, and the existing writer materializes and appends it using the pinned branch schema. Use the already active `IcebergWriteSchemaContext` for validation so it agrees with binding and planning, and cover a branch static INSERT after a main-only rename.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6212668863

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 24.63 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit 6cf4d69938059e2e0d4eaa728692c18056428e5a, data reload: false
   
   query1	0.01	0.01	0.01
   query2	0.10	0.05	0.05
   query3	0.27	0.12	0.12
   query4	1.61	0.12	0.11
   query5	0.24	0.25	0.25
   query6	1.18	0.69	0.67
   query7	0.04	0.01	0.01
   query8	0.05	0.04	0.04
   query9	0.41	0.35	0.32
   query10	0.63	0.62	0.61
   query11	0.21	0.14	0.14
   query12	0.18	0.14	0.14
   query13	0.51	0.48	0.50
   query14	1.03	1.01	1.01
   query15	0.63	0.61	0.61
   query16	0.34	0.35	0.35
   query17	1.15	1.12	1.16
   query18	0.23	0.21	0.21
   query19	2.10	2.04	2.00
   query20	0.01	0.01	0.01
   query21	15.49	0.28	0.14
   query22	4.52	0.06	0.05
   query23	16.26	0.32	0.13
   query24	3.27	0.58	0.44
   query25	0.10	0.08	0.06
   query26	1.24	0.24	0.15
   query27	0.04	0.03	0.04
   query28	2.19	0.59	0.36
   query29	12.48	4.18	3.31
   query30	0.29	0.14	0.13
   query31	2.77	0.57	0.34
   query32	3.22	0.61	0.51
   query33	3.23	3.19	3.19
   query34	15.62	3.98	3.40
   query35	3.36	3.35	3.35
   query36	0.54	0.43	0.45
   query37	0.10	0.07	0.06
   query38	0.05	0.04	0.04
   query39	0.04	0.03	0.02
   query40	0.17	0.15	0.14
   query41	0.09	0.03	0.03
   query42	0.04	0.03	0.03
   query43	0.04	0.04	0.03
   Total cold run time: 96.08 s
   Total hot run time: 24.63 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](iceberg) Fix static partition writes for renamed identity fields [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69188:
URL: https://github.com/apache/doris/pull/69188#issuecomment-6213770503

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 152075 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit 1ff3d44d061b4403856095555af481ef9a89f926, data reload: false
   
   query5	4318	582	451	451
   query6	430	204	189	189
   query7	4814	450	237	237
   query8	330	170	154	154
   query9	8780	3951	3977	3951
   query10	464	340	256	256
   query11	6003	3772	3542	3542
   query12	146	94	86	86
   query13	1235	424	301	301
   query14	6096	4046	3704	3704
   query14_1	3486	3459	3472	3459
   query15	203	197	180	180
   query16	952	432	439	432
   query17	838	621	516	516
   query18	2401	417	292	292
   query19	201	163	138	138
   query20	85	85	84	84
   query21	215	135	112	112
   query22	12978	12999	12819	12819
   query23	13467	12933	12486	12486
   query23_1	12715	12531	12604	12531
   query24	7121	827	476	476
   query24_1	463	482	480	480
   query25	529	424	359	359
   query26	1279	255	144	144
   query27	2767	444	274	274
   query28	4605	1946	1939	1939
   query29	1564	602	462	462
   query30	303	220	184	184
   query31	995	923	801	801
   query32	179	95	91	91
   query33	532	300	249	249
   query34	923	854	496	496
   query35	739	750	644	644
   query36	814	826	718	718
   query37	127	104	94	94
   query38	1792	1716	1678	1678
   query39	803	798	740	740
   query39_1	730	737	748	737
   query40	223	116	100	100
   query41	70	68	68	68
   query42	91	85	84	84
   query43	364	387	325	325
   query44	1293	691	693	691
   query45	184	191	163	163
   query46	875	955	565	565
   query47	2948	2988	2934	2934
   query48	307	318	223	223
   query49	582	400	311	311
   query50	694	277	208	208
   query51	10595	10625	10663	10625
   query52	82	80	77	77
   query53	191	205	157	157
   query54	238	200	203	200
   query55	74	76	68	68
   query56	259	220	230	220
   query57	1601	1582	1583	1582
   query58	293	287	255	255
   query59	2114	2190	1989	1989
   query60	290	258	236	236
   query61	172	168	168	168
   query62	396	338	293	293
   query63	200	168	168	168
   query64	2767	951	767	767
   query65	3284	3239	3207	3207
   query66	1776	437	303	303
   query67	20439	19925	20122	19925
   query68	3074	1018	610	610
   query69	390	278	239	239
   query70	850	814	789	789
   query71	307	233	200	200
   query72	2839	2545	2223	2223
   query73	507	519	290	290
   query74	4561	4471	4282	4282
   query75	2353	2262	1927	1927
   query76	2312	1005	620	620
   query77	324	375	272	272
   query78	9733	9726	9221	9221
   query79	961	883	515	515
   query80	1110	485	345	345
   query81	592	326	268	268
   query82	890	138	106	106
   query83	307	225	177	177
   query84	317	120	101	101
   query85	995	424	372	372
   query86	367	238	226	226
   query87	1993	1950	1795	1795
   query88	3584	2669	2650	2650
   query89	345	293	257	257
   query90	1779	180	177	177
   query91	173	147	123	123
   query92	99	91	83	83
   query93	1010	1000	563	563
   query94	566	303	272	272
   query95	603	342	318	318
   query96	656	527	237	237
   query97	2453	2460	2348	2348
   query98	162	154	144	144
   query99	773	766	648	648
   Total cold run time: 235594 ms
   Total hot run time: 152075 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org