Skip to content

[feature](iceberg) support insert into iceberg table with sort-order - #60540

Merged
morningman merged 5 commits into
apache:masterfrom
zhangstar333:iceberg_stats_orders
Feb 22, 2026
Merged

[feature](iceberg) support insert into iceberg table with sort-order#60540
morningman merged 5 commits into
apache:masterfrom
zhangstar333:iceberg_stats_orders

Conversation

@zhangstar333

@zhangstar333 zhangstar333 commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:

support write iceberg table with sort-order, the write data have been local sorted, and have add lower/upper_bounds metadata. so the iceberg plan could use it to prune datafile.
Notes: this is only a local sort, not global sort. so if you are more parallel about iceberg writer, you many see overlapping of lower/upper_bounds between files.
if you need a global sort, maybe could add order by cluster in the insert SQL.

you could create table, and then alter table eg:

CREATE TABLE test_table2 (
    id INT,
    name STRING,
    score DOUBLE,
    create_time datetime
)
ORDER BY (
    id ASC NULLS FIRST,           
    score DESC NULLS LAST)         
PROPERTIES (
  'write-format'='ORC'
); 

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • 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
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • 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?

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 79.29% (1792/2260)
Line Coverage 64.74% (31827/49158)
Region Coverage 65.42% (15883/24280)
Branch Coverage 55.94% (8435/15078)

@doris-robot

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

------ Round 1 ----------------------------------
q1	17607	4602	4313	4313
q2	2036	383	227	227
q3	10114	1287	722	722
q4	10205	834	326	326
q5	7848	2214	1913	1913
q6	203	180	145	145
q7	864	726	592	592
q8	9278	1406	1133	1133
q9	5442	4918	4842	4842
q10	6864	1966	1563	1563
q11	529	324	282	282
q12	391	382	219	219
q13	17822	4080	3212	3212
q14	238	232	221	221
q15	910	814	810	810
q16	697	665	609	609
q17	678	881	450	450
q18	7363	6694	6530	6530
q19	1344	991	614	614
q20	393	358	251	251
q21	2733	2034	1907	1907
q22	355	319	268	268
Total cold run time: 103914 ms
Total hot run time: 31149 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4448	4298	4373	4298
q2	267	340	249	249
q3	2141	2568	2221	2221
q4	1386	1737	1287	1287
q5	4306	4218	4230	4218
q6	219	183	137	137
q7	1852	1752	2074	1752
q8	2666	2593	2430	2430
q9	7614	7680	7478	7478
q10	2953	3085	2626	2626
q11	567	486	490	486
q12	665	738	600	600
q13	3920	4609	3952	3952
q14	287	314	279	279
q15	883	811	823	811
q16	675	729	678	678
q17	1164	1409	1404	1404
q18	8263	7692	7725	7692
q19	885	896	999	896
q20	2159	2195	2052	2052
q21	4833	4511	4120	4120
q22	590	574	493	493
Total cold run time: 52743 ms
Total hot run time: 50159 ms

@doris-robot

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

query1	0.06	0.05	0.04
query2	0.13	0.07	0.07
query3	0.30	0.08	0.08
query4	1.61	0.10	0.09
query5	0.26	0.25	0.24
query6	1.14	0.65	0.65
query7	0.03	0.02	0.02
query8	0.07	0.06	0.06
query9	0.59	0.52	0.51
query10	0.56	0.56	0.55
query11	0.26	0.13	0.13
query12	0.26	0.16	0.15
query13	0.63	0.61	0.60
query14	0.98	0.97	0.98
query15	0.92	0.82	0.83
query16	0.40	0.42	0.39
query17	1.06	1.00	1.06
query18	0.25	0.23	0.22
query19	1.95	1.86	1.84
query20	0.02	0.01	0.02
query21	15.38	0.32	0.29
query22	4.92	0.13	0.11
query23	15.35	0.44	0.28
query24	2.24	0.57	0.38
query25	0.12	0.12	0.10
query26	0.18	0.19	0.17
query27	0.10	0.11	0.11
query28	3.54	1.14	0.98
query29	12.53	4.10	3.27
query30	0.32	0.13	0.11
query31	2.79	0.69	0.44
query32	3.23	0.63	0.51
query33	2.95	3.06	3.02
query34	16.68	5.05	4.48
query35	4.46	4.42	4.52
query36	0.59	0.49	0.49
query37	0.30	0.09	0.09
query38	0.26	0.06	0.06
query39	0.08	0.05	0.05
query40	0.20	0.18	0.17
query41	0.13	0.07	0.07
query42	0.08	0.06	0.05
query43	0.07	0.06	0.06
Total cold run time: 97.98 s
Total hot run time: 28.15 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/684) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.48% (19372/36910)
Line Coverage 35.99% (179940/499942)
Region Coverage 32.34% (139452/431182)
Branch Coverage 33.33% (60401/181200)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 40.41% (276/683) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.24% (26491/36172)
Line Coverage 56.43% (281425/498753)
Region Coverage 54.30% (236513/435599)
Branch Coverage 55.77% (101465/181932)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/46) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 40.41% (276/683) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.21% (26482/36172)
Line Coverage 56.40% (281288/498753)
Region Coverage 54.29% (236469/435599)
Branch Coverage 55.75% (101422/181932)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/46) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 40.41% (276/683) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.24% (26491/36172)
Line Coverage 56.43% (281430/498753)
Region Coverage 54.31% (236553/435599)
Branch Coverage 55.77% (101467/181932)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/46) 🎉
Increment coverage report
Complete coverage report

