Skip to content

feat(stage): support ORC unload#20123

Merged
youngsofun merged 3 commits into
databendlabs:mainfrom
youngsofun:codex/support-orc-avro-output-format
Jul 13, 2026
Merged

feat(stage): support ORC unload#20123
youngsofun merged 3 commits into
databendlabs:mainfrom
youngsofun:codex/support-orc-avro-output-format

Conversation

@youngsofun

@youngsofun youngsofun commented Jul 8, 2026

Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Add ORC support for COPY INTO unload.

This is needed so users can write stage output as ORC in addition to existing columnar formats. The implementation reuses the shared columnar unload processor logic for Arrow, Parquet, and ORC, while keeping ORC-specific encoding and type validation local to the stage storage crate.

The ORC writer currently follows the supported write path of orc-rust::ArrowWriter, not the full ORC specification type matrix. Unsupported Databend types return a user-facing Unimplemented error before Arrow schema conversion. String and binary view arrays are converted to ORC-writer-compatible Arrow arrays before writing.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Validated with:

  • cargo fmt --check
  • cargo check -p databend-common-storages-stage
  • env PYTHONPYCACHEPREFIX=/private/tmp/databend_pycache python3 -m py_compile tests/nox/suites/copy/test_orc.py tests/nox/suites/copy/test_metadata.py tests/nox/suites/copy/test_avro.py

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions Bot added the pr-feature this PR introduces a new feature to the codebase label Jul 8, 2026
@youngsofun youngsofun force-pushed the codex/support-orc-avro-output-format branch from 6199da0 to 21fb58b Compare July 8, 2026 09:58
@youngsofun youngsofun requested a review from sundy-li July 8, 2026 12:23
@sundy-li sundy-li requested a review from Copilot July 10, 2026 01:56

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

Adds ORC support for COPY INTO unload in the stage storage subsystem, reusing a shared “columnar unload” writer flow alongside existing Arrow/Parquet handling while keeping ORC-specific schema/type validation and Arrow-compat conversions local to the stage crate.

Changes:

  • Add ORC unload pipeline + writer processor built on orc-rust::ArrowWriter, including Databend-type validation and Arrow view-array compatibility conversions.
  • Refactor Arrow + Parquet unload writers to share a new generic ColumnarFileWriter / ColumnarFileEncoder abstraction.
  • Add logic tests for ORC unload roundtrip, max_file_size behavior, and unsupported-type reporting; expand metadata-format coverage.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/nox/suites/copy/test_orc.py Adds ORC unload logic tests (roundtrip, max_file_size, unsupported type error).
tests/nox/suites/copy/test_metadata.py Includes ORC/Avro in metadata-column validation matrix; adjusts column reference logic and query types.
src/query/storages/stage/src/append/stage_sink_table.rs Routes ORC format to a new ORC append pipeline during unload.
src/query/storages/stage/src/append/parquet_file/writer_processor.rs Refactors Parquet unload writer to use the shared columnar writer abstraction.
src/query/storages/stage/src/append/orc_file/writer_processor.rs Implements ORC encoder/writer processor, including schema validation and Arrow compatibility conversions.
src/query/storages/stage/src/append/orc_file/pipeline.rs Adds ORC unload pipeline wiring with file-size limiting integration.
src/query/storages/stage/src/append/orc_file/mod.rs Introduces the ORC append module and exports the pipeline entrypoint.
src/query/storages/stage/src/append/mod.rs Registers the new ORC module and re-exports its append function.
src/query/storages/stage/src/append/column_based/mod.rs Exposes the new shared columnar file-writer module.
src/query/storages/stage/src/append/column_based/file_writer.rs Introduces shared ColumnarFileWriter processor + ColumnarFileEncoder trait for columnar unload formats.
src/query/storages/stage/src/append/arrow_file/writer_processor.rs Refactors Arrow IPC unload writer to use the shared columnar writer abstraction.
src/query/storages/stage/Cargo.toml Adds orc-rust dependency to the stage storage crate.
src/query/formats/src/file_format_type.rs Treats ORC like Parquet for stage format MIME typing (application/octet-stream).
Cargo.lock Locks the new orc-rust dependency.

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

Comment thread tests/nox/suites/copy/test_orc.py
Comment thread src/query/storages/stage/src/append/orc_file/pipeline.rs
@youngsofun youngsofun force-pushed the codex/support-orc-avro-output-format branch from 21fb58b to 2d83561 Compare July 10, 2026 07:35
@youngsofun

Copy link
Copy Markdown
Member Author

Error: [LicenseManager] Feature 'private_task' requires Databend Enterprise Edition license. License key expired for tenant: test_tenant. Learn more at https://docs.databend.com/guides/products/dee/

cc @sundy-li @everpcpc

@youngsofun youngsofun enabled auto-merge July 13, 2026 01:52
@youngsofun youngsofun added this pull request to the merge queue Jul 13, 2026
Merged via the queue into databendlabs:main with commit 22a7627 Jul 13, 2026
176 of 178 checks passed
@youngsofun youngsofun deleted the codex/support-orc-avro-output-format branch July 13, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants