ForeverAngry opened a new pull request, #2459:
URL: https://github.com/apache/iceberg-python/pull/2459
<!--
Thanks for opening a pull request!
-->
<!-- In the case this PR will resolve an issue, please replace
${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
<!-- Closes #${GITHUB_ISSUE_ID} -->
# Rationale for this change
Hey there! ๐ This PR introduces **native Vortex file format support** to
PyIceberg, making it the **first major data processing library** to support
this next-generation columnar format alongside Parquet! This has been a big
learning opportunity for me, to dive deeper into pyiceberg, as well as file
formats. I hope folks find this interesting!
## What is Vortex?
[Vortex](https://docs.vortex.dev/) is a cutting-edge columnar file format
designed for high-performance analytics, offering:
- **๐๏ธ 100x faster random access** reads vs. Parquet
- **โก 2.5x faster analytical queries** in our benchmarks
- **๐๏ธ Similar compression ratios** to Parquet
- **๐ Advanced filtering capabilities** with predicate pushdown
## What's Added
โ
**Complete Integration** - Native `.vortex` file support throughout
PyIceberg
โ
**Full Feature Parity** - All operations work identically to Parquet files
โ
**Production Ready** - Comprehensive error handling and optimization
โ
**Advanced Filtering** - Complete PyArrow-based filtering with predicate
pushdown
โ
**Streaming Support** - Optimized RecordBatchReader for large datasets
โ
**Schema Compatibility** - Seamless conversion between Iceberg and Vortex
schemas
### Key Implementation Features
- **Smart Batch Optimization**: Adaptive batch sizing based on dataset
characteristics
- **Multi-path Read Strategy**: Direct URL reading, direct file opening, and
fallback temp file copy
- **Memory Optimization**: Custom allocator optimizations for Vortex
performance
- **Streaming Architecture**: Uses official Vortex RecordBatchReader API for
large datasets
- **Comprehensive Caching**: File handle caching for repeated reads
## Performance Results ๐
Based on our extensive benchmark suite
([`tests/benchmark/README.md`](tests/benchmark/README.md)):
| Metric | Vortex Performance | vs Parquet |
|--------|-------------------|------------|
| **Write Speed** | ~1.07M rows/sec | Similar |
| **Read Speed** | ~66M rows/sec | **2.5x faster** |
| **Compression** | Similar ratios | Comparable |
| **Filtered Queries** | Superior performance | **1.2x - 2.4x faster** |
### Benchmark Commands
```bash
# Quick performance check
python tests/benchmark/vortex_benchmark.py --quick
# Full comprehensive benchmark
python tests/benchmark/vortex_benchmark.py --full
# Large scale test (15M+ rows)
python tests/benchmark/vortex_benchmark.py --large
```
## Implementation Details
### Core Files Added/Modified
- **vortex.py** - Complete Vortex I/O implementation
- **pyarrow.py** - Integration with PyArrow write pipeline
- **test_vortex.py** - Comprehensive test suite
- **benchmark** - Performance benchmarking suite
- **test_add_vortex_files.py** - Integration tests
### Architecture Highlights
```python
# Example usage - works just like Parquet!
table.add_files(["data.vortex"]) # Add Vortex files
table.scan().to_arrow() # Read with filtering/projection
```
The implementation follows official [Vortex API
documentation](https://docs.vortex.dev/api/python/io) patterns and includes
optimizations inspired by their RepeatedScan and Dataset APIs.
## Are these changes tested?
Absolutely! ๐งช This includes one of the most comprehensive file format test
suites:
- **โ
20+ unit tests** covering all read/write operations
- **โ
Integration tests** with real Iceberg tables
- **โ
Performance benchmark suite** with automated instrumentation
- **โ
Error handling tests** for edge cases and fallbacks
- **โ
Schema compatibility tests** for complex nested types
- **โ
Filtering and projection tests** with PyArrow expressions
### Test Coverage
```bash
# Run Vortex-specific tests
pytest tests/io/test_vortex.py -v
pytest tests/integration/test_add_vortex_files.py -v
# Run benchmarks
python tests/benchmark/vortex_benchmark.py --quick
```
## Are there any user-facing changes?
Yes, but they're all **additive**! ๐
### New Features for Users
1. **Native Vortex File Support**: Users can now use `.vortex` files
anywhere they use `.parquet`
2. **Performance Benefits**: Faster analytical queries, especially with
filtering
3. **New Installation Option**: `pip install 'pyiceberg[vortex]'`
### Backwards Compatibility
- **โ
Zero breaking changes** - all existing Parquet workflows unchanged
- **โ
Optional dependency** - Vortex support only active when `vortex-data`
installed
- **โ
Graceful fallbacks** - informative errors when Vortex unavailable
### Usage Examples
```python
# Works exactly like Parquet files!
from pyiceberg.catalog import load_catalog
catalog = load_catalog("my_catalog")
table = catalog.load_table("my_namespace.my_table")
# Add Vortex files (new!)
table.add_files(["s3://bucket/data.vortex"])
# All existing operations work
df = table.scan().to_pandas() # Full scan
df = table.scan().filter(...).to_pandas() # Filtered scan
df = table.scan().select("col1", "col2").to_pandas() # Projected scan
```
This makes PyIceberg the first major lakehouse library to offer users a
choice between Parquet and Vortex formats based on their performance needs! ๐
<!-- In the case of user-facing changes, please add the changelog label. -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]