Skip to content

Document new array functions #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

This is a Docusaurus-based documentation site for QuestDB. Key commands:

### Local Development
- `yarn start` - Start development server on port 3001
- `yarn build` - Build production version
- `yarn serve` - Serve built site locally

### Prerequisites
- Node.js and Yarn package manager
- Java (for railroad diagram generation)
- Python (for railroad diagram scripts)

## Architecture Overview

### Documentation Structure
- **Source**: Content lives in `/documentation/` directory
- **Static Assets**: Images, diagrams, and files in `/static/`
- **Components**: React components for documentation in `/src/components/`
- **Themes**: Custom Docusaurus theme overrides in `/src/theme/`

### Key Directories
- `documentation/` - Main documentation content (markdown/MDX files)
- `documentation/reference/` - API and SQL reference documentation
- `documentation/guides/` - User guides and tutorials
- `documentation/concept/` - Conceptual documentation
- `static/images/` - Documentation images and diagrams
- `src/components/` - Custom React components for docs
- `plugins/` - Custom Docusaurus plugins

### Content Organization
- Documentation uses hierarchical structure with sidebars defined in `documentation/sidebars.js`
- Supports both `.md` and `.mdx` files
- Partial files (`.partial.mdx`) are excluded from routing but can be imported
- Math expressions supported via KaTeX
- Mermaid diagrams supported

## Documentation Features

### Special Syntax
- **QuestDB SQL**: Use `questdb-sql` language identifier for syntax highlighting
- **Railroad Diagrams**: SQL syntax diagrams generated via `scripts/railroad.py`
- **Math**: LaTeX-style math between `$` (inline) or `$$` (block)
- **Admonitions**: `:::note`, `:::tip`, `:::info`, `:::warning`, `:::danger`

### Custom Components
- `<RemoteRepoExample />` - Include code from other QuestDB repositories
- `<TabItem />` and `<Tabs />` - Tabbed content sections
- Various custom theme components in `src/theme/`

### Image Optimization
- Lint-staged hook optimizes images automatically
- WebP conversion supported via `scripts/webp-converter.sh`
- Size checking via `scripts/check-size-hook.sh`

## Development Workflow

### Creating Railroad Diagrams
1. Use [Railroad online editor](https://www.bottlecaps.de/rr/ui) to design
2. Save syntax to `static/images/docs/diagrams/.railroad`
3. Run `python3 scripts/railroad.py [name]` to generate SVG
4. Include generated markdown in documentation

### Content Guidelines
- Follow existing file naming conventions
- Use proper admonitions for important information
- Include code examples with appropriate language identifiers
- Optimize images before committing (handled automatically by hooks)

### Linting and Formatting
- ESLint and Prettier configured for code quality
- JavaScript Standard Style rules enforced
- Format on save recommended in editor
- Webpack handles linting during development

## Configuration

### Key Config Files
- `docusaurus.config.js` - Main Docusaurus configuration
- `documentation/sidebars.js` - Documentation navigation structure
- `package.json` - Dependencies and scripts
- `tailwind.config.js` - Tailwind CSS configuration

### Environment Variables
- `ALGOLIA_APP_ID` and `ALGOLIA_API_KEY` - Search functionality
- `NETLIFY` and `CONTEXT` - Build environment detection

## Testing and Deployment
- Production builds minify CSS and disable update notifiers
- Preview builds use relaxed error handling
- Algolia search integration for documentation search
- PWA support configured with custom manifest
105 changes: 105 additions & 0 deletions documentation/reference/function/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,46 @@ SELECT array_cum_sum(ARRAY[ [1.0, 1.0], [2.0, 2.0] ]);
| ---------------------- |
| ARRAY[1.0,2.0,4.0,6.0] |

## array_max

`array_max(array)` returns the maximum value from all the array elements. `NULL`
elements and non-finite values (NaN, Infinity) are ignored. If the array
contains no finite values, the function returns `NULL`.

#### Parameter

- `array` — the array

#### Example

```questdb-sql
SELECT array_max(ARRAY[ [1.0, 5.0], [3.0, 2.0] ]);
```

| array_max |
| --------- |
| 5.0 |

## array_min

`array_min(array)` returns the minimum value from all the array elements. `NULL`
elements and non-finite values (NaN, Infinity) are ignored. If the array
contains no finite values, the function returns `NULL`.

#### Parameter

- `array` — the array

#### Example

```questdb-sql
SELECT array_min(ARRAY[ [1.0, 5.0], [3.0, 2.0] ]);
```

| array_min |
| --------- |
| 1.0 |

## array_position

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

## array_stddev

`array_stddev(array)` returns the sample standard deviation of all the array
elements. This is an alias for `array_stddev_samp()`. `NULL` elements and
non-finite values (NaN, Infinity) are ignored. If the array contains fewer than
2 finite values, the function returns `NULL`.

#### Parameter

- `array` — the array

#### Example

```questdb-sql
SELECT array_stddev(ARRAY[ [1.0, 2.0], [3.0, 4.0] ]);
```

| array_stddev |
| ------------ |
| 1.29099445 |

## array_stddev_pop

`array_stddev_pop(array)` returns the population standard deviation of all the
array elements. `NULL` elements and non-finite values (NaN, Infinity) are
ignored. The population standard deviation uses N in the denominator of the
standard deviation formula. If the array contains no finite values, the function
returns `NULL`.

#### Parameter

- `array` — the array

#### Example

```questdb-sql
SELECT array_stddev_pop(ARRAY[ [1.0, 2.0], [3.0, 4.0] ]);
```

| array_stddev_pop |
| ---------------- |
| 1.11803399 |

## array_stddev_samp

`array_stddev_samp(array)` returns the sample standard deviation of all the
array elements. `NULL` elements and non-finite values (NaN, Infinity) are
ignored. The sample standard deviation uses N-1 in the denominator of the
standard deviation formula. If the array contains fewer than 2 finite values,
the function returns `NULL`.

#### Parameter

- `array` — the array

#### Example

```questdb-sql
SELECT array_stddev_samp(ARRAY[ [1.0, 2.0], [3.0, 4.0] ]);
```

| array_stddev_samp |
| ----------------- |
| 1.29099445 |

## dim_length

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