github stoolap/stoolap v0.3.7

latest releases: v0.5.0, v0.4.2, v0.4.1...
8 months ago

What's New in v0.3.7

PostgreSQL-Inspired DISTINCT ON

New DISTINCT ON (expr, ...) syntax for per-group deduplication, returning the first row for each unique combination of the specified expressions.

  • Hash-based dedup with O(groups) memory, correctly handles arbitrary ORDER BY patterns including non-leading sort orders
  • Pipeline order: ORDER BY, DISTINCT ON, column removal, LIMIT/OFFSET
  • Works across all query paths: single-table scans, JOINs, CTEs, subqueries, and complex ORDER BY
  • Supports aliased keys, computed expressions, keys not in SELECT, qualified identifiers, and NULL equality
  • Guards distinct index pushdown to prevent bypassing key-based dedup
-- First (highest) order per customer
SELECT DISTINCT ON (customer) customer, amount, order_date
FROM orders
ORDER BY customer, amount DESC;

-- Per-group dedup on joins with qualified keys
SELECT DISTINCT ON (c.name) c.name, p.amount
FROM customers c JOIN purchases p ON c.id = p.customer_id
ORDER BY c.name, p.amount DESC;

ON CONFLICT Upsert (PostgreSQL-Style)

  • ON CONFLICT (cols) DO UPDATE SET and DO NOTHING syntax
  • EXCLUDED pseudo-table to reference attempted insert values
  • Conflict target matching against PK and composite unique constraints
  • CHECK constraint validation during upsert updates
  • RETURNING clause and INSERT ... SELECT support for conflict handling
INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.com')
ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, email = EXCLUDED.email;

Constant Folding and Non-Deterministic Function Tracking

  • Compile-time constant folding for deterministic column-free expressions
  • FunctionInfo.deterministic flag with registry-based lookup
  • NOW, CURRENT_DATE, CURRENT_TIMESTAMP, RANDOM, SLEEP, EMBED marked non-deterministic
  • Semantic cache bypass for queries with non-deterministic functions
  • Pushdown evaluator for stable expressions like NOW() - INTERVAL '24h'

GROUP BY and Aggregation Optimizations

  • 3-column GROUP BY uses tuple keys (no Vec heap allocation)
  • 4+ columns use direct AHashMap (replaces hash-collision approach)
  • Early termination extended to 1, 2, and 3-column paths
  • FIRST/LAST aggregates support ORDER BY with O(1) sort-key tracking

Snapshot and Persistence

  • Persist default_value in both WAL and snapshot serialization
  • Re-record index and view DDL to WAL during snapshots so they survive truncation
  • Skip snapshot when WAL has not grown since last snapshot
  • Auto-snapshot loop sleeps min(cleanup, snapshot) interval
  • HNSW m and ef_construction exposed on Index trait for persistence

Performance

  • Restore panic = "abort" in release profile, recovering 5-15% across all benchmarks
  • Dev profile optimizations and thin LTO for faster builds

Parser and SQL Compatibility

  • CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP parsed as niladic functions (SQL standard, no parentheses required)
  • Keyword identifiers fold to lowercase (PostgreSQL compatibility)
  • Parse ISO 8601 timestamps with fractional seconds and UTC Z suffix
  • Keywords accepted as column names in SET assignments

Bug Fixes

  • Fix transaction INSERT with partial column lists: delegate to full executor pipeline for correct column mapping, default values, type coercion, and FK validation
  • Fix qualified column ambiguity in joins: ORDER BY and DISTINCT ON with qualified identifiers (e.g., c.name vs p.name) now correctly resolve when both joined tables have the same column name
  • Fix DISTINCT ON key resolution after projection: qualified keys resolve correctly when projected as bare names or under aliases
  • Fix classification cache: include DISTINCT ON expressions in hash key to prevent stale cache hits
  • Fix TimeTruncFunction duration cache miss on zero-duration values

Documentation

  • Go driver docs synced with stoolap-go README
  • Driver icons with official brand colors in docs sidebar and page headers

Full Changelog: v0.3.5...v0.3.7

Don't miss a new stoolap release

NewReleases is sending notifications on new releases.