Skip to content

[fix](fe) Preserve external schema generations and timestamp precision - #67904

Open
Gabriel39 wants to merge 9 commits into
apache:masterfrom
Gabriel39:fix/paimon-schema-and-timestamp
Open

[fix](fe) Preserve external schema generations and timestamp precision#67904
Gabriel39 wants to merge 9 commits into
apache:masterfrom
Gabriel39:fix/paimon-schema-and-timestamp

Conversation

@Gabriel39

@Gabriel39 Gabriel39 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Paimon statement data fences could rewind schema-only changes, allow later branch commits to become visible, or restore fields with another generation's options. Timestamp predicates could also prune matching rows after losing precision. The connector-generic schema pin exposed an Iceberg mismatch between cached columns and live partition metadata.

  • Bind schema generations independently of data snapshots for plain reads, reader-only OPTIONS aliases, system wrappers, and branches.
  • Keep exact/latest schema-file reads and scan-side restoration inside the connector authentication and classloader scope.
  • Build FE RANGE/LIST partition items from the locally pinned schema, including its partition types and arity.
  • Restore schema-owned Paimon options with their fields, replay only catalog/runtime overrides, and preserve fallback branch provenance and privilege checks.
  • Preserve microseconds in NTZ literals and leave comparisons on TIMESTAMP(7..9) to Doris residual filtering.
  • Keep later Paimon system-source preparation inside the bound-schema authentication/TCCL scope.
  • Fall back to the reloaded Iceberg spec when a cached spec ID disappears after an external drop/recreate.
  • Retain Iceberg partition spec IDs for pinned schema assembly and resolve partition source names from that schema, including cached empty-table schemas before and after the first append.
  • Exempt connector-synthesized columns from physical schema matching so Iceberg row-ID reads and DML continue to work with eagerly retained latest schemas; keep the guard for physical and GENERATED columns.
  • Record the five deterministic regression queries with named order_qt_ cases and a harness-generated .out file.

Scope: this PR fixes Paimon schema-generation and timestamp handling, plus direct consequences of retaining connector schemas in the generic FE MVCC bridge. Historical Iceberg partition-spec isolation in RANGE/LIST views and derived cache keys is outside this change. A spec-only partition-style drift reproduces identically on the pre-PR implementation at ee4a91720f; review thread records the evidence.

Release note

Paimon reads retain consistent schema and data generations across analysis and execution, including schema-only changes and branch reads. Timestamp predicates preserve microseconds without incorrectly pruning nanosecond values. Iceberg pinned schemas retain consistent partition metadata after schema-only changes.

Check List (For Author)

  • Test:
    • Unit tests
    • Regression test and generated baseline
    • Local end-to-end validation
  • Behavior changed: Yes, preserve external schema provenance and avoid incorrect timestamp pruning.
  • Does this need documentation: No.

Validation:

  • Latest generation-identity fixes at 54a5294b6c: Paimon retains the actual statement schema instead of using the historical memo for latest binding; Iceberg checks the physical-table identity before applying cached schema/spec IDs, invalidates mismatches, and reports a retryable statement error. Recreation tests cover reused IDs, replacement-row reads, and retry recovery. 1,008 related unit/SDK tests passed, one connectivity test skipped; FE build, connector packages, and Checkstyle passed.

  • Earlier external regression fix at b6f108f838: preserve schema-cache validation when eagerly pinning latest schemas. All 116 related FE unit tests passed; the duplicate-column SQL assertion was reproduced before the fix and passed afterward in Native and JNI modes against a local Paimon table. FE build and Checkstyle passed. The existing test_paimon_catalog assertion is unchanged.

  • Earlier review fixes at a56a252a07: 801 related tests passed (572 Paimon, 199 Iceberg metadata/cache, 30 metastore); one Paimon connectivity test skipped. Warm-cache table recreation and the full Paimon JNI scan-property authentication path each failed before the fix and passed afterward. Final FE build, connector packages, and Checkstyle passed. The native historical schema-dictionary authentication path is unchanged from pre-PR ee4a91720f and is outside this fix, as explained in the review reply.

  • Paimon: 576 tests passed, one live-connectivity test skipped; package build passed. Three new tests verify real schema-file reads run in the authentication/TCCL scope, including a warm latest-cache hit and scan restoration. These use a guarded local FileIO, not a live Kerberos cluster.

  • Earlier Iceberg validation at 75ceac1: 1,390 tests passed, five skipped; package build passed. IcebergWritePlanProviderTest.planMergePreservesExplicitlyEmptyReadAcrossConcurrentFirstAppend also fails on the previous PR head and was excluded after reproducing that baseline failure.

  • FE MVCC: 71 tests passed, including three new RANGE/LIST partition type/arity guards. The unrelated existing IvmNormalizeMTMVJoinTest compile failure was temporarily excluded; the build configuration was restored afterward.

  • Current fixes at 1cf784fb4a: all 29 originally failing Iceberg suites passed locally after the fix, using the final FE and matching BE artifacts. This includes hidden row IDs, UPDATE/DELETE/MERGE, v3 row lineage, schema time travel, and initial defaults. Existing test baselines were unchanged.

  • Current fixes: 234 FE scan/MVCC tests and 251 Iceberg metadata/MVCC/scan-provider tests passed. The synthesized-column and empty-table evolution regressions were reproduced with failing tests before their fixes.

  • FE Checkstyle and the final FE build passed.

  • test_paimon_schema_only_snapshot_precision (validated at 75ceac1): generated the baseline and reran successfully, covering plain, OPTIONS, branch, native precision, and JNI precision queries.

  • Local regression used the current FE and Paimon JNI extension with an existing BE. enable_local_shuffle_planner=false was set on the isolated test instance for plan-node compatibility; no environment configuration is included in this PR.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

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?

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/34735774547

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: four findings remain (three P1, one P2). The NTZ constructor change itself is sound, but the schema/data-generation handling is not end-to-end safe.

Critical checkpoint conclusions:

  • Goal and proof: The goal is to retain the current Paimon schema while fencing data and to preserve NTZ sub-millisecond predicates. M1, M2, and M4 show the schema/MVCC goal is not achieved in branch, cached-table, and schema-derived system paths; M3 shows the end-to-end precision regression does not exercise NTZ.
  • Scope and focus: The patch is otherwise focused across three production files and targeted tests. No additional user focus was supplied, so the full changed-file scope was reviewed.
  • Concurrency: No threads or locks are added. External data/schema commits can race statement binding and planning; the unfenced branch transition is M1 and exact-schema drift is M2.
  • Lifecycle and static initialization: Table handles, transient Paimon tables, and scan-option copies are statement-scoped; no new static initialization or resource-release issue was found. The branch handle reload lifecycle is part of M1.
  • Configuration: No production configuration is added. The regression restores force_jni_scanner in finally.
  • Compatibility: No public SPI, thrift, storage format, symbol, or rolling-upgrade surface changes. Paimon 1.3.1 provides the APIs used.
  • Parallel paths: Normal, branch, options, native, JNI, system-table, privilege, fallback, partition, and statistics paths were traced. Distinct gaps are M1, M2, and M4.
  • Special conditions: The new FileStoreTable/preserve-marker condition is documented but insufficient: it excludes schema-derived wrappers (M4), and the marker carries no exact schema generation (M2).
  • Test coverage: Added unit cases cover a fresh ordinary table and the converter helper, but miss branch mutation, warm catalog cache, schema-derived system aliases, and a true NTZ end-to-end setup (M1-M4). No additional negative/empty-branch test covers the first-commit race.
  • Test results: Expected rows are deterministic for the stable setup, but the precision assertions can pass via residual filtering because the Spark column is LTZ (M3). No result file is changed.
  • Observability: No new logging or metrics are required for this local read-path change; no separate observability defect was found.
  • Transactions and persistence: No Doris transaction, EditLog, failover, or persisted-metadata path is modified.
  • Data writes and atomicity: Production changes are read-only; no write/crash atomicity path is modified.
  • FE/BE variables: No new cross-process variable or thrift field is introduced. Existing serialized-table/native paths are inconsistent only as described in M2/M4.
  • Performance: The added map/table copies are bounded per statement; no distinct CPU, memory, or asymptotic regression was found.
  • Other issues: No additional correctness, error-handling, security, or style blocker remained after three converged review rounds.

Static review only: per the review contract, no builds or tests were run, so author/CI test claims were not independently executed.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16965 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 4ae6c48c3265cce9a18f85cb99ecac6ff86b1067, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17587	3116	3113	3113
q2	2098	265	256	256
q3	10185	873	519	519
q4	4668	253	199	199
q5	7671	574	383	383
q6	138	118	96	96
q7	547	496	390	390
q8	9239	897	894	894
q9	3437	2366	2381	2366
q10	6513	873	697	697
q11	387	199	181	181
q12	610	255	200	200
q13	18143	1532	1160	1160
q14	162	146	137	137
q15	q16	450	393	368	368
q17	1402	839	767	767
q18	3099	2229	2233	2229
q19	1265	872	783	783
q20	378	290	202	202
q21	5621	1790	1845	1790
q22	339	274	235	235
Total cold run time: 93939 ms
Total hot run time: 16965 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3486	3440	3449	3440
q2	503	395	365	365
q3	2171	2535	2114	2114
q4	1191	1189	895	895
q5	2176	2124	2080	2080
q6	165	119	89	89
q7	1004	919	865	865
q8	1588	1404	1418	1404
q9	3150	3121	3137	3121
q10	1886	1786	1628	1628
q11	352	267	256	256
q12	455	429	349	349
q13	1481	1532	1134	1134
q14	169	181	174	174
q15	q16	398	389	354	354
q17	3570	3341	3228	3228
q18	4797	4444	4723	4444
q19	858	927	855	855
q20	1008	951	837	837
q21	3811	3054	3190	3054
q22	402	344	319	319
Total cold run time: 34621 ms
Total hot run time: 31005 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 82255 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 4ae6c48c3265cce9a18f85cb99ecac6ff86b1067, data reload: false

