Skip to content

Commit 75d8cfa

Browse files
authored
Document new array functions (#219)
array_min, array_max, array_stddev_*
1 parent be5114b commit 75d8cfa

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed

CLAUDE.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
This is a Docusaurus-based documentation site for QuestDB. Key commands:
8+
9+
### Local Development
10+
- `yarn start` - Start development server on port 3001
11+
- `yarn build` - Build production version
12+
- `yarn serve` - Serve built site locally
13+
14+
### Prerequisites
15+
- Node.js and Yarn package manager
16+
- Java (for railroad diagram generation)
17+
- Python (for railroad diagram scripts)
18+
19+
## Architecture Overview
20+
21+
### Documentation Structure
22+
- **Source**: Content lives in `/documentation/` directory
23+
- **Static Assets**: Images, diagrams, and files in `/static/`
24+
- **Components**: React components for documentation in `/src/components/`
25+
- **Themes**: Custom Docusaurus theme overrides in `/src/theme/`
26+
27+
### Key Directories
28+
- `documentation/` - Main documentation content (markdown/MDX files)
29+
- `documentation/reference/` - API and SQL reference documentation
30+
- `documentation/guides/` - User guides and tutorials
31+
- `documentation/concept/` - Conceptual documentation
32+
- `static/images/` - Documentation images and diagrams
33+
- `src/components/` - Custom React components for docs
34+
- `plugins/` - Custom Docusaurus plugins
35+
36+
### Content Organization
37+
- Documentation uses hierarchical structure with sidebars defined in `documentation/sidebars.js`
38+
- Supports both `.md` and `.mdx` files
39+
- Partial files (`.partial.mdx`) are excluded from routing but can be imported
40+
- Math expressions supported via KaTeX
41+
- Mermaid diagrams supported
42+
43+
## Documentation Features
44+
45+
### Special Syntax
46+
- **QuestDB SQL**: Use `questdb-sql` language identifier for syntax highlighting
47+
- **Railroad Diagrams**: SQL syntax diagrams generated via `scripts/railroad.py`
48+
- **Math**: LaTeX-style math between `$` (inline) or `$$` (block)
49+
- **Admonitions**: `:::note`, `:::tip`, `:::info`, `:::warning`, `:::danger`
50+
51+
### Custom Components
52+
- `<RemoteRepoExample />` - Include code from other QuestDB repositories
53+
- `<TabItem />` and `<Tabs />` - Tabbed content sections
54+
- Various custom theme components in `src/theme/`
55+
56+
### Image Optimization
57+
- Lint-staged hook optimizes images automatically
58+
- WebP conversion supported via `scripts/webp-converter.sh`
59+
- Size checking via `scripts/check-size-hook.sh`
60+
61+
## Development Workflow
62+
63+
### Creating Railroad Diagrams
64+
1. Use [Railroad online editor](https://www.bottlecaps.de/rr/ui) to design
65+
2. Save syntax to `static/images/docs/diagrams/.railroad`
66+
3. Run `python3 scripts/railroad.py [name]` to generate SVG
67+
4. Include generated markdown in documentation
68+
69+
### Content Guidelines
70+
- Follow existing file naming conventions
71+
- Use proper admonitions for important information
72+
- Include code examples with appropriate language identifiers
73+
- Optimize images before committing (handled automatically by hooks)
74+
75+
### Linting and Formatting
76+
- ESLint and Prettier configured for code quality
77+
- JavaScript Standard Style rules enforced
78+
- Format on save recommended in editor
79+
- Webpack handles linting during development
80+
81+
## Configuration
82+
83+
### Key Config Files
84+
- `docusaurus.config.js` - Main Docusaurus configuration
85+
- `documentation/sidebars.js` - Documentation navigation structure
86+
- `package.json` - Dependencies and scripts
87+
- `tailwind.config.js` - Tailwind CSS configuration
88+
89+
### Environment Variables
90+
- `ALGOLIA_APP_ID` and `ALGOLIA_API_KEY` - Search functionality
91+
- `NETLIFY` and `CONTEXT` - Build environment detection
92+
93+
## Testing and Deployment
94+
- Production builds minify CSS and disable update notifiers
95+
- Preview builds use relaxed error handling
96+
- Algolia search integration for documentation search
97+
- PWA support configured with custom manifest

documentation/reference/function/array.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,46 @@ SELECT array_cum_sum(ARRAY[ [1.0, 1.0], [2.0, 2.0] ]);
7070
| ---------------------- |
7171
| ARRAY[1.0,2.0,4.0,6.0] |
7272

73+
## array_max
74+
75+
`array_max(array)` returns the maximum value from all the array elements. `NULL`
76+
elements and non-finite values (NaN, Infinity) are ignored. If the array
77+
contains no finite values, the function returns `NULL`.
78+
79+
#### Parameter
80+
81+
- `array` — the array
82+
83+
#### Example
84+
85+
```questdb-sql
86+
SELECT array_max(ARRAY[ [1.0, 5.0], [3.0, 2.0] ]);
87+
```
88+
89+
| array_max |
90+
| --------- |
91+
| 5.0 |
92+
93+
## array_min
94+
95+
`array_min(array)` returns the minimum value from all the array elements. `NULL`
96+
elements and non-finite values (NaN, Infinity) are ignored. If the array
97+
contains no finite values, the function returns `NULL`.
98+
99+
#### Parameter
100+
101+
- `array` — the array
102+
103+
#### Example
104+
105+
```questdb-sql
106+
SELECT array_min(ARRAY[ [1.0, 5.0], [3.0, 2.0] ]);
107+
```
108+
109+
| array_min |
110+
| --------- |
111+
| 1.0 |
112+
73113
## array_position
74114

75115
`array_position(array, elem)` returns the position of `elem` inside the 1D `array`. If
@@ -112,6 +152,71 @@ SELECT array_sum(ARRAY[ [1.0, 1.0], [2.0, 2.0] ]);
112152
| --------- |
113153
| 6.0 |
114154

155+
## array_stddev
156+
157+
`array_stddev(array)` returns the sample standard deviation of all the array
158+
elements. This is an alias for `array_stddev_samp()`. `NULL` elements and
159+
non-finite values (NaN, Infinity) are ignored. If the array contains fewer than
160+
2 finite values, the function returns `NULL`.
161+
162+
#### Parameter
163+
164+
- `array` — the array
165+
166+
#### Example
167+
168+
```questdb-sql
169+
SELECT array_stddev(ARRAY[ [1.0, 2.0], [3.0, 4.0] ]);
170+
```
171+
172+
| array_stddev |
173+
| ------------ |
174+
| 1.29099445 |
175+
176+
## array_stddev_pop
177+
178+
`array_stddev_pop(array)` returns the population standard deviation of all the
179+
array elements. `NULL` elements and non-finite values (NaN, Infinity) are
180+
ignored. The population standard deviation uses N in the denominator of the
181+
standard deviation formula. If the array contains no finite values, the function
182+
returns `NULL`.
183+
184+
#### Parameter
185+
186+
- `array` — the array
187+
188+
#### Example
189+
190+
```questdb-sql
191+
SELECT array_stddev_pop(ARRAY[ [1.0, 2.0], [3.0, 4.0] ]);
192+
```
193+
194+
| array_stddev_pop |
195+
| ---------------- |
196+
| 1.11803399 |
197+
198+
## array_stddev_samp
199+
200+
`array_stddev_samp(array)` returns the sample standard deviation of all the
201+
array elements. `NULL` elements and non-finite values (NaN, Infinity) are
202+
ignored. The sample standard deviation uses N-1 in the denominator of the
203+
standard deviation formula. If the array contains fewer than 2 finite values,
204+
the function returns `NULL`.
205+
206+
#### Parameter
207+
208+
- `array` — the array
209+
210+
#### Example
211+
212+
```questdb-sql
213+
SELECT array_stddev_samp(ARRAY[ [1.0, 2.0], [3.0, 4.0] ]);
214+
```
215+
216+
| array_stddev_samp |
217+
| ----------------- |
218+
| 1.29099445 |
219+
115220
## dim_length
116221

117222
`dim_length(array, dim)` returns the length of the n-dimensional array along

0 commit comments

Comments
 (0)