[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DJFXPT2R9HQGDNNA6GRFQH":3,"skill-same:01M6DJFXPT2R9HQGDNNA6GRFQH":223},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":49,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M6DJFXPT2R9HQGDNNA6GRFQH","duckdb",null,"DuckDB v1.5 spatial\u002FGIS analytics with 155+ ST_* functions. Use this skill for DuckDB, spatial queries, GeoParquet, geometry data, or geospatial analytics. Workflow: Discovery → Understanding → Analysis (Phase 1: glob\u002FDESCRIBE\u002FST_Read_Meta, Phase 2: SUMMARIZE\u002Fparquet_metadata\u002FCRS detection, Phase 3: targeted queries). Query profiling with EXPLAIN ANALYZE for troubleshooting. Spatial: CRS\u002FEPSG transforms, automatic R-Tree indexes, distance\u002Farea calculations, spatial joins, H3\u002FA5\u002FS2 indexing, QUADBIN tiling, geometry shredding (3x compression), core GEOMETRY type (no extension), GeoParquet (v1\u002Fv2\u002FBOTH), GDAL formats (Shapefile, GeoJSON, GeoPackage, FlatGeobuf, OSM). Data sources: Overture Maps (6 themes), DuckLake lakehouse, Apache Iceberg (REST catalogs, time travel), BigQuery connector, raster (RaQuet, raquet-io CLI), VARIANT type. Also: BM25\u002FFTS, HNSW vector search, friendly SQL, Python API, v1.5 breaking changes, common pitfalls.","yharby\u002Fduckdb-skill","yharby","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F13020265?v=4","01M6DJFTNJB8T1EDMH8SCVS9BG","Youssef Harby","01M6DJFTSTAJ6N4THXKJZ9D8A8",8,"MIT","https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002FSKILL.md",[],[5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"common","bm25","io","indexing","geometry","time","query","maps","Connector","cli","analyze","api","analysis","Meta","vector","search","iceberg","apache","workflow","2026-11-10 10:12:30",false,"---\nname: duckdb\ndescription: \"DuckDB v1.5 spatial\u002FGIS analytics with 155+ ST_* functions. Use this skill for DuckDB, spatial queries, GeoParquet, geometry data, or geospatial analytics. Workflow: Discovery → Understanding → Analysis (Phase 1: glob\u002FDESCRIBE\u002FST_Read_Meta, Phase 2: SUMMARIZE\u002Fparquet_metadata\u002FCRS detection, Phase 3: targeted queries). Query profiling with EXPLAIN ANALYZE for troubleshooting. Spatial: CRS\u002FEPSG transforms, automatic R-Tree indexes, distance\u002Farea calculations, spatial joins, H3\u002FA5\u002FS2 indexing, QUADBIN tiling, geometry shredding (3x compression), core GEOMETRY type (no extension), GeoParquet (v1\u002Fv2\u002FBOTH), GDAL formats (Shapefile, GeoJSON, GeoPackage, FlatGeobuf, OSM). Data sources: Overture Maps (6 themes), DuckLake lakehouse, Apache Iceberg (REST catalogs, time travel), BigQuery connector, raster (RaQuet, raquet-io CLI), VARIANT type. Also: BM25\u002FFTS, HNSW vector search, friendly SQL, Python API, v1.5 breaking changes, common pitfalls.\"\n---\n\n# DuckDB v1.5 Skill\n\n> DuckDB v1.5.0 \"Variegata\" — Released 2026-03-09.\n\n## How to Think: Discovery → Understanding → Analysis\n\nThe most common mistake is jumping straight to queries. Instead, follow this workflow — it prevents wrong assumptions, bad joins, and wasted work.\n\n### Phase 1: Discover the Data\n\nBefore writing any analytical query, find out what you're working with.\n\n**Local files — use glob patterns to find them:**\n\n```sql\n-- Find what files exist (Parquet, CSV, JSON, GeoJSON, etc.)\nFROM glob('data\u002F*.parquet');\nFROM glob('**\u002F*.csv');\nFROM glob('\u002Fpath\u002Fto\u002Fproject\u002F**\u002F*.geojson');\n```\n\n**Remote files — always load httpfs first, then probe:**\n\n```sql\nINSTALL httpfs; LOAD httpfs;\n-- For S3, also set the region:\nSET s3_region = 'us-west-2';\n\n-- Remote Parquet (only reads metadata, not full file)\nDESCRIBE FROM 'https:\u002F\u002Fexample.com\u002Fdata.parquet';\n\n-- S3 \u002F Azure \u002F GCS\nDESCRIBE FROM 's3:\u002F\u002Fbucket\u002Fpath\u002Ffile.parquet';\n\n-- S3 buckets with dots in the name (e.g., source.coop) need path-style URLs,\n-- because virtual-hosted style breaks SSL certificate validation:\nSET s3_url_style = 'path';\nDESCRIBE FROM 's3:\u002F\u002Fus-west-2.opendata.source.coop\u002Frepo\u002Fdata.parquet';\n\n-- Hive-partitioned datasets — check partition structure\nFROM parquet_metadata('s3:\u002F\u002Fbucket\u002Fdataset\u002F**\u002F*.parquet') LIMIT 5;\n```\n\n**Databases — inspect what's available:**\n\n```sql\n-- Attached databases\nSHOW ALL TABLES;\nDESCRIBE table_name;\n\n-- External DuckDB files (new in v1.5 — no ATTACH needed)\nFROM read_duckdb('other.duckdb', table_name := 'my_table');\n\n-- External databases via ODBC (new in v1.5, requires INSTALL odbc_scanner)\n-- odbc_connect(conn_str) + odbc_query(conn, sql)\n```\n\n**Discover functions from DuckDB itself** — when unsure about a function signature:\n\n```sql\n-- Search for functions by name pattern\nSELECT function_name, parameters, return_type\nFROM duckdb_functions() WHERE function_name LIKE 'ST_Coverage%';\n\n-- List all extensions and their status\nFROM duckdb_extensions();\n\n-- List all settings\nFROM duckdb_settings() WHERE name LIKE '%geometry%';\n```\n\n**Geospatial files — check layers and metadata:**\n\n```sql\nLOAD spatial;\nSELECT * FROM ST_Read_Meta('data.gpkg');       -- layers, CRS, field schemas\nSELECT * FROM ST_Read_Meta('data.gdb');        -- ESRI File Geodatabase\n```\n\n### Phase 2: Understand the Shape\n\nOnce you know WHAT files exist, understand their structure before querying.\n\n```sql\n-- Schema: column names and types (instant, reads only metadata)\nDESCRIBE FROM 'data.parquet';\nDESCRIBE FROM 'data.csv';\n\n-- Stats: min, max, approx_unique, avg, std, quartiles, nulls (scans full data)\nSUMMARIZE FROM 'data.parquet';\nSUMMARIZE FROM 'data.csv';\n\n-- Quick sample: see actual values (avoids scanning everything)\nFROM 'data.parquet' LIMIT 10;\nFROM 'data.csv' LIMIT 10;\n\n-- Row count estimate (fast for Parquet — reads metadata only)\nSELECT count(*) FROM 'data.parquet';\n\n-- For Parquet: row group structure, column statistics, file-level metadata\nFROM parquet_metadata('data.parquet');\nFROM parquet_schema('data.parquet');\nFROM parquet_kv_metadata('data.parquet');  -- GeoParquet metadata lives here\n```\n\nThis phase is critical because:\n- DESCRIBE tells you column types — you'll know if geometry is WKB blob vs native GEOMETRY\n- SUMMARIZE reveals data quality issues (null percentages, unexpected ranges, cardinality)\n- A quick LIMIT sample shows actual values — field naming conventions, coordinate order, encoding\n- For spatial data: you need to know the CRS before any spatial operations\n\n### Detecting the CRS\n\nKnowing the CRS is essential before any spatial operation. The method depends on how geometry is stored:\n\n**Step 1: Identify the format.** Run DESCRIBE first — the column type tells you which case you're in:\n\n| Column type | Format | CRS location |\n|---|---|---|\n| `geometry('epsg:4326')` | GeoParquet or native Parquet geometry | CRS in column type (spatial resolves EPSG) |\n| `geometry` (no CRS) | Native Parquet geometry with no CRS, or CRS not resolved | Check `parquet_schema()` logical_type |\n| `blob` | Plain Parquet with WKB | No CRS embedded — must know from context |\n\n**Case 1: GeoParquet (Parquet with `geo` KV metadata)**\n\n```sql\n-- Quickest: DESCRIBE shows CRS in the column type (requires LOAD spatial for EPSG resolution)\nLOAD spatial;\nDESCRIBE FROM 'data.parquet';\n-- → geom  geometry('epsg:4326')\n\n-- Or use ST_CRS on a row\nSELECT ST_CRS(geom) FROM 'data.parquet' LIMIT 1;\n-- → 'EPSG:4326'\n\n-- Without spatial loaded, DESCRIBE still works but shows raw PROJJSON instead of the short code:\n-- → geom  geometry('{\"$schema\":\"https:\u002F\u002Fproj.org\u002Fschemas\u002Fv0.5\u002Fprojjson.schema.json\",...}')\n\n-- Full GeoParquet metadata inspection (no spatial extension needed):\nWITH kv AS (\n    SELECT file_name,\n           decode(key) AS key_str,\n           decode(value)::JSON AS geo_json\n    FROM parquet_kv_metadata('data\u002F*.parquet')\n)\nSELECT file_name,\n       geo_json->>'$.columns.geometry.encoding' AS encoding,\n       geo_json->'$.columns.geometry.geometry_types' AS geom_types,\n       geo_json->'$.columns.geometry.bbox' AS bbox,\n       geo_json->'$.columns.geometry.crs.id.authority' AS crs_authority,\n       geo_json->'$.columns.geometry.crs.id.code' AS crs_code,\n       geo_json->>'$.primary_column' AS primary_column\nFROM kv WHERE key_str = 'geo';\n-- If crs is NULL → default is OGC:CRS84 (WGS84 lon\u002Flat) per GeoParquet spec\n```\n\n**Case 2: Native Parquet geometry (Format 2.11+ — no `geo` key)**\n\nThese files store CRS in the Parquet schema's logical type, not in KV metadata. DuckDB reads it automatically.\n\n```sql\n-- DESCRIBE shows the resolved CRS when spatial can resolve it\nLOAD spatial;\nDESCRIBE FROM 'native_geo.parquet';\n-- → geometry  geometry('epsg:5070')    ← CRS resolved\n-- → geometry  geometry                 ← CRS not resolved or absent\n\n-- Check the raw Parquet logical type to see how CRS is encoded\nSELECT name, logical_type\nFROM parquet_schema('native_geo.parquet')\nWHERE logical_type LIKE 'GeometryType%';\n-- → geometry  GeometryType(crs=srid:5070)     ← SRID-based CRS\n-- → geometry  GeometryType(crs=\u003Cprojjson>)     ← full PROJJSON CRS\n-- → geometry  GeometryType(crs=\u003Cnull>)         ← no CRS specified\n```\n\n**Case 3: Plain Parquet (WKB blob, no geometry metadata)**\n\n```sql\n-- DESCRIBE shows blob type — no CRS information available\nDESCRIBE FROM 'data.parquet';\n-- → wkb_geom  blob\n\n-- No CRS is embedded. You must know the CRS from documentation or context,\n-- then assign it after converting to GEOMETRY:\nLOAD spatial;\nSELECT ST_SetCRS(ST_GeomFromWKB(wkb_geom), 'EPSG:4326') FROM 'data.parquet';\n```\n\n**Case 4: GDAL-supported formats (GPKG, Shapefile, GDB, FlatGeobuf, GeoJSON, KML)**\n\n```sql\n-- Use ST_Read_Meta to get CRS from any GDAL-readable format\nLOAD spatial;\nSELECT\n    layers[1].geometry_fields[1].crs.auth_name AS authority,\n    layers[1].geometry_fields[1].crs.auth_code AS code\nFROM ST_Read_Meta('data.gpkg');\n-- → EPSG  4326\n\n-- For multi-layer files, inspect all layers:\nSELECT * FROM ST_Read_Meta('data.gdb');\n```\n\n**Case 5: H3\u002Fspatial-indexed data (no geometry column)**\n\nSome datasets store location as H3 BIGINT indices instead of geometry columns. H3 cells are always WGS84 — the CRS is implicit. Derive coordinates on the fly:\n\n```sql\nINSTALL h3 FROM community; LOAD h3;\nSELECT h3_index,\n       h3_h3_to_string(h3_index) AS h3_hex,  -- BIGINT → hex string (e.g., '820007fffffffff')\n       h3_cell_to_lat(h3_index) AS lat,\n       h3_cell_to_lng(h3_index) AS lon\nFROM 'data.parquet' LIMIT 5;\n```\n\n### Phase 3: Analyze with Purpose\n\nNow that you understand the data, write targeted queries. Some principles:\n\n**Start narrow, expand.** Query a small subset first (WHERE + LIMIT), verify the logic, then remove the constraints.\n\n**Use FROM-first syntax** — it's more readable and DuckDB-idiomatic:\n\n```sql\n-- Instead of SELECT * FROM tbl WHERE ...\nFROM tbl SELECT col1, col2 WHERE x > 10;\nFROM tbl;  -- implicit SELECT *\n```\n\n**Use GROUP BY ALL** — let DuckDB infer grouping columns from context:\n\n```sql\nSELECT region, category, sum(amount), count()\nFROM sales\nGROUP BY ALL;  -- infers GROUP BY region, category\n```\n\n**Use SUMMARIZE on intermediate results** to verify transformations:\n\n```sql\nSUMMARIZE (\n    SELECT *, ST_Area_Spheroid(geom) AS area_m2\n    FROM parcels\n    WHERE area_m2 > 0\n);\n-- Check: are the area values reasonable? Any nulls introduced?\n```\n\n**Chain analysis steps** — use CTEs or CREATE OR REPLACE TABLE for iterative exploration:\n\n```sql\nCREATE OR REPLACE TABLE enriched AS\n    SELECT p.*, z.zone_name\n    FROM points p\n    JOIN zones z ON ST_Intersects(p.geom, z.geom);\n\nSUMMARIZE enriched;  -- verify the join didn't explode or lose rows\n```\n\n### When Queries Fail or Perform Poorly: Use EXPLAIN ANALYZE\n\nIf a query is **complex, slow, or failing unexpectedly**, use `EXPLAIN ANALYZE` to understand what's happening. It shows the query plan with runtime metrics — actual row counts, estimated cardinalities, and timing for each operation.\n\n```sql\nEXPLAIN ANALYZE SELECT ... ;\n```\n\n**When to use it:**\n- Query runs slower than expected\n- Getting unexpected results or row counts\n- Complex joins or subqueries that you want to verify\n- Need to see if indexes or spatial joins are being used\n- Want to break down a complex query into analyzable parts\n\nThe output shows a tree of operations with:\n- **EC (Estimated Cardinality)**: what DuckDB predicted\n- **Actual cardinality**: what actually happened\n- **Timing**: cumulative wall-clock time per operator\n\nIf estimated vs actual cardinalities are far off, or if certain operations dominate the time, that tells you where to focus optimization. For deep-dive details and examples, read `refs\u002Fexplain-analyze.md`.\n\n## v1.5 Breaking Changes — Must Know\n\nThese trip up anyone using pre-v1.5 patterns:\n\n| Old pattern | v1.5+ correct way |\n|---|---|\n| `x -> x + 1` (arrow lambda) | `lambda x: x + 1` — arrow syntax is deprecated, errors in v2.0 |\n| Missing `geometry_always_xy` | `SET geometry_always_xy = true;` after `LOAD spatial` — v1.5 warns, v2.1 makes it default |\n| `INSTALL spatial` for GEOMETRY columns | Not needed — GEOMETRY is a core type in v1.5 (only INSTALL spatial for ST_* functions) |\n| `GEOMETRY('EPSG:4326')` without spatial | EPSG codes require spatial extension. Without it, use `GEOMETRY('OGC:CRS84')` or plain `GEOMETRY` |\n| Mixing CRS in spatial operations | v1.5 errors at bind time. Use consistent CRS or strip with `::GEOMETRY` |\n| `.fetch_arrow_table()` with parquet geometry | Use `.arrow().read_all()` — crashes with `TransactionContext` error (see `refs\u002Fpython-api.md`) |\n| `TRY_CAST(x AS GEOMETRY)` | `TRY(ST_GeomFromText(x))` — TRY_CAST broken for GEOMETRY in v1.5 |\n| `ST_Read('f.fgb', spatial_filter_box=...)` | Removed in v1.5 — use `WHERE geom && ST_MakeBox2D(...)` instead (auto-pushed down) |\n| `ST_Read(..., sequential_layer_scan=true)` | Removed in v1.5 — auto-applied for OSM format |\n| `register_geoarrow_extensions()` in Python | No longer needed — GEOMETRY defaults to GeoArrow in Arrow export |\n| Invalid HEXWKB silently accepted | v1.5 now throws proper error on invalid HEXWKB input |\n\n## Core GEOMETRY Type (no extension needed)\n\n```sql\n-- GEOMETRY is now a built-in type with optional CRS parameter\nCREATE TABLE t1 (g GEOMETRY);                    -- no CRS\nCREATE TABLE t2 (g GEOMETRY('OGC:CRS84'));       -- built-in CRS (no spatial needed)\nCREATE TABLE t3 (g GEOMETRY('EPSG:4326'));       -- requires LOAD spatial for EPSG codes\n\n-- Built-in functions (no LOAD spatial needed):\nST_GeomFromWKB(blob)          -- WKB → geometry\nST_AsWKB(geom)                -- geometry → WKB (alias: ST_AsBinary)\nST_AsWKT(geom)                -- geometry → WKT (alias: ST_AsText)\nST_Intersects_Extent(a, b)    -- bbox intersection\na && b                        -- operator alias (uses row-group stats!)\nST_CRS(geom)                  -- get CRS identifier\nST_SetCRS(geom, 'OGC:CRS84') -- assign CRS (no coordinate transform)\n'POINT(0 0)'::GEOMETRY        -- cast from WKT\n```\n\nSubtypes: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection. Vertices can have Z, M, or ZM dimensions.\n\n### CRS System\n\n```sql\nSELECT * FROM duckdb_coordinate_systems();  -- list all known CRSs (works without spatial)\n-- Built-in: OGC:CRS84, OGC:CRS83. Spatial ext adds 7,000+ EPSG codes.\n-- Accepts: AUTH:CODE, full PROJJSON, full WKT2-2019\nSET ignore_unknown_crs = true;  -- silently drop unknown CRS (works without spatial)\n```\n\n### Geometry Shredding (~3x compression)\n\nAutomatic: when all geometries in a row group share the same subtype, DuckDB decomposes to STRUCT\u002FLIST\u002FDOUBLE with ALP compression. Control with `SET geometry_minimum_shredding_size = 30000` (default), `0` (always), `-1` (disable). Not shredded: GeometryCollection, empty geometries, mixed subtypes.\n\n## Spatial Recipes (requires `LOAD spatial`)\n\n### Session Setup\n\nAlways start spatial work with:\n\n```sql\nINSTALL spatial; LOAD spatial;\nSET geometry_always_xy = true;  -- lon\u002Flat = x\u002Fy consistently\n```\n\n### Spatial Joins (automatic R-tree, v1.3+)\n\n```sql\n-- Point-in-polygon (automatic R-tree, no index creation needed)\nSELECT p.*, z.zone_name\nFROM points p JOIN zones z ON ST_Intersects(p.geom, z.geom);\n\n-- Proximity join — ST_DWithin is fastest (triggers SPATIAL_JOIN operator)\nSELECT a.*, b.*\nFROM table_a a JOIN table_b b ON ST_DWithin(a.geom, b.geom, 1000);\n```\n\nPredicates that trigger SPATIAL_JOIN: `ST_Intersects`, `ST_Contains`, `ST_ContainsProperly`, `ST_Within`, `ST_Covers`, `ST_CoveredBy`, `ST_Overlaps`, `ST_Touches`, `ST_Crosses`, `ST_DWithin`, `&&` \u002F `ST_Intersects_Extent`.\n\n**Spatial join gotchas:**\n- R-Tree indexes created with `CREATE INDEX ... USING RTREE` are for `WHERE` filter scans only — they are NOT used for `JOIN ... ON ST_Intersects()`. The spatial join optimizer builds its own internal R-tree. They are independent features.\n- For very small build sides, block-nested-loop may outperform the spatial join optimizer. DuckDB's vectorized constant-vector optimization is very fast for small tables.\n- Spatial operations do NOT spill to disk — OOM can occur with large spatial pipelines. Monitor memory usage.\n\n### CRS Transform\n\n```sql\n-- v1.5: 2-arg form (source CRS inferred from typed column)\nSELECT ST_Transform(geom, 'EPSG:4326') FROM tbl;\n\n-- Explicit source\u002Ftarget\nSELECT ST_Transform(geom, 'EPSG:4326', 'EPSG:3857') FROM tbl;\n```\n\n### Distance & Area\n\n```sql\nSELECT ST_Distance_Spheroid(ST_Point(-74.0, 40.7), ST_Point(-0.1, 51.5));  -- meters\nSELECT ST_Distance_Sphere(a.geom, b.geom);   -- haversine, meters\nSELECT ST_Area_Spheroid(geom);                -- m²\nSELECT ST_Length_Spheroid(geom);              -- meters\n-- ST_Point(x, y) = ST_Point(lon, lat) — x is always longitude\n```\n\n### Export\n\n```sql\n-- GeoParquet (default: v1 metadata)\nCOPY tbl TO 'output.parquet' (FORMAT PARQUET);\n\n-- Max compatibility: GeoParquet v1 metadata + native Parquet geometry stats\nCOPY tbl TO 'output.parquet' (FORMAT PARQUET, GEOPARQUET_VERSION 'BOTH');\n\n-- GDAL formats (read refs\u002Fgdal-formats.md for full reference)\nCOPY tbl TO 'out.geojson' WITH (FORMAT GDAL, DRIVER 'GeoJSON');\nCOPY tbl TO 'out.gpkg' WITH (FORMAT GDAL, DRIVER 'GPKG', LAYER_NAME 'my_layer');\nCOPY tbl TO 'out.shp' WITH (FORMAT GDAL, DRIVER 'ESRI Shapefile');\n\n-- Hilbert-ordered for best spatial query performance\nCOPY (SELECT * FROM tbl ORDER BY ST_Hilbert(geom)) TO 'sorted.parquet' (FORMAT PARQUET);\n```\n\n### R-Tree Index\n\n```sql\n-- Populate table FIRST, then create index (bulk load is 10x+ faster)\nCREATE INDEX idx ON tbl USING RTREE (geom);\n-- Auto-used with WHERE spatial predicates (NOT with JOIN — see spatial join notes above)\n```\n\n**Note:** R-Tree index scans can be skipped if the table also has a PRIMARY KEY or other index type. If spatial filtering seems slow on a table with a PK, verify with `EXPLAIN ANALYZE`.\n\n## Friendly SQL Quick Reference\n\n```sql\n-- FROM-first\nFROM tbl;                                      -- implicit SELECT *\nFROM tbl SELECT col1, col2 WHERE x > 10;       -- FROM leads, then SELECT, then WHERE\n\n-- GROUP BY ALL \u002F ORDER BY ALL\nSELECT region, count() FROM sales GROUP BY ALL ORDER BY ALL;\n\n-- Star expressions\nSELECT * EXCLUDE (internal_id, tmp) FROM tbl;\nSELECT * REPLACE (upper(name) AS name) FROM tbl;\n\n-- COLUMNS() — apply across matching columns\nSELECT min(COLUMNS('.*_price')) FROM products;\nSELECT COLUMNS(lambda c: c LIKE '%name%') FROM tbl;\n\n-- Lambda syntax (v1.5+ — arrow syntax deprecated)\nSELECT list_transform([1,2,3], lambda x: x * 2);\nSELECT list_filter(range(10), lambda x: x % 2 = 0);\n\n-- Dot operator chaining\nSELECT ('hello world').upper().split(' ').list_transform(lambda x: x.len());\n\n-- List comprehension\nSELECT [x * 2 FOR x IN [1, 2, 3]];\n\n-- ASOF join (time-series)\nSELECT * FROM trades ASOF JOIN quotes USING (symbol, timestamp);\n\n-- LATERAL join\nSELECT * FROM customers, LATERAL (SELECT * FROM orders WHERE orders.cust_id = customers.id LIMIT 3);\n\n-- POSITIONAL join (by row position)\nSELECT * FROM t1 POSITIONAL JOIN t2;\n\n-- Direct file queries (no CREATE TABLE needed)\nFROM 'data.csv';\nFROM 'data.parquet';\nFROM 'https:\u002F\u002Fexample.com\u002Fdata.parquet';\nFROM 'data\u002F**\u002F*.parquet';  -- glob patterns\n\n-- Top-N aggregates (no window function needed)\nSELECT max(val, 3) FROM t GROUP BY grp;           -- top-3 per group\nSELECT arg_max(name, score, 3) FROM t GROUP BY grp;  -- names of top-3\n\n-- FILTER clause\nSELECT count() FILTER (status = 'active'), sum(amt) FILTER (year = 2025) FROM orders;\n\n-- PIVOT \u002F UNPIVOT\nPIVOT sales ON product USING sum(amount);\nUNPIVOT monthly ON jan, feb, mar INTO NAME month VALUE amount;\n\n-- Variables\nSET VARIABLE my_threshold = 100;\nSELECT * FROM tbl WHERE val > getvariable('my_threshold');\n\n-- Trailing commas are OK\nSELECT col1, col2, FROM tbl;\n\n-- Percentage LIMIT\nSELECT * FROM tbl LIMIT 10%;\n```\n\n## VARIANT Type (new in v1.5)\n\nTyped binary semi-structured data. Better compression and query performance than JSON.\n\n```sql\nSELECT 42::VARIANT;\nSELECT {'name': 'Alice', 'age': 30}::VARIANT;\nSELECT variant_typeof(data) FROM tbl;  -- inspect type\nSELECT data.name FROM tbl;             -- dot notation\n-- Supported in Parquet (shredded), DuckLake, Delta Lake\n```\n\n## Key Extensions\n\n| Extension | Purpose | Install |\n|-----------|---------|---------|\n| `spatial` | ST_* functions, GDAL I\u002FO | `INSTALL spatial; LOAD spatial;` |\n| `httpfs` | Remote files (S3\u002FHTTP\u002FGCS\u002FAzure) | `INSTALL httpfs; LOAD httpfs;` |\n| `h3` | H3 hexagonal spatial index | `INSTALL h3 FROM community; LOAD h3;` |\n| `a5` | A5 pentagonal index | `INSTALL a5 FROM community; LOAD a5;` |\n| `geography` | S2 spherical geometry | community extension |\n| `bigquery` | Connect to Google BigQuery | `FORCE INSTALL bigquery FROM community; LOAD bigquery;` |\n| `iceberg` | Apache Iceberg tables (read\u002Fwrite, catalogs) | `INSTALL iceberg; LOAD iceberg;` |\n| `ducklake` | Lakehouse (SQL catalog + Parquet) | `INSTALL ducklake; LOAD ducklake;` |\n| `odbc_scanner` | Query via ODBC (new in v1.5) | `INSTALL odbc_scanner; LOAD odbc_scanner;` |\n| `fts` | Full-text search (BM25) | `INSTALL fts; LOAD fts;` |\n| `vss` | Vector similarity search (HNSW) | `INSTALL vss; LOAD vss;` |\n\n## Common Pitfalls\n\n| Mistake | Fix |\n|---------|-----|\n| `x -> x + 1` | `lambda x: x + 1` |\n| Mixing CRS in spatial ops | Ensure consistent CRS or strip with `::GEOMETRY` |\n| Not setting `geometry_always_xy` | `SET geometry_always_xy = true;` after `LOAD spatial` |\n| `ST_Point(lat, lon)` | `ST_Point(lon, lat)` — x is longitude |\n| `INSTALL spatial` for GEOMETRY columns | Not needed in v1.5 — GEOMETRY is core |\n| `NOT ST_Intersects(a, b)` in JOINs | Causes OOM — use `NOT EXISTS (SELECT 1 ... WHERE ST_Intersects(...))` |\n| `ST_Transform` without `ST_SetCRS` | Output has no CRS metadata — always set CRS on input first |\n| FlatGeobuf WHERE ST_Intersects | Use `WHERE geom && ST_MakeBox2D(...)` — bbox auto-pushed to GDAL, then predicate evaluated |\n| Large geometries in GeoParquet | Default row group too big → full file download — use `ROW_GROUP_SIZE 2500` |\n| `ST_DWithin_Spheroid` in JOINs | No SPATIAL_JOIN optimization — use `ST_DWithin` instead |\n| `ST_Intersection_Agg(geom)` without ORDER BY | Result depends on processing order (not associative) — use `ST_Intersection_Agg(geom ORDER BY id)` |\n| `ST_AsEWKB` \u002F `ST_AsEWKT` | Don't exist — DuckDB stores SRID at column\u002Ftype level, not per-geometry value |\n| COPY multiple layers to same GPKG | File gets overwritten — only one layer per COPY. Use FileGDB for multi-layer export |\n| Large GDAL exports to S3 | Fails with \"Unknown part number\" — export locally first, then upload |\n| `ST_Read_Meta` on Parquet files | Crashes — Parquet is handled by the parquet extension, not GDAL\u002Fspatial. Use `parquet_kv_metadata()` |\n| KML export with `SRS 'EPSG:4326'` | GDAL axis order issue — coordinates may be swapped. Set `geometry_always_xy = true` first |\n\n## Reference Files — Load on Demand\n\nRead these ONLY when the task requires the specific topic. Do not preload.\n\n**Geospatial formats and I\u002FO:**\n- `refs\u002Fgdal-formats.md` — Read when: converting between formats (GPKG, Shapefile, GeoJSON, FlatGeobuf, KML, FileGDB), querying WFS\u002FAPI endpoints.\n- `refs\u002Foverture-maps.md` — Read when: working with **Overture Maps** data (places, buildings, roads — includes S3\u002FAzure paths, bbox filtering, GeoParquet metadata inspection).\n\n**Spatial function deep-dives (read `refs\u002Fspatial\u002Findex.md` first for the function index, then drill in):**\n- `refs\u002Fspatial\u002Fcreation.md` — ST_Point, ST_Point2D, ST_Point3D, ST_Point4D, ST_MakePoint, ST_MakeLine, ST_MakePolygon, ST_MakeBox2D, ST_MakeEnvelope, ST_Collect, ST_Multi, ST_BuildArea\n- `refs\u002Fspatial\u002Fpredicates.md` — ST_Intersects, ST_Intersects_Extent, ST_Contains, ST_ContainsProperly, ST_CoveredBy, ST_Covers, ST_Crosses, ST_DWithin, ST_DWithin_GEOS, ST_DWithin_Spheroid, ST_Disjoint, ST_Equals, ST_Overlaps, ST_Touches, ST_Within, ST_WithinProperly\n- `refs\u002Fspatial\u002Fmeasurement.md` — ST_Distance, ST_Distance_GEOS, ST_Distance_Sphere, ST_Distance_Spheroid, ST_Area, ST_Area_Spheroid, ST_Length, ST_Length_Spheroid, ST_Perimeter, ST_Perimeter_Spheroid, ST_Azimuth, ST_ClosestPoint, ST_ShortestLine\n- `refs\u002Fspatial\u002Ftransforms.md` — ST_Transform, ST_Buffer, ST_Simplify, ST_SimplifyPreserveTopology, ST_ReducePrecision, ST_RemoveRepeatedPoints, ST_Reverse, ST_FlipCoordinates, ST_Force2D, ST_Force3DM, ST_Force3DZ, ST_Force4D, ST_MakeValid, ST_Normalize, ST_Centroid, ST_ConvexHull, ST_ConcaveHull, ST_Envelope, ST_Boundary, ST_Difference, ST_Intersection, ST_Union, ST_Affine, ST_VoronoiDiagram, ST_MaximumInscribedCircle, ST_MinimumRotatedRectangle, ST_PointOnSurface, ST_Hilbert, ST_Node\n- `refs\u002Fspatial\u002Faccessors.md` — ST_X, ST_Y, ST_Z, ST_M, ST_HasM, ST_HasZ, ST_ZMFlag, ST_XMax, ST_XMin, ST_YMax, ST_YMin, ST_ZMax, ST_ZMin, ST_MMax, ST_MMin, ST_Dimension, ST_NGeometries, ST_NInteriorRings, ST_NPoints, ST_NumGeometries, ST_NumInteriorRings, ST_NumPoints, ST_ExteriorRing, ST_InteriorRingN, ST_StartPoint, ST_EndPoint, ST_PointN, ST_Points, ST_IsClosed, ST_IsEmpty, ST_IsRing, ST_IsSimple, ST_IsValid, ST_Extent, ST_Extent_Approx, ST_Dump, ST_CollectionExtract, ST_Polygonize, ST_GeometryType\n- `refs\u002Fspatial\u002Fconversion-io.md` — ST_AsText, ST_AsWKB, ST_AsGeoJSON, ST_AsHEXWKB, ST_AsMVTGeom, ST_AsSVG, ST_GeomFromText, ST_GeomFromWKB, ST_GeomFromGeoJSON, ST_GeomFromHEXWKB, ST_GeomFromHEXEWKB\n- `refs\u002Fspatial\u002Faggregates.md` — ST_Union_Agg, ST_MemUnion_Agg, ST_Extent_Agg, ST_Envelope_Agg, ST_Intersection_Agg, ST_AsMVT, ST_CoverageInvalidEdges_Agg, ST_CoverageSimplify_Agg, ST_CoverageUnion_Agg\n- `refs\u002Fspatial\u002Flinear-ref.md` — ST_LineInterpolatePoint, ST_LineInterpolatePoints, ST_LineLocatePoint, ST_LineMerge, ST_LineSubstring, ST_LocateAlong, ST_LocateBetween, ST_InterpolatePoint, ST_LineString2DFromWKB, ST_Polygon2DFromWKB, ST_Point2DFromWKB\n- `refs\u002Fspatial\u002Fcoverage-tiling.md` — ST_CoverageUnion, ST_CoverageInvalidEdges, ST_CoverageSimplify, ST_TileEnvelope, ST_QuadKey\n- `refs\u002Fspatial\u002Fmacros.md` — ST_Rotate, ST_RotateX, ST_RotateY, ST_RotateZ, ST_Scale, ST_TransScale, ST_Translate\n- `refs\u002Fspatial\u002Ftable-functions.md` — ST_Read, ST_ReadOSM, ST_ReadSHP, ST_Read_Meta, ST_Drivers, ST_GeneratePoints\n- `refs\u002Fspatial\u002Fcore-v15.md` — ST_GeomFromWKB, ST_CRS, ST_SetCRS (v1.5 built-in, no extension needed)\n- `refs\u002Fspatial\u002Fa5-s2.md` — A5: a5_lonlat_to_cell, a5_cell_to_lonlat, a5_cell_to_boundary, a5_cell_to_parent, a5_cell_to_children, a5_cell_area, a5_get_resolution, a5_get_num_cells, a5_get_res0_cells, a5_compact, a5_uncompact. S2\u002FGeography: s2_area, s2_dimension, s2_distance, s2_dwithin, s2_is_valid, s2_is_valid_reason, s2_isempty, s2_length, s2_max_distance, s2_num_points, s2_perimeter, s2_x, s2_y, s2_bounds_box, s2_box, s2_box_intersects, s2_box_struct, s2_box_union, s2_box_wkb, s2_covering, s2_covering_fixed_level, s2_cellfromlonlat, s2_cellfromwkb, s2_arbitrarycellfromwkb, s2_cell_child, s2_cell_contains, s2_cell_edge_neighbor, s2_cell_from_token, s2_cell_intersects, s2_cell_level, s2_cell_parent, s2_cell_range_max, s2_cell_range_min, s2_cell_token, s2_cell_vertex, s2_astext, s2_aswkb, s2_format, s2_geogfromtext, s2_geogfromtext_novalidate, s2_geogfromwkb, s2_geogfromwkb_novalidate, s2_prepare, s2_contains, s2_equals, s2_intersects, s2_mayintersect, s2_difference, s2_intersection, s2_union, s2_data_city, s2_data_country, s2_data_cities, s2_data_countries\n\n**Spatial indexing and tiling:**\n- `refs\u002Fspatial-indexes.md` — Read when: comparing H3 vs A5 vs S2 vs QUADBIN to choose the right spatial index. Overview and comparison tables.\n- `refs\u002Fh3.md` — h3_latlng_to_cell, h3_latlng_to_cell_string, h3_cell_to_lat, h3_cell_to_lng, h3_cell_to_latlng, h3_string_to_h3, h3_h3_to_string, h3_cell_to_parent, h3_cell_to_children, h3_cell_to_children_size, h3_cell_to_center_child, h3_cell_to_child_pos, h3_child_pos_to_cell, h3_get_resolution, h3_get_base_cell_number, h3_is_valid_cell, h3_is_pentagon, h3_is_res_class_iii, h3_get_icosahedron_faces, h3_grid_disk, h3_grid_disk_distances, h3_grid_disk_unsafe, h3_grid_ring, h3_grid_ring_unsafe, h3_grid_path_cells, h3_grid_distance, h3_max_grid_disk_size, h3_cell_to_boundary_wkt, h3_cell_to_boundary_wkb, h3_cells_to_multi_polygon_wkt, h3_cells_to_multi_polygon_wkb, h3_directed_edge_to_boundary_wkt, h3_directed_edge_to_boundary_wkb, h3_polygon_wkt_to_cells, h3_polygon_wkb_to_cells, h3_polygon_wkt_to_cells_string, h3_polygon_wkb_to_cells_string, h3_polygon_wkt_to_cells_experimental, h3_polygon_wkb_to_cells_experimental, h3_compact_cells, h3_uncompact_cells, h3_origin_to_directed_edges, h3_get_directed_edge_origin, h3_get_directed_edge_destination, h3_directed_edge_to_cells, h3_cells_to_directed_edge, h3_are_neighbor_cells, h3_is_valid_directed_edge, h3_cell_to_vertex, h3_cell_to_vertexes, h3_vertex_to_lat, h3_vertex_to_lng, h3_vertex_to_latlng, h3_is_valid_vertex, h3_cell_area, h3_edge_length, h3_great_circle_distance, h3_get_hexagon_area_avg, h3_get_hexagon_edge_length_avg, h3_get_num_cells, h3_get_res0_cells, h3_get_res0_cells_string, h3_get_pentagons, h3_get_pentagons_string\n- `refs\u002Fa5.md` — a5_lonlat_to_cell, a5_cell_to_lonlat, a5_cell_area, a5_cell_to_boundary, a5_cell_to_parent, a5_cell_to_children, a5_get_resolution, a5_get_num_cells, a5_get_res0_cells, a5_compact, a5_uncompact\n\n**Python API:**\n- `refs\u002Fpython-api.md` — Read when: using DuckDB from Python, Arrow export, `fetch_arrow_table()` v1.5 bug, connection setup, GeoParquet writing, result fetching with geometry columns, v1.5 migration patterns.\n\n**External database connectors:**\n- `refs\u002Fbigquery.md` — Read when: connecting to Google BigQuery, querying BigQuery tables from DuckDB, working with BigQuery GEOGRAPHY columns, using bigquery_scan\u002Fbigquery_query functions, managing BigQuery datasets, or accessing public BigQuery datasets. Covers authentication (DuckDB Secrets, service accounts, gcloud), DDL operations, geometry mapping, and cost optimization.\n- `refs\u002Ficeberg.md` — Read when: working with Apache Iceberg tables, attaching to Iceberg REST catalogs (Polaris, Lakekeeper, AWS Glue, S3 Tables, BigLake), reading\u002Fwriting Iceberg tables, time travel via snapshots, partition pruning, schema evolution, or using iceberg_scan\u002Ficeberg_metadata\u002Ficeberg_snapshots functions.\n\n**Specialized topics:**\n- `refs\u002Fducklake.md` — Read when: working with DuckLake lakehouse (setup, time travel, partitioning, ACID, spatial support, VARIANT).\n- `refs\u002Fraster-tiling.md` — Read when: working with raster data, RASTER type, RT_* functions, RaQuet (raster-in-Parquet), QUADBIN spatial indexing, converting GeoTIFF\u002FCOG\u002FNetCDF to RaQuet, tile statistics, raquet-io CLI, Pyramid GeoParquet.\n- `refs\u002Ffts.md` — Read when: implementing full-text search (BM25 index creation, match_bm25 queries, stemming).\n- `refs\u002Fvss.md` — Read when: working with vector embeddings and similarity search (HNSW indexes, distance metrics).\n- `refs\u002Fwasm-patterns.md` — Read when: targeting DuckDB-WASM in the browser (extension loading, geocoding, MVT generation).\n- `refs\u002Fsummarize.md` — Read when: needing SUMMARIZE command details beyond the basics above.\n- `refs\u002Fautocomplete.md` — Read when: building interactive SQL tools with auto-complete.\n- `refs\u002Fexplain-analyze.md` — Read when: queries are complex or failing repeatedly, you need to understand query execution plans, diagnose performance issues, or break down complex queries into analyzable parts. Use EXPLAIN ANALYZE to see runtime metrics, actual vs estimated cardinalities, and operator timing.\n\n## Troubleshooting Extension Installation\n\nIf a standard extension installation fails or you encounter errors related to outdated functionality, try installing from the `core_nightly` repository to get the latest development build:\n\n```sql\n-- Standard installation (try this first)\nINSTALL extension_name;\nLOAD extension_name;\n\n-- If the above fails or you encounter version-related errors:\nFORCE INSTALL extension_name FROM core_nightly;\nLOAD extension_name;\n\n-- Example: DuckLake with latest features\nFORCE INSTALL ducklake FROM core_nightly;\nLOAD ducklake;\n```\n\n**When to use `core_nightly`:**\n- Standard installation fails with compatibility errors\n- You need features not yet in the stable release\n- Documentation mentions functionality you don't have\n- Error messages indicate version mismatches\n\n**Note**: `FORCE INSTALL` overwrites any existing installation. Nightly builds are development versions and may be less stable than official releases.\n\n## Configuration Quick Reference\n\n```sql\nSET geometry_always_xy = true;              -- lon\u002Flat = x\u002Fy axis order\nSET geometry_minimum_shredding_size = 30000; -- geometry shredding threshold\nSET enable_geoparquet_conversion = true;    -- auto-decode GeoParquet (default: true)\nSET ignore_unknown_crs = false;             -- error on unknown CRS (default: false)\n```\n","# DuckDB v1.5 Skill\n\n> DuckDB v1.5.0 \"Variegata\" — Released 2026-03-09.\n\n## How to Think: Discovery → Understanding → Analysis\n\nThe most common mistake is jumping straight to queries. Instead, follow this workflow — it prevents wrong assumptions, bad joins, and wasted work.\n\n### Phase 1: Discover the Data\n\nBefore writing any analytical query, find out what you're working with.\n\n**Local files — use glob patterns to find them:**\n\n```sql\n-- Find what files exist (Parquet, CSV, JSON, GeoJSON, etc.)\nFROM glob('data\u002F*.parquet');\nFROM glob('**\u002F*.csv');\nFROM glob('\u002Fpath\u002Fto\u002Fproject\u002F**\u002F*.geojson');\n```\n\n**Remote files — always load httpfs first, then probe:**\n\n```sql\nINSTALL httpfs; LOAD httpfs;\n-- For S3, also set the region:\nSET s3_region = 'us-west-2';\n\n-- Remote Parquet (only reads metadata, not full file)\nDESCRIBE FROM 'https:\u002F\u002Fexample.com\u002Fdata.parquet';\n\n-- S3 \u002F Azure \u002F GCS\nDESCRIBE FROM 's3:\u002F\u002Fbucket\u002Fpath\u002Ffile.parquet';\n\n-- S3 buckets with dots in the name (e.g., source.coop) need path-style URLs,\n-- because virtual-hosted style breaks SSL certificate validation:\nSET s3_url_style = 'path';\nDESCRIBE FROM 's3:\u002F\u002Fus-west-2.opendata.source.coop\u002Frepo\u002Fdata.parquet';\n\n-- Hive-partitioned datasets — check partition structure\nFROM parquet_metadata('s3:\u002F\u002Fbucket\u002Fdataset\u002F**\u002F*.parquet') LIMIT 5;\n```\n\n**Databases — inspect what's available:**\n\n```sql\n-- Attached databases\nSHOW ALL TABLES;\nDESCRIBE table_name;\n\n-- External DuckDB files (new in v1.5 — no ATTACH needed)\nFROM read_duckdb('other.duckdb', table_name := 'my_table');\n\n-- External databases via ODBC (new in v1.5, requires INSTALL odbc_scanner)\n-- odbc_connect(conn_str) + odbc_query(conn, sql)\n```\n\n**Discover functions from DuckDB itself** — when unsure about a function signature:\n\n```sql\n-- Search for functions by name pattern\nSELECT function_name, parameters, return_type\nFROM duckdb_functions() WHERE function_name LIKE 'ST_Coverage%';\n\n-- List all extensions and their status\nFROM duckdb_extensions();\n\n-- List all settings\nFROM duckdb_settings() WHERE name LIKE '%geometry%';\n```\n\n**Geospatial files — check layers and metadata:**\n\n```sql\nLOAD spatial;\nSELECT * FROM ST_Read_Meta('data.gpkg');       -- layers, CRS, field schemas\nSELECT * FROM ST_Read_Meta('data.gdb');        -- ESRI File Geodatabase\n```\n\n### Phase 2: Understand the Shape\n\nOnce you know WHAT files exist, understand their structure before querying.\n\n```sql\n-- Schema: column names and types (instant, reads only metadata)\nDESCRIBE FROM 'data.parquet';\nDESCRIBE FROM 'data.csv';\n\n-- Stats: min, max, approx_unique, avg, std, quartiles, nulls (scans full data)\nSUMMARIZE FROM 'data.parquet';\nSUMMARIZE FROM 'data.csv';\n\n-- Quick sample: see actual values (avoids scanning everything)\nFROM 'data.parquet' LIMIT 10;\nFROM 'data.csv' LIMIT 10;\n\n-- Row count estimate (fast for Parquet — reads metadata only)\nSELECT count(*) FROM 'data.parquet';\n\n-- For Parquet: row group structure, column statistics, file-level metadata\nFROM parquet_metadata('data.parquet');\nFROM parquet_schema('data.parquet');\nFROM parquet_kv_metadata('data.parquet');  -- GeoParquet metadata lives here\n```\n\nThis phase is critical because:\n- DESCRIBE tells you column types — you'll know if geometry is WKB blob vs native GEOMETRY\n- SUMMARIZE reveals data quality issues (null percentages, unexpected ranges, cardinality)\n- A quick LIMIT sample shows actual values — field naming conventions, coordinate order, encoding\n- For spatial data: you need to know the CRS before any spatial operations\n\n### Detecting the CRS\n\nKnowing the CRS is essential before any spatial operation. The method depends on how geometry is stored:\n\n**Step 1: Identify the format.** Run DESCRIBE first — the column type tells you which case you're in:\n\n| Column type | Format | CRS location |\n|---|---|---|\n| `geometry('epsg:4326')` | GeoParquet or native Parquet geometry | CRS in column type (spatial resolves EPSG) |\n| `geometry` (no CRS) | Native Parquet geometry with no CRS, or CRS not resolved | Check `parquet_schema()` logical_type |\n| `blob` | Plain Parquet with WKB | No CRS embedded — must know from context |\n\n**Case 1: GeoParquet (Parquet with `geo` KV metadata)**\n\n```sql\n-- Quickest: DESCRIBE shows CRS in the column type (requires LOAD spatial for EPSG resolution)\nLOAD spatial;\nDESCRIBE FROM 'data.parquet';\n-- → geom  geometry('epsg:4326')\n\n-- Or use ST_CRS on a row\nSELECT ST_CRS(geom) FROM 'data.parquet' LIMIT 1;\n-- → 'EPSG:4326'\n\n-- Without spatial loaded, DESCRIBE still works but shows raw PROJJSON instead of the short code:\n-- → geom  geometry('{\"$schema\":\"https:\u002F\u002Fproj.org\u002Fschemas\u002Fv0.5\u002Fprojjson.schema.json\",...}')\n\n-- Full GeoParquet metadata inspection (no spatial extension needed):\nWITH kv AS (\n    SELECT file_name,\n           decode(key) AS key_str,\n           decode(value)::JSON AS geo_json\n    FROM parquet_kv_metadata('data\u002F*.parquet')\n)\nSELECT file_name,\n       geo_json->>'$.columns.geometry.encoding' AS encoding,\n       geo_json->'$.columns.geometry.geometry_types' AS geom_types,\n       geo_json->'$.columns.geometry.bbox' AS bbox,\n       geo_json->'$.columns.geometry.crs.id.authority' AS crs_authority,\n       geo_json->'$.columns.geometry.crs.id.code' AS crs_code,\n       geo_json->>'$.primary_column' AS primary_column\nFROM kv WHERE key_str = 'geo';\n-- If crs is NULL → default is OGC:CRS84 (WGS84 lon\u002Flat) per GeoParquet spec\n```\n\n**Case 2: Native Parquet geometry (Format 2.11+ — no `geo` key)**\n\nThese files store CRS in the Parquet schema's logical type, not in KV metadata. DuckDB reads it automatically.\n\n```sql\n-- DESCRIBE shows the resolved CRS when spatial can resolve it\nLOAD spatial;\nDESCRIBE FROM 'native_geo.parquet';\n-- → geometry  geometry('epsg:5070')    ← CRS resolved\n-- → geometry  geometry                 ← CRS not resolved or absent\n\n-- Check the raw Parquet logical type to see how CRS is encoded\nSELECT name, logical_type\nFROM parquet_schema('native_geo.parquet')\nWHERE logical_type LIKE 'GeometryType%';\n-- → geometry  GeometryType(crs=srid:5070)     ← SRID-based CRS\n-- → geometry  GeometryType(crs=\u003Cprojjson>)     ← full PROJJSON CRS\n-- → geometry  GeometryType(crs=\u003Cnull>)         ← no CRS specified\n```\n\n**Case 3: Plain Parquet (WKB blob, no geometry metadata)**\n\n```sql\n-- DESCRIBE shows blob type — no CRS information available\nDESCRIBE FROM 'data.parquet';\n-- → wkb_geom  blob\n\n-- No CRS is embedded. You must know the CRS from documentation or context,\n-- then assign it after converting to GEOMETRY:\nLOAD spatial;\nSELECT ST_SetCRS(ST_GeomFromWKB(wkb_geom), 'EPSG:4326') FROM 'data.parquet';\n```\n\n**Case 4: GDAL-supported formats (GPKG, Shapefile, GDB, FlatGeobuf, GeoJSON, KML)**\n\n```sql\n-- Use ST_Read_Meta to get CRS from any GDAL-readable format\nLOAD spatial;\nSELECT\n    layers[1].geometry_fields[1].crs.auth_name AS authority,\n    layers[1].geometry_fields[1].crs.auth_code AS code\nFROM ST_Read_Meta('data.gpkg');\n-- → EPSG  4326\n\n-- For multi-layer files, inspect all layers:\nSELECT * FROM ST_Read_Meta('data.gdb');\n```\n\n**Case 5: H3\u002Fspatial-indexed data (no geometry column)**\n\nSome datasets store location as H3 BIGINT indices instead of geometry columns. H3 cells are always WGS84 — the CRS is implicit. Derive coordinates on the fly:\n\n```sql\nINSTALL h3 FROM community; LOAD h3;\nSELECT h3_index,\n       h3_h3_to_string(h3_index) AS h3_hex,  -- BIGINT → hex string (e.g., '820007fffffffff')\n       h3_cell_to_lat(h3_index) AS lat,\n       h3_cell_to_lng(h3_index) AS lon\nFROM 'data.parquet' LIMIT 5;\n```\n\n### Phase 3: Analyze with Purpose\n\nNow that you understand the data, write targeted queries. Some principles:\n\n**Start narrow, expand.** Query a small subset first (WHERE + LIMIT), verify the logic, then remove the constraints.\n\n**Use FROM-first syntax** — it's more readable and DuckDB-idiomatic:\n\n```sql\n-- Instead of SELECT * FROM tbl WHERE ...\nFROM tbl SELECT col1, col2 WHERE x > 10;\nFROM tbl;  -- implicit SELECT *\n```\n\n**Use GROUP BY ALL** — let DuckDB infer grouping columns from context:\n\n```sql\nSELECT region, category, sum(amount), count()\nFROM sales\nGROUP BY ALL;  -- infers GROUP BY region, category\n```\n\n**Use SUMMARIZE on intermediate results** to verify transformations:\n\n```sql\nSUMMARIZE (\n    SELECT *, ST_Area_Spheroid(geom) AS area_m2\n    FROM parcels\n    WHERE area_m2 > 0\n);\n-- Check: are the area values reasonable? Any nulls introduced?\n```\n\n**Chain analysis steps** — use CTEs or CREATE OR REPLACE TABLE for iterative exploration:\n\n```sql\nCREATE OR REPLACE TABLE enriched AS\n    SELECT p.*, z.zone_name\n    FROM points p\n    JOIN zones z ON ST_Intersects(p.geom, z.geom);\n\nSUMMARIZE enriched;  -- verify the join didn't explode or lose rows\n```\n\n### When Queries Fail or Perform Poorly: Use EXPLAIN ANALYZE\n\nIf a query is **complex, slow, or failing unexpectedly**, use `EXPLAIN ANALYZE` to understand what's happening. It shows the query plan with runtime metrics — actual row counts, estimated cardinalities, and timing for each operation.\n\n```sql\nEXPLAIN ANALYZE SELECT ... ;\n```\n\n**When to use it:**\n- Query runs slower than expected\n- Getting unexpected results or row counts\n- Complex joins or subqueries that you want to verify\n- Need to see if indexes or spatial joins are being used\n- Want to break down a complex query into analyzable parts\n\nThe output shows a tree of operations with:\n- **EC (Estimated Cardinality)**: what DuckDB predicted\n- **Actual cardinality**: what actually happened\n- **Timing**: cumulative wall-clock time per operator\n\nIf estimated vs actual cardinalities are far off, or if certain operations dominate the time, that tells you where to focus optimization. For deep-dive details and examples, read `refs\u002Fexplain-analyze.md`.\n\n## v1.5 Breaking Changes — Must Know\n\nThese trip up anyone using pre-v1.5 patterns:\n\n| Old pattern | v1.5+ correct way |\n|---|---|\n| `x -> x + 1` (arrow lambda) | `lambda x: x + 1` — arrow syntax is deprecated, errors in v2.0 |\n| Missing `geometry_always_xy` | `SET geometry_always_xy = true;` after `LOAD spatial` — v1.5 warns, v2.1 makes it default |\n| `INSTALL spatial` for GEOMETRY columns | Not needed — GEOMETRY is a core type in v1.5 (only INSTALL spatial for ST_* functions) |\n| `GEOMETRY('EPSG:4326')` without spatial | EPSG codes require spatial extension. Without it, use `GEOMETRY('OGC:CRS84')` or plain `GEOMETRY` |\n| Mixing CRS in spatial operations | v1.5 errors at bind time. Use consistent CRS or strip with `::GEOMETRY` |\n| `.fetch_arrow_table()` with parquet geometry | Use `.arrow().read_all()` — crashes with `TransactionContext` error (see `refs\u002Fpython-api.md`) |\n| `TRY_CAST(x AS GEOMETRY)` | `TRY(ST_GeomFromText(x))` — TRY_CAST broken for GEOMETRY in v1.5 |\n| `ST_Read('f.fgb', spatial_filter_box=...)` | Removed in v1.5 — use `WHERE geom && ST_MakeBox2D(...)` instead (auto-pushed down) |\n| `ST_Read(..., sequential_layer_scan=true)` | Removed in v1.5 — auto-applied for OSM format |\n| `register_geoarrow_extensions()` in Python | No longer needed — GEOMETRY defaults to GeoArrow in Arrow export |\n| Invalid HEXWKB silently accepted | v1.5 now throws proper error on invalid HEXWKB input |\n\n## Core GEOMETRY Type (no extension needed)\n\n```sql\n-- GEOMETRY is now a built-in type with optional CRS parameter\nCREATE TABLE t1 (g GEOMETRY);                    -- no CRS\nCREATE TABLE t2 (g GEOMETRY('OGC:CRS84'));       -- built-in CRS (no spatial needed)\nCREATE TABLE t3 (g GEOMETRY('EPSG:4326'));       -- requires LOAD spatial for EPSG codes\n\n-- Built-in functions (no LOAD spatial needed):\nST_GeomFromWKB(blob)          -- WKB → geometry\nST_AsWKB(geom)                -- geometry → WKB (alias: ST_AsBinary)\nST_AsWKT(geom)                -- geometry → WKT (alias: ST_AsText)\nST_Intersects_Extent(a, b)    -- bbox intersection\na && b                        -- operator alias (uses row-group stats!)\nST_CRS(geom)                  -- get CRS identifier\nST_SetCRS(geom, 'OGC:CRS84') -- assign CRS (no coordinate transform)\n'POINT(0 0)'::GEOMETRY        -- cast from WKT\n```\n\nSubtypes: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection. Vertices can have Z, M, or ZM dimensions.\n\n### CRS System\n\n```sql\nSELECT * FROM duckdb_coordinate_systems();  -- list all known CRSs (works without spatial)\n-- Built-in: OGC:CRS84, OGC:CRS83. Spatial ext adds 7,000+ EPSG codes.\n-- Accepts: AUTH:CODE, full PROJJSON, full WKT2-2019\nSET ignore_unknown_crs = true;  -- silently drop unknown CRS (works without spatial)\n```\n\n### Geometry Shredding (~3x compression)\n\nAutomatic: when all geometries in a row group share the same subtype, DuckDB decomposes to STRUCT\u002FLIST\u002FDOUBLE with ALP compression. Control with `SET geometry_minimum_shredding_size = 30000` (default), `0` (always), `-1` (disable). Not shredded: GeometryCollection, empty geometries, mixed subtypes.\n\n## Spatial Recipes (requires `LOAD spatial`)\n\n### Session Setup\n\nAlways start spatial work with:\n\n```sql\nINSTALL spatial; LOAD spatial;\nSET geometry_always_xy = true;  -- lon\u002Flat = x\u002Fy consistently\n```\n\n### Spatial Joins (automatic R-tree, v1.3+)\n\n```sql\n-- Point-in-polygon (automatic R-tree, no index creation needed)\nSELECT p.*, z.zone_name\nFROM points p JOIN zones z ON ST_Intersects(p.geom, z.geom);\n\n-- Proximity join — ST_DWithin is fastest (triggers SPATIAL_JOIN operator)\nSELECT a.*, b.*\nFROM table_a a JOIN table_b b ON ST_DWithin(a.geom, b.geom, 1000);\n```\n\nPredicates that trigger SPATIAL_JOIN: `ST_Intersects`, `ST_Contains`, `ST_ContainsProperly`, `ST_Within`, `ST_Covers`, `ST_CoveredBy`, `ST_Overlaps`, `ST_Touches`, `ST_Crosses`, `ST_DWithin`, `&&` \u002F `ST_Intersects_Extent`.\n\n**Spatial join gotchas:**\n- R-Tree indexes created with `CREATE INDEX ... USING RTREE` are for `WHERE` filter scans only — they are NOT used for `JOIN ... ON ST_Intersects()`. The spatial join optimizer builds its own internal R-tree. They are independent features.\n- For very small build sides, block-nested-loop may outperform the spatial join optimizer. DuckDB's vectorized constant-vector optimization is very fast for small tables.\n- Spatial operations do NOT spill to disk — OOM can occur with large spatial pipelines. Monitor memory usage.\n\n### CRS Transform\n\n```sql\n-- v1.5: 2-arg form (source CRS inferred from typed column)\nSELECT ST_Transform(geom, 'EPSG:4326') FROM tbl;\n\n-- Explicit source\u002Ftarget\nSELECT ST_Transform(geom, 'EPSG:4326', 'EPSG:3857') FROM tbl;\n```\n\n### Distance & Area\n\n```sql\nSELECT ST_Distance_Spheroid(ST_Point(-74.0, 40.7), ST_Point(-0.1, 51.5));  -- meters\nSELECT ST_Distance_Sphere(a.geom, b.geom);   -- haversine, meters\nSELECT ST_Area_Spheroid(geom);                -- m²\nSELECT ST_Length_Spheroid(geom);              -- meters\n-- ST_Point(x, y) = ST_Point(lon, lat) — x is always longitude\n```\n\n### Export\n\n```sql\n-- GeoParquet (default: v1 metadata)\nCOPY tbl TO 'output.parquet' (FORMAT PARQUET);\n\n-- Max compatibility: GeoParquet v1 metadata + native Parquet geometry stats\nCOPY tbl TO 'output.parquet' (FORMAT PARQUET, GEOPARQUET_VERSION 'BOTH');\n\n-- GDAL formats (read refs\u002Fgdal-formats.md for full reference)\nCOPY tbl TO 'out.geojson' WITH (FORMAT GDAL, DRIVER 'GeoJSON');\nCOPY tbl TO 'out.gpkg' WITH (FORMAT GDAL, DRIVER 'GPKG', LAYER_NAME 'my_layer');\nCOPY tbl TO 'out.shp' WITH (FORMAT GDAL, DRIVER 'ESRI Shapefile');\n\n-- Hilbert-ordered for best spatial query performance\nCOPY (SELECT * FROM tbl ORDER BY ST_Hilbert(geom)) TO 'sorted.parquet' (FORMAT PARQUET);\n```\n\n### R-Tree Index\n\n```sql\n-- Populate table FIRST, then create index (bulk load is 10x+ faster)\nCREATE INDEX idx ON tbl USING RTREE (geom);\n-- Auto-used with WHERE spatial predicates (NOT with JOIN — see spatial join notes above)\n```\n\n**Note:** R-Tree index scans can be skipped if the table also has a PRIMARY KEY or other index type. If spatial filtering seems slow on a table with a PK, verify with `EXPLAIN ANALYZE`.\n\n## Friendly SQL Quick Reference\n\n```sql\n-- FROM-first\nFROM tbl;                                      -- implicit SELECT *\nFROM tbl SELECT col1, col2 WHERE x > 10;       -- FROM leads, then SELECT, then WHERE\n\n-- GROUP BY ALL \u002F ORDER BY ALL\nSELECT region, count() FROM sales GROUP BY ALL ORDER BY ALL;\n\n-- Star expressions\nSELECT * EXCLUDE (internal_id, tmp) FROM tbl;\nSELECT * REPLACE (upper(name) AS name) FROM tbl;\n\n-- COLUMNS() — apply across matching columns\nSELECT min(COLUMNS('.*_price')) FROM products;\nSELECT COLUMNS(lambda c: c LIKE '%name%') FROM tbl;\n\n-- Lambda syntax (v1.5+ — arrow syntax deprecated)\nSELECT list_transform([1,2,3], lambda x: x * 2);\nSELECT list_filter(range(10), lambda x: x % 2 = 0);\n\n-- Dot operator chaining\nSELECT ('hello world').upper().split(' ').list_transform(lambda x: x.len());\n\n-- List comprehension\nSELECT [x * 2 FOR x IN [1, 2, 3]];\n\n-- ASOF join (time-series)\nSELECT * FROM trades ASOF JOIN quotes USING (symbol, timestamp);\n\n-- LATERAL join\nSELECT * FROM customers, LATERAL (SELECT * FROM orders WHERE orders.cust_id = customers.id LIMIT 3);\n\n-- POSITIONAL join (by row position)\nSELECT * FROM t1 POSITIONAL JOIN t2;\n\n-- Direct file queries (no CREATE TABLE needed)\nFROM 'data.csv';\nFROM 'data.parquet';\nFROM 'https:\u002F\u002Fexample.com\u002Fdata.parquet';\nFROM 'data\u002F**\u002F*.parquet';  -- glob patterns\n\n-- Top-N aggregates (no window function needed)\nSELECT max(val, 3) FROM t GROUP BY grp;           -- top-3 per group\nSELECT arg_max(name, score, 3) FROM t GROUP BY grp;  -- names of top-3\n\n-- FILTER clause\nSELECT count() FILTER (status = 'active'), sum(amt) FILTER (year = 2025) FROM orders;\n\n-- PIVOT \u002F UNPIVOT\nPIVOT sales ON product USING sum(amount);\nUNPIVOT monthly ON jan, feb, mar INTO NAME month VALUE amount;\n\n-- Variables\nSET VARIABLE my_threshold = 100;\nSELECT * FROM tbl WHERE val > getvariable('my_threshold');\n\n-- Trailing commas are OK\nSELECT col1, col2, FROM tbl;\n\n-- Percentage LIMIT\nSELECT * FROM tbl LIMIT 10%;\n```\n\n## VARIANT Type (new in v1.5)\n\nTyped binary semi-structured data. Better compression and query performance than JSON.\n\n```sql\nSELECT 42::VARIANT;\nSELECT {'name': 'Alice', 'age': 30}::VARIANT;\nSELECT variant_typeof(data) FROM tbl;  -- inspect type\nSELECT data.name FROM tbl;             -- dot notation\n-- Supported in Parquet (shredded), DuckLake, Delta Lake\n```\n\n## Key Extensions\n\n| Extension | Purpose | Install |\n|-----------|---------|---------|\n| `spatial` | ST_* functions, GDAL I\u002FO | `INSTALL spatial; LOAD spatial;` |\n| `httpfs` | Remote files (S3\u002FHTTP\u002FGCS\u002FAzure) | `INSTALL httpfs; LOAD httpfs;` |\n| `h3` | H3 hexagonal spatial index | `INSTALL h3 FROM community; LOAD h3;` |\n| `a5` | A5 pentagonal index | `INSTALL a5 FROM community; LOAD a5;` |\n| `geography` | S2 spherical geometry | community extension |\n| `bigquery` | Connect to Google BigQuery | `FORCE INSTALL bigquery FROM community; LOAD bigquery;` |\n| `iceberg` | Apache Iceberg tables (read\u002Fwrite, catalogs) | `INSTALL iceberg; LOAD iceberg;` |\n| `ducklake` | Lakehouse (SQL catalog + Parquet) | `INSTALL ducklake; LOAD ducklake;` |\n| `odbc_scanner` | Query via ODBC (new in v1.5) | `INSTALL odbc_scanner; LOAD odbc_scanner;` |\n| `fts` | Full-text search (BM25) | `INSTALL fts; LOAD fts;` |\n| `vss` | Vector similarity search (HNSW) | `INSTALL vss; LOAD vss;` |\n\n## Common Pitfalls\n\n| Mistake | Fix |\n|---------|-----|\n| `x -> x + 1` | `lambda x: x + 1` |\n| Mixing CRS in spatial ops | Ensure consistent CRS or strip with `::GEOMETRY` |\n| Not setting `geometry_always_xy` | `SET geometry_always_xy = true;` after `LOAD spatial` |\n| `ST_Point(lat, lon)` | `ST_Point(lon, lat)` — x is longitude |\n| `INSTALL spatial` for GEOMETRY columns | Not needed in v1.5 — GEOMETRY is core |\n| `NOT ST_Intersects(a, b)` in JOINs | Causes OOM — use `NOT EXISTS (SELECT 1 ... WHERE ST_Intersects(...))` |\n| `ST_Transform` without `ST_SetCRS` | Output has no CRS metadata — always set CRS on input first |\n| FlatGeobuf WHERE ST_Intersects | Use `WHERE geom && ST_MakeBox2D(...)` — bbox auto-pushed to GDAL, then predicate evaluated |\n| Large geometries in GeoParquet | Default row group too big → full file download — use `ROW_GROUP_SIZE 2500` |\n| `ST_DWithin_Spheroid` in JOINs | No SPATIAL_JOIN optimization — use `ST_DWithin` instead |\n| `ST_Intersection_Agg(geom)` without ORDER BY | Result depends on processing order (not associative) — use `ST_Intersection_Agg(geom ORDER BY id)` |\n| `ST_AsEWKB` \u002F `ST_AsEWKT` | Don't exist — DuckDB stores SRID at column\u002Ftype level, not per-geometry value |\n| COPY multiple layers to same GPKG | File gets overwritten — only one layer per COPY. Use FileGDB for multi-layer export |\n| Large GDAL exports to S3 | Fails with \"Unknown part number\" — export locally first, then upload |\n| `ST_Read_Meta` on Parquet files | Crashes — Parquet is handled by the parquet extension, not GDAL\u002Fspatial. Use `parquet_kv_metadata()` |\n| KML export with `SRS 'EPSG:4326'` | GDAL axis order issue — coordinates may be swapped. Set `geometry_always_xy = true` first |\n\n## Reference Files — Load on Demand\n\nRead these ONLY when the task requires the specific topic. Do not preload.\n\n**Geospatial formats and I\u002FO:**\n- `refs\u002Fgdal-formats.md` — Read when: converting between formats (GPKG, Shapefile, GeoJSON, FlatGeobuf, KML, FileGDB), querying WFS\u002FAPI endpoints.\n- `refs\u002Foverture-maps.md` — Read when: working with **Overture Maps** data (places, buildings, roads — includes S3\u002FAzure paths, bbox filtering, GeoParquet metadata inspection).\n\n**Spatial function deep-dives (read `refs\u002Fspatial\u002Findex.md` first for the function index, then drill in):**\n- `refs\u002Fspatial\u002Fcreation.md` — ST_Point, ST_Point2D, ST_Point3D, ST_Point4D, ST_MakePoint, ST_MakeLine, ST_MakePolygon, ST_MakeBox2D, ST_MakeEnvelope, ST_Collect, ST_Multi, ST_BuildArea\n- `refs\u002Fspatial\u002Fpredicates.md` — ST_Intersects, ST_Intersects_Extent, ST_Contains, ST_ContainsProperly, ST_CoveredBy, ST_Covers, ST_Crosses, ST_DWithin, ST_DWithin_GEOS, ST_DWithin_Spheroid, ST_Disjoint, ST_Equals, ST_Overlaps, ST_Touches, ST_Within, ST_WithinProperly\n- `refs\u002Fspatial\u002Fmeasurement.md` — ST_Distance, ST_Distance_GEOS, ST_Distance_Sphere, ST_Distance_Spheroid, ST_Area, ST_Area_Spheroid, ST_Length, ST_Length_Spheroid, ST_Perimeter, ST_Perimeter_Spheroid, ST_Azimuth, ST_ClosestPoint, ST_ShortestLine\n- `refs\u002Fspatial\u002Ftransforms.md` — ST_Transform, ST_Buffer, ST_Simplify, ST_SimplifyPreserveTopology, ST_ReducePrecision, ST_RemoveRepeatedPoints, ST_Reverse, ST_FlipCoordinates, ST_Force2D, ST_Force3DM, ST_Force3DZ, ST_Force4D, ST_MakeValid, ST_Normalize, ST_Centroid, ST_ConvexHull, ST_ConcaveHull, ST_Envelope, ST_Boundary, ST_Difference, ST_Intersection, ST_Union, ST_Affine, ST_VoronoiDiagram, ST_MaximumInscribedCircle, ST_MinimumRotatedRectangle, ST_PointOnSurface, ST_Hilbert, ST_Node\n- `refs\u002Fspatial\u002Faccessors.md` — ST_X, ST_Y, ST_Z, ST_M, ST_HasM, ST_HasZ, ST_ZMFlag, ST_XMax, ST_XMin, ST_YMax, ST_YMin, ST_ZMax, ST_ZMin, ST_MMax, ST_MMin, ST_Dimension, ST_NGeometries, ST_NInteriorRings, ST_NPoints, ST_NumGeometries, ST_NumInteriorRings, ST_NumPoints, ST_ExteriorRing, ST_InteriorRingN, ST_StartPoint, ST_EndPoint, ST_PointN, ST_Points, ST_IsClosed, ST_IsEmpty, ST_IsRing, ST_IsSimple, ST_IsValid, ST_Extent, ST_Extent_Approx, ST_Dump, ST_CollectionExtract, ST_Polygonize, ST_GeometryType\n- `refs\u002Fspatial\u002Fconversion-io.md` — ST_AsText, ST_AsWKB, ST_AsGeoJSON, ST_AsHEXWKB, ST_AsMVTGeom, ST_AsSVG, ST_GeomFromText, ST_GeomFromWKB, ST_GeomFromGeoJSON, ST_GeomFromHEXWKB, ST_GeomFromHEXEWKB\n- `refs\u002Fspatial\u002Faggregates.md` — ST_Union_Agg, ST_MemUnion_Agg, ST_Extent_Agg, ST_Envelope_Agg, ST_Intersection_Agg, ST_AsMVT, ST_CoverageInvalidEdges_Agg, ST_CoverageSimplify_Agg, ST_CoverageUnion_Agg\n- `refs\u002Fspatial\u002Flinear-ref.md` — ST_LineInterpolatePoint, ST_LineInterpolatePoints, ST_LineLocatePoint, ST_LineMerge, ST_LineSubstring, ST_LocateAlong, ST_LocateBetween, ST_InterpolatePoint, ST_LineString2DFromWKB, ST_Polygon2DFromWKB, ST_Point2DFromWKB\n- `refs\u002Fspatial\u002Fcoverage-tiling.md` — ST_CoverageUnion, ST_CoverageInvalidEdges, ST_CoverageSimplify, ST_TileEnvelope, ST_QuadKey\n- `refs\u002Fspatial\u002Fmacros.md` — ST_Rotate, ST_RotateX, ST_RotateY, ST_RotateZ, ST_Scale, ST_TransScale, ST_Translate\n- `refs\u002Fspatial\u002Ftable-functions.md` — ST_Read, ST_ReadOSM, ST_ReadSHP, ST_Read_Meta, ST_Drivers, ST_GeneratePoints\n- `refs\u002Fspatial\u002Fcore-v15.md` — ST_GeomFromWKB, ST_CRS, ST_SetCRS (v1.5 built-in, no extension needed)\n- `refs\u002Fspatial\u002Fa5-s2.md` — A5: a5_lonlat_to_cell, a5_cell_to_lonlat, a5_cell_to_boundary, a5_cell_to_parent, a5_cell_to_children, a5_cell_area, a5_get_resolution, a5_get_num_cells, a5_get_res0_cells, a5_compact, a5_uncompact. S2\u002FGeography: s2_area, s2_dimension, s2_distance, s2_dwithin, s2_is_valid, s2_is_valid_reason, s2_isempty, s2_length, s2_max_distance, s2_num_points, s2_perimeter, s2_x, s2_y, s2_bounds_box, s2_box, s2_box_intersects, s2_box_struct, s2_box_union, s2_box_wkb, s2_covering, s2_covering_fixed_level, s2_cellfromlonlat, s2_cellfromwkb, s2_arbitrarycellfromwkb, s2_cell_child, s2_cell_contains, s2_cell_edge_neighbor, s2_cell_from_token, s2_cell_intersects, s2_cell_level, s2_cell_parent, s2_cell_range_max, s2_cell_range_min, s2_cell_token, s2_cell_vertex, s2_astext, s2_aswkb, s2_format, s2_geogfromtext, s2_geogfromtext_novalidate, s2_geogfromwkb, s2_geogfromwkb_novalidate, s2_prepare, s2_contains, s2_equals, s2_intersects, s2_mayintersect, s2_difference, s2_intersection, s2_union, s2_data_city, s2_data_country, s2_data_cities, s2_data_countries\n\n**Spatial indexing and tiling:**\n- `refs\u002Fspatial-indexes.md` — Read when: comparing H3 vs A5 vs S2 vs QUADBIN to choose the right spatial index. Overview and comparison tables.\n- `refs\u002Fh3.md` — h3_latlng_to_cell, h3_latlng_to_cell_string, h3_cell_to_lat, h3_cell_to_lng, h3_cell_to_latlng, h3_string_to_h3, h3_h3_to_string, h3_cell_to_parent, h3_cell_to_children, h3_cell_to_children_size, h3_cell_to_center_child, h3_cell_to_child_pos, h3_child_pos_to_cell, h3_get_resolution, h3_get_base_cell_number, h3_is_valid_cell, h3_is_pentagon, h3_is_res_class_iii, h3_get_icosahedron_faces, h3_grid_disk, h3_grid_disk_distances, h3_grid_disk_unsafe, h3_grid_ring, h3_grid_ring_unsafe, h3_grid_path_cells, h3_grid_distance, h3_max_grid_disk_size, h3_cell_to_boundary_wkt, h3_cell_to_boundary_wkb, h3_cells_to_multi_polygon_wkt, h3_cells_to_multi_polygon_wkb, h3_directed_edge_to_boundary_wkt, h3_directed_edge_to_boundary_wkb, h3_polygon_wkt_to_cells, h3_polygon_wkb_to_cells, h3_polygon_wkt_to_cells_string, h3_polygon_wkb_to_cells_string, h3_polygon_wkt_to_cells_experimental, h3_polygon_wkb_to_cells_experimental, h3_compact_cells, h3_uncompact_cells, h3_origin_to_directed_edges, h3_get_directed_edge_origin, h3_get_directed_edge_destination, h3_directed_edge_to_cells, h3_cells_to_directed_edge, h3_are_neighbor_cells, h3_is_valid_directed_edge, h3_cell_to_vertex, h3_cell_to_vertexes, h3_vertex_to_lat, h3_vertex_to_lng, h3_vertex_to_latlng, h3_is_valid_vertex, h3_cell_area, h3_edge_length, h3_great_circle_distance, h3_get_hexagon_area_avg, h3_get_hexagon_edge_length_avg, h3_get_num_cells, h3_get_res0_cells, h3_get_res0_cells_string, h3_get_pentagons, h3_get_pentagons_string\n- `refs\u002Fa5.md` — a5_lonlat_to_cell, a5_cell_to_lonlat, a5_cell_area, a5_cell_to_boundary, a5_cell_to_parent, a5_cell_to_children, a5_get_resolution, a5_get_num_cells, a5_get_res0_cells, a5_compact, a5_uncompact\n\n**Python API:**\n- `refs\u002Fpython-api.md` — Read when: using DuckDB from Python, Arrow export, `fetch_arrow_table()` v1.5 bug, connection setup, GeoParquet writing, result fetching with geometry columns, v1.5 migration patterns.\n\n**External database connectors:**\n- `refs\u002Fbigquery.md` — Read when: connecting to Google BigQuery, querying BigQuery tables from DuckDB, working with BigQuery GEOGRAPHY columns, using bigquery_scan\u002Fbigquery_query functions, managing BigQuery datasets, or accessing public BigQuery datasets. Covers authentication (DuckDB Secrets, service accounts, gcloud), DDL operations, geometry mapping, and cost optimization.\n- `refs\u002Ficeberg.md` — Read when: working with Apache Iceberg tables, attaching to Iceberg REST catalogs (Polaris, Lakekeeper, AWS Glue, S3 Tables, BigLake), reading\u002Fwriting Iceberg tables, time travel via snapshots, partition pruning, schema evolution, or using iceberg_scan\u002Ficeberg_metadata\u002Ficeberg_snapshots functions.\n\n**Specialized topics:**\n- `refs\u002Fducklake.md` — Read when: working with DuckLake lakehouse (setup, time travel, partitioning, ACID, spatial support, VARIANT).\n- `refs\u002Fraster-tiling.md` — Read when: working with raster data, RASTER type, RT_* functions, RaQuet (raster-in-Parquet), QUADBIN spatial indexing, converting GeoTIFF\u002FCOG\u002FNetCDF to RaQuet, tile statistics, raquet-io CLI, Pyramid GeoParquet.\n- `refs\u002Ffts.md` — Read when: implementing full-text search (BM25 index creation, match_bm25 queries, stemming).\n- `refs\u002Fvss.md` — Read when: working with vector embeddings and similarity search (HNSW indexes, distance metrics).\n- `refs\u002Fwasm-patterns.md` — Read when: targeting DuckDB-WASM in the browser (extension loading, geocoding, MVT generation).\n- `refs\u002Fsummarize.md` — Read when: needing SUMMARIZE command details beyond the basics above.\n- `refs\u002Fautocomplete.md` — Read when: building interactive SQL tools with auto-complete.\n- `refs\u002Fexplain-analyze.md` — Read when: queries are complex or failing repeatedly, you need to understand query execution plans, diagnose performance issues, or break down complex queries into analyzable parts. Use EXPLAIN ANALYZE to see runtime metrics, actual vs estimated cardinalities, and operator timing.\n\n## Troubleshooting Extension Installation\n\nIf a standard extension installation fails or you encounter errors related to outdated functionality, try installing from the `core_nightly` repository to get the latest development build:\n\n```sql\n-- Standard installation (try this first)\nINSTALL extension_name;\nLOAD extension_name;\n\n-- If the above fails or you encounter version-related errors:\nFORCE INSTALL extension_name FROM core_nightly;\nLOAD extension_name;\n\n-- Example: DuckLake with latest features\nFORCE INSTALL ducklake FROM core_nightly;\nLOAD ducklake;\n```\n\n**When to use `core_nightly`:**\n- Standard installation fails with compatibility errors\n- You need features not yet in the stable release\n- Documentation mentions functionality you don't have\n- Error messages indicate version mismatches\n\n**Note**: `FORCE INSTALL` overwrites any existing installation. Nightly builds are development versions and may be less stable than official releases.\n\n## Configuration Quick Reference\n\n```sql\nSET geometry_always_xy = true;              -- lon\u002Flat = x\u002Fy axis order\nSET geometry_minimum_shredding_size = 30000; -- geometry shredding threshold\nSET enable_geoparquet_conversion = true;    -- auto-decode GeoParquet (default: true)\nSET ignore_unknown_crs = false;             -- error on unknown CRS (default: false)\n```\n",{"name":5,"description":7},"main","5fe69681d9e9b9b0d9646773dd9a8d3586b2ff86","",0,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill","https:\u002F\u002Fgithub.com\u002Fyharby","https:\u002F\u002Fyoussefharby.com\u002F","Using data to support lives","2026-03-19 18:19:08",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add yharby\u002Fduckdb-skill --skill duckdb",{"tool":58,"command":59},"bunx","bunx skills add yharby\u002Fduckdb-skill --skill duckdb",{"tool":61,"command":62},"pnpm","pnpm dlx skills add yharby\u002Fduckdb-skill --skill duckdb","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002FSKILL.md",true,[66,72,76,80,84,90,95,99,103,107,111,115,119,123,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,211,215,219],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},".claude-plugin\u002Fmarketplace.json","REFERENCE","参考文档",868,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002F.claude-plugin\u002Fmarketplace.json",{"path":73,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":74,"sourceHtmlUrl":75},".claude-plugin\u002Fplugin.json",466,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002F.claude-plugin\u002Fplugin.json",{"path":77,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":78,"sourceHtmlUrl":79},"commands\u002Fdetect.md",2077,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Fcommands\u002Fdetect.md",{"path":81,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":82,"sourceHtmlUrl":83},"hooks\u002Fhooks.json",276,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Fhooks\u002Fhooks.json",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"hooks\u002Fpost-bash-check.js","SCRIPT","脚本",2581,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Fhooks\u002Fpost-bash-check.js",{"path":91,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"LICENSE","许可证",1070,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002FLICENSE",{"path":96,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":97,"sourceHtmlUrl":98},"README.md",11826,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002FREADME.md",{"path":100,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":101,"sourceHtmlUrl":102},"refs\u002Fa5.md",4678,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fa5.md",{"path":104,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":105,"sourceHtmlUrl":106},"refs\u002Fautocomplete.md",1264,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fautocomplete.md",{"path":108,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":109,"sourceHtmlUrl":110},"refs\u002Fbigquery.md",20843,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fbigquery.md",{"path":112,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":113,"sourceHtmlUrl":114},"refs\u002Fducklake.md",39392,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fducklake.md",{"path":116,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":117,"sourceHtmlUrl":118},"refs\u002Fexplain-analyze.md",5119,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fexplain-analyze.md",{"path":120,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":121,"sourceHtmlUrl":122},"refs\u002Ffts.md",3425,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Ffts.md",{"path":124,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":125,"sourceHtmlUrl":126},"refs\u002Fgdal-formats.md",7602,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fgdal-formats.md",{"path":128,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":129,"sourceHtmlUrl":130},"refs\u002Fh3.md",6920,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fh3.md",{"path":132,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":133,"sourceHtmlUrl":134},"refs\u002Ficeberg.md",22109,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Ficeberg.md",{"path":136,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":137,"sourceHtmlUrl":138},"refs\u002Foverture-maps.md",3076,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Foverture-maps.md",{"path":140,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":141,"sourceHtmlUrl":142},"refs\u002Fpython-api.md",9664,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fpython-api.md",{"path":144,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":145,"sourceHtmlUrl":146},"refs\u002Fraster-tiling.md",20864,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fraster-tiling.md",{"path":148,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":149,"sourceHtmlUrl":150},"refs\u002Fspatial-indexes.md",2466,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial-indexes.md",{"path":152,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":153,"sourceHtmlUrl":154},"refs\u002Fspatial\u002Fa5-s2.md",7946,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fa5-s2.md",{"path":156,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":157,"sourceHtmlUrl":158},"refs\u002Fspatial\u002Faccessors.md",12632,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Faccessors.md",{"path":160,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":161,"sourceHtmlUrl":162},"refs\u002Fspatial\u002Faggregates.md",5351,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Faggregates.md",{"path":164,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":165,"sourceHtmlUrl":166},"refs\u002Fspatial\u002Fconversion-io.md",5418,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fconversion-io.md",{"path":168,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":169,"sourceHtmlUrl":170},"refs\u002Fspatial\u002Fcore-v15.md",2110,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fcore-v15.md",{"path":172,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":173,"sourceHtmlUrl":174},"refs\u002Fspatial\u002Fcoverage-tiling.md",4429,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fcoverage-tiling.md",{"path":176,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":177,"sourceHtmlUrl":178},"refs\u002Fspatial\u002Fcreation.md",4835,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fcreation.md",{"path":180,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":181,"sourceHtmlUrl":182},"refs\u002Fspatial\u002Findex.md",15539,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Findex.md",{"path":184,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":185,"sourceHtmlUrl":186},"refs\u002Fspatial\u002Flinear-ref.md",4227,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Flinear-ref.md",{"path":188,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":189,"sourceHtmlUrl":190},"refs\u002Fspatial\u002Fmacros.md",2138,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fmacros.md",{"path":192,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":193,"sourceHtmlUrl":194},"refs\u002Fspatial\u002Fmeasurement.md",7430,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fmeasurement.md",{"path":196,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":197,"sourceHtmlUrl":198},"refs\u002Fspatial\u002Fpredicates.md",4469,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Fpredicates.md",{"path":200,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":201,"sourceHtmlUrl":202},"refs\u002Fspatial\u002Ftable-functions.md",9373,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Ftable-functions.md",{"path":204,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":205,"sourceHtmlUrl":206},"refs\u002Fspatial\u002Ftransforms.md",15641,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fspatial\u002Ftransforms.md",{"path":208,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":209,"sourceHtmlUrl":210},"refs\u002Fsummarize.md",4957,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fsummarize.md",{"path":212,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":213,"sourceHtmlUrl":214},"refs\u002Fvss.md",3843,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fvss.md",{"path":216,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":217,"sourceHtmlUrl":218},"refs\u002Fwasm-patterns.md",5552,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Frefs\u002Fwasm-patterns.md",{"path":220,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":221,"sourceHtmlUrl":222},"settings.json",463,"https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Fsettings.json",[224],{"skillNo":225,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":226,"categories":227,"keywords":228,"publishedAt":38},"01M6DJG5E7N7J29T34XNTVQW0E","https:\u002F\u002Fgithub.com\u002Fyharby\u002Fduckdb-skill\u002Fblob\u002Fmain\u002Fskills\u002Fduckdb\u002FSKILL.md",[],[5]]