query5	4246	429	337	337
query6	378	140	123	123
query7	4936	428	226	226
query8	289	128	132	128
query9	8679	2892	2889	2889
query10	404	223	186	186
query11	5406	1051	914	914
query12	126	72	71	71
query13	1196	454	319	319
query14	6109	2214	2093	2093
query14_1	1977	1982	1959	1959
query15	178	114	114	114
query16	908	359	348	348
query17	783	456	357	357
query18	2328	334	238	238
query19	166	141	107	107
query20	72	72	71	71
query21	198	102	86	86
query22	5514	5414	5479	5414
query23	6737	6227	6106	6106
query23_1	5997	6053	5986	5986
query24	7281	1116	763	763
query24_1	748	791	776	776
query25	429	299	262	262
query26	1216	231	130	130
query27	2795	423	252	252
query28	4689	1505	1478	1478
query29	922	430	354	354
query30	257	158	129	129
query31	823	399	341	341
query32	129	74	78	74
query33	460	232	183	183
query34	971	819	475	475
query35	399	400	344	344
query36	558	574	533	533
query37	118	78	74	74
query38	996	846	812	812
query39	500	478	484	478
query39_1	469	469	465	465
query40	200	91	80	80
query41	59	60	54	54
query42	74	73	73	73
query43	242	244	219	219
query44	997	529	540	529
query45	112	112	101	101
query46	764	856	554	554
query47	757	764	706	706
query48	312	317	240	240
query49	542	249	191	191
query50	722	261	191	191
query51	8135	8201	8215	8201
query52	67	66	71	66
query53	200	204	141	141
query54	224	267	166	166
query55	70	61	57	57
query56	195	160	170	160
query57	692	658	632	632
query58	186	158	156	156
query59	1273	1251	1104	1104
query60	231	187	168	168
query61	126	136	110	110
query62	385	217	172	172
query63	172	138	137	137
query64	2868	653	654	653
query65	1679	1566	1585	1566
query66	1892	256	203	203
query67	9751	12006	9599	9599
query68	2940	1242	745	745
query69	344	217	203	203
query70	678	657	577	577
query71	268	172	160	160
query72	2210	1648	1652	1648
query73	633	558	343	343
query74	1970	1201	1134	1134
query75	1152	1079	963	963
query76	2382	701	494	494
query77	252	256	217	217
query78	3943	3686	3228	3228
query79	2379	833	569	569
query80	1552	313	267	267
query81	484	151	134	134
query82	597	133	92	92
query83	268	201	187	187
query84	290	113	88	88
query85	764	346	273	273
query86	384	169	161	161
query87	1020	948	915	915
query88	2764	2130	2119	2119
query89	273	197	177	177
query90	1993	120	128	120
query91	127	115	94	94
query92	78	68	65	65
query93	1435	1038	700	700
query94	647	263	226	226
query95	512	317	225	225
query96	815	575	270	270
query97	1046	1069	1035	1035
query98	167	132	130	130
query99	414	356	313	313
Total cold run time: 177531 ms
Total hot run time: 82255 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.79 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 4ae6c48c3265cce9a18f85cb99ecac6ff86b1067, data reload: false

query1	0.01	0.00	0.01
query2	0.07	0.04	0.03
query3	0.24	0.10	0.10
query4	1.60	0.10	0.09
query5	0.18	0.16	0.16
query6	1.27	0.69	0.69
query7	0.03	0.01	0.01
query8	0.05	0.03	0.03
query9	0.28	0.21	0.22
query10	0.35	0.34	0.34
query11	0.16	0.12	0.12
query12	0.15	0.12	0.12
query13	0.31	0.33	0.30
query14	0.46	0.45	0.45
query15	0.36	0.35	0.34
query16	0.23	0.24	0.23
query17	0.63	0.69	0.70
query18	0.19	0.17	0.17
query19	1.19	1.19	1.16
query20	0.01	0.01	0.01
query21	15.42	0.15	0.12
query22	5.09	0.04	0.04
query23	16.18	0.25	0.10
query24	2.99	0.31	0.26
query25	0.10	0.05	0.04
query26	0.84	0.17	0.12
query27	0.03	0.03	0.03
query28	3.62	0.58	0.28
query29	12.46	3.16	2.59
query30	0.24	0.11	0.12
query31	2.75	0.37	0.17
query32	3.55	0.32	0.22
query33	1.50	1.41	1.47
query34	15.35	2.16	1.81
query35	1.74	1.74	1.73
query36	0.44	0.29	0.28
query37	0.06	0.04	0.04
query38	0.04	0.03	0.02
query39	0.04	0.02	0.02
query40	0.12	0.08	0.08
query41	0.07	0.03	0.02
query42	0.03	0.02	0.03
query43	0.04	0.03	0.03
Total cold run time: 90.47 s
Total hot run time: 14.79 s

### What problem does this PR solve?

Related PR: apache#67904

Problem Summary: Cached Paimon tables and system wrappers could use a different
schema than statement binding, and branch reads could observe later commits.
Carry the exact schema generation and positive or empty branch data fence
through binding, native planning and JNI serialization. Use explicit NTZ
literals in the timestamp precision regression.

### Release note

Paimon statement reads retain consistent schema and data generations.

### Check List (For Author)

- Test: Paimon package build (570 passed, 1 skipped); FE MVCC unit tests
  (68 passed); FE Checkstyle. External regression updated, not run locally.
- Behavior changed: Yes, schema and data fences remain consistent through reads.
- Does this need documentation: No.
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of exact head 4ffdc1fc1d5b4dbf94ad6dac896b9c24a9976bb3 against base 73b2a153cb5eb34b474386d678ee4a02af5788bd. I am requesting changes for four P1 correctness defects and one P2 regression-standard defect, detailed inline.

Checkpoint conclusions:

  • Goal and proof: the ordinary stale-table, system-wrapper, branch-fence, and microsecond cases are addressed, but schema-owned options, fallback topology, TIMESTAMP(7..9), and Iceberg's generic latest pin remain inconsistent; the release-note claim is therefore not yet established for supported paths.
  • Focus and scope: all 12 changed files plus relevant callers and consumers were reviewed; no user-specific focus was supplied. The change is otherwise focused.
  • Concurrency and lifecycle: the schema memo is statement-scoped, concurrently safe, and discarded with metadata; handle identity separates base/system/branch tables. No lock-order or teardown issue found.
  • Configuration and compatibility: no new user configuration, persisted format, public symbol, storage protocol, or FE-BE field is introduced. The internal marker is stripped before Paimon/backend options.
  • Parallel paths and conditions: plain, OPTIONS, branch, empty, system-wrapper, fallback/decorator, native dictionary, catalog-loader removal, JNI serialization, and Iceberg paths were traced. The surviving defects are the five inline points; prior GitHub threads were treated as duplicate fences.
  • Tests and results: the changed unit tests statically reach the main intended paths but miss renamed schema-owned options, stale fallback pairs, precision above 6, and mixed Iceberg cache generations. Stable regression rows also bypass the required qt_/order_qt_ generated-output workflow. This review ran no builds or tests. The author reports 570 Paimon tests, 68 MVCC tests, and Checkstyle passing; the external Spark/Doris regression was not run locally.
  • Observability and performance: existing errors/logging are adequate, the per-statement map and schema lookup are bounded, and no separate observability or performance blocker was found.
  • Transactions, persistence, and data writes are unchanged. Memory-safety and BE nullable checkpoints are not applicable to this FE Java/test-only diff.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 17215 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 4ffdc1fc1d5b4dbf94ad6dac896b9c24a9976bb3, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17717	3061	3065	3061
q2	2093	264	227	227
q3	10234	849	527	527
q4	4668	253	208	208
q5	7663	575	393	393
q6	140	113	100	100
q7	541	507	394	394
q8	9233	931	938	931
q9	3538	2407	2420	2407
q10	6493	866	721	721
q11	390	201	182	182
q12	615	263	194	194
q13	18164	1545	1183	1183
q14	161	157	139	139
q15	q16	450	401	380	380
q17	1312	894	810	810
q18	3198	2316	2270	2270
q19	1257	939	806	806
q20	375	294	204	204
q21	5604	1840	1897	1840
q22	328	273	238	238
Total cold run time: 94174 ms
Total hot run time: 17215 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3417	3374	3390	3374
q2	502	394	377	377
q3	2356	2867	2302	2302
q4	1220	1206	916	916
q5	2261	2165	2151	2151
q6	172	123	91	91
q7	1041	945	861	861
q8	1606	1410	1409	1409
q9	3204	3169	3178	3169
q10	1910	1855	1675	1675
q11	362	270	254	254
q12	462	440	344	344
q13	1496	1548	1189	1189
q14	192	177	162	162
q15	q16	399	409	370	370
q17	3699	3417	3313	3313
q18	4976	4538	5118	4538
q19	906	858	842	842
q20	1040	992	842	842
q21	3839	3141	3222	3141
q22	400	344	308	308
Total cold run time: 35460 ms
Total hot run time: 31628 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 83453 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 4ffdc1fc1d5b4dbf94ad6dac896b9c24a9976bb3, data reload: false

