Skip to main content

BumbleBee Datalog analytics engine

Project description

BumbleBee DL

A high-performance Datalog-based analytics engine — with SQL support — from Python.

BumbleBee DL is a lightweight, in-memory analytics engine powered by Datalog — a declarative logic language that makes recursive queries, graph analysis, and complex joins natural to express. It also supports SQL as an alternative query language, so you can mix and match both in the same session. Query CSV files, Parquet files, and pandas DataFrames through a simple Python API. Built in C++ with push-based execution, columnar storage, and multithreading, it delivers serious performance on a single machine.

Quick Start

Install

pip install bumbledl

Platform support: Pre-built wheels are available for Linux x86_64 and macOS ARM (Apple Silicon). If your platform is not supported, you can still use BumbleBee (DL) in Google Colab.

Your first query

import bumbledl as bb

db = bb.db()

# Query a CSV file with SQL — alias names the output predicate
db.sql("""
    SELECT DEPARTMENT_ID, COUNT(*) AS CNT, SUM(SALARY) AS TOTAL
    FROM "examples/data/employees.csv"
    GROUP BY DEPARTMENT_ID
""", alias="dept_stats")

# Get results as a pandas DataFrame
# 3 is the arity (number of columns) of the dept_stats predicate
df = db.get_table("dept_stats", 3).to_df(
    col_names=["dept_id", "count", "total_salary"]
)
print(df)

Recursive Datalog — something SQL can't easily do

BumbleBee supports recursive Datalog rules, enabling graph analysis, transitive closure, and hierarchical queries with a clean, declarative syntax:

import bumbledl as bb
import pandas as pd

hierarchy = pd.DataFrame({
    "manager": ["alice", "alice", "bob", "bob", "carol", "dave"],
    "report":  ["bob",   "carol", "dave", "eve", "frank", "grace"],
})

db = bb.db()

# Load a pandas DataFrame as a predicate that can be queried
db.load_df(hierarchy, "manages")

# Recursive Datalog: compute all direct and indirect reports
db.run("""
    reports_to(M, R) :- manages(M, R).
    reports_to(M, R) :- manages(M, X), reports_to(X, R).
    reports_to(X, Y)?
""")

df = db.get_table("reports_to", 2).to_df(col_names=["manager", "report"])
print("reports_to:")
print(df.sort_values(["manager", "report"]).to_string(index=False))
print()

# You can also run SQL on top of Datalog results — count reports per manager
db.sql("""
    SELECT COL_0, COUNT(*) AS CNT
    FROM reports_to
    GROUP BY COL_0
""", alias="report_count")

df2 = db.get_table("report_count", 2).to_df(col_names=["manager", "num_reports"])
print("num_reports:")
print(df2.sort_values("num_reports", ascending=False).to_string(index=False))
print()

Features

  • Python client librarypip install bumbledl, query and get DataFrames back
  • Dual query languages — SQL and Datalog, including recursive Datalog
  • High-performance engine — push-based execution, columnar storage, multithreading
  • Read and write CSV and Parquet — import data from and export results to CSV and Parquet files
  • Native NULL support — NULL across all operators: IS NULL/IS NOT NULL, NULL-aware aggregates, three-valued comparisons, and CSV/Parquet/pandas (None/pd.NA) round-trip
  • DataFrame interop — load any pandas DataFrame as input via db.load_df(), meaning you can connect to virtually any data source (databases, APIs, Excel, in-memory structures) before handing it off for analysis
  • Command-line interface — run queries directly from the terminal

Python API

Method Description
db = bb.db(args={}) Create a new engine instance (only one per session). Optional args dict for CLI flags, e.g. {"-t": "4", "-d": ""}
db.run(program) Run a Datalog program
db.sql(query, alias="", overwrite=True) Run a SQL query. If alias is provided, wraps the query as (query) AS alias. If overwrite is True (default), any existing predicate with the same alias is replaced
db.run_file(filepath) Run a program from a file
db.load_df(df, alias) Load a pandas DataFrame as a predicate. Alias must start with a lowercase letter
db.explain(program) Return the generated Datalog rules as a string without executing
db.get_output_predicates() List all output predicates as (name, arity) tuples
db.get_table(name, arity=-1) Get a result table. Arity is optional
table.tuples() Get results as a list of tuples
table.to_df(col_names=[]) Get results as a pandas DataFrame. Column names are optional
db.remove_table(name, arity) Remove a predicate from the engine

Examples

Check out the examples/ folder for a collection of ready-to-use examples in Python, SQL, and Datalog, covering data imports, aggregations, joins, recursion, exports, and more.

CLI Quick Start

BumbleBee is also available as a standalone command-line tool.

Prerequisites

  • CMake 3.20+
  • C++20-compatible compiler (GCC 13+ or Clang 18+ with libc++)

Build

cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release
cmake --build cmake-build-release --target BumbleBee -j 8
./cmake-build-release/BumbleBee --help

Run a query

cd examples

# SQL
../cmake-build-release/BumbleBee -i sql/01_import/basic_csv_import.sql

# Datalog
../cmake-build-release/BumbleBee -i dl/01_import/basic_csv_import.dl -a
Flag Description
-a Print all predicates
-t N Use N threads (default: all cores)
-r Print profiling data
--print-program Print the generated Datalog program and exit

Optimizer

BumbleBee DL includes a rule-based query optimizer that applies logical rewrites such as filter push-down and column pruning. The current optimizer does not reorder joins — the execution order follows the join sequence as written in the query. A cost-based join reordering optimizer is planned as a future enhancement.

Roadmap

  • Code generation: cover complex AND and OR clause combinations in filter expressions
  • Predicate table types: allow users to explicitly declare column types for predicates (currently auto-deduced at runtime)
  • Left and right joins: support for LEFT JOIN and RIGHT JOIN
  • Cost-based join optimizer: reorder joins based on cardinality estimates

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bumbledl-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

bumbledl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

bumbledl-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

bumbledl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

bumbledl-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

bumbledl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

bumbledl-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

bumbledl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl (5.8 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file bumbledl-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e4d66f02ef686e60abbfc7e47f328b7a92fc7803b6333c6cbbb7935fed56922d
MD5 8020c384555e06be4d33dc00cba26f5e
BLAKE2b-256 d302281fb7fdb1a79b50445e8e7d17285cff1c76028e7452dbe7acd0ebb80b70

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 13bba5bec70260a8bab88c61460db4b59573fca7ebff808ebd9c37d705e1a7d5
MD5 fe8fb058cc6d3f0bf4897c8d1d145c0b
BLAKE2b-256 03732d21b4d6483e57b440342f796e864c99d9df4743e7b41bb1ecb6d7c949c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f45100137a9629001e6d5bb415462270f6ac0f259f46743765edcb5cf147c848
MD5 09308b70a7146f08d08e22f4a1d2200a
BLAKE2b-256 eee99611d8108b1840db5b6193064c0554420c8fc5ffd5241c1dc0b5abefec4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 bc3c508fa23f44833c8d06b238990b0b2b176f3d971d65c0e2085224bb7c7bf4
MD5 0ecf044ea4b4cd00c2595f7274990624
BLAKE2b-256 31dddf2379c74a9e4de8345bf2fb383fbe0921691043f11e74dc5802dced5c05

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 eff5a46aeeca3c1c71f8625cf5b6fa1400ad3dfafe58df70f7bcb33401df6295
MD5 bd7e0696d3150f43eea20eeea892cef8
BLAKE2b-256 33ac86d1ec46a4f83a0ad28372725ae5666093a2d6af14b439befec94b082e47

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 aafca4cd092de3ef1d976d60dc9f22026291d11c92cddce110cc95aebdb2c1a1
MD5 29f3770e4c98e40c487093a0787728d4
BLAKE2b-256 f13a80f93e361e8d7f22dd688cc4ab2aeb9ccdfb482766276f48623333343ec3

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d97fa9e9fb8c9063f9b2dc297b153699aeda7ad1ed49631188b072b69deedb55
MD5 7ce48931e682781eddd270a52520300a
BLAKE2b-256 1ad08a58af05be2bed0f1d06ee4323f05ea7ab818ea347738be41eaee4ecc0a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bumbledl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bumbledl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 bbe8609009aa4610f1cc3128e94a182f64381984bb81130454f2585fdf815d60
MD5 6dd36860eac9374983b883301ec42691
BLAKE2b-256 f95156d7b68c1a7fe7c2cbece13272af51ea75d928db276b3ddb53df628a1079

See more details on using hashes here.

Provenance

The following attestation bundles were made for bumbledl-0.4.0-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: publish.yml on dave90/BumbleBee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page