Copilot AI 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.

Pull request overview

This PR adds support for writing Iceberg tables with sort-order, allowing data to be sorted during writes and adding lower/upper bounds statistics to enable query-time data file pruning.

Changes:

  • Added column statistics collection (column sizes, value counts, null counts, lower/upper bounds) for both Parquet and ORC formats
  • Introduced VIcebergSortWriter that sorts data in-memory before writing to files, with spilling support when memory limits are exceeded
  • Extended Iceberg table sink to support sort-info from table properties and use the sort writer when sort order is configured
  • Added SpillIcebergTableSinkOperator to support spillable sorting operations in the pipeline execution model

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
gensrc/thrift/DataSinks.thrift Added TIcebergColumnStats structure and integrated it into TIcebergCommitData; added sort_info to TIcebergTableSink
fe/fe-core/src/main/java/org/apache/doris/planner/IcebergTableSink.java Modified to convert Iceberg table sort order to SortInfo and pass output expressions for sorting
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java Added logic to set output expressions on IcebergTableSink for sort writer
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/helper/IcebergWriterHelper.java Enhanced to build Metrics from column statistics and pass to DataFile builder
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergTransaction.java Updated to use new convertToWriterResult signature with Table parameter
be/src/vec/sink/writer/iceberg/vpartition_writer_base.h New base interface for partition writers to support polymorphism
be/src/vec/sink/writer/iceberg/viceberg_table_writer.h Modified to use IPartitionWriterBase interface and track current writer
be/src/vec/sink/writer/iceberg/viceberg_table_writer.cpp Updated to create VIcebergSortWriter when sort_info is present
be/src/vec/sink/writer/iceberg/viceberg_sort_writer.h New writer that sorts data and writes to files with spilling support
be/src/vec/sink/writer/iceberg/viceberg_partition_writer.h Modified to implement IPartitionWriterBase interface
be/src/vec/sink/writer/iceberg/viceberg_partition_writer.cpp Added statistics collection after closing file writers
be/src/vec/runtime/vparquet_transformer.h Added collect_file_statistics_after_close method
be/src/vec/runtime/vparquet_transformer.cpp Implemented statistics collection by reading Parquet file metadata
be/src/vec/runtime/vorc_transformer.h Added collect_file_statistics_after_close method and helper methods
be/src/vec/runtime/vorc_transformer.cpp Implemented statistics collection by reading ORC file metadata
be/src/vec/exec/format/table/parquet_utils.h Added merge_stats function declaration
be/src/vec/exec/format/table/parquet_utils.cpp Implemented merge_stats to merge Parquet statistics across row groups
be/src/vec/common/sort/sorter.h Exposed merge_sort_state and _do_sort methods for external use
be/src/pipeline/pipeline_fragment_context.cpp Added logic to create SpillIcebergTableSinkOperator when sort_info is present
be/src/pipeline/exec/spill_iceberg_table_sink_operator.h New operator for spillable Iceberg table sink operations
be/src/pipeline/exec/spill_iceberg_table_sink_operator.cpp Implemented spillable sink operator with memory revocation support
be/src/pipeline/exec/operator.cpp Registered new SpillIcebergTableSinkLocalState operator
be/src/pipeline/exec/iceberg_table_sink_operator.cpp Updated init_properties call with new signature
regression-test/suites/external_table_p0/iceberg/write/test_iceberg_write_stats2.groovy Added comprehensive test for statistics collection in Parquet and ORC
regression-test/data/external_table_p0/iceberg/write/test_iceberg_write_stats2.out Test expected output
docker/thirdparties/docker-compose/iceberg/scripts/create_preinstalled_scripts/iceberg/run26.sql Setup script for test tables with sort order

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread be/src/vec/sink/writer/iceberg/viceberg_sort_writer.h
Comment thread be/src/vec/runtime/vorc_transformer.cpp
Comment thread be/src/vec/sink/writer/iceberg/viceberg_sort_writer.h
Comment thread be/src/vec/sink/writer/iceberg/viceberg_table_writer.h
Comment thread be/src/vec/sink/writer/iceberg/viceberg_sort_writer.h
Comment thread be/src/vec/sink/writer/iceberg/viceberg_partition_writer.cpp Outdated
Comment thread be/src/vec/common/sort/sorter.h Outdated
@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 79.35% (1795/2262)
Line Coverage 64.86% (31956/49269)
Region Coverage 65.55% (15944/24323)
Branch Coverage 56.05% (8472/15114)