query5	4269	417	342	342
query6	393	148	128	128
query7	4938	401	233	233
query8	309	138	138	138
query9	8710	2936	2909	2909
query10	415	249	193	193
query11	5387	1057	924	924
query12	117	75	80	75
query13	1215	456	341	341
query14	6121	2249	2137	2137
query14_1	2019	2019	1980	1980
query15	175	125	113	113
query16	921	370	377	370
query17	783	451	372	372
query18	2349	322	242	242
query19	163	135	115	115
query20	77	74	72	72
query21	205	102	90	90
query22	5510	5479	5437	5437
query23	6961	6396	6298	6298
query23_1	6197	6285	6100	6100
query24	7255	1107	780	780
query24_1	797	782	775	775
query25	429	308	253	253
query26	1223	248	132	132
query27	2773	422	265	265
query28	4680	1507	1498	1498
query29	905	414	335	335
query30	249	157	124	124
query31	827	396	331	331
query32	114	74	79	74
query33	458	226	175	175
query34	981	816	485	485
query35	404	418	346	346
query36	585	558	547	547
query37	117	86	73	73
query38	1007	874	845	845
query39	504	513	487	487
query39_1	483	503	465	465
query40	204	89	76	76
query41	55	53	51	51
query42	72	72	72	72
query43	241	245	213	213
query44	993	539	549	539
query45	110	111	101	101
query46	807	842	524	524
query47	806	770	715	715
query48	310	303	227	227
query49	541	246	200	200
query50	745	260	199	199
query51	8348	8146	8158	8146
query52	71	68	60	60
query53	201	205	147	147
query54	222	160	165	160
query55	77	65	56	56
query56	200	165	160	160
query57	709	692	669	669
query58	212	156	169	156
query59	1237	1233	1095	1095
query60	257	187	167	167
query61	135	117	113	113
query62	354	210	180	180
query63	170	143	155	143
query64	2739	693	665	665
query65	1665	1664	1646	1646
query66	1914	287	258	258
query67	10183	9821	9943	9821
query68	2800	1219	756	756
query69	343	225	202	202
query70	679	628	586	586
query71	252	181	178	178
query72	2250	1689	1546	1546
query73	679	562	329	329
query74	1574	1229	1186	1186
query75	1194	1120	977	977
query76	2297	723	535	535
query77	256	266	211	211
query78	4043	3683	3299	3299
query79	2812	838	569	569
query80	1584	325	281	281
query81	500	160	135	135
query82	620	124	103	103
query83	274	217	189	189
query84	294	111	91	91
query85	780	352	289	289
query86	477	177	181	177
query87	1037	1010	913	913
query88	3489	2120	2137	2120
query89	280	196	175	175
query90	2115	136	132	132
query91	129	121	96	96
query92	98	73	74	73
query93	3196	1140	691	691
query94	637	253	237	237
query95	539	331	236	236
query96	795	608	274	274
query97	1086	1084	1030	1030
query98	186	141	135	135
query99	416	346	312	312
Total cold run time: 181767 ms
Total hot run time: 83453 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.97 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 4ffdc1fc1d5b4dbf94ad6dac896b9c24a9976bb3, data reload: false

query1	0.00	0.00	0.01
query2	0.08	0.04	0.04
query3	0.25	0.12	0.11
query4	1.60	0.10	0.11
query5	0.18	0.16	0.16
query6	1.25	0.70	0.67
query7	0.04	0.01	0.01
query8	0.05	0.03	0.03
query9	0.28	0.22	0.22
query10	0.35	0.35	0.36
query11	0.17	0.12	0.12
query12	0.15	0.12	0.13
query13	0.32	0.32	0.32
query14	0.47	0.46	0.45
query15	0.38	0.36	0.36
query16	0.21	0.24	0.21
query17	0.74	0.69	0.70
query18	0.19	0.18	0.19
query19	1.21	1.16	1.22
query20	0.02	0.01	0.01
query21	15.44	0.17	0.11
query22	5.06	0.04	0.05
query23	16.18	0.25	0.11
query24	3.00	0.33	0.28
query25	0.12	0.04	0.04
query26	0.83	0.17	0.12
query27	0.04	0.02	0.02
query28	3.72	0.55	0.26
query29	12.46	3.20	2.58
query30	0.26	0.12	0.12
query31	2.76	0.39	0.18
query32	3.50	0.33	0.22
query33	1.45	1.50	1.53
query34	15.35	2.24	1.83
query35	1.77	1.81	1.74
query36	0.46	0.30	0.28
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.04	0.02	0.02
query40	0.12	0.07	0.08
query41	0.08	0.03	0.02
query42	0.04	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.76 s
Total hot run time: 14.97 s

### What problem does this PR solve?

Related PR: apache#67904

Problem Summary: Restoring a bound Paimon schema could retain field-referencing options from a different generation or overwrite a fallback branch's schema and identity. Exact nanosecond timestamp pushdown could reject values that compare equal after Doris truncation. Iceberg cached schema pins could expose live partition names and specs. Preserve each schema's options and fallback provenance, retain privilege checks, keep high-precision comparisons residual, and pin Iceberg partition specs with their schema.

### Release note

External scans retain consistent schema and partition metadata. Paimon nanosecond timestamps are compared at Doris precision without unsafe source pruning.

### Check List (For Author)

- Test: 1,963 connector unit tests passed, 6 skipped; one existing Iceberg test failure reproduced before the changes and excluded. FE Checkstyle and plugin packages passed. Generated and verified all five regression baselines through the regression harness.
- Behavior changed: Yes, preserve schema provenance and avoid false timestamp pruning.
- Does this need documentation: No.
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@Gabriel39 Gabriel39 changed the title [fix](paimon) Preserve current schema and timestamp precision [fix](fe) Preserve external schema generations and timestamp precision Sep 13, 2026
@Gabriel39

Copy link
Copy Markdown
Contributor Author

Addressed the five review findings in 75ceac1:

  • Preserve bound Paimon schema options and replay only catalog/runtime overrides; added a bucket/sequence-key warm-cache rename test.
  • Restore the main fallback leaf independently, retain the fallback schema/branch, and preserve the privilege checker; verified fallback-only rows and SELECT denial enforcement.
  • Leave TIMESTAMP(7..9) comparisons residual; covered nanosecond values across comparison operators.
  • Pin Iceberg partition spec IDs with schema IDs and resolve source names against the pinned schema; covered a shared latest-cache hit after live rename/spec evolution.
  • Converted all five fixed result checks to order_qt_ cases, generated the .out with the regression harness, and reran successfully.

Validation: 1,963 connector tests passed and 6 skipped; one pre-existing Iceberg MERGE test failure was reproduced on the previous PR head and excluded. FE Checkstyle, FE build, and plugin packages passed. Local regression used the current FE/JNI extension with an existing BE and disabled the FE local-shuffle planner only on that isolated test instance for compatibility.

The PR description has been updated. GitHub review-reply and thread-resolution APIs are returning server errors, so this top-level comment records the fixes while those discussion updates remain unavailable.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16922 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 75ceac12b856aca84f572e2337b52870837950b7, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17572	3077	3068	3068
q2	2097	264	223	223
q3	10226	924	535	535
q4	4669	252	209	209
q5	7672	561	402	402
q6	137	119	96	96
q7	533	499	392	392
q8	9228	895	930	895
q9	3530	2439	2436	2436
q10	6522	868	708	708
q11	403	206	179	179
q12	612	263	205	205
q13	18126	1559	1180	1180
q14	160	147	139	139
q15	q16	427	398	365	365
q17	1362	824	756	756
q18	3182	2274	2307	2274
q19	1264	892	786	786
q20	385	279	209	209
q21	5591	1628	1885	1628
q22	341	271	237	237
Total cold run time: 94039 ms
Total hot run time: 16922 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3433	3384	3379	3379
q2	495	399	375	375
q3	2252	2347	2170	2170
q4	1206	1179	917	917
q5	2203	2169	2126	2126
q6	166	120	90	90
q7	1042	968	882	882
q8	1600	1406	1405	1405
q9	3171	3172	3137	3137
q10	1905	1855	1677	1677
q11	355	272	250	250
q12	453	428	349	349
q13	1467	1533	1184	1184
q14	172	185	156	156
q15	q16	395	401	363	363
q17	3619	3291	3249	3249
q18	4900	4510	4788	4510
q19	998	877	875	875
q20	1012	977	862	862
q21	3869	3217	3189	3189
q22	400	354	320	320
Total cold run time: 35113 ms
Total hot run time: 31465 ms

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review outcome: request changes on exact head 75ceac12b856aca84f572e2337b52870837950b7.

Goal and focus: this PR separates data, schema, and Iceberg spec generations for statement-stable external-table reads and fixes Paimon timestamp literal precision. No additional review focus was supplied. The implementation addresses the previously reported branch, wrapper, bound-schema, schema-builder, timestamp-test, and regression-baseline gaps, but three statement-consistency blockers remain.

Blocking findings:

  1. Paimon exact-schema discovery/materialization/restoration performs schema-file I/O after the connector authentication/TCCL scope has closed.
  2. Iceberg records the latest spec ID for schema assembly but drops it before partition-view construction and cache identity.
  3. The generic MVCC layer computes an exact local pinned schema, then builds partition items through ambient no-argument schema accessors before the pin is registered.

Checkpoint conclusions:

  • Goal alignment and tests: the changed tests exercise warm-table Paimon schema restoration, branch/options/native/JNI paths, NTZ precision, Iceberg schema assembly, and generated regression output. They stop before the three failing boundaries described inline.
  • Scope, clarity, and reuse: the changes are focused and reuse the statement snapshot abstraction, but the coordinate is not propagated through every generic/connector consumer.
  • Concurrency and synchronization: statement maps and immutable/single-flight caches show no new lock-order or mutation race; omitting specId from the derived cache identity is nevertheless a cross-generation correctness error.
  • Lifecycle and cleanup: statement metadata ownership and connector close paths are sound. Snapshot registration timing leaves partition construction unable to observe the local pin.
  • Configuration: no new configuration contract is introduced. Existing metadata-cache behavior and secured connector deployments expose the reported gaps.
  • Compatibility and parallel paths: no persisted or FE/BE wire format changes were found. Base tables, OPTIONS/system/fallback/branch variants, empty snapshots, native/JNI reads, and RANGE/LIST Iceberg paths were checked; existing comments remain duplicate fences.
  • Conditions and error handling: timestamp comparison, IN/OR, null propagation, and residual filtering are consistent. The remaining schema I/O can escape authentication, while mixed partition arity/types can fail analysis or silently omit partitions.
  • Test execution: per the review contract, I did not build or run tests; conclusions are static. Changed tests were inspected, including the generated ordered regression baseline.
  • Observability: no separate logging or metrics gap was identified; fixing context and generation propagation is preferable to diagnosing the resulting failures later.
  • Persistence, transactions, and writes: not applicable beyond read-side metadata coordinates; no EditLog, storage-format, or data-write change is present.
  • Resource and null safety: Java-only changes introduce no BE ownership or memory-safety issue; nullable timestamp/filter paths retain residual evaluation.
  • Performance: statement memoization and bounded caches are reasonable. The spec-view cache key must include the complete generation coordinate.
  • Security and other risks: the Doris threat model was applied. Privilege-wrapper retention is sound and no security vulnerability is asserted; the Paimon issue is authenticated connector correctness/availability in secured deployments.

The three inline P1 findings must be fixed and covered before approval.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 83385 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 75ceac12b856aca84f572e2337b52870837950b7, data reload: false

query5	4243	415	342	342
query6	403	134	124	124
query7	4928	415	227	227
query8	289	132	117	117
query9	8658	2917	2932	2917
query10	399	225	203	203
query11	5392	1053	962	962
query12	114	74	73	73
query13	1193	458	315	315
query14	6157	2252	2130	2130
query14_1	2021	2005	2017	2005
query15	177	124	125	124
query16	932	408	380	380
query17	801	478	364	364
query18	2334	324	241	241
query19	167	147	121	121
query20	84	74	73	73
query21	201	103	89	89
query22	5566	5520	5420	5420
query23	6853	6335	6164	6164
query23_1	6323	6259	6249	6249
query24	7236	1106	774	774
query24_1	747	792	777	777
query25	427	303	253	253
query26	1239	238	127	127
query27	2778	428	256	256
query28	4670	1516	1507	1507
query29	925	453	358	358
query30	244	159	133	133
query31	821	417	342	342
query32	137	75	78	75
query33	458	232	175	175
query34	988	840	494	494
query35	411	404	357	357
query36	589	580	520	520
query37	120	81	72	72
query38	1021	860	851	851
query39	521	497	479	479
query39_1	497	452	480	452
query40	203	96	79	79
query41	60	58	58	58
query42	77	74	76	74
query43	255	246	218	218
query44	991	526	562	526
query45	123	113	105	105
query46	793	869	549	549
query47	775	748	719	719
query48	310	291	241	241
query49	540	245	245	245
query50	756	259	197	197
query51	8158	8165	8083	8083
query52	73	73	59	59
query53	213	233	150	150
query54	207	171	157	157
query55	73	62	63	62
query56	203	160	197	160
query57	726	657	662	657
query58	196	175	176	175
query59	1228	1245	1128	1128
query60	239	179	183	179
query61	112	106	107	106
query62	345	201	177	177
query63	173	144	146	144
query64	2699	725	604	604
query65	1620	1665	1657	1657
query66	1774	269	208	208
query67	9990	10042	9952	9952
query68	2985	1209	690	690
query69	339	233	209	209
query70	677	632	619	619
query71	250	172	162	162
query72	2316	1757	1369	1369
query73	682	591	329	329
query74	2007	1249	1171	1171
query75	1201	1135	983	983
query76	2356	725	537	537
query77	257	271	213	213
query78	4073	3822	3292	3292
query79	2363	813	595	595
query80	1600	340	277	277
query81	493	157	137	137
query82	625	129	97	97
query83	273	212	198	198
query84	290	111	90	90
query85	788	342	282	282
query86	392	173	180	173
query87	1039	970	908	908
query88	2771	2144	2129	2129
query89	289	199	180	180
query90	1998	132	129	129
query91	131	127	98	98
query92	81	71	76	71
query93	1431	1102	708	708
query94	631	229	237	229
query95	537	251	228	228
query96	791	557	281	281
query97	1068	1108	1063	1063
query98	144	140	135	135
query99	420	345	318	318
Total cold run time: 178826 ms
Total hot run time: 83385 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 15.27 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 75ceac12b856aca84f572e2337b52870837950b7, data reload: false

query1	0.01	0.00	0.01
query2	0.08	0.03	0.04
query3	0.24	0.12	0.11
query4	1.60	0.10	0.10
query5	0.19	0.16	0.16
query6	1.25	0.72	0.69
query7	0.03	0.01	0.00
query8	0.05	0.04	0.03
query9	0.29	0.21	0.22
query10	0.36	0.37	0.36
query11	0.18	0.12	0.12
query12	0.16	0.12	0.12
query13	0.31	0.31	0.31
query14	0.47	0.47	0.46
query15	0.38	0.35	0.36
query16	0.24	0.23	0.24
query17	0.68	0.71	0.70
query18	0.18	0.17	0.17
query19	1.24	1.20	1.20
query20	0.02	0.01	0.01
query21	15.45	0.16	0.14
query22	5.08	0.04	0.05
query23	16.17	0.26	0.11
query24	2.96	0.31	0.27
query25	0.11	0.04	0.04
query26	0.82	0.17	0.13
query27	0.03	0.04	0.03
query28	3.62	0.58	0.31
query29	12.43	3.18	2.59
query30	0.26	0.11	0.12
query31	2.75	0.38	0.17
query32	3.51	0.32	0.24
query33	1.42	1.65	1.63
query34	15.36	2.28	1.80
query35	1.81	1.80	1.78
query36	0.46	0.29	0.28
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.04	0.02	0.02
query40	0.11	0.08	0.08
query41	0.07	0.03	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.59 s
Total hot run time: 15.27 s

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of exact head 1cf784fb4a972f2ec242919db51c05c4cfa121c0 found two blocking correctness issues; the inline comments contain the concrete failure paths and requested coverage.

Checkpoint conclusions:

  • Goal and scope: I reviewed all 19 changed files and traced schema/snapshot/spec binding end to end. The main schema-generation and timestamp-precision direction is coherent, subject to the two gaps below.
  • Concurrency, lifecycle, and static state: statement maps and connector caches remain bounded/owned by their existing lifecycles. The Iceberg table-name/access-TTL pin can outlive an external recreate while the raw table is deliberately reloaded, producing the missing-spec failure.
  • Configuration and dynamic behavior: no public configuration contract changed. Paimon internal bound-schema markers are stripped before SDK validation, but two later system-source transformations escape the connector authentication scope.
  • Compatibility, rolling upgrade, and FE-BE values: no SPI/Thrift/edit-log format change was found. Native/JNI/backend schema paths otherwise agree, and high-precision Paimon timestamps remain residual instead of being unsafely pushed.
  • Parallel and special paths: latest/empty, snapshot/time/tag/branch/options, normal/system, fallback/privilege, native/JNI, Iceberg first-append, RANGE/LIST, and synthesized/generated-column paths were checked. The two inline issues are the remaining distinct divergences; the known Iceberg partition-view spec issue was not duplicated.
  • Tests and result correctness: the unit and regression additions cover the principal schema and precision paths, and deterministic regression rows use generated order_qt_ baselines. Results cited in the PR are author-reported; I ran no build or tests because this review environment expressly prohibited them. Both accepted issues lack the production-shaped negative coverage described inline.
  • Observability and error handling: existing validation generally fails loud, but the Iceberg gap surfaces as an unhelpful null dereference and the Paimon gap as a catalog authentication failure during property construction.
  • Persistence, replay, writes, and transactions: not applicable to these read-side metadata/planning changes; no new durable or transactional state was introduced.
  • Performance: cache/memo capacities remain bounded and no separate hot-loop regression was established. The Paimon manifest-cap path performs an avoidable source reconstruction, but its correctness impact is covered by the auth comment.
  • Security/trust model: external catalogs are administrator-trusted under the repository threat model. The authentication-scope finding is an operational connector correctness failure, not a Doris security vulnerability.

