xiaohongshu
xiaohongshu
duckdb-remote-parquet-query
Query remote Parquet files via HTTP without downloading using DuckDB httpfs. Leverage column pruning, row filtering, and range requests for efficient bandwidth usage. Use for crypto/trading data distribution and analytics.
Full skill instructions
This skill teaches how to query remote Parquet files over HTTP/HTTPS without downloading the entire file, using DuckDB's httpfs extension. This pattern is essential for distributing large datasets (crypto OHLCV data, trade history, orderbook snapshots) while allowing users to run filtered queries with minimal bandwidth.
Core Pattern: DuckDB httpfs extension → HTTP range requests → Column/row pruning → Query only needed data
Use Cases:
Use this skill when you need to:
Common Questions:
# Install DuckDB (Python)
pip install duckdb>=1.0.0
# Or install DuckDB CLI
brew install duckdb # macOS
import duckdb
# 1. Setup connection with httpfs extension
conn = duckdb.connect(":memory:")
conn.execute("INSTALL httpfs")
conn.execute("LOAD httpfs")
# 2. Query remote Parquet file (replace URL)
url = "https://cdn.jsdelivr.net/gh/org/repo@tag/data.parquet"
result = conn.execute(f"""
SELECT date, symbol, close_price
FROM read_parquet('{url}')
WHERE symbol = 'BTCUSDT'
AND date >= '2024-01-01'
LIMIT 10
""").fetchall()
# Network transfer: ~60 KB (not full 20 MB file!)
for row in result:
print(row)
Key Points:
date, symbol, close_price columnsDuckDB's httpfs extension uses HTTP Range: bytes=X-Y headers to read only required portions of Parquet file:
Example:
SELECT date FROM table WHERE symbol = 'BTCUSDT' (1 of 327 symbols)Requirements:
Accept-Ranges: bytes headerOnly downloads columns referenced in SELECT/WHERE/ORDER BY:
-- Bad: Downloads all 20 columns
SELECT * FROM read_parquet('https://example.com/data.parquet')
-- Good: Downloads only 3 columns (85% bandwidth reduction)
SELECT date, symbol, volume FROM read_parquet('https://example.com/data.parquet')
DuckDB pushes WHERE filters to Parquet reader, skipping entire row groups:
-- Skips row groups where date < '2024-01-01'
SELECT * FROM read_parquet('https://example.com/data.parquet')
WHERE date >= '2024-01-01' -- Filter pushed to Parquet reader
Best filters (highest selectivity):
symbol = 'BTCUSDT'symbol IN ('BTCUSDT', 'ETHUSDT')scripts/remote_query_example.pyComprehensive working examples demonstrating:
Usage:
# View examples
cat skills/duckdb-remote-parquet-query/scripts/remote_query_example.py
# Run examples (replace URL first!)
python skills/duckdb-remote-parquet-query/scripts/remote_query_example.py
Copy-paste friendly: Each function is self-contained, can be adapted to your use case.
references/performance-optimization.mdIn-depth guide covering:
Usage: Reference when optimizing query performance or troubleshooting issues.
# Check HTTP headers
curl -I https://example.com/data.parquet
# Look for:
# HTTP/1.1 200 OK
# Accept-Ranges: bytes ← Required for efficient queries
If missing: Use CDN proxy (jsDelivr, Cloudflare) or download full file.
import duckdb
conn = duckdb.connect(":memory:") # Or persistent: "local.duckdb"
conn.execute("INSTALL httpfs") # Download extension (once)
conn.execute("LOAD httpfs") # Load into connection
url = "https://cdn.jsdelivr.net/gh/org/repo@tag/data.parquet"
# Check available columns and types
schema = conn.execute(f"""
DESCRIBE SELECT * FROM read_parquet('{url}')
""").fetchall()
for col in schema:
print(f"{col[0]:<20} {col[1]:<15}") # column_name, type
Why: Avoid trial-and-error queries, plan optimal SELECT statement.
Checklist:
SELECT *)Example:
result = conn.execute(f"""
SELECT date, symbol, volume, close_price
FROM read_parquet('{url}')
WHERE symbol = 'BTCUSDT'
AND date >= '2024-01-01'
ORDER BY date DESC
LIMIT 100
""").fetchall()
# Download filtered subset once
conn.execute(f"""
CREATE TABLE local_cache AS
SELECT *
FROM read_parquet('{url}')
WHERE date >= '2024-01-01'
AND symbol IN ('BTCUSDT', 'ETHUSDT', 'SOLUSDT')
""")
# Run many queries on local table (fast, no network)
counts = conn.execute("SELECT symbol, COUNT(*) FROM local_cache GROUP BY symbol").fetchall()
trends = conn.execute("SELECT date, AVG(volume) FROM local_cache GROUP BY date").fetchall()
When to cache:
# Export to Parquet
conn.execute("""
COPY (SELECT * FROM local_cache)
TO '/tmp/filtered_data.parquet' (FORMAT PARQUET)
""")
# Export to CSV
conn.execute("""
COPY (SELECT * FROM local_cache)
TO '/tmp/filtered_data.csv' (HEADER, DELIMITER ',')
""")
This skill is optimized for:
Data Types:
Common Patterns:
WHERE symbol IN (...) (1 of 300+ symbols → 99% data skipped)WHERE date BETWEEN '2024-01-01' AND '2024-12-31'WHERE volume > 1000000 (filter low-liquidity periods)Performance Examples (20 MB Parquet, 327 symbols, 2019-2025 history):
SELECT * defeats purpose of remote queriessymbol = 'BTCUSDT' (high) vs volume > 0 (low)GROUP BY date reduces network transfer 100-1000xDESCRIBE SELECT * shows available columns without data transferWHERE volume > 0 doesn't skip row groupsDiagnose:
curl -I https://your-url/data.parquet | grep "Accept-Ranges"
Solutions:
Accept-Ranges: bytes: Use CDN proxy (jsDelivr)https://cdn.jsdelivr.net/gh/org/repo@tag/file.parquetDiagnose:
EXPLAIN SELECT ... FROM read_parquet('url') WHERE ...
Solutions:
SELECT *)curl -w "@curl-format.txt" URLSolution:
# Install extension manually
conn.execute("INSTALL httpfs FROM 'https://extensions.duckdb.org'")
conn.execute("LOAD httpfs")
Solution:
SET memory_limit = '4GB'; -- Increase limit (default: 80% of RAM)
import duckdb
# Setup
conn = duckdb.connect(":memory:")
conn.execute("INSTALL httpfs; LOAD httpfs")
# Query availability database (327 symbols, 2019-2025, 20 MB file)
url = "https://cdn.jsdelivr.net/gh/org/[email protected]/availability.parquet"
# Get BTCUSDT availability for 2024 (downloads ~60 KB vs 20 MB)
result = conn.execute(f"""
SELECT date, is_available, file_size_bytes
FROM read_parquet('{url}')
WHERE symbol = 'BTCUSDT'
AND date >= '2024-01-01'
ORDER BY date
""").fetchall()
# Calculate uptime percentage
total_days = len(result)
available_days = sum(1 for row in result if row[1])
uptime_pct = 100.0 * available_days / total_days
print(f"BTCUSDT availability in 2024: {uptime_pct:.2f}% ({available_days}/{total_days} days)")
Performance:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience