dsq-core
Core library for dsq data processing.
dsq-core provides the fundamental data processing capabilities for dsq, extending jq-compatible syntax to work with structured data formats like Parquet, Avro, CSV, and more. It leverages Polars DataFrames for high-performance data manipulation.
Key Components
Value Type System
The core Value enum bridges between JSON-like values and Polars DataFrames:
use Value;
// JSON-like values
let json_val = object;
// DataFrame values
let df_val = dataframe;
Operations Framework
Comprehensive data operations library:
use ;
// Select columns
let selected = select_columns?;
// Sort data
let sorted = sort_by_columns?;
// Take first N rows
let result = head?;
I/O Support
Input/output for multiple file formats:
use io;
// Read CSV file
let data = read_file?;
// Write to Parquet
write_file?;
Filter System
jq-compatible filter compilation and execution:
use ;
// Execute jq-style filter
let mut executor = with_config;
let result = executor.execute_str?;
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Or for the latest development version:
[]
= { = "https://github.com/durableprogramming/dsq", = "main" }
Requirements
- Rust 1.69 or later
- Polars for full DataFrame functionality
API Reference
Full API documentation is available at docs.rs/dsq-core.
Quick Start
use ;
// Read data from a file
let data = read_file?;
// Apply operations
let result = new
.select
.filter?
.sort_by
.head
.execute?;
// Write to Parquet
write_file?;
# Ok::
High-Level API
For more convenient usage, dsq-core provides a fluent API:
use Dsq;
// Chain operations easily
let result = from_file?
.select
.filter_expr
.sort_by
.group_by
.aggregate
.to_json?;
Feature Flags
dsq-core supports optional features for different use cases:
default- Includesall-formats,io, andfilterfor full functionalityall-formats- Enables all supported data formatsio- File I/O operations and format conversionfilter- jq-compatible filter compilation and executionrepl- Interactive REPL supportcli- Command-line interface components
Format-Specific Features
csv- CSV/TSV reading and writingjson- JSON and JSON Lines supportparquet- Apache Parquet format supportavro- Apache Avro format support (requires Polars avro feature)
Dependencies
dsq-core builds on several key dependencies:
- Polars - High-performance DataFrame operations
- Arrow - Columnar memory format
- Serde - Serialization/deserialization
- Tokio - Async runtime for streaming operations
- Nom - Parser combinators for filter syntax
- dsq-shared - Shared types and utilities
Contributing
Contributions are welcome! Please see the main CONTRIBUTING.md file for guidelines.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.