User focus: no additional focus was supplied, so the full PR was reviewed without narrowing scope. Two complete review rounds converged with no additional distinct findings.

…reparation

### What problem does this PR solve?

Related PR: apache#67904

Problem Summary: A warm Iceberg latest pin can retain a partition spec ID
that disappears after an external table recreation. Fall back to the reloaded
table's current spec, matching the existing missing-schema behavior.
Paimon scan properties can also restore bound system-source schemas after
backend-table preparation leaves its authenticated scope. Authenticate both
later source transformations with the existing classloader-aware helper.

### Release note

Avoid null partition specs after Iceberg table recreation and preserve the
Paimon authentication scope while preparing bound system-source scan properties.

### Check List (For Author)

- Test: 801 related connector and metastore tests passed, one connectivity test
  skipped. Both new regressions failed before their fixes. FE build and
  connector package validation passed, including Checkstyle.
- Behavior changed: Yes, preserve missing-history fallback and schema-read authentication.
- Does this need documentation: No.
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of exact head a56a252a07840b42527a527f865e15d400168329 found two blocking table-generation correctness issues; the inline comments contain the concrete failure paths and requested coverage.

Checkpoint conclusions:

  • Goal and proof: the patch largely separates schema and data coordinates and preserves timestamp precision, but two generation-reuse gaps remain. Existing tests cover same-generation and missing-ID behavior, not numeric-ID reuse after recreation.
  • Scope and focus: all 19 changed files and the full authoritative diff were reviewed; no additional user focus was supplied.
  • Concurrency and lifecycle: no new lock, thread-safety, or deadlock issue was found. Statement metadata, connector caches, invalidation, and external DDL lifecycle were traced; both findings are missing generation-identity fences.
  • Configuration and compatibility: no new configuration or public storage, SPI, Thrift, or EditLog compatibility issue was found. Existing cache/TTL and vended-credential paths were checked.
  • Parallel paths: plain/options/branch/system Paimon reads; latest/empty/time-travel Iceberg reads; native/JNI; RANGE/LIST; and synthesized/generated columns were traced.
  • Special conditions and error handling: marker handling and timestamp precision gates are sound, but reused numeric IDs bypass the intended fallback/guard in the two reported paths.
  • Tests and results: unit and regression coverage is broad, and expected outputs are consistent on static inspection, but the two production-shaped recreate/reuse cases are absent. Per the review prompt, I did not build or run tests; CI evidence is author-reported rather than independently executed here.
  • Observability: no new metrics or logging requirement was identified; direct invariant coverage is preferable.
  • Persistence, transactions, and writes: this is read-side planning/metadata work; no Doris persistent-state or write-path defect was found.
  • FE/BE variables: the new Paimon schema coordinate and Iceberg spec selection were traced across their consumers; no additional carrier issue remains beyond existing hard duplicate fences.
  • Performance: no separate hot-loop or asymptotic regression was found.
  • Other: exactly two findings were accepted after two bounded review rounds; all other candidates were disproven or duplicate-fenced.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16713 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a56a252a07840b42527a527f865e15d400168329, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17660	3067	3057	3057
q2	2056	252	223	223
q3	10264	889	506	506
q4	4678	247	207	207
q5	7667	558	382	382
q6	134	114	95	95
q7	528	497	409	409
q8	9226	862	943	862
q9	3444	2359	2379	2359
q10	6502	838	729	729
q11	394	194	177	177
q12	630	262	197	197
q13	18100	1523	1162	1162
q14	159	151	138	138
q15	q16	434	391	363	363
q17	1382	883	774	774
q18	3091	2218	2242	2218
q19	1292	918	799	799
q20	387	280	197	197
q21	5622	1625	1801	1625
q22	329	263	234	234
Total cold run time: 93979 ms
Total hot run time: 16713 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3430	3349	3350	3349
q2	510	403	398	398
q3	2196	2397	2209	2209
q4	1183	1159	886	886
q5	2155	2076	2083	2076
q6	170	115	85	85
q7	1011	928	838	838
q8	1592	1390	1399	1390
q9	3109	3065	3051	3051
q10	1835	1807	1590	1590
q11	354	268	253	253
q12	447	425	341	341
q13	1479	1504	1165	1165
q14	178	178	171	171
q15	q16	389	389	357	357
q17	3528	3302	3149	3149
q18	4786	4420	4693	4420
q19	844	780	868	780
q20	992	961	834	834
q21	3752	3004	3192	3004
q22	405	351	321	321
Total cold run time: 34345 ms
Total hot run time: 30667 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 80839 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit a56a252a07840b42527a527f865e15d400168329, data reload: false

query5	4269	413	342	342
query6	388	137	120	120
query7	4947	426	230	230
query8	282	129	112	112
query9	8681	2868	2873	2868
query10	400	241	169	169
query11	5412	1014	896	896
query12	111	69	74	69
query13	1186	429	323	323
query14	6047	2182	2052	2052
query14_1	1954	1940	1943	1940
query15	178	115	108	108
query16	907	357	352	352
query17	810	457	347	347
query18	2319	323	228	228
query19	169	140	107	107
query20	76	68	68	68
query21	201	102	89	89
query22	5455	5356	5312	5312
query23	6586	6127	5920	5920
query23_1	6090	5842	5841	5841
query24	7275	1078	735	735
query24_1	774	758	773	758
query25	424	301	253	253
query26	1228	246	124	124
query27	2773	425	258	258
query28	4699	1474	1491	1474
query29	931	440	351	351
query30	262	154	130	130
query31	837	396	335	335
query32	133	80	77	77
query33	467	218	180	180
query34	984	813	486	486
query35	397	391	345	345
query36	566	573	528	528
query37	116	81	68	68
query38	998	848	811	811
query39	490	516	468	468
query39_1	447	468	452	452
query40	206	90	77	77
query41	61	57	55	55
query42	74	71	72	71
query43	239	243	210	210
query44	993	537	534	534
query45	109	110	102	102
query46	759	838	511	511
query47	762	764	701	701
query48	315	312	240	240
query49	550	238	191	191
query50	715	261	202	202
query51	8173	8032	8012	8012
query52	65	64	56	56
query53	190	192	139	139
query54	224	157	153	153
query55	78	58	52	52
query56	182	171	152	152
query57	671	676	607	607
query58	207	195	207	195
query59	1225	1212	1121	1121
query60	239	188	171	171
query61	109	112	122	112
query62	364	200	166	166
query63	171	141	139	139
query64	2703	692	540	540
query65	1683	1527	1632	1527
query66	1863	256	193	193
query67	9898	9483	10283	9483
query68	2761	1124	727	727
query69	353	215	193	193
query70	659	625	621	621
query71	248	182	160	160
query72	2302	1667	1511	1511
query73	635	598	343	343
query74	1565	1194	1147	1147
query75	1154	1104	935	935
query76	2293	693	512	512
query77	253	268	215	215
query78	3692	3811	3164	3164
query79	2419	855	572	572
query80	1586	337	274	274
query81	493	149	132	132
query82	650	118	96	96
query83	274	204	184	184
query84	291	106	87	87
query85	765	340	286	286
query86	413	179	174	174
query87	995	959	910	910
query88	2764	2088	2083	2083
query89	286	196	172	172
query90	1971	125	128	125
query91	130	110	96	96
query92	72	69	71	69
query93	1373	1020	662	662
query94	611	246	235	235
query95	525	263	221	221
query96	784	570	287	287
query97	1033	1047	1006	1006
query98	140	134	134	134
query99	415	346	304	304
Total cold run time: 176419 ms
Total hot run time: 80839 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.48 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit a56a252a07840b42527a527f865e15d400168329, data reload: false

query1	0.01	0.00	0.01
query2	0.07	0.04	0.04
query3	0.26	0.11	0.11
query4	1.61	0.09	0.11
query5	0.17	0.15	0.15
query6	1.32	0.68	0.69
query7	0.03	0.00	0.01
query8	0.05	0.03	0.03
query9	0.28	0.22	0.21
query10	0.34	0.35	0.34
query11	0.17	0.11	0.12
query12	0.14	0.13	0.13
query13	0.29	0.30	0.31
query14	0.45	0.44	0.44
query15	0.36	0.34	0.34
query16	0.20	0.22	0.24
query17	0.70	0.67	0.67
query18	0.18	0.17	0.17
query19	1.20	1.16	1.06
query20	0.02	0.01	0.01
query21	15.42	0.16	0.12
query22	5.05	0.04	0.04
query23	16.18	0.25	0.09
query24	3.01	0.31	0.24
query25	0.12	0.03	0.04
query26	0.80	0.17	0.13
query27	0.04	0.03	0.02
query28	3.65	0.59	0.28
query29	12.45	3.19	2.56
query30	0.26	0.12	0.12
query31	2.75	0.39	0.16
query32	3.51	0.31	0.23
query33	1.35	1.39	1.47
query34	15.31	2.23	1.73
query35	1.74	1.74	1.71
query36	0.47	0.30	0.31
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.04	0.02	0.02
query40	0.11	0.08	0.07
query41	0.07	0.02	0.02
query42	0.04	0.03	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.36 s
Total hot run time: 14.48 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 86.67% (13/15) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Related PR: apache#67904

