All skills
clickhouse avatar

/chdb-sql

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

Use when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake) without setting up a server. Provides chDB — embedded ClickHouse SQL in Python with 1000+ functions, Session for stateful multi-step pipelines, parametrized queries, and cross-source joins via `s3()`, `mysql()`, `postgresql()`, `iceberg()`, `deltaLake()`, `remoteSecure()` table functions. TRIGGER when: user wants SQL on parquet/csv/files or across remote analytical sources; uses ClickHouse SQL features (window functions, windowFunnel, geoToH3, JSON path ops, Session, parametrized queries); imports `chdb` or calls `chdb.query()`. SKIP this skill for pandas-style DataFrame method-chaining (use chdb-datastore instead) or ClickHouse server administration.

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

This session only. Nothing lands on disk.

referencestable-functions.md

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

ClickHouse Table Functions for chdb

Table functions let you query external data sources directly in SQL. Use them with chdb.query() or inside a Session.

Table of Contents


File Sources

file()

Query local files. Format is auto-detected from extension or specified explicitly.

SELECT * FROM file('data.parquet', Parquet)
SELECT * FROM file('data.csv', CSVWithNames)
SELECT * FROM file('events.jsonl', JSONEachRow)
SELECT * FROM file('logs/*.parquet', Parquet)              -- glob pattern
SELECT * FROM file('data/2024-*/events.csv', CSVWithNames) -- nested glob

Parameters: file(path [, format [, structure [, compression]]])

Supported formats: Parquet, CSVWithNames, CSV, TSVWithNames, JSONEachRow, JSON, Arrow, ORC, Avro, XMLWithNames.

Supported compression: auto-detected from extension (.gz, .zst, .bz2, .xz, .lz4).


Cloud Storage

s3()

-- Public (no auth)
SELECT * FROM s3('s3://bucket/path.parquet', NOSIGN)

-- With credentials
SELECT * FROM s3('s3://bucket/path.parquet', 'ACCESS_KEY', 'SECRET_KEY', 'Parquet')

-- Glob pattern
SELECT * FROM s3('s3://bucket/logs/2024-*.parquet', 'KEY', 'SECRET', 'Parquet')

Parameters: s3(url [, NOSIGN | access_key, secret_key] [, format [, structure [, compression]]])

gcs()

SELECT * FROM gcs('gs://bucket/data.parquet', NOSIGN)
SELECT * FROM gcs('gs://bucket/data.parquet', 'HMAC_KEY', 'HMAC_SECRET', 'Parquet')

Parameters: Same as s3().

azureBlobStorage()

SELECT * FROM azureBlobStorage(
    'DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...',
    'container', 'path/data.parquet', 'Parquet')

Parameters: azureBlobStorage(connection_string, container, path [, format [, structure [, compression]]])

hdfs()

SELECT * FROM hdfs('hdfs://namenode:9000/warehouse/data.parquet', 'Parquet')
SELECT * FROM hdfs('hdfs://namenode:9000/logs/*.parquet', 'Parquet')

Parameters: hdfs(uri [, format [, structure [, compression]]])


Databases

mysql()

SELECT * FROM mysql('host:3306', 'database', 'table', 'user', 'password')

-- With WHERE pushdown
SELECT * FROM mysql('db:3306', 'shop', 'orders', 'root', 'pass')
WHERE status = 'shipped' AND amount > 100

Parameters: mysql(host:port, database, table, user, password)

Note: Port is part of the host string (e.g., 'db:3306'), not a separate parameter.

postgresql()

SELECT * FROM postgresql('host:5432', 'database', 'table', 'user', 'password')

SELECT * FROM postgresql('pg:5432', 'analytics', 'events', 'analyst', 'pass')
ORDER BY created_at DESC LIMIT 100

Parameters: postgresql(host:port, database, table, user, password)

remote() / remoteSecure()

Query a remote ClickHouse server:

SELECT * FROM remote('host:9000', 'database', 'table', 'user', 'password')
SELECT * FROM remoteSecure('host:9440', 'database', 'table', 'user', 'password')

