Style guide for writing LPTS documentation. Auto-loaded when writing, editing, or reviewing docs, README, user guides, or SQL reference pages. Blends Snowflake's structured clarity with DuckDB's concise, example-first approach.
This guide defines how to write documentation for LPTS. The style blends Snowflake's structured clarity (hierarchical sections, thorough parameter docs) with DuckDB's concise, example-first approach (lead with code, short sentences, practical tone).
# Page Title <- H1: noun phrase, no verb
<- 2-3 sentence intro: what this is + why it matters
## How It Works <- H2: explain the mechanism
### Sub-concept <- H3: one per distinct idea
## When to Use This <- H2: use cases, decision criteria
## Limitations <- H2: always present, even if short
## Examples <- H2: 2-4 progressively complex examples
## See Also <- H2: links to related pages
# STATEMENT NAME <- H1: the SQL command
<- 1-2 sentence description
## Examples <- H2: FIRST, before syntax
## Syntax <- H2: formal syntax block
## Parameters <- H2: every parameter documented
## Usage Notes <- H2: behavioral details, edge cases
## Limitations <- H2: what doesn't work
## See Also <- H2: related commands
Use fenced SQL code blocks. Follow Snowflake's notation for formal syntax:
PRAGMA lpts('<select_statement>');
Notation conventions:
<placeholder> -- user-supplied value (angle brackets)[ optional ] -- optional clause (square brackets){ choice1 | choice2 } -- choose one (braces + pipe)For informal examples (the Examples section), use real values:
PRAGMA lpts('SELECT name FROM users WHERE age > 25');
foo/bar/baz. Use users, orders, products.-- Create a table and convert a query to CTE SQL
CREATE TABLE users (id INTEGER, name VARCHAR, age INTEGER);
INSERT INTO users VALUES (1, 'Alice', 30), (2, 'Bob', 22), (3, 'Carol', 28);
PRAGMA lpts('SELECT name FROM users WHERE age > 25');
WITH scan_0(t0_age, t0_name) AS (SELECT age, name FROM memory.main.users),
filter_1 AS (SELECT * FROM scan_0 WHERE (t0_age) > (CAST(25 AS INTEGER))),
projection_2(t1_name) AS (SELECT t0_name FROM filter_1)
SELECT t1_name AS name FROM projection_2;
-- Verify round-trip correctness
PRAGMA lpts_check('SELECT name FROM users WHERE age > 25');
true
-- comments, not /* */Three types, used sparingly:
> **Note:** Each CTE corresponds to exactly one operator from DuckDB's logical plan.
> **Important:** The `lpts_check` function compares bag equality. ORDER BY differences
> alone will not cause a mismatch.
> **Tip:** Use `SET lpts_dialect = 'postgres'` to generate Postgres-compatible SQL
> without catalog/schema prefixes in table references.
Rules:
Use tables for structured reference data:
| Function | Usage | Description |
|---|---|---|
| `PRAGMA lpts('query')` | Interactive | Returns CTE SQL for the given query |
| `lpts_query('query')` | Table function | Same as above, usable in SELECT |
| `PRAGMA lpts_exec('query')` | Testing | Runs LPTS-transformed query |
| `PRAGMA lpts_check('query')` | Testing | Round-trip correctness check |
Every feature page must have a Limitations section:
## Limitations
- Window functions are not yet supported.
- FULL OUTER JOIN, CROSS JOIN, and SEMI JOIN may throw NotImplementedException.
- CTEs in the source query are expanded by DuckDB's planner before LPTS processes
them -- the output will not preserve the original CTE structure.
- Very complex nested expressions may produce verbose output.
Rules:
Before publishing any documentation page, verify:
sql or text language tagsREADME.md (project root) -- The landing page. Contains:
docs/ for detailed documentationdocs/ -- Detailed documentation, organized by topic:
docs/
├── getting-started.md <- Quick start guide
├── user-guide/
│ ├── cte-pipeline.md <- Conceptual: how the pipeline works
│ ├── ast-layer.md <- Conceptual: AST nodes and tree structure
│ ├── dialect-support.md <- Conceptual: DuckDB vs Postgres output
│ └── debugging.md <- Using LPTS_DEBUG, print_ast, EXPLAIN
├── sql-reference/
│ ├── pragma-lpts.md
│ ├── pragma-lpts-exec.md
│ ├── pragma-lpts-check.md
│ ├── lpts-query.md
│ └── configuration.md
└── limitations.md <- Global limitations page