Problem Summary: Eager latest-schema pinning bypassed the schema cache loader's validation. A Paimon table with case-insensitive duplicate columns therefore reached connector planning and reported a different error. Validate the mapped pinned schema before partition enumeration to preserve the existing duplicate-column error.

### Release note

Preserve duplicate-column validation when pinning external table schemas.

### Check List (For Author)

- Test: 116 FE unit tests; local Paimon duplicate-column regression in Native and JNI modes; FE build and Checkstyle.
- Behavior changed: Yes. Restore the existing duplicate-column error on the new latest-schema pinning path.
- Does this need documentation: No.
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review at exact head b6f108f8388b502e508ae33cfd6066e0acf756fd: request changes.

Two P1 correctness blockers remain unresolved, both already reported inline on this head:

  • Paimon generation-blind schema memo: external drop/recreate can reuse schema ID 0, allowing the long-lived name/schema-ID memo to bind generation B's scan to generation A's schema indefinitely.
  • Iceberg reused cached spec ID: an externally recreated table can reuse a cached numeric spec ID, causing current schema assembly to consume an unrelated historical spec from the replacement generation.

I did not duplicate these inline comments. All required full-coverage and risk-focused sweeps returned NO_NEW_VALUABLE_FINDINGS; every residual candidate was independently reduced to an existing thread, a fixed earlier thread, pre-existing behavior, or dismissed with concrete code evidence.

Checkpoint conclusions:

  • Goal and evidence: the patch largely implements independent schema/data fencing for Paimon and Iceberg and preserves Paimon NTZ microseconds, with focused unit and regression coverage. The two generation-identity gaps above mean the goal is not yet complete under external recreation.
  • Scope and clarity: the production changes are broad but mostly follow the necessary metadata, scan, wrapper, native/JNI, and generic-FE consumers. No additional user-provided focus was present.
  • Concurrency and lifecycle: no new lock-order, deadlock, or shared-mutation issue was found. The blocking lifecycle problem is semantic: catalog-lifetime caches outlive physical table generations while their keys carry only names and reusable numeric IDs.
  • Configuration and compatibility: no new user configuration, storage format, persisted metadata, public SPI, or FE/BE protocol change was found. Connector-private schema markers remain FE-side or are materialized into the existing serialized table representation.
  • Parallel paths and conditions: ordinary, OPTIONS, branch, fallback, privilege-decorated, system-table, native, JNI, Iceberg statement-scope, partition, and schema-dictionary paths were traced. New special conditions are documented; the scan guard exempts only connector-classified SYNTHESIZED columns, while generated and physical mismatches remain fail-loud.
  • Tests and results: targeted tests cover schema-only evolution, empty-table transition, missing IDs, partition-column pinning, timestamp precisions/operators, native/JNI reads, and deterministic regression output. The missing cases are external recreation with a reused Paimon schema ID and a reused Iceberg spec ID. Per task constraints this was a static-only review: I ran no build or test; test/build results in the PR and thread replies are author-reported, not independently verified.
  • Observability, persistence, writes, and performance: no new logging/metrics requirement, Doris transaction/EditLog path, or Doris data-write path applies. No obvious hot-loop regression was found; cache/memo lookup is cheap, but the under-specified cache identity is correctness-blocking. Authentication/TCCL restoration for the new Paimon schema reads appears consistently covered.

Review convergence is complete for this head; resolving the two existing P1 threads is required before approval.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16690 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit b6f108f8388b502e508ae33cfd6066e0acf756fd, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17575	3063	3052	3052
q2	2081	258	215	215
q3	10265	896	498	498
q4	4668	251	202	202
q5	7674	545	382	382
q6	136	111	92	92
q7	527	492	393	393
q8	9230	858	842	842
q9	3420	2373	2369	2369
q10	6529	841	696	696
q11	397	194	178	178
q12	632	264	192	192
q13	18116	1522	1150	1150
q14	166	147	139	139
q15	q16	442	389	361	361
q17	1337	914	813	813
q18	3110	2233	2217	2217
q19	1265	862	792	792
q20	378	276	204	204
q21	5562	1675	1868	1675
q22	320	271	228	228
Total cold run time: 93830 ms
Total hot run time: 16690 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3436	3388	3388	3388
q2	498	392	366	366
q3	2183	2238	2222	2222
q4	1177	1148	885	885
q5	2169	2087	2101	2087
q6	169	117	87	87
q7	1013	904	848	848
q8	1585	1397	1393	1393
q9	3105	3097	3057	3057
q10	1842	1758	1584	1584
q11	355	274	250	250
q12	448	430	340	340
q13	1470	1532	1168	1168
q14	168	181	156	156
q15	q16	397	397	354	354
q17	3549	3189	3245	3189
q18	4795	4351	4704	4351
q19	866	825	810	810
q20	1082	962	827	827
q21	3854	3096	3303	3096
q22	400	346	314	314
Total cold run time: 34561 ms
Total hot run time: 30772 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81033 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit b6f108f8388b502e508ae33cfd6066e0acf756fd, data reload: false

query5	4251	398	343	343
query6	389	129	123	123
query7	4969	428	226	226
query8	296	136	118	118
query9	8697	2855	2864	2855
query10	403	212	183	183
query11	5375	1016	907	907
query12	111	68	67	67
query13	1190	440	315	315
query14	6061	2165	2077	2077
query14_1	1962	1938	1945	1938
query15	176	119	112	112
query16	927	360	305	305
query17	800	472	366	366
query18	2332	317	248	248
query19	166	136	109	109
query20	88	71	74	71
query21	203	99	88	88
query22	5290	5184	5168	5168
query23	6741	6431	6297	6297
query23_1	6268	6209	5967	5967
query24	7290	1093	751	751
query24_1	763	747	764	747
query25	397	279	233	233
query26	1215	229	125	125
query27	2803	434	252	252
query28	4661	1480	1466	1466
query29	923	423	322	322
query30	245	151	126	126
query31	839	393	332	332
query32	122	71	68	68
query33	473	200	161	161
query34	988	837	477	477
query35	392	395	338	338
query36	570	547	523	523
query37	122	76	69	69
query38	1004	842	802	802
query39	501	470	489	470
query39_1	464	468	462	462
query40	203	87	73	73
query41	57	53	54	53
query42	71	70	72	70
query43	236	248	211	211
query44	1002	524	546	524
query45	110	104	99	99
query46	774	811	509	509
query47	758	763	694	694
query48	303	300	228	228
query49	532	241	198	198
query50	791	257	193	193
query51	7985	7927	7973	7927
query52	64	70	63	63
query53	191	201	150	150
query54	223	154	156	154
query55	72	60	54	54
query56	199	158	153	153
query57	686	645	649	645
query58	209	168	240	168
query59	1208	1219	1092	1092
query60	231	189	194	189
query61	122	115	104	104
query62	361	210	176	176
query63	174	136	136	136
query64	2689	731	569	569
query65	1557	1589	1609	1589
query66	1847	280	203	203
query67	9853	9673	9459	9459
query68	2749	1214	706	706
query69	349	226	196	196
query70	670	625	593	593
query71	248	168	162	162
query72	2351	1638	1456	1456
query73	691	593	353	353
query74	1578	1237	1120	1120
query75	1156	1087	959	959
query76	2293	704	514	514
query77	244	261	201	201
query78	3951	3602	3217	3217
query79	1239	812	558	558
query80	1209	336	269	269
query81	485	152	128	128
query82	643	121	96	96
query83	308	210	192	192
query84	298	112	87	87
query85	793	329	279	279
query86	396	175	166	166
query87	1009	966	882	882
query88	2731	2104	2090	2090
query89	287	200	171	171
query90	1936	128	130	128
query91	138	135	106	106
query92	83	73	78	73
query93	1273	1173	733	733
query94	637	247	208	208
query95	511	242	307	242
query96	834	605	265	265
query97	1028	1040	1004	1004
query98	143	135	134	134
query99	420	362	303	303
Total cold run time: 175106 ms
Total hot run time: 81033 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.58 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit b6f108f8388b502e508ae33cfd6066e0acf756fd, data reload: false

query1	0.00	0.01	0.00
query2	0.08	0.04	0.04
query3	0.25	0.10	0.10
query4	1.60	0.10	0.10
query5	0.17	0.16	0.16
query6	1.27	0.70	0.67
query7	0.04	0.00	0.01
query8	0.05	0.03	0.04
query9	0.28	0.22	0.21
query10	0.34	0.36	0.33
query11	0.16	0.12	0.12
query12	0.14	0.12	0.12
query13	0.31	0.31	0.32
query14	0.44	0.44	0.45
query15	0.37	0.35	0.34
query16	0.21	0.22	0.21
query17	0.71	0.71	0.73
query18	0.18	0.18	0.16
query19	1.18	1.09	1.15
query20	0.02	0.01	0.01
query21	15.46	0.15	0.13
query22	5.07	0.05	0.05
query23	16.19	0.24	0.09
query24	3.01	0.35	0.27
query25	0.11	0.04	0.03
query26	0.71	0.17	0.12
query27	0.04	0.04	0.03
query28	3.65	0.52	0.27
query29	12.49	3.13	2.56
query30	0.26	0.10	0.11
query31	2.76	0.41	0.17
query32	3.50	0.30	0.22
query33	1.34	1.38	1.39
query34	15.34	2.17	1.78
query35	1.73	1.71	1.74
query36	0.48	0.29	0.30
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.08	0.07
query41	0.07	0.02	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.32 s
Total hot run time: 14.58 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 87.50% (14/16) 🎉
Increment coverage report
Complete coverage report