Parameters: remote(host:port, database, table [, user [, password]])

mongodb()

SELECT * FROM mongodb('host:27017', 'database', 'collection', 'user', 'password')

Parameters: mongodb(host:port, database, collection, user, password)

sqlite()

SELECT * FROM sqlite('/path/to/database.db', 'table_name')

Parameters: sqlite(database_path, table)


Data Lakes

iceberg()

SELECT * FROM iceberg('s3://bucket/iceberg/table', 'ACCESS_KEY', 'SECRET_KEY')
SELECT * FROM iceberg('s3://bucket/iceberg/table', NOSIGN)

Parameters: iceberg(url [, NOSIGN | access_key, secret_key] [, format])

deltaLake()

SELECT * FROM deltaLake('s3://bucket/delta/table', 'ACCESS_KEY', 'SECRET_KEY')
SELECT * FROM deltaLake('s3://bucket/delta/table', NOSIGN)

Parameters: deltaLake(url [, NOSIGN | access_key, secret_key])

Note: Function name is deltaLake (camelCase), not deltalake.

hudi()

SELECT * FROM hudi('s3://bucket/hudi/table', 'ACCESS_KEY', 'SECRET_KEY')
SELECT * FROM hudi('s3://bucket/hudi/table', NOSIGN)

Parameters: hudi(url [, NOSIGN | access_key, secret_key])


Utility Functions

numbers()

Generate a sequence of numbers (useful for testing and date generation):

SELECT * FROM numbers(100)              -- 0 to 99
SELECT * FROM numbers(10, 100)          -- 10 to 109
SELECT toDate('2025-01-01') + number AS date FROM numbers(365)  -- date range

Parameters: numbers([offset,] count)

Python()

Use a Python dict or DataFrame as a SQL table:

import chdb

data = {"name": ["Alice", "Bob"], "score": [95, 87]}
chdb.query("SELECT * FROM Python(data) ORDER BY score DESC")

import pandas as pd
df = pd.DataFrame({"id": [1, 2, 3], "value": [10, 20, 30]})
chdb.query("SELECT * FROM Python(df) WHERE value > 15")

Note: The Python variable must be in scope when the query executes.

url()

Query data from an HTTP/HTTPS URL:

SELECT * FROM url('https://example.com/data.csv', CSVWithNames)
SELECT * FROM url('https://api.example.com/data.json', JSONEachRow)

Parameters: url(url, format [, structure])

Source: SKILL.md on GitHub

1 warning17d4 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides instructions and references for 'chdb', an official in-process ClickHouse SQL engine by ClickHouse Inc. It allows the agent to run analytical SQL queries on local files (CSV, Parquet, JSON), remote databases (MySQL, Postgres, MongoDB), and cloud storage (S3, GCS). All identified library dependencies and remote sources are standard components of the ClickHouse ecosystem.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: MEDIUM · 1 issue

  • 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"
}
  • Python
  • clickhouse
  • chdb
  • sql
  • analytics
  • parquet
  • csv
  • s3
  • postgres
  • mysql
  • mongodb
  • data-lakes

README badge

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

Runs ClickHouse SQL directly in Python against local files (parquet, CSV, JSON), remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud), and data lakes (Iceberg, Delta Lake) without a server. Use for analytical queries with window functions, cross-source joins, and parametrized statements via chdb.query() or Session for stateful pipelines.

Generated from the current SKILL.md.

Does chdb require a running ClickHouse server?
No. chdb is embedded ClickHouse SQL that runs directly in your Python process without needing a server.
What remote data sources can I query?
Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake, S3, and local files (parquet, CSV, JSON).
Can I join data across different sources in a single query?
Yes. You can use table functions like `mysql()`, `postgresql()`, `s3()`, and `deltaLake()` together in cross-source JOINs.
What Python versions does this support?
Python 3.9 and later on macOS or Linux.
Does this work for pandas-style DataFrame operations?
No. For method-chaining DataFrame workflows, use the chdb-datastore skill instead.

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