Gabriel 7fda449b7a [fix](arrow) Correct year-zero DATE conversion on branch-4.1 (#68649)
### What problem does this PR solve?

Related issue: #67366
Related PR: #67449

On branch-4.1, Arrow Flight SQL returns `0000-01-02` for a stored DATE
of `0000-01-01`. Doris follows the MySQL calendar, which excludes year
zero's leap day, while Arrow DATE uses the proleptic Gregorian calendar.
Subtracting the Unix epoch day number directly shifts dates in
`0000-01-01` through `0000-02-28` by one day, including elements of
`ARRAY<DATE>`.

Adapt the DATE portion of #67449 to branch-4.1, with credit to its
author. Convert between the calendars at Arrow and ORC write boundaries
and Arrow/default Parquet/ORC read boundaries. Use the same conversion
for ORC statistics so pushed-down MIN/MAX agrees with row decoding.
Reject unrepresentable external dates and ignore undefined payloads in
null Arrow slots.

The two DATE regression suites and their expected results are copied
unchanged from #67449. Add its DATE unit coverage plus an explicit
null-payload test and an exhaustive comparison against the civil
calendar for all 3,652,424 representable dates.

Also align Iceberg DATE day/bucket partition transforms with file
ordinals. For ORC/Parquet, metadata is usable only when its raw DATE
range proves that every ordinal is representable, including the interior
of the range. Unsafe ranges fall back to decoding: strict reads retain
their errors, non-strict Parquet reads retain conversion-generated
NULLs, and COUNT uses materialized values when physical null counts are
insufficient. ORC uses a metadata-only SARG to check projected DATE
leaves per stripe: safe excluded stripes retain SARG pruning, while
unsafe stripes remain readable with SDK row-group pruning disabled. ORC
COUNT validates every DATE leaf of its argument in each selected stripe,
and strict Parquet COUNT validates projected DATE descendants before
reading only levels.

Scope: DATE, including its Iceberg partition transforms. This does not
include DATETIME changes or the independent legacy file scanner
conversions used when `enable_file_scanner_v2=false`. V1 reader changes
and mixed-version/rolling-upgrade compatibility gates are explicitly
outside this PR's scope.

### Validation

- Baseline: 9 of the original 10 DATE unit tests fail; the unchanged
Flight regression reproduces the one-day shift.
- Fixed: 250 unit tests pass under ASAN, including the complete ORC
reader suite, DATE SerDe exhaustive calendar check, Iceberg partition
transforms, Parquet statistics, DATE scans and COUNT tests. These
compile the modified branch-4.1 sources against cached test
dependencies.
- The unchanged `test_date_year_zero` Flight regression passes locally,
including nullable and array values.
- `test_outfile_date_year_zero` passes for Parquet and ORC using the
original rows and golden assertions, with S3 transport replaced by local
outfile/TVF only for the local run. The committed suite retains S3
transport for CI.
- Local integration runs use the same fix rebuilt into an existing
ASAN/UBSAN BE build at `5bcb996a5ff`, with an existing FE. A full
branch-4.1 build and the original S3 run remain for CI.
- clang-format 16 passes for all affected C++ files. Source whitespace
checks pass; generated golden files retain their conventional trailing
blank line from #67449.
- Review coverage: new tests reproduce partition mismatches,
invalid-interior MIN/MAX bypass, ORC SARG/Parquet footer/page pruning
inconsistencies, and Parquet IS NULL/COUNT discrepancies. All five
reproducing tests fail before the review fixes.
- Added a DATE-only Spark/Iceberg partitioned write/read regression,
including selective day/bucket predicates and partition metadata
comparison. Its Groovy compilation passes; execution requires the
external CI environment.

- Follow-up review: scalar/nested ORC COUNT and strict nested Parquet
COUNT reproductions fail before the guards and pass afterward. ARRAY,
STRUCT, MAP, all-null values, safe ranges, non-strict Parquet, and
unprojected DATE siblings are covered.
- External ORC regression: retain the original LZ4 file as a BE fixture
and verify that ordinal `-719530` raises a data-quality error. Replace
the obsolete `1900-01-01` golden result with an explicit error
assertion, restoring the scanner setting afterward. The fixture test and
Groovy compilation pass locally. The complete group6 suite is also
validated locally with HDFS transport replaced by LOCAL TVF; the
committed suite retains HDFS for CI.

- Pruning review: both new tests fail before the fixes and pass
afterward. Partial ORC STRUCT projection retains SARG when the invalid
DATE sibling is not read; selecting that DATE still preserves its error.
Multi-page Parquet tests retain the unsafe DATE page while pruning safe
pages for IS NULL and range predicates, through both single-slot and
multi-slot OR evaluators.

- Mixed-stripe ORC coverage: the original file-wide guard prunes zero
safe stripes; the fix prunes both safe excluded stripes and still
reports the invalid DATE in the retained stripe. The active SDK options
outlive their reader, and the cached SARG evaluator is discarded before
opening an unsafe range.
- External group6 coverage: the original `non_vec_orc_scanner.orc`
fixture encodes `20191111` as an invalid epoch-day ordinal. Replace its
obsolete `1900-01-01` golden result with an explicit data-quality error
assertion and keep the original bytes as a small BE fixture; projecting
other columns still succeeds.

- Final local integration after the stripe fix: all three suites pass
with no failures or skips (complete group6: 41 fixtures, 39
golden-result assertions and two expected errors; Flight year zero;
Parquet/ORC outfile year zero). These use the incremental ASAN/UBSAN
build and local transport substitutions described above.

- Metadata safety review: the malformed pruned-stripe index and
truncated nested DATE statistics reproduce SDK bounds assertions before
the fix. Both regressions pass afterward; the DATE preflight now adds no
file read calls or bytes compared with the same excluded stripe without
DATE projection.
- Historical-file migration: an explicit offline tool converts only
confirmed legacy Doris DATE ordinals, including nested values. It
publishes a separate output atomically and refuses overwrites. Tests
cover year-zero boundaries, NULLs, hidden null-container payloads,
nested ORC/Parquet round trips, schema metadata, timestamp precision,
and failed-write cleanup.

- Final follow-up validation: all 250 ASAN tests and 10 migration-tool
tests pass. The final incremental production BE passes the three
existing local suites plus six legacy migration/read/export/read checks,
covering both ORC and Parquet. Original HDFS/S3 transport and the full
branch build remain for CI as described above.

### Release note

Fix year-zero DATE values being returned one day late through Arrow
Flight SQL, align DATE encoding and decoding in the default Parquet/ORC
paths, and keep Iceberg DATE partition values consistent with file
contents.

Existing files written with the former year-zero encoding cannot be
distinguished automatically from correctly encoded files. Before
switching their consumers to the corrected reader, use the explicit
[legacy DATE migration tool and
procedure](https://github.com/apache/doris/blob/082429b00f2392f8e8eabcee6e6a5a94a403e7aa/tools/legacy_date_migration/README.md)
on files confirmed to use the old Doris encoding, or re-export from
authoritative original data. The tool writes new ORC/Parquet files
without modifying the source. Existing Iceberg files must be migrated
through a new table or a supported table-format transaction that
recomputes partition metadata; do not replace files in existing
snapshots. The proleptic-only `0000-02-29` remains unrepresentable as a
Doris DATE.

### Check List (For Author)

- Test
  - [x] Regression test
  - [x] Unit Test
- Behavior changed:
- [x] Yes, external DATE ordinals use the correct calendar; internal
DATE arithmetic is unchanged.
- Does this need documentation?
  - [x] No.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
2026-10-08 10:48:32 +08:00
…
…
…
…
…
…
…
…
…
…
…
…
…

Apache Doris

License GitHub release OSSRank Commit activity EN doc CN doc

Official Website Quick Download

     

Apache Doris is an easy-to-use, high-performance and real-time analytical database based on MPP architecture, known for its extreme speed and ease of use. It only requires a sub-second response time to return query results under massive data and can support not only high-concurrency point query scenarios but also high-throughput complex analysis scenarios.

All this makes Apache Doris an ideal tool for scenarios including report analysis, ad-hoc query, unified data warehouse, and data lake query acceleration. On Apache Doris, users can build various applications, such as user behavior analysis, AB test platform, log retrieval analysis, user portrait analysis, and order analysis.

🎉 Check out the 🔗All releases, where you'll find a chronological summary of Apache Doris versions released over the past year.

👀 Explore the 🔗Official Website to discover Apache Doris's core features, blogs, and user cases in detail.

📈 Usage Scenarios

As shown in the figure below, after various data integration and processing, the data sources are usually stored in the real-time data warehouse Apache Doris and the offline data lake or data warehouse (in Apache Hive, Apache Iceberg or Apache Hudi).



Apache Doris is widely used in the following scenarios:

  • Real-time Data Analysis:

    • Real-time Reporting and Decision-making: Doris provides real-time updated reports and dashboards for both internal and external enterprise use, supporting real-time decision-making in automated processes.

    • Ad Hoc Analysis: Doris offers multidimensional data analysis capabilities, enabling rapid business intelligence analysis and ad hoc queries to help users quickly uncover insights from complex data.

    • User Profiling and Behavior Analysis: Doris can analyze user behaviors such as participation, retention, and conversion, while also supporting scenarios like population insights and crowd selection for behavior analysis.

  • Lakehouse Analytics:

    • Lakehouse Query Acceleration: Doris accelerates lakehouse data queries with its efficient query engine.

    • Federated Analytics: Doris supports federated queries across multiple data sources, simplifying architecture and eliminating data silos.

    • Real-time Data Processing: Doris combines real-time data streams and batch data processing capabilities to meet the needs of high concurrency and low-latency complex business requirements.

  • SQL-based Observability:

    • Log and Event Analysis: Doris enables real-time or batch analysis of logs and events in distributed systems, helping to identify issues and optimize performance.

Overall Architecture

Apache Doris uses the MySQL protocol, is highly compatible with MySQL syntax, and supports standard SQL. Users can access Apache Doris through various client tools, and it seamlessly integrates with BI tools.

Storage-Compute Integrated Architecture

The storage-compute integrated architecture of Apache Doris is streamlined and easy to maintain. As shown in the figure below, it consists of only two types of processes:

  • Frontend (FE): Primarily responsible for handling user requests, query parsing and planning, metadata management, and node management tasks.

  • Backend (BE): Primarily responsible for data storage and query execution. Data is partitioned into shards and stored with multiple replicas across BE nodes.

The overall architecture of Apache Doris


In a production environment, multiple FE nodes can be deployed for disaster recovery. Each FE node maintains a full copy of the metadata. The FE nodes are divided into three roles:

Role Function
Master The FE Master node is responsible for metadata read and write operations. When metadata changes occur in the Master, they are synchronized to Follower or Observer nodes via the BDB JE protocol.
Follower The Follower node is responsible for reading metadata. If the Master node fails, a Follower node can be selected as the new Master.
Observer The Observer node is responsible for reading metadata and is mainly used to increase query concurrency. It does not participate in cluster leadership elections.

Both FE and BE processes are horizontally scalable, enabling a single cluster to support hundreds of machines and tens of petabytes of storage capacity. The FE and BE processes use a consistency protocol to ensure high availability of services and high reliability of data. The storage-compute integrated architecture is highly integrated, significantly reducing the operational complexity of distributed systems.

Core Features of Apache Doris

  • High Availability: In Apache Doris, both metadata and data are stored with multiple replicas, synchronizing data logs via the quorum protocol. Data write is considered successful once a majority of replicas have completed the write, ensuring that the cluster remains available even if a few nodes fail. Apache Doris supports both same-city and cross-region disaster recovery, enabling dual-cluster master-slave modes. When some nodes experience failures, the cluster can automatically isolate the faulty nodes, preventing the overall cluster availability from being affected.

  • High Compatibility: Apache Doris is highly compatible with the MySQL protocol and supports standard SQL syntax, covering most MySQL and Hive functions. This high compatibility allows users to seamlessly migrate and integrate existing applications and tools. Apache Doris supports the MySQL ecosystem, enabling users to connect Doris using MySQL Client tools for more convenient operations and maintenance. It also supports MySQL protocol compatibility for BI reporting tools and data transmission tools, ensuring efficiency and stability in data analysis and data transmission processes.

  • Real-Time Data Warehouse: Based on Apache Doris, a real-time data warehouse service can be built. Apache Doris offers second-level data ingestion capabilities, capturing incremental changes from upstream online transactional databases into Doris within seconds. Leveraging vectorized engines, MPP architecture, and Pipeline execution engines, Doris provides sub-second data query capabilities, thereby constructing a high-performance, low-latency real-time data warehouse platform.

  • Unified Lakehouse: Apache Doris can build a unified lakehouse architecture based on external data sources such as data lakes or relational databases. The Doris unified lakehouse solution enables seamless integration and free data flow between data lakes and data warehouses, helping users directly utilize data warehouse capabilities to solve data analysis problems in data lakes while fully leveraging data lake data management capabilities to enhance data value.

  • Flexible Modeling: Apache Doris offers various modeling approaches, such as wide table models, pre-aggregation models, star/snowflake schemas, etc. During data import, data can be flattened into wide tables and written into Doris through compute engines like Flink or Spark, or data can be directly imported into Doris, performing data modeling operations through views, materialized views, or real-time multi-table joins.

Technical overview

Doris provides an efficient SQL interface and is fully compatible with the MySQL protocol. Its query engine is based on an MPP (Massively Parallel Processing) architecture, capable of efficiently executing complex analytical queries and achieving low-latency real-time queries. Through columnar storage technology for data encoding and compression, it significantly optimizes query performance and storage compression ratio.

Interface

Apache Doris adopts the MySQL protocol, supports standard SQL, and is highly compatible with MySQL syntax. Users can access Apache Doris through various client tools and seamlessly integrate it with BI tools, including but not limited to Smartbi, DataEase, FineBI, Tableau, Power BI, and Apache Superset. Apache Doris can work as the data source for any BI tools that support the MySQL protocol.

Storage engine

Apache Doris has a columnar storage engine, which encodes, compresses, and reads data by column. This enables a very high data compression ratio and largely reduces unnecessary data scanning, thus making more efficient use of IO and CPU resources.

Apache Doris supports various index structures to minimize data scans:

  • Sorted Compound Key Index: Users can specify three columns at most to form a compound sort key. This can effectively prune data to better support highly concurrent reporting scenarios.

  • Min/Max Index: This enables effective data filtering in equivalence and range queries of numeric types.

  • BloomFilter Index: This is very effective in equivalence filtering and pruning of high-cardinality columns.

  • Inverted Index: This enables fast searching for any field.

Apache Doris supports a variety of data models and has optimized them for different scenarios:

  • Detail Model (Duplicate Key Model): A detail data model designed to meet the detailed storage requirements of fact tables.

  • Primary Key Model (Unique Key Model): Ensures unique keys; data with the same key is overwritten, enabling row-level data updates.

  • Aggregate Model (Aggregate Key Model): Merges value columns with the same key, significantly improving performance through pre-aggregation.

Apache Doris also supports strongly consistent single-table materialized views and asynchronously refreshed multi-table materialized views. Single-table materialized views are automatically refreshed and maintained by the system, requiring no manual intervention from users. Multi-table materialized views can be refreshed periodically using in-cluster scheduling or external scheduling tools, reducing the complexity of data modeling.

🔍 Query Engine

Apache Doris has an MPP-based query engine for parallel execution between and within nodes. It supports distributed shuffle join for large tables to better handle complicated queries.


Query Engine


The query engine of Apache Doris is fully vectorized, with all memory structures laid out in a columnar format. This can largely reduce virtual function calls, increase cache hit rates, and make efficient use of SIMD instructions. Apache Doris delivers a 5~10 times higher performance in wide table aggregation scenarios than non-vectorized engines.


Doris query engine


Apache Doris uses adaptive query execution technology to dynamically adjust the execution plan based on runtime statistics. For example, it can generate a runtime filter and push it to the probe side. Specifically, it pushes the filters to the lowest-level scan node on the probe side, which largely reduces the data amount to be processed and increases join performance. The runtime filter of Apache Doris supports In/Min/Max/Bloom Filter.

Apache Doris uses a Pipeline execution engine that breaks down queries into multiple sub-tasks for parallel execution, fully leveraging multi-core CPU capabilities. It simultaneously addresses the thread explosion problem by limiting the number of query threads. The Pipeline execution engine reduces data copying and sharing, optimizes sorting and aggregation operations, thereby significantly improving query efficiency and throughput.

In terms of the optimizer, Apache Doris employs a combined optimization strategy of CBO (Cost-Based Optimizer), RBO (Rule-Based Optimizer), and HBO (History-Based Optimizer). RBO supports constant folding, subquery rewriting, predicate pushdown, and more. CBO supports join reordering and other optimizations. HBO recommends the optimal execution plan based on historical query information. These multiple optimization measures ensure that Doris can enumerate high-performance query plans across various types of queries.

🎆 Why choose Apache Doris?

  • 🎯 Easy to Use: Two processes, no other dependencies; online cluster scaling, automatic replica recovery; compatible with MySQL protocol, and using standard SQL.

  • 🚀 High Performance: Extremely fast performance for low-latency and high-throughput queries with columnar storage engine, modern MPP architecture, vectorized query engine, pre-aggregated materialized view and data index.

  • 🖥️ Single Unified: A single system can support real-time data serving, interactive data analysis and offline data processing scenarios.

  • ⚛️ Federated Querying: Supports federated querying of data lakes such as Hive, Iceberg, Hudi, and databases such as MySQL and Elasticsearch.

  • ⏩ Various Data Import Methods: Supports batch import from HDFS/S3 and stream import from MySQL Binlog/Kafka; supports micro-batch writing through HTTP interface and real-time writing using Insert in JDBC.

  • 🚙 Rich Ecology: Spark uses Spark-Doris-Connector to read and write Doris; Flink-Doris-Connector enables Flink CDC to implement exactly-once data writing to Doris; DBT Doris Adapter is provided to transform data in Doris with DBT.

🙌 Contributors

Apache Doris has graduated from Apache incubator successfully and become a Top-Level Project in June 2022.

We deeply appreciate 🔗community contributors for their contribution to Apache Doris.

contrib graph

👨‍👩‍👧‍👦 Users

Apache Doris now has a wide user base in China and around the world, and as of today, Apache Doris is used in production environments in thousands of companies worldwide. More than 80% of the top 50 Internet companies in China in terms of market capitalization or valuation have been using Apache Doris for a long time, including Baidu, Meituan, Xiaomi, Jingdong, Bytedance, Tencent, NetEase, Kwai, Sina, 360, Mihoyo, and Ke Holdings. It is also widely used in some traditional industries such as finance, energy, manufacturing, and telecommunications.

The users of Apache Doris: 🔗Users

Add your company logo at Apache Doris Website: 🔗Add Your Company

👣 Get Started

📚 Docs

All Documentation 🔗Docs

⬇️ Download

All release and binary version 🔗Download

🗄️ Compile

See how to compile 🔗Compilation)

📮 Install

See how to install and deploy 🔗Installation and deployment

🧩 Components

📝 Doris Connector

Doris provides support for Spark/Flink to read data stored in Doris through Connector, and also supports to write data to Doris through Connector.

🔗apache/doris-flink-connector

🔗apache/doris-spark-connector

🌈 Community and Support

📤 Subscribe Mailing Lists

Mail List is the most recognized form of communication in Apache community. See how to 🔗Subscribe Mailing Lists

🙋 Report Issues or Submit Pull Request

If you meet any questions, feel free to file a 🔗GitHub Issue or post it in 🔗GitHub Discussion and fix it by submitting a 🔗Pull Request

🍻 How to Contribute

We welcome your suggestions, comments (including criticisms), comments and contributions. See 🔗How to Contribute and 🔗Code Submission Guide

⌨️ Doris Improvement Proposals (DSIP)

🔗Doris Improvement Proposal (DSIP) can be thought of as A Collection of Design Documents for all Major Feature Updates or Improvements.

🔑 Backend C++ Coding Specification

🔗 Backend C++ Coding Specification should be strictly followed, which will help us achieve better code quality.

💬 Contact Us

Contact us through the following mailing list.

Name Scope
dev@doris.apache.org Development-related discussions Subscribe Unsubscribe Archives

📜 License

Apache License, Version 2.0

Note

Some licenses of the third-party dependencies are not compatible with Apache 2.0 License. So you need to disable some Doris features to be complied with Apache 2.0 License. For details, refer to the thirdparty/LICENSE.txt

Languages
Java 43.5%
C++ 39%
Csound 12.3%
Python 3.2%
Shell 0.8%
Other 0.9%