@924060929 924060929 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head b6f108f8388b502e508ae33cfd6066e0acf756fd.

The overall schema/data-fence direction is sound, and the current CI is green, but two P1 generation-identity gaps remain unresolved:

  • Paimon schema memo: the catalog-lifetime memo is keyed by table name plus reusable schema ID. After an external drop/recreate, generation B can reuse schema ID 0 and remain bound to generation A's cached schema until an explicit Doris invalidation.
  • Iceberg cached spec: the missing-spec fallback does not cover a replacement table that reuses the cached numeric spec ID. In that case the current schema can be combined with an unrelated older spec from the replacement generation.

The existing tests cover same-generation schema evolution and missing IDs, but not external recreation with ID reuse. Please bind the cached coordinates to a stable physical-table generation identity and add both recreate/reuse regressions before approval.

### What problem does this PR solve?

Related PR: apache#67904

Problem Summary: External table recreation can reuse schema and partition-spec IDs. The new Paimon latest-schema path could bind metadata from a historical memo belonging to the previous table, while Iceberg could apply a cached spec ID to an unrelated replacement table. Retain the actual Paimon statement schema for metadata and column handles. Bind Iceberg latest pins to the table identity, reject a mismatch before interpreting its schema/spec IDs, and invalidate the stale cache entry so a retry resolves the replacement table.

### Release note

Preserve Paimon latest-schema binding after external table recreation. Detect stale Iceberg pins across table replacement and allow recovery by retrying the statement.

### Check List (For Author)

- Test: 1,008 related unit and SDK tests passed, one connectivity test skipped; FE build, connector packages, and Checkstyle passed. Recreation regressions failed before the fix.
- Behavior changed: Yes. Paimon latest metadata agrees with the replacement table. Iceberg rejects a pin from a different table identity and clears it for the next statement.
- Does this need documentation: No.
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Selected model is at capacity. Please try a different model.
Workflow run: https://github.com/apache/doris/actions/runs/34798431771

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@924060929 924060929 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed current head 54a5294. The Iceberg table-identity fix and the Paimon latest-schema fix address the two previously reported cases. One Paimon explicit time-travel path still allows a recreated table to reuse a schema ID and hit the previous table schema; details are inline.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16810 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 54a5294b6cb8490693a157d0d465a47e5e15c9a6, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17580	3001	3018	3001
q2	2077	259	213	213
q3	10252	882	505	505
q4	4673	255	210	210
q5	7665	580	389	389
q6	137	119	95	95
q7	526	504	390	390
q8	9236	897	884	884
q9	3434	2412	2422	2412
q10	6527	879	739	739
q11	415	192	179	179
q12	616	268	197	197
q13	18128	1567	1175	1175
q14	167	155	140	140
q15	q16	444	401	378	378
q17	1345	843	767	767
q18	3188	2332	2310	2310
q19	1255	903	740	740
q20	375	287	211	211
q21	5644	1651	1859	1651
q22	330	269	224	224
Total cold run time: 94014 ms
Total hot run time: 16810 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3412	3335	3332	3332
q2	499	405	366	366
q3	2283	2280	2194	2194
q4	1205	1184	899	899
q5	2245	2164	2141	2141
q6	174	120	88	88
q7	1063	957	890	890
q8	1599	1403	1402	1402
q9	3241	3198	3201	3198
q10	1882	1827	1673	1673
q11	356	277	253	253
q12	443	438	343	343
q13	1473	1557	1150	1150
q14	183	170	170	170
q15	q16	393	404	367	367
q17	3807	3379	3273	3273
q18	4946	4530	4969	4530
q19	959	861	861	861
q20	1015	986	832	832
q21	3868	3152	3263	3152
q22	381	341	325	325
Total cold run time: 35427 ms
Total hot run time: 31439 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 82486 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 54a5294b6cb8490693a157d0d465a47e5e15c9a6, data reload: false

query5	4238	400	313	313
query6	377	136	138	136
query7	4988	411	219	219
query8	298	129	125	125
query9	8696	2853	2857	2853
query10	404	231	178	178
query11	5382	1039	914	914
query12	117	73	68	68
query13	1184	448	291	291
query14	6106	2254	2144	2144
query14_1	2017	2018	2001	2001
query15	179	127	111	111
query16	916	375	360	360
query17	800	448	378	378
query18	2340	339	240	240
query19	157	136	111	111
query20	87	70	70	70
query21	202	101	88	88
query22	5500	5475	5433	5433
query23	7008	6439	6092	6092
query23_1	6273	6089	6331	6089
query24	7289	1066	758	758
query24_1	751	782	779	779
query25	421	297	258	258
query26	1238	224	132	132
query27	2789	416	262	262
query28	4662	1505	1484	1484
query29	928	422	345	345
query30	250	147	132	132
query31	824	403	340	340
query32	135	79	74	74
query33	464	226	176	176
query34	982	795	481	481
query35	420	419	347	347
query36	578	581	531	531
query37	122	82	69	69
query38	1018	867	825	825
query39	486	509	465	465
query39_1	478	469	474	469
query40	204	92	78	78
query41	62	56	57	56
query42	76	78	74	74
query43	242	244	213	213
query44	990	538	545	538
query45	113	110	101	101
query46	762	869	546	546
query47	770	793	726	726
query48	315	330	238	238
query49	544	244	200	200
query50	747	261	231	231
query51	8054	8049	7943	7943
query52	71	69	59	59
query53	191	198	145	145
query54	261	165	137	137
query55	76	57	54	54
query56	193	151	163	151
query57	695	680	698	680
query58	193	170	162	162
query59	1242	1260	1131	1131
query60	233	174	201	174
query61	111	107	108	107
query62	373	206	183	183
query63	177	140	143	140
query64	2674	726	582	582
query65	1676	1670	1610	1610
query66	1767	250	191	191
query67	10100	9974	9857	9857
query68	2984	1230	699	699
query69	348	233	203	203
query70	673	619	653	619
query71	252	183	162	162
query72	2279	1634	1471	1471
query73	633	584	339	339
query74	1994	1245	1180	1180
query75	1198	1105	972	972
query76	2364	733	517	517
query77	240	248	223	223
query78	4221	3892	3297	3297
query79	1607	805	572	572
query80	1178	318	268	268
query81	504	155	137	137
query82	633	124	97	97
query83	273	212	189	189
query84	301	107	87	87
query85	774	343	282	282
query86	401	176	177	176
query87	1018	998	898	898
query88	2761	2117	2111	2111
query89	274	195	176	176
query90	1993	129	127	127
query91	126	113	95	95
query92	78	69	61	61
query93	1348	1040	700	700
query94	646	257	216	216
query95	531	241	290	241
query96	790	539	262	262
query97	1047	1110	1041	1041
query98	140	146	131	131
query99	417	339	320	320
Total cold run time: 177459 ms
Total hot run time: 82486 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.73 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 54a5294b6cb8490693a157d0d465a47e5e15c9a6, data reload: false

query1	0.01	0.01	0.00
query2	0.07	0.04	0.03
query3	0.25	0.11	0.11
query4	1.60	0.09	0.10
query5	0.17	0.16	0.15
query6	1.27	0.66	0.70
query7	0.04	0.01	0.00
query8	0.05	0.03	0.03
query9	0.27	0.21	0.22
query10	0.34	0.33	0.35
query11	0.16	0.11	0.11
query12	0.15	0.12	0.12
query13	0.29	0.32	0.31
query14	0.46	0.46	0.46
query15	0.37	0.35	0.35
query16	0.20	0.21	0.24
query17	0.69	0.70	0.68
query18	0.18	0.16	0.17
query19	1.26	1.18	1.25
query20	0.01	0.01	0.01
query21	15.44	0.16	0.12
query22	5.08	0.05	0.04
query23	16.20	0.26	0.10
query24	2.97	0.35	0.26
query25	0.10	0.04	0.04
query26	0.75	0.16	0.13
query27	0.04	0.04	0.04
query28	3.60	0.54	0.28
query29	12.46	3.19	2.54
query30	0.25	0.11	0.12
query31	2.76	0.39	0.17
query32	3.52	0.33	0.24
query33	1.41	1.40	1.62
query34	15.37	2.21	1.82
query35	1.76	1.73	1.78
query36	0.46	0.29	0.27
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.02	0.03
query40	0.13	0.08	0.08
query41	0.08	0.03	0.02
query42	0.04	0.02	0.03
query43	0.03	0.03	0.03
Total cold run time: 90.42 s
Total hot run time: 14.73 s

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@924060929 924060929 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the current head with the local pipeline-style review. The previously reported schema, timestamp, authentication, and Iceberg identity fixes are present, but four distinct Major regressions remain: captured-schema lifetime across INSERT replanning, fallback-child schema restoration, catalog option provenance, and HMS Iceberg capability forwarding. Details are inline.

