Skip to content

[doc](sql-functions) numbered-example authoring format — array-filter.md as demo#3784

Open
boluor wants to merge 1 commit into
apache:masterfrom
boluor:convention/array-filter-numbered-examples
Open

[doc](sql-functions) numbered-example authoring format — array-filter.md as demo#3784
boluor wants to merge 1 commit into
apache:masterfrom
boluor:convention/array-filter-numbered-examples

Conversation

@boluor
Copy link
Copy Markdown
Contributor

@boluor boluor commented May 26, 2026

Summary

Demo PR proposing a small authoring convention for sql-manual/sql-functions/ doc pages, applied here to array-filter.md (EN + ZH) as a concrete example. Looking for maintainer feedback on the shape before scaling to other pages.

The convention in one paragraph

Inside ## Examples, each runnable example becomes a numbered pair of fenced blocks:

```sql {example="N"}      ← SQL to execute (copy button, runnable)
```result {example="N"}   ← expected output (no copy)
```error {example="N"}    ← expected error (no copy)

One-time fixture data goes in ```sql {setup}. The ## Syntax block stays unchanged. EN and ZH share the same example="N" numbers, so cross-language drift becomes mechanically detectable.

Why

  1. Machine-verifiable. A doc-verify tool can match every sql {example="N"} to its result|error block by ID — zero heuristic guessing about where SQL ends and output begins.
  2. EN/ZH consistency. Same example numbers across languages → missing or drifted examples are detectable by tooling, not by manual review.
  3. UX. Readers copy SQL safely; expected output stays visually distinct and is not mis-copied as input.
  4. Backward compatible. Pages that don't use the convention keep working exactly as today. It's opt-in per page.

What's in this PR

Just array-filter.md, both languages:

  • versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-filter.md
  • i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/array-functions/array-filter.md

Before / after (one example)

Before:

Using lambda expression to filter elements in double_array greater than or equal to 3:
```sql
SELECT array_filter(x -> x >= 3, double_array) FROM array_filter_test WHERE id = 1;
+------------------------------------------+
| array_filter(x -> x >= 3, double_array)  |
+------------------------------------------+
| [3.3, 4.4, 5.5]                          |
+------------------------------------------+
```

After:

**Example 1** — Lambda over a DOUBLE array column: keep elements `>= 3`.

```sql {example="1"}
SELECT array_filter(x -> x >= 3, double_array) FROM array_filter_test WHERE id = 1;
```

```result {example="1"}
+------------------------------------------+
| array_filter(x -> x >= 3, double_array)  |
+------------------------------------------+
| [3.3, 4.4, 5.5]                          |
+------------------------------------------+
```

Bundled fix

The original EN page had a code block at line ~164 with only the result table (the SELECT statement was missing). Reconstructed the SELECT from the result column header — it is now Example 9.

Verification

Ran every example on a single-node Apache Doris 4.1.1 cluster:

  • EN: 20 pass / 0 fail / 1 not_checked (Syntax illustrative block)
  • ZH: 20 pass / 0 fail / 1 not_checked
  • All 4 error examples carry kind=error expected output and match the actual errCode = …, detailMessage = … from Doris, after stripping environment-specific IP prefixes.

Rendering

Without any theme changes, docusaurus renders:

  • sql fences with syntax highlight + copy button (default behavior, unchanged)
  • result and error fences as plain code blocks (Prism doesn't know these languages, so no highlight; copy button still present by default)

The convention's full UX (red-styled error block, no copy on result/error) needs a small theme override, which would be a separate follow-up PR. This PR does not require any theme change — the markdown is valid and renders correctly today.

Asking for

  • Is the convention shape ({example="N"}, three fence types) OK?
  • Where should the full authoring spec live? Suggestions: .docs-governance/ or doc-tools/. A separate spec-doc PR can follow.
  • If approved, follow-ups will convert other array-* function pages in the same style.

Co-authored-by: doris-verify #3781

Demonstration of a proposed authoring convention for sql-manual function
docs. Each runnable example becomes a numbered pair of fenced blocks:

  ```sql {example="N"}     -- the SQL (copy button, runnable)
  ```result {example="N"}  -- expected output (no copy)
  ```error {example="N"}   -- expected error (no copy)

One-time fixture data goes in ```sql {setup}. Syntax / Description sections
stay unchanged. EN and ZH versions share example=N IDs for mechanical
cross-language consistency checks.

Verified on Apache Doris 4.1.1 single-node cluster: every example runs as
documented (20 pass / 0 fail across both languages).

Bundled fix: the original EN page had a code block at line ~164 with only
the result table (the SELECT statement was missing). Reconstructed the
SELECT from the result column header — it is now Example 9.

Backward compatible: pages that don't use this convention keep working
exactly as today; this is opt-in per page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant