All skills
clickhouse avatar

/chdb-datastore

@46ef08c official
by clickhouseclickhouse/agent-skills543 stars
39

Use when the user has tabular data (pandas DataFrame, parquet, csv, Arrow, json) and wants to filter, group, aggregate, join, or speed up slow pandas. Provides chDB DataStore — same pandas API, ClickHouse engine underneath. Also handles reading from S3, MySQL, PostgreSQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake as DataFrames and joining across sources. TRIGGER when: user mentions DataFrame, parquet, csv, "fast pandas", "speed up pandas", or cross-source DataFrame joins; user imports `chdb.datastore` or `from datastore import DataStore`. SKIP this skill for raw SQL syntax (use chdb-sql instead), ClickHouse server administration, or non-Python DataStore API work.

Use this Skill: https://skilld.dev/gh/clickhouse/agent-skills/chdb-datastore

This session only. Nothing lands on disk.

referencesapi-reference.md

≈2.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

DataStore API Reference

Complete method signatures for the DataStore class. DataStore provides a pandas-compatible API backed by ClickHouse.

Table of Contents


Import & Construction

from datastore import DataStore
# or: from chdb.datastore import DataStore
# or: import chdb.datastore as pd  (drop-in replacement)

Constructor

DataStore(source=None, table=None, database=":memory:", connection=None, **kwargs)
Source type Usage
dict DataStore({'col1': [1, 2], 'col2': ['a', 'b']})
pd.DataFrame DataStore(df)
str (source type) DataStore("file", path="data.parquet")
str (source type) DataStore("mysql", host="host:3306", database="db", table="t", user="u", password="p")

Factory Methods

See connectors.md for all factory methods (from_file, from_mysql, from_s3, uri, etc.).


Selection & Filtering

Expression Returns Description
ds['col'] LazySeries Single column
ds[['c1', 'c2']] DataStore Multiple columns
ds[condition] DataStore Boolean filter (e.g., ds[ds['age'] > 25])
.select(*fields) DataStore SQL-style SELECT with expressions
.filter(condition) DataStore SQL-style WHERE clause
.where(condition) DataStore Mask values where condition is False (pandas semantics)
result = ds[ds["age"] > 25]
result = ds[(ds["status"] == "active") & (ds["revenue"] > 1000)]
result = ds[["name", "city", "revenue"]]
result = ds.select("name", "revenue * 1.1 AS adjusted_revenue")
result = ds.filter(ds["country"] == "US")
result = ds.where(ds["age"] > 25)  # keeps all rows; non-matching values become NaN

Sorting & Limiting

Method Description
.sort_values(by, ascending=True) Pandas-style sort (by can be str or list)
.sort(*columns, ascending=True) SQL-style ORDER BY
.orderby(*columns, ascending=True) Alias for .sort()
.limit(n) LIMIT n rows
.offset(n) Skip first n rows
.head(n=5) First n rows
.tail(n=5) Last n rows
result = ds.sort_values("revenue", ascending=False)
result = ds.sort_values(["country", "city"])
result = ds.head(10)
result = ds.limit(100).offset(50)

GroupBy & Aggregation

grouped = ds.groupby(*columns)          # returns LazyGroupBy
grouped = ds.groupby("dept")
grouped = ds.groupby(["region", "product"])
Method Description
.agg(func=None, **kwargs) Aggregate with named functions
.sum(), .mean(), .count(), .min(), .max() Single aggregation
.std(), .var() Standard deviation / variance
.having(condition) HAVING clause (after aggregation)
result = ds.groupby("dept")["salary"].mean()
result = ds.groupby("dept").agg({"salary": "mean", "bonus": "sum"})
result = ds.groupby(["region", "product"]).agg(
    total_revenue=("revenue", "sum"),
    avg_quantity=("quantity", "mean"))

Joins

.join(other, on=None, how='inner', left_on=None, right_on=None, suffixes=('_x', '_y'))
.merge(other, on=None, how='inner')
how Description
'inner' Only matching rows (default)
'left' All left rows + matching right
'right' All right rows + matching left
'outer' All rows from both sides
'cross' Cartesian product
result = orders.join(customers, left_on="customer_id", right_on="id")
result = orders.join(customers, on="customer_id", how="left")
result = ds1.merge(ds2, on="key", how="outer")

Cross-source joins work transparently — join a MySQL table with a Parquet file:

mysql_ds = DataStore.from_mysql(host="db:3306", database="crm", table="users", user="root", password="pass")
parquet_ds = DataStore.from_file("orders.parquet")
result = mysql_ds.join(parquet_ds, left_on="id", right_on="user_id")

Mutation

Method Description
.assign(**kwargs) Add computed columns
.with_column(name, expr) Add single column
.drop(columns) Remove columns (str or list)
.rename(columns={}) Rename columns via mapping
.fillna(value) Fill NaN/NULL values
.dropna(subset=None) Drop rows with NaN/NULL
.distinct(subset=None, keep='first') Deduplicate rows
result = ds.assign(
    profit=ds["revenue"] - ds["cost"],
    margin=lambda x: x["profit"] / x["revenue"])
result = ds.drop("temp_column")
result = ds.rename(columns={"old_name": "new_name"})
result = ds.fillna(0)
result = ds.dropna(subset=["email", "phone"])
result = ds.distinct(subset=["user_id"], keep="first")

String Accessor (.str)

Access via ds['column'].str.*. 56 methods available, including:

Method Description
.str.upper(), .str.lower() Case conversion
.str.strip(), .str.lstrip(), .str.rstrip() Whitespace trimming
.str.contains(pattern) Substring/regex match → boolean
.str.startswith(prefix), .str.endswith(suffix) Prefix/suffix check
.str.replace(old, new) String replacement
.str.split(sep) Split into parts
.str.len() String length
.str.slice(start, stop) Substring extraction
.str.cat(sep=None) Concatenation
.str.extract(pattern) Regex group extraction
.str.pad(width), .str.zfill(width) Padding
.str.match(pattern) Full regex match
ds["name"].str.upper()
ds["email"].str.contains("@gmail")
ds["code"].str.slice(0, 3)

DateTime Accessor (.dt)

Access via ds['column'].dt.*. 42+ methods available, including:

Property/Method Description
.dt.year, .dt.month, .dt.day Date components
.dt.hour, .dt.minute, .dt.second Time components
.dt.dayofweek, .dt.dayofyear Day ordinals
.dt.quarter Quarter (1-4)
.dt.date, .dt.time Date/time part
.dt.strftime(format) Format as string
.dt.floor(freq), .dt.ceil(freq) Round to frequency
.dt.tz_localize(tz), .dt.tz_convert(tz) Timezone handling
.dt.normalize() Reset time to midnight
ds["order_date"].dt.year
ds["order_date"].dt.month
ds["timestamp"].dt.hour
ds["created_at"].dt.strftime("%Y-%m-%d")

Inspection & Execution Triggers

These properties/methods trigger execution of the lazy query:

Property/Method Returns Description
.columns list Column names
.shape (rows, cols) Dimensions
.dtypes dict Column types
.head(n=5) DataStore First n rows
.tail(n=5) DataStore Last n rows
.describe() DataStore Summary statistics
.info() None Print DataFrame info
print(ds) — Display results
len(ds) int Row count
for row in ds — Iterate rows
.equals(other) bool Compare DataStores

These methods do not trigger execution:

Method Returns Description
.to_sql() str View the generated SQL
.explain() str Execution plan
print(ds.columns)          # → ['name', 'age', 'city']
print(ds.shape)            # → (1000, 3)
print(ds.to_sql())         # → SELECT ... FROM ... WHERE ...
print(ds.describe())       # → statistics table

Writing Data

Use the insert_into / select_from pattern:

source = DataStore.from_mysql(host="db:3306", database="shop", table="orders", user="root", password="pass")
target = DataStore("file", path="output.parquet", format="Parquet")

target.insert_into("col1", "col2").select_from(
    source.select("col1", "col2").filter(source['value'] > 100)
).execute()

Configuration

from datastore import config

config.use_chdb()           # force chDB/SQL backend
config.use_pandas()         # force pandas backend
config.prefer_chdb()        # prefer chDB when possible, fallback to pandas
config.prefer_pandas()      # prefer pandas when possible, fallback to chDB
config.enable_debug()       # verbose logging (shows generated SQL)
config.enable_profiling()   # performance profiling

Source: SKILL.md on GitHub

No alerts17d4 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill is a legitimate tool provided by ClickHouse Inc to use the chdb DataStore API, which is an optimized, ClickHouse-backed replacement for the pandas library. It allows users to perform high-performance data analysis on various sources including local files (CSV, Parquet), cloud storage (S3, GCS), and databases (MySQL, PostgreSQL). The analysis found no evidence of malicious behavior, prompt injection, or unauthorized data exfiltration. All external resources and packages trace back to the official vendor infrastructure.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 46ef08c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
compatibility
Requires Python 3.9+, macOS or Linux. pip install chdb.
Other metadata
metadata
{
  "author": "chdb-io",
  "version": "4.1",
  "homepage": "https://clickhouse.com/docs/chdb"
}
  • chdb
  • clickhouse
  • pandas
  • dataframe
  • parquet
  • csv
  • s3
  • mysql
  • postgresql
  • mongodb
  • lazy-evaluation
  • sql
  • data-analysis

README badge

README badge for clickhouse/agent-skills/chdb-datastore

Provides chdb DataStore, a ClickHouse-backed pandas replacement with the same API but lazy evaluation and SQL compilation underneath. Load tabular data from files, S3, MySQL, PostgreSQL, MongoDB, or other sources as DataFrames, then filter, group, aggregate, and join across sources using familiar pandas syntax — typically faster than pandas for large datasets.

Generated from the current SKILL.md.

Does DataStore work with my existing pandas code?
Yes. DataStore implements the pandas API — you can often replace `import pandas as pd` with `import chdb.datastore as pd` and keep the rest of your code unchanged. Operations are lazy and compile to SQL under the hood.
What data sources does DataStore support?
DataStore connects to 16+ sources including local files (parquet, csv, json, arrow, orc, avro, tsv, xml), MySQL, PostgreSQL, MongoDB, ClickHouse Cloud, S3, Iceberg, and Delta Lake. Use `.from_file()`, `.from_mysql()`, `.from_s3()`, or the `.uri()` shorthand to auto-detect the source.
Can I join data across different sources?
Yes. Create separate DataStore instances for each source and use `.join()` to combine them. The skill includes examples of joining data from MySQL, parquet files, and S3 in a single query.
What Python versions does this require?
Python 3.9+, and only works on macOS or Linux. Install with `pip install chdb`.
Should I use this skill for raw SQL queries?
No. Use the chdb-sql skill instead. This skill is for the DataStore pandas-compatible API. If you need raw SQL syntax, switch to chdb-sql.

Generated from the current SKILL.md. These answers refresh after source changes.