// existing direct-construction tests compile unchanged; production goes through the 5-arg ctor.
private final PaimonLatestSnapshotCache latestSnapshotCache;

// Metadata is statement-scoped: aliases sharing a data fence must also share one schema generation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The captured schema is owned by one ConnectorMetadata instance, but an INSERT planning retry resets the connector scope while retaining the source MVCC snapshot. The replacement metadata has an empty statementSchemas map, so a preserved latest pin with a schema ID falls through to the catalog-lifetime schemaAtMemo. With an old table generation still memoized and a recreated same-name table reusing that schema ID, attempt 1 can bind the new table while attempt 2 obtains old column handles and fails. Please make the exact captured schema live as long as the retained MVCC pin, or re-read it once in the replacement scope without consulting the historical memo. Add an INSERT replan regression with an old-generation memo.

FallbackReadFileStoreTable pair = (FallbackReadFileStoreTable) table;
// Schema IDs are branch-local. Broadcasting the main schema through copy(TableSchema)
// overwrites the fallback's provenance and can even reset its branch to main.
return new FallbackReadFileStoreTable(restoreBoundSchema(pair.wrapped(), schemaId), pair.fallback());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This restores only the main child and keeps the cached fallback child unchanged. If a warm M0/F0 fallback table has since received the same compatible nullable ADD COLUMN on both real branches, the current state is M1/F1 but Doris constructs M1/F0. Paimon 1.3.1 validates the complete row types before projection, so even SELECT id fails although the external branches are compatible. Capture and restore each child using its own branch-local schema coordinate; a main schema ID cannot be broadcast to the fallback branch.

Map<String, String> merged = new HashMap<>(bound.options());
// Field-referencing options evolve with the schema (e.g. bucket-key and sequence.field
// on rename). Only replay the catalog/runtime delta, never another generation's options.
table.options().forEach((key, value) -> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value equality cannot recover option provenance. For example, an explicit catalog read.batch-size=64 is indistinguishable here from an old physical value of 64. After an external option-only change makes the physical value 128, this filter drops the explicit catalog override and the scan incorrectly uses 128; a new value of 0 can instead make a previously valid query fail validation. Preserve explicit catalog/runtime overrides separately and merge bound physical options, then catalog/runtime overrides, then relation overrides.

if (connectorSnapshot.getSchemaId() >= 0) {
// Latest data and schema can advance independently. Keep the connector's exact schema
// on the statement pin so analysis cannot fall back to a different cached generation.
ConnectorTableSchema atSchema = metadata.getTableSchema(session, pinnedHandle, connectorSnapshot);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly retained latest schema calls the snapshot-aware metadata overload. Through an HMS catalog, Hive delegates that overload to the Iceberg sibling but does not apply the capability reflection used by the ordinary two-argument overload. The resulting pinned schema has an empty capability set and shadows the enriched schema, disabling TopN lazy materialization, nested-column pruning, and storage predicate inference for ordinary HMS Iceberg reads. Please reuse the existing sibling capability inheritance helper in the snapshot-aware Hive path and add a retained-latest publication test for all three capabilities.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes. Static review of exact head 54a5294b6cb8490693a157d0d465a47e5e15c9a6 found two additional P1 correctness/availability failures. An equivalent P2 catalog-option provenance issue was posted meanwhile in discussion r4004077352, so I have not duplicated it.

Critical checkpoints

  • Goal and proof: The PR aims to keep external-table data, schema, spec, and predicate semantics coherent across schema-only evolution and recreation. The direct paths are substantially covered, but the goal is incomplete: Paimon can cross physical generations within one statement, and valid UUID-less Iceberg evolution is rejected.
  • Focus/minimality: The 19-file diff is focused on Paimon/Iceberg MVCC pinning, generic FE consumers, and their tests; no unrelated edits were found.
  • Concurrency/thread safety: External catalog ALTER/commit/DROP/CREATE operations are the relevant concurrent actors. Cache values are immutable and statement maps use the existing concurrent machinery; no new lock-order or deadlock issue was found. The Paimon logical handle key nevertheless lacks a physical-generation fence, producing the first inline issue.
  • Lifecycle: Statement metadata, independently resolved Paimon handles, Iceberg statement-frozen tables, cache invalidation/retry, leases, authentication scopes, and decorator teardown were traced. The two inline issues are lifecycle/cache-boundary defects; no separate leak, double close, circular lifetime, or static-initialization issue was found.
  • Configuration: No new public configuration is added. Existing no-cache/reload Paimon behavior makes the generation crossing reachable; REST vended credentials intentionally keep latestSnapshotCache while disabling tableCache, making the Iceberg failure reachable. Existing paimon.table-option.* precedence has a separate equal-value provenance gap already covered by r4004077352.
  • Compatibility: No persisted format, SPI symbol, EditLog, or FE-BE wire change is introduced. UUID-less format-V1 Iceberg metadata is an explicitly supported compatibility path, and the new exact-filename identity fallback breaks valid same-table commits there. No additional rolling-upgrade issue was found.
  • Parallel paths: Latest, empty, reader-only OPTIONS, explicit selectors, branches, supported system wrappers, RANGE/LIST/UNPARTITIONED materialization, synchronous/streaming/count scans, native dictionaries, JNI serialization, and metadata tables were checked. No additional distinct issue survived; the known explicit Paimon historical-memo and Iceberg partition-view/spec points are already fenced by existing discussions.
  • Conditions and error handling: The Iceberg mismatch error includes the table and retry guidance, but its condition is over-broad for ordinary UUID-less commits. Paimon numeric-ID/equality checks cannot prove physical identity. No separate swallowed status/exception or speculative defensive branch was found.
  • Test coverage: The added unit/regression tests broadly cover cache hits, empty-to-first-append, recreation, schema rename, partition arity/type, synthesized versus generated columns, authentication, fallback/branch behavior, native/JNI paths, and timestamp precision. They miss recreation between one statement's pin and later scan-handle resolution, and an ordinary UUID-less M1-to-M2 commit under warm-pin/fresh-table caching.
  • Test results/output: Query labels and expected regression output were checked statically. Per the review contract, I did not run builds or tests; author/CI-reported results are not independent verification.
  • Observability: Existing errors carry useful table/retry context. Paimon generation mixing has no fail-loud signal, while the Iceberg signal fires on valid evolution; fixing those conditions is the actionable need. No separate logging or metrics gap was substantiated.
  • Transactions/persistence: The changed code is read-metadata/planning logic and adds no Doris transaction, journal, failover, or persistent-state behavior.
  • Data writes: No Doris data-write path is modified. Existing Iceberg writer identity ancestry was inspected as evidence for valid V1 evolution; no separate write atomicity issue was found.
  • FE-BE variables: No new transmitted variable or scattered protocol send path is added; snapshot identity/schema/spec properties remain FE-internal. Native/JNI consumers were included in the consistency trace.
  • Performance, memory, and BE nullability: This is FE Java code; no BE allocator/nullability issue applies. Schema/identity work is bounded to statement/cache operations. Apart from the recurring valid-query retry and the already-reported lost reader policy, no material CPU or memory regression was found.
  • Other data correctness: Paimon timestamp precision 0-6 preserves the visible wall clock; precision 7-9 pushdown fails closed while Doris retains residual evaluation. The synthesized-column exemption remains narrow enough that physical/generated skew fails loudly. No further distinct issue was found.

User focus: No additional user-provided focus was supplied; the full authoritative diff was reviewed.

Completion: Complete after three convergence rounds. All candidates were accepted, dismissed with code evidence, or duplicate-fenced; this review submits the two remaining distinct findings.

}

private long statementSchemaId(PaimonTableHandle handle, Table table) {
return statementSchemas.computeIfAbsent(handle,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Fence the physical Paimon generation across one statement. statementSchemas is keyed by PaimonTableHandle equality, which omits the transient Table/generation. materializeLatest can capture generation A, but PluginDrivenScanNode.create later resolves the handle again; if an external DROP/CREATE occurs between them and B reuses the snapshot/schema IDs, schemaForPin returns A while withScanOptions preserves B and restoration skips because the IDs match. The FE guard therefore passes on A/A while native/JNI planning reads B's rows. This is distinct from the existing cross-statement memo thread because it occurs after the current statement pinned A. Please freeze or validate the physical generation through scan resolution, and cover recreation between pinning and scan-handle resolution in one metadata instance.

return metadata.uuid();
}
// Legacy V1 metadata may lack a UUID. Only the exact metadata file can safely reuse its IDs.
return "metadata:" + Objects.requireNonNull(metadata.metadataFileLocation(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Do not equate a UUID-less table's identity with its current metadata file. An ordinary Iceberg commit writes a new metadata file for the same table. With REST vended credentials, latestSnapshotCache stays enabled while tableCache is disabled, so the next statement can receive cached M1 coordinates, freshly load the same table at M2, and fail this identity check; active V1 tables then require a retry after every commit. IcebergWriteSchemaContext already handles this case by accepting a retained metadata ancestor. Please disable latest-pin caching for UUID-less tables or validate ancestry, and test a normal same-table commit under the warm-pin/fresh-table cache combination while retaining recreate protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants