Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7e184af
systemd timers
nwoolmer Oct 1, 2025
99431d5
add note about aggregation functions to help robots
nwoolmer Oct 1, 2025
4ace104
add the error message specifically
nwoolmer Oct 1, 2025
d175276
ilp notes
nwoolmer Oct 1, 2025
86d9975
scrap potentially vestigial window function
nwoolmer Oct 1, 2025
9815e15
IN list
nwoolmer Oct 1, 2025
db0ce17
mode
nwoolmer Oct 1, 2025
8b6a9bc
robot one shot
nwoolmer Oct 1, 2025
c2221b1
some edits
nwoolmer Oct 1, 2025
86903da
show columns
nwoolmer Oct 8, 2025
cc8b400
asof first pass
nwoolmer Oct 8, 2025
9a6f6a3
Merge branch 'main' into release-roundup-parquet-export
anizzi Oct 23, 2025
5edd45b
Merge remote-tracking branch 'origin/release-roundup-parquet-export' …
nwoolmer Oct 27, 2025
8ebd42c
correct table
nwoolmer Oct 27, 2025
3ba5815
doc fixes
nwoolmer Oct 27, 2025
4301187
simplify path
nwoolmer Oct 27, 2025
146e7ea
Merge branch 'main' into release-roundup-parquet-export
nwoolmer Oct 27, 2025
b9ad967
see if this fixes
nwoolmer Oct 27, 2025
c790824
Merge remote-tracking branch 'origin/release-roundup-parquet-export' …
nwoolmer Oct 27, 2025
4e48bcd
Apply suggestions from code review
nwoolmer Oct 28, 2025
2e41170
add note about rw requirement
nwoolmer Oct 28, 2025
2323a59
Merge remote-tracking branch 'origin/release-roundup-parquet-export' …
nwoolmer Oct 28, 2025
9375dc7
addressing comments
nwoolmer Oct 28, 2025
d879175
scrap meta
nwoolmer Oct 28, 2025
e6c5b1e
add example
nwoolmer Oct 28, 2025
f4aef9b
add tip reference
nwoolmer Oct 28, 2025
2b9a224
probably fixing links
nwoolmer Oct 28, 2025
603b526
nix rmode, leave it undocumented
nwoolmer Oct 28, 2025
4bb6fa8
fix links
nwoolmer Oct 28, 2025
626c30c
fix acorn
nwoolmer Oct 28, 2025
175be68
fix acorn maybe
nwoolmer Oct 28, 2025
304e664
definitely fixed
nwoolmer Oct 28, 2025
d3028d4
fixes
nwoolmer Oct 28, 2025
c53cf80
fixes
nwoolmer Oct 28, 2025
2f6bc1e
cleanup
nwoolmer Oct 28, 2025
1e223d2
cleanup
nwoolmer Oct 28, 2025
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
67 changes: 66 additions & 1 deletion documentation/reference/api/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,42 @@ returned in a tabular form to be saved and reused as opposed to JSON.
`/exp` is expecting an HTTP GET request with following parameters:

| Parameter | Required | Description |
| :-------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|:----------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `query` | Yes | URL encoded query text. It can be multi-line. |
| `limit` | No | Paging opp parameter. For example, `limit=10,20` will return row numbers 10 through to 20 inclusive and `limit=20` will return first 20 rows, which is equivalent to `limit=0,20`. `limit=-20` will return the last 20 rows. |
| `nm` | No | `true` or `false`. Skips the metadata section of the response when set to `true`. |
| `fmt` | No | Export format. Valid values: `parquet`, `csv`. When set to `parquet`, exports data in Parquet format instead of CSV. |

#### Parquet Export Parameters

:::warning

Parquet exports currently require writing interim data to disk, and therefore must be run on **read-write instances only**.

This limitation will be removed in future.

:::

When `fmt=parquet`, the following additional parameters are supported:

| Parameter | Required | Default | Description |
|:---------------------|:---------|:----------|:----------------------------------------------------------------------------------------------------|
| `partition_by` | No | `NONE` | Partition unit: `NONE`, `HOUR`, `DAY`, `WEEK`, `MONTH`, or `YEAR`. |
| `compression_codec` | No | `ZSTD` | Compression algorithm: `UNCOMPRESSED`, `SNAPPY`, `GZIP`, `LZ4`, `ZSTD`, `LZ4_RAW`, `BROTLI`, `LZO`. |
| `compression_level` | No | `9` | Compression level (codec-specific). Higher values = better compression but slower. |
| `row_group_size` | No | `100000` | Number of rows per Parquet row group. |
| `data_page_size` | No | `1048576` | Size of data pages in bytes (default 1MB). |
| `statistics_enabled` | No | `true` | Enable Parquet column statistics: `true` or `false`. |
| `parquet_version` | No | `2` | Parquet format version: `1` (v1.0) or `2` (v2.0). |
| `raw_array_encoding` | No | `true` | Use raw encoding for arrays: `true` or `false`. |
| `rmode` | No | `false` | Set HTTP response mode: `nodelay` or not sent |

The parameters must be URL encoded.

### Examples

#### CSV Export (default)

Considering the query:

```shell
Expand All @@ -620,6 +647,44 @@ A HTTP status code of `200` is returned with the following response body:
200501BS00005,"2005-01-10T00:00:00.000Z",21:13
```

#### Parquet Export

Export query results to Parquet format:

```shell
curl -G \
--data-urlencode "query=SELECT * FROM trades WHERE timestamp IN today()" \
--data-urlencode "fmt=parquet" \
http://localhost:9000/exp > trades_today.parquet
```

#### Parquet Export with Custom Options

Export with custom compression and partitioning:

```shell
curl -G \
--data-urlencode "query=SELECT * FROM trades" \
--data-urlencode "fmt=parquet" \
--data-urlencode "partition_by=DAY" \
--data-urlencode "compression_codec=ZSTD" \
--data-urlencode "compression_level=9" \
--data-urlencode "row_group_size=1000000" \
http://localhost:9000/exp > trades.parquet
```

#### Parquet Export with LZ4 Compression

Export with LZ4_RAW compression for faster export:

```shell
curl -G \
--data-urlencode "query=SELECT symbol, price, amount FROM trades WHERE timestamp > dateadd('h', -1, now())" \
--data-urlencode "fmt=parquet" \
--data-urlencode "compression_codec=LZ4_RAW" \
http://localhost:9000/exp > recent_trades.parquet
```

## Error responses

### Malformed queries
Expand Down
53 changes: 49 additions & 4 deletions documentation/reference/function/aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ Running it will result in the following error:

You can work around this limitation by using CTEs or subqueries:

```questdb-sql title="aggregates as function args workaround" demo
```questdb-sql title="CTE workaround"
-- CTE
WITH minmax AS (
SELECT min(timestamp) as min_date, max(timestamp) as max_date FROM trades
SELECT min(timestamp) AS min_date, max(timestamp) AS max_date FROM trades
)
SELECT datediff('d', min_date, max_date) FROM minmax;

-- Subquery
SELECT datediff('d', min_date, max_date) FROM (
SELECT min(timestamp) as min_date, max(timestamp) as max_date FROM trades
SELECT datediff('d', min_date, max_date)
FROM (
SELECT min(timestamp) AS min_date, max(timestamp) AS max_date FROM trades
);

```

:::
Expand Down Expand Up @@ -921,6 +923,49 @@ FROM (SELECT rnd_double() a FROM long_sequence(100));
| :--------------- |
| 49.5442334742831 |

## mode

`mode(value)` - calculates the mode (most frequent) value out of a particular dataset.

For `mode(B)`, if there are an equal number of `true` and `false` values, `true` will be returned as a tie-breaker.

For other modes, if there are equal mode values, the returned value will be whichever the code identifies first.

To make the result deterministic, you must enforce an underlying sort order.

#### Parameters

- `value` - one of (LONG, DOUBLE, BOOLEAN, STRING, VARCHAR, SYMBOL)

#### Return value

Return value type is the same as the type of the input `value`.


#### Examples

With this dataset:

| symbol | value |
|-----------|-------|
| A | alpha |
| A | alpha |
| A | alpha |
| A | omega |
| B | beta |
| B | beta |
| B | gamma |

```questdb-sql
SELECT symbol, mode(value) as mode FROM dataset;
```

| symbol | mode |
|--------|-------|
| A | alpha |
| B | beta |


## stddev / stddev_samp

`stddev_samp(value)` - Calculates the sample standard deviation of a set of
Expand Down
49 changes: 49 additions & 0 deletions documentation/reference/function/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,55 @@ If you want to re-read metadata for all user tables, simply use an asterisk:
SELECT hydrate_table_metadata('*');
```

## sys.copy_export_log

`sys.copy_export_log` is a pseudo-table containing the export log for `COPY TO` operations.

**Arguments:**

- `sys.copy_export_log` does not require arguments.

**Return value:**

Returns metadata on `COPY TO` export operations for the last three days, including the columns:

- `ts` - timestamp of the log event
- `id` - export identifier that can be used to track export progress
- `table_name` - source table name (or 'query' for subquery exports)
- `export_path` - destination directory path for the export
- `num_exported_files` - how many output files were written
- `phase` - progress markers for each export step
- `status` - event status for each phase, for example 'started', 'finished'
- `message` - additional text (important for error rows)
- `errors` - error number or flag

**Examples:**

```questdb-sql
COPY trades TO 'trades' WITH FORMAT PARQUET;
```

| id |
|------------------|
| 38b2b45f28aa822e |

Checking the log:

```questdb-sql
SELECT * FROM copy_export_log() WHERE id = '38b2b45f28aa822e';
```

| ts | id | table_name | export_path | num_exported_files | phase | status | message | errors |
|-----------------------------|------------------|------------|--------------------------------|--------------------|-----------------------|----------|---------|--------|
| 2025-10-27T14:07:20.513119Z | 38b2b45f28aa822e | trades | null | null | wait_to_run | started | queued | 0 |
| 2025-10-27T14:07:20.541779Z | 38b2b45f28aa822e | trades | null | null | wait_to_run | finished | 0 |
| 2025-10-27T14:07:20.542552Z | 38b2b45f28aa822e | trades | null | null | converting_partitions | started | null | 0 |
| 2025-10-27T14:07:20.658111Z | 38b2b45f28aa822e | trades | null | null | converting_partitions | finished | null | 0 |
| 2025-10-27T14:07:20.658185Z | 38b2b45f28aa822e | trades | null | null | move_files | started | null | 0 |
| 2025-10-27T14:07:20.670200Z | 38b2b45f28aa822e | trades | null | null | move_files | finished | null | 0 |
| 2025-10-27T14:07:20.670414Z | 38b2b45f28aa822e | trades | /<dbroot>/export/trades/ | 26 | success | finished | null | 0 |


## flush_query_cache()

`flush_query_cache' invalidates cached query execution plans.
Expand Down
Loading