@doris-robot

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

------ Round 1 ----------------------------------
q1	17614	4445	4306	4306
q2	2015	351	255	255
q3	10163	1328	789	789
q4	10198	786	308	308
q5	7536	2239	1940	1940
q6	243	179	145	145
q7	930	712	612	612
q8	9275	1419	1073	1073
q9	4992	4605	4622	4605
q10	6863	1974	1577	1577
q11	469	257	243	243
q12	400	382	223	223
q13	17834	4081	3294	3294
q14	224	233	230	230
q15	873	803	808	803
q16	698	710	626	626
q17	774	821	507	507
q18	7177	5818	6310	5818
q19	1548	1019	654	654
q20	545	538	414	414
q21	2716	1963	1917	1917
q22	339	308	245	245
Total cold run time: 103426 ms
Total hot run time: 30584 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4703	4617	4510	4510
q2	260	333	258	258
q3	2381	2990	2314	2314
q4	1506	1822	1456	1456
q5	4569	4680	4668	4668
q6	218	177	136	136
q7	2020	1919	1712	1712
q8	2612	2526	2466	2466
q9	7675	7686	7528	7528
q10	2864	3093	2590	2590
q11	502	430	417	417
q12	655	759	604	604
q13	3837	4431	3604	3604
q14	266	287	257	257
q15	817	771	779	771
q16	631	674	649	649
q17	1095	1289	1280	1280
q18	7549	7354	7128	7128
q19	865	830	860	830
q20	1954	2023	1852	1852
q21	4535	4230	4098	4098
q22	538	469	400	400
Total cold run time: 52052 ms
Total hot run time: 49528 ms

@doris-robot

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

query1	0.05	0.05	0.05
query2	0.10	0.04	0.05
query3	0.26	0.08	0.09
query4	1.61	0.11	0.11
query5	0.27	0.24	0.25
query6	1.17	0.67	0.67
query7	0.03	0.03	0.02
query8	0.05	0.04	0.04
query9	0.54	0.49	0.49
query10	0.53	0.54	0.54
query11	0.14	0.09	0.10
query12	0.14	0.11	0.10
query13	0.63	0.61	0.62
query14	1.06	1.07	1.06
query15	0.88	0.86	0.88
query16	0.40	0.40	0.40
query17	1.18	1.13	1.15
query18	0.23	0.22	0.25
query19	2.00	2.05	2.06
query20	0.02	0.02	0.01
query21	15.41	0.28	0.16
query22	5.24	0.06	0.05
query23	15.99	0.27	0.10
query24	1.50	0.37	0.18
query25	0.09	0.06	0.09
query26	0.15	0.13	0.13
query27	0.07	0.07	0.05
query28	3.26	1.14	0.96
query29	12.56	3.83	3.15
query30	0.28	0.13	0.13
query31	2.82	0.63	0.42
query32	3.23	0.60	0.49
query33	3.22	3.21	3.31
query34	16.52	5.35	4.70
query35	4.83	5.38	5.34
query36	0.66	0.55	0.55
query37	0.11	0.07	0.07
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.20	0.19	0.16
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 97.71 s
Total hot run time: 28.88 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 28.66% (45/157) 🎉
Increment coverage report
Complete coverage report

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 0.29% (2/698) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.63% (19450/36953)
Line Coverage 36.14% (181091/501031)
Region Coverage 32.52% (140629/432468)
Branch Coverage 33.55% (60950/181653)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.29% (2/697) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.38% (20774/36206)
Line Coverage 40.36% (201682/499766)
Region Coverage 37.22% (162587/436835)
Branch Coverage 37.88% (69065/182349)

1 similar comment
@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.29% (2/697) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 57.38% (20774/36206)
Line Coverage 40.36% (201682/499766)
Region Coverage 37.22% (162587/436835)
Branch Coverage 37.88% (69065/182349)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 26.75% (42/157) 🎉
Increment coverage report
Complete coverage report

