Metadata-Version: 2.4
Name: xorq
Version: 0.2.4
Summary: Data processing library built on top of Ibis and DataFusion to write multi-engine data workflows.
Project-URL: Homepage, https://www.letsql.com/
Project-URL: Repository, https://github.com/letsql/xorq.git
Project-URL: Issues, https://github.com/letsql/xorq/issues
Project-URL: Changelog, https://github.com/letsql/xorq/blob/main/CHANGELOG.md
Author-email: Hussain Sultan <hussain@letsql.com>
Maintainer-email: Dan Lovell <dan@letsql.com>, Daniel Mesejo <mesejo@letsql.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Rust
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3.10
Requires-Dist: atpublic>=5.1
Requires-Dist: attrs<26,>=24.0.0; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: cityhash<1,>=0.4.7; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: cloudpickle>=3.1.1
Requires-Dist: dask==2025.1.0; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: envyaml>=1.10.211231
Requires-Dist: geoarrow-types<1,>=0.2; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: opentelemetry-exporter-otlp>=1.32.1
Requires-Dist: opentelemetry-exporter-prometheus>=0.55b1
Requires-Dist: opentelemetry-sdk>=1.32.1
Requires-Dist: pandas<3,>=1.5.3; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: parsy>=2
Requires-Dist: prometheus-client>=0.22.1
Requires-Dist: pyarrow-hotfix<1,>=0.4; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: pyarrow<21,>=13.0.0; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: pytest-mock<4,>=3.14.0; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: pythran>=0.17.0; sys_platform == 'darwin'
Requires-Dist: pytz>=2022.7
Requires-Dist: pyyaml>=6.0.2
Requires-Dist: sqlglot==25.20.2
Requires-Dist: structlog<26,>=24.2.0; python_version >= '3.10' and python_version < '4.0'
Requires-Dist: toolz>=0.11
Requires-Dist: typing-extensions>=4.3.0
Requires-Dist: xorq-datafusion==0.2.3
Provides-Extra: datafusion
Requires-Dist: datafusion<48,>=0.6; (python_version >= '3.10' and python_version < '4.0') and extra == 'datafusion'
Provides-Extra: duckdb
Requires-Dist: duckdb>=1.1.3; extra == 'duckdb'
Provides-Extra: examples
Requires-Dist: adbc-driver-postgresql>=1.4.0; extra == 'examples'
Requires-Dist: cryptography>=45.0.3; extra == 'examples'
Requires-Dist: duckdb<2,>=0.10.3; (python_version >= '3.10' and python_version < '4.0') and extra == 'examples'
Requires-Dist: fsspec<2025.5.2,>=2024.6.1; (python_version >= '3.10' and python_version < '4.0') and extra == 'examples'
Requires-Dist: mcp>=1.5.0; extra == 'examples'
Requires-Dist: openai>=1.65.4; extra == 'examples'
Requires-Dist: pins[gcs]<1,>=0.8.3; (python_version >= '3.10' and python_version < '4.0') and extra == 'examples'
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'examples'
Requires-Dist: quickgrove>=0.1.2; extra == 'examples'
Requires-Dist: requests>=2.32.3; extra == 'examples'
Requires-Dist: scikit-learn<2.0.0,>=1.4.0; extra == 'examples'
Requires-Dist: xgboost>=1.6.1; (python_version >= '3.10' and python_version < '4.0') and extra == 'examples'
Requires-Dist: xorq-feature-utils; extra == 'examples'
Requires-Dist: xorq-weather-lib; extra == 'examples'
Provides-Extra: postgres
Requires-Dist: adbc-driver-postgresql>=1.4.0; extra == 'postgres'
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'postgres'
Provides-Extra: pyiceberg
Requires-Dist: pyiceberg[sql-postgres,sql-sqlite]>=0.9.0; extra == 'pyiceberg'
Provides-Extra: quickgrove
Requires-Dist: quickgrove>=0.1.2; extra == 'quickgrove'
Provides-Extra: snowflake
Requires-Dist: adbc-driver-snowflake>=1.5.0; extra == 'snowflake'
Requires-Dist: snowflake-connector-python<4,>=3.10.1; (python_version >= '3.10' and python_version < '4.0') and extra == 'snowflake'
Description-Content-Type: text/markdown

<div align="center">

![Xorq Logo](docs/images/Xorq_WordMark_RGB_Midnight.png)
![GitHub License](https://img.shields.io/github/license/xorq-labs/xorq)
![PyPI - Version](https://img.shields.io/pypi/v/xorq)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/xorq-labs/xorq/ci-test.yml)

</div>

> **✨ Xorq is an opinionated framework for cataloging composable compute
> expressions for your data in flight. ✨**

Popular Python tools like pandas and Ibis make data exploration enjoyable—but
when it's time to build reliable ML pipelines across multiple engines, things
quickly become complex.

As data scientists, we found that building ML pipelines, especially multi-stage
and multi-source pipelines, is frustrating work. SQL-pandas impedance
mismatches. Wasteful recomputation time and costs. Pipelines that work
perfectly in notebooks, but take forever to re-engineer for deployment--and
then deliver different results or fail in production. We built Xorq to
eliminate these problems - a library with a simple declarative syntax for
defining ML pipelines as portable, reusable components that can be cataloged
and governed like code.

[More on why we built Xorq](#why-xorq).

Xorq lets you:

* **Write expressive, pandas-style transformations** without memory constraints.
* **Move between SQL engines and Python** within a single declarative pipeline.
* **Build portable UDFs** that run consistently across engines and effortlessly composed.
* **Serve cached intermediate results**, so no computation is wasted.
* **Save diff-able YAML artifacts** for reproducibility and CI/CD.
* **Get compile-time validation** through declarative expressions.

## Demo Time!

Let's see Xorq in action.

[TBD: This section will be updated with a video demo soon!]

## Getting Started with Xorq

###  Installation and Requirements

```bash
pip install xorq  # or pip install "xorq[examples]"
```
* Python 3.9+
* Apache Arrow 19.0+

### 1. Load and Prepare Data

```python
import xorq as xo
from xorq.expr.ml.pipeline_lib import Step
from sklearn.neighbors import KNeighborsClassifier

# Fetch penguins dataset from pandas backend
pandas_con = xo.pandas.connect()
expr = xo.examples.penguins.fetch(backend=pandas_con)

# Filter out rows with missing values
expr = expr.filter(
    expr.bill_length_mm.isnull() == False,
    expr.bill_depth_mm.isnull() == False,
    expr.flipper_length_mm.isnull() == False,
    expr.body_mass_g.isnull() == False,
)
print(expr.schema())
print(expr.ls.backends)
```
> ```sh
> Out[2]:
> ibis.Schema {
>   species            string
>   island             string
>   bill_length_mm     float64
>   bill_depth_mm      float64
>   flipper_length_mm  int64
>   body_mass_g        int64
>   sex                string
>   year               int64
> }
> Out[3]:
> (<xorq.backends.pandas.Backend at 0x107767f70>,) #<-- just a pandas backend
> ```

### 2. Define Features and Move to Xorq Backend

```python
features = ['bill_length_mm', 'bill_depth_mm', 'flipper_length_mm', 'body_mass_g']
target = 'species'

# Move to Xorq's embedded backend for deferred execution
# Xorq ships with a modified DataFusion based engine that is especially
# designed for Arrow UDF and UDAF execution.
con = xo.connect()
expr = expr.into_backend(con)
print(expr.ls.backends)
```
> ```sh
> (<xorq.backends.pandas.Backend object at 0x107767f70>, <xorq.backends.let.Backend object at 0x17fcbeb00>)
> ```

### 3. Build and Fit ML Pipeline

```python
# Create a KNN classifier step
step = Step(KNeighborsClassifier)

# Fit the model - this creates a deferred pipeline
fitted = step.fit(expr, features=features, target=target)
print(fitted)
```

This creates a `FittedStep` object that contains both the trained model and the computational graph needed to reproduce predictions.

> **Output:**
> ```
> FittedStep(step=Step(typ=<class 'sklearn.neighbors._classification.KNeighborsClassifier'>,
> name='kneighborsclassifier_5353694976', params_tuple=()),
> expr=r0 := Read[name=penguins, method_name=read_csv, source=pandas-4354090912]
>   species           string
>   island            string
>   bill_length_mm    float64
>   bill_depth_mm     float64
>   flipper_length_mm int64
>   body_mass_g       int64
>   sex               string
>   year              int64
>
> r1 := Filter[r0]
>   IsNull(r0.bill_length_mm) == False
>   IsNull(r0.bill_depth_mm) == False
>   IsNull(r0.flipper_length_mm) == False
>   IsNull(r0.body_mass_g) == False
>
> RemoteTable[r1, name=ibis_rbr-placeholder_pz63nqkmljeujh]
>   features=('bill_length_mm', 'bill_depth_mm', 'flipper_length_mm', 'body_mass_g'),
>   target='species', storage=None, dest_col=None)
> ```

> Aside:
> What does deferred execution mean? Deferred execution means that the actual
> computation is not executed immediately. Instead, it builds a computational
> graph that can be executed later, allowing for optimizations and better
> resource management.

### 5. Make Predictions with Deferred Execution

```python
# Create a new expression that includes predictions
y_expr = expr.mutate(
    predicted=fitted.deferred_predict.on_expr  # Features and target are automatically inferred
)

# Execute only when needed
y_pred = y_expr.predicted.execute()
y_actual = expr[target].execute()

# Calculate accuracy
accuracy = (y_actual == y_pred).mean()
print(f'Deferred pipeline accuracy: {accuracy:.2%}')
```

> **Output:**
> ```
> Deferred pipeline accuracy: 97%
> ```

Save this as file as `expr.py`.
### 4. Build and Deploy the Pipeline

Once you have your fitted pipeline, you can build and deploy it using Xorq's CLI:

```bash
# Build the pipeline for deployment
xorq build expr.py -e y_expr
```

> **Build Output:**
> ```
> Building y_expr from scripts/expr.py
> Written 'y_expr' to builds/ca3da8b86a86
> builds/ca3da8b86a86
> ```

Now you can run the built pipeline:

```bash
xorq run builds/ca3da8b86a86
```
> **Run Output:**
>
> ```
> ❯ lt builds/ca3da8b86a86
> .
> ├── 8b5f90115b97.sql
> ├── 8d14b1afefa2.sql
> ├── 984aa14b8fde.sql
> ├── 6130850ff0a4.sql
> ├── deferred_reads.yaml
> ├── expr.yaml
> ├── metadata.json
> ├── profiles.yaml
> └── sql.yaml
> ```
Notice that we have an expr.yaml file with complete schemas and lineage
information as well as debug outputs for SQL. The expr can rountrip back and
forth from Ibis expressions.

>```yaml
>❯ cat deferred_reads.yaml
>reads:
>  penguins-36877e5b81573dffe4e988965ce3950b:
>    engine: pandas
>    profile_name: 08f39a9ca2742d208a09d0ee9c7756c0_1
>    relations:
>    - penguins-36877e5b81573dffe4e988965ce3950b
>    options:
>      method_name: read_csv
>      name: penguins
>      read_kwargs:
>      - source: /Users/hussainsultan/Library/Caches/pins-py/gs_d3037fb8920d01eb3b262ab08d52335c89ba62aa41299e5236f01807aa8b726d/penguins/20250206T212843Z-8f28a/penguins.csv
>      - table_name: penguins
>    sql_file: 8b5f90115b97.sql
>
>```
and similarly expr.yaml (just a snippet):

> ```yaml
> predicted:
>   op: ExprScalarUDF
>   class_name: _predicted_e1d43fe620d0175d76276
>   kwargs:
>     op: dict
>     bill_length_mm:
>       node_ref: ecb7ceed7bab79d4e96ed0ce037f4dbd
>     bill_depth_mm:
>       node_ref: 26ca5f78d58daed6adf20dd2eba92d41
>     flipper_length_mm:
>       node_ref: 916dc998f8de70812099b2191256f4c1
>     body_mass_g:
>       node_ref: e094d235b0c1b297da5c194a5c4c331f
>   meta:
>     op: dict
>     dtype:
>       op: DataType
>       type: String
>       nullable:
>         op: bool
>         value: true
>     __input_type__:
>       op: InputType
>       name: PYARROW
>     __config__:
>       op: dict
>       computed_kwargs_expr:
>         op: AggUDF
>         class_name: _fit_predicted_e1d43fe620d0175d7
>         kwargs:
>           op: dict
>           bill_length_mm:
>             node_ref: ecb7ceed7bab79d4e96ed0ce037f4dbd
>           bill_depth_mm:
>             node_ref: 26ca5f78d58daed6adf20dd2eba92d41
>           flipper_length_mm:
>             node_ref: 916dc998f8de70812099b2191256f4c1
>           body_mass_g:
>             node_ref: e094d235b0c1b297da5c194a5c4c331f
>           species:
>             node_ref: a9fa43a2d8772c7eca4a7e2067107bfc
> ```

Please note that this is still in beta and the spec is subject to change.


### 6. Explore Pipeline Lineage

One of Xorq's most powerful features is its ability to track the complete lineage of your computations:

```python
from xorq.common.utils.lineage_utils import build_column_trees, print_tree

# Visualize the computational graph for predictions
print_tree(build_column_trees(y_expr)['predicted'])
```

> **Lineage Tree Output:**
> ```
> ExprScalarUDF #1
> └── _fit_predicted_e1d43fe620d0175d7 #2
>     ├── Field:bill_length_mm #3
>     │   └── Filter #4
>     │       ├── RemoteTable:ibis_rbr-placeholder_rx26s3k3fvdldn #5
>     │       │   └── Read #6
>     │       ├── Equals #7
>     │       │   ├── IsNull #8
>     │       │   │   └── Field:bill_length_mm #9
>     │       │   │       └── ↻ see #5
>     │       │   └── Literal: False #10
>     │       ├── Equals #11
>     │       │   ├── IsNull #12
>     │       │   │   └── Field:bill_depth_mm #13
>     │       │   │       └── ↻ see #5
>     │       │   └── ↻ see #10
>     │       ├── Equals #14
>     │       │   ├── IsNull #15
>     │       │   │   └── Field:flipper_length_mm #16
>     │       │   │       └── ↻ see #5
>     │       │   └── ↻ see #10
>     │       └── Equals #17
>     │           ├── IsNull #18
>     │           │   └── Field:body_mass_g #19
>     │           │       └── ↻ see #5
>     │           └── ↻ see #10
>     ├── Field:bill_depth_mm #20
>     │   └── ↻ see #4
>     ├── Field:flipper_length_mm #21
>     │   └── ↻ see #4
>     ├── Field:body_mass_g #22
>     │   └── ↻ see #4
>     └── Field:species #23
>         └── ↻ see #4
> ```

### Next:
Explore [Profiles](https://docs.xorq.dev/core_concepts/profiles_guide) to
connect to Remote backends, explore the [Caching
system](https://docs.xorq.dev/core_concepts/caching) that automatically names
and stores up-to date entries, and how to serve(coming soon!) the prediction
UDF.

### Scikit-learn `Pipeline` Example:
For more examples using `scikit-learn`, check out the [scikit-learn examples](examples/pipelines_example.py).

## How Xorq works

![Xorq Architecture](docs/images/how-xorq-works.png)

Xorq uses Apache Arrow for zero-copy data transfer and leverages Ibis and
DataFusion under the hood for efficient computation.

## Why Xorq?

Here's the challenge we faced:

* **SQL engines** like Snowflake or DuckDB excel at heavy computation but often feel disconnected from Python workflows.
* **Python libraries** like pandas and scikit-learn are fantastic for complex transformations but struggle with scale.
* **Python UDFs** handle custom logic beautifully, yet orchestrating them across engines can get cumbersome.
* **Caching intermediate results** should save precious compute resources but isn't always automatic.
* **Automated column-level lineage** is crucial for reproducibility but usually an afterthought.
* **Fail-fast pipelines** should give feedback at compile time, not runtime—but current solutions rarely achieve this.

We built Xorq because existing tools fall short:

* **Ibis** is great for SQL but is single-engine/single-session.
* **PySpark** is complex and heavyweight for many use cases, especially when you just need a simple pipeline.
* **Airflow** is powerful but overkill for many ML workflows with state management and task-level retries.
* **dbt** lets you compose SQL models but not Python functions.
* **Feast** provides feature management and serving but lacks batch transformations.

Xorq’s key differentiators are:

* **Multi-engine workflows**: Combine Snowflake, DuckDB, and Python effortlessly.
* **Built-in caching**: No repeated expensive joins or wasted resources.
* **Serializable pipelines**: YAML and SQL artifacts for reproducibility and easy deployment.
* **Portable UDxFs**: Write your logic once and run it anywhere supported by DataFusion.


## Current Limitations

We're upfront about what’s not quite there yet:

* **API Stability**: Xorq is rapidly evolving, and breaking changes are common until v1.0.
* **Single-Machine**: We don't have distributed support for `xorq-datafusion` engine.
* **Documentation Gaps**: Docs are improving but still thin in areas.

### Out of Scope (for now)

* Real-time sources (Kafka, Pulsar, etc.)
* Rust-based UDFs
* R, Javascript, or other language support

We'd love your feedback! Your ⭐, issues, and contributions help us shape Xorq's future.




## FAQ

### **What exactly does Xorq replace in my existing data stack?**


### **Can I use my existing Python UDFs in Xorq?**

Yes! Xorq makes it easy to adapt existing pandas-style UDFs into portable UDxFs
that run consistently across multiple SQL engines and Python contexts. Simply
wrap your logic with Xorq’s decorators, and your UDFs become multi-engine
compatible automatically.

### **Is Xorq ready for production workloads?**

Xorq is rapidly evolving and still pre-1.0, meaning breaking changes are
expected as the API stabilizes. While many teams use Xorq successfully in their
workflows today, we recommend caution in production environments and encourage
active involvement to help shape the stable release.

## Getting Involved

Interested? Dive deeper:

* Read the [full article](https://www.xorq.dev/posts/introducing-xorq).
* Join the discussion on Discord: [#xorq](https://discord.gg/8Kma9DhcJG).
* Contribute via [GitHub](https://github.com/xorq-labs/xorq).

## License & Acknowledgements

Xorq is licensed under [Apache 2.0](https://github.com/xorq-labs/xorq/blob/main/LICENSE).

This project heavily relies on [Ibis](https://github.com/ibis-project/ibis) and [DataFusion](https://github.com/apache/datafusion).