@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Feb 14, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 32.61% (15/46) 🎉
Increment coverage report
Complete coverage report

@doris-robot

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

------ Round 1 ----------------------------------
============================================
q1	17641	4509	4304	4304
q2	q3	10724	797	527	527
q4	4722	375	254	254
q5	8146	1224	1038	1038
q6	244	172	145	145
q7	819	854	678	678
q8	10864	1509	1354	1354
q9	6609	4787	4750	4750
q10	6881	1872	1642	1642
q11	465	259	236	236
q12	744	570	476	476
q13	17779	4383	3413	3413
q14	229	225	213	213
q15	944	799	790	790
q16	756	737	665	665
q17	700	876	421	421
q18	5971	5562	5166	5166
q19	1218	975	697	697
q20	631	566	431	431
q21	4461	1895	1506	1506
q22	392	306	263	263
Total cold run time: 100940 ms
Total hot run time: 28969 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4731	4491	4495	4491
q2	q3	1803	2225	1767	1767
q4	849	1217	789	789
q5	4126	4550	4371	4371
q6	189	170	141	141
q7	1782	1661	1556	1556
q8	2483	2732	2626	2626
q9	7564	7531	7277	7277
q10	2624	2823	2576	2576
q11	511	424	408	408
q12	498	593	444	444
q13	3965	4399	3587	3587
q14	293	306	288	288
q15	840	818	801	801
q16	719	790	784	784
q17	1201	1570	1305	1305
q18	7047	6750	6529	6529
q19	908	847	859	847
q20	2282	2155	2008	2008
q21	4020	3587	3324	3324
q22	488	449	420	420
Total cold run time: 48923 ms
Total hot run time: 46339 ms

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

Copy link
Copy Markdown

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 79.33% (1796/2264)
Line Coverage 64.83% (32007/49372)
Region Coverage 65.55% (15980/24378)
Branch Coverage 56.00% (8492/15164)

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 0.29% (2/698) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.60% (19523/37117)
Line Coverage 36.18% (182023/503107)
Region Coverage 32.51% (141169/434230)
Branch Coverage 33.55% (61212/182443)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.43% (3/697) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.64% (26056/36369)
Line Coverage 54.36% (272834/501857)
Region Coverage 51.70% (226749/438606)
Branch Coverage 53.23% (97480/183147)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 69.57% (32/46) 🎉
Increment coverage report
Complete coverage report

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Feb 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@morningman

Copy link
Copy Markdown
Contributor

run check_coverage

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.43% (3/697) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.64% (26056/36369)
Line Coverage 54.36% (272834/501857)
Region Coverage 51.70% (226749/438606)
Branch Coverage 53.23% (97480/183147)

@dataroaring dataroaring 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.

LGTM

@morningman
morningman merged commit a396f34 into apache:master Feb 22, 2026
31 of 34 checks passed
morningman added a commit to morningman/doris that referenced this pull request Mar 3, 2026
Based on PR apache#60540 review suggestions:

6.1: Encapsulate _current_writer in VIcebergTableWriter
  - Move _current_writer from public to private
  - Add const getter method current_writer()
  - Update SpillIcebergTableSinkLocalState to use getter

6.2: Split VIcebergSortWriter header-only into .h + .cpp
  - Move all method implementations to viceberg_sort_writer.cpp
  - Replace heavy includes (spill_stream.h, spill_stream_manager.h) with
    forward declarations in header to reduce compilation dependencies
  - Add comprehensive documentation comments to all methods and members

6.4: Fix error handling in VIcebergSortWriter::close()
  - Track internal_status for intermediate operations
  - Pass actual error status to underlying partition writer's close()
    instead of the original caller status (which could be OK)

6.5: Add explicit do_sort() in _do_spill()
  - Call _sorter->do_sort() before prepare_for_read() for clarity
  - Add detailed comments explaining the relationship with
    FullSorter::prepare_for_read() internal sorting

6.6: Fix typo 'SpillReadDerializeBlockTime' -> 'SpillReadDeserializeBlockTime'
  - Fix counter name string in spill_iceberg_table_sink_operator.cpp
  - Fix counter name string in operator.h (PipelineXSpillLocalState)
  - Fix counter lookup string in spill_reader.h
  - Fix member variable name _spill_read_derialize_block_timer
morningman added a commit that referenced this pull request Mar 6, 2026
### What problem does this PR solve?

Based on PR #60540 review suggestions:

1: Encapsulate _current_writer in VIcebergTableWriter
  - Move _current_writer from public to private
  - Add const getter method current_writer()
  - Update SpillIcebergTableSinkLocalState to use getter

2: Split VIcebergSortWriter header-only into .h + .cpp
  - Move all method implementations to viceberg_sort_writer.cpp
- Replace heavy includes (spill_stream.h, spill_stream_manager.h) with
forward declarations in header to reduce compilation dependencies
  - Add comprehensive documentation comments to all methods and members

4: Fix error handling in VIcebergSortWriter::close()
  - Track internal_status for intermediate operations
- Pass actual error status to underlying partition writer's close()
instead of the original caller status (which could be OK)

5: Add explicit do_sort() in _do_spill()
  - Call _sorter->do_sort() before prepare_for_read() for clarity
- Add detailed comments explaining the relationship with
FullSorter::prepare_for_read() internal sorting

6: Fix typo 'SpillReadDerializeBlockTime' ->
'SpillReadDeserializeBlockTime'
  - Fix counter name string in spill_iceberg_table_sink_operator.cpp
  - Fix counter name string in operator.h (PipelineXSpillLocalState)
  - Fix counter lookup string in spill_reader.h
  - Fix member variable name _spill_read_derialize_block_timer
zhangstar333 added a commit to zhangstar333/incubator-doris that referenced this pull request Mar 17, 2026
…pache#60540)

Problem Summary:

support write iceberg table with sort-order, the write data have been
local sorted, and have add lower/upper_bounds metadata. so the iceberg
plan could use it to prune datafile.
**Notes**: this is only a local sort, not global sort. so if you are
more parallel about iceberg writer, you many see overlapping of
lower/upper_bounds between files.
if you need a global sort, maybe could add order by cluster in the
insert SQL.

you could create table, and then alter table eg:
```
CREATE TABLE test_table2 (
    id INT,
    name STRING,
    score DOUBLE,
    create_time datetime
)
ORDER BY (
    id ASC NULLS FIRST,
    score DESC NULLS LAST)
PROPERTIES (
  'write-format'='ORC'
);
```
morningman pushed a commit that referenced this pull request Mar 17, 2026
… sort-order (#60540) (#61414)

Problem Summary:
cherry-pick from master (#60540)
morningman added a commit to morningman/doris that referenced this pull request Mar 18, 2026
…e#60978)

### What problem does this PR solve?

Based on PR apache#60540 review suggestions:

1: Encapsulate _current_writer in VIcebergTableWriter
  - Move _current_writer from public to private
  - Add const getter method current_writer()
  - Update SpillIcebergTableSinkLocalState to use getter

2: Split VIcebergSortWriter header-only into .h + .cpp
  - Move all method implementations to viceberg_sort_writer.cpp
- Replace heavy includes (spill_stream.h, spill_stream_manager.h) with
forward declarations in header to reduce compilation dependencies
  - Add comprehensive documentation comments to all methods and members

4: Fix error handling in VIcebergSortWriter::close()
  - Track internal_status for intermediate operations
- Pass actual error status to underlying partition writer's close()
instead of the original caller status (which could be OK)

5: Add explicit do_sort() in _do_spill()
  - Call _sorter->do_sort() before prepare_for_read() for clarity
- Add detailed comments explaining the relationship with
FullSorter::prepare_for_read() internal sorting

6: Fix typo 'SpillReadDerializeBlockTime' ->
'SpillReadDeserializeBlockTime'
  - Fix counter name string in spill_iceberg_table_sink_operator.cpp
  - Fix counter name string in operator.h (PipelineXSpillLocalState)
  - Fix counter lookup string in spill_reader.h
  - Fix member variable name _spill_read_derialize_block_timer
zhangstar333 added a commit to zhangstar333/incubator-doris that referenced this pull request Apr 10, 2026
…pache#60540)

Problem Summary:

support write iceberg table with sort-order, the write data have been
local sorted, and have add lower/upper_bounds metadata. so the iceberg
plan could use it to prune datafile.
**Notes**: this is only a local sort, not global sort. so if you are
more parallel about iceberg writer, you many see overlapping of
lower/upper_bounds between files.
if you need a global sort, maybe could add order by cluster in the
insert SQL.

you could create table, and then alter table eg:
```
CREATE TABLE test_table2 (
    id INT,
    name STRING,
    score DOUBLE,
    create_time datetime
)
ORDER BY (
    id ASC NULLS FIRST,
    score DESC NULLS LAST)
PROPERTIES (
  'write-format'='ORC'
);
```
@morningman morningman mentioned this pull request Jul 3, 2026
76 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.1.0-merged kind/need-document-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants