From 01970ff212390f57d6099331dea552e9c883166c Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Sun, 8 Dec 2024 22:08:24 +0100 Subject: [PATCH] Linter and typo fixes --- docs/api/node_neo/overview.md | 21 +++++++++++++++++---- docs/data/json/installing_and_loading.md | 2 +- docs/data/json/loading_json.md | 2 +- docs/extensions/spatial/functions.md | 9 ++++----- docs/sql/functions/aggregates.md | 4 ++-- docs/sql/functions/utility.md | 2 +- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/docs/api/node_neo/overview.md b/docs/api/node_neo/overview.md index 1dbb1dada96..aebb4ab5b40 100644 --- a/docs/api/node_neo/overview.md +++ b/docs/api/node_neo/overview.md @@ -3,8 +3,6 @@ layout: docu title: Node.js API (Neo) --- -# DuckDB Node.js API (Neo) - An API for using [DuckDB](https://duckdb.org/) in [Node.js](https://nodejs.org/). This is a high-level API meant for applications. @@ -14,6 +12,7 @@ available separately as [@duckdb/duckdb-bindings](https://www.npmjs.com/package/ ## Features ### Main differences from [duckdb-node](https://www.npmjs.com/package/duckdb) + - Native support for Promises; no need for separate [duckdb-async](https://www.npmjs.com/package/duckdb-async) wrapper. - DuckDB-specific API; not based on the [SQLite Node API](https://www.npmjs.com/package/sqlite3). - Lossless & efficent support for values of all [DuckDB data types](https://duckdb.org/docs/sql/data_types/overview). @@ -23,6 +22,7 @@ available separately as [@duckdb/duckdb-bindings](https://www.npmjs.com/package/ ### Roadmap Some features are not yet complete: + - Appending and binding advanced data types. (Additional DuckDB C API support needed.) - Writing to data chunk vectors. (Needs special handling in Node.) - User-defined types & functions. (Support for this was added to the DuckDB C API in v1.1.0.) @@ -55,21 +55,25 @@ import { DuckDBInstance } from '@duckdb/node-api'; ``` Create with an in-memory database: + ```ts const instance = await DuckDBInstance.create(':memory:'); ``` Equivalent to the above: + ```ts const instance = await DuckDBInstance.create(); ``` Read from and write to a database file, which is created if needed: + ```ts const instance = await DuckDBInstance.create('my_duckdb.db'); ``` Set configuration options: + ```ts const instance = await DuckDBInstance.create('my_duckdb.db', { threads: '4' @@ -100,17 +104,20 @@ const result = await prepared.run(); ### Inspect Result Get column names and types: + ```ts const columnNames = result.columnNames(); const columnTypes = result.columnTypes(); ``` Fetch all chunks: + ```ts const chunks = await result.fetchAllChunks(); ``` Fetch one chunk at a time: + ```ts const chunks = []; while (true) { @@ -124,18 +131,21 @@ while (true) { ``` Read chunk data (column-major): + ```ts // array of columns, each as an array of values const columns = chunk.getColumns(); ``` Read chunk data (row-major): + ```ts // array of rows, each as an array of values const columns = chunk.getRows(); ``` -Read chunk data (one value at a time) +Read chunk data (one value at a time): + ```ts const columns = []; const columnCount = chunk.columnCount; @@ -154,13 +164,15 @@ for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) { ### Result Reader Run and read all data: + ```ts const reader = await connection.runAndReadAll('from test_all_types()'); const rows = reader.getRows(); // OR: const columns = reader.getColumns(); ``` -Run and read up to (at lesat) some number of rows: +Run and read up to (at least) some number of rows: + ```ts const reader = await connection.runAndReadUtil('from range(5000)', 1000); const rows = reader.getRows(); @@ -168,6 +180,7 @@ const rows = reader.getRows(); ``` Read rows incrementally: + ```ts const reader = await connection.runAndRead('from range(5000)'); reader.readUntil(2000); diff --git a/docs/data/json/installing_and_loading.md b/docs/data/json/installing_and_loading.md index f48c7515556..eb4b32b9ec9 100644 --- a/docs/data/json/installing_and_loading.md +++ b/docs/data/json/installing_and_loading.md @@ -8,4 +8,4 @@ The `json` extension is shipped by default in DuckDB builds, otherwise, it will ```sql INSTALL json; LOAD json; -``` \ No newline at end of file +``` diff --git a/docs/data/json/loading_json.md b/docs/data/json/loading_json.md index ead143744b8..a81fb81ee52 100644 --- a/docs/data/json/loading_json.md +++ b/docs/data/json/loading_json.md @@ -114,7 +114,7 @@ Besides the `maximum_object_size`, `format`, `ignore_errors` and `compression`, | `sample_size` | Option to define number of sample objects for automatic JSON type detection. Set to -1 to scan the entire input file | `UBIGINT` | `20480` | | `timestampformat` | Specifies the date format to use when parsing timestamps. See [Date Format]({% link docs/sql/functions/dateformat.md %}) | `VARCHAR` | `'iso'`| | `union_by_name` | Whether the schema's of multiple JSON files should be [unified]({% link docs/data/multiple_files/combining_schemas.md %}) | `BOOL` | `false` | -| `map_inference_threshold` | Controls the threshold for number of columns whose schema will be auto-detected; if JSON schema auto-detection would infer a `STRUCT` type for a field that has _more_ than this threshold number of subfields, it infers a `MAP` type instead. Set to -1 to disable `MAP` inference. | `BIGINT` | `24` +| `map_inference_threshold` | Controls the threshold for number of columns whose schema will be auto-detected; if JSON schema auto-detection would infer a `STRUCT` type for a field that has _more_ than this threshold number of subfields, it infers a `MAP` type instead. Set to -1 to disable `MAP` inference. | `BIGINT` | `24` | Example usage: diff --git a/docs/extensions/spatial/functions.md b/docs/extensions/spatial/functions.md index c4ac78b465d..53ced9fba43 100644 --- a/docs/extensions/spatial/functions.md +++ b/docs/extensions/spatial/functions.md @@ -255,12 +255,11 @@ VARCHAR ST_AsSVG (col0 GEOMETRY, col1 BOOLEAN, col2 INTEGER) Convert the geometry into a SVG fragment or path -Convert the geometry into a SVG fragment or path - The SVG fragment is returned as a string. The fragment is a path element that can be used in an SVG document. - The second Boolean argument specifies whether the path should be relative or absolute. - The third argument specifies the maximum number of digits to use for the coordinates. +The SVG fragment is returned as a string. The fragment is a path element that can be used in an SVG document. +The second Boolean argument specifies whether the path should be relative or absolute. +The third argument specifies the maximum number of digits to use for the coordinates. - Points are formatted as cx/cy using absolute coordinates or x/y using relative coordinates. +Points are formatted as cx/cy using absolute coordinates or x/y using relative coordinates. #### Example diff --git a/docs/sql/functions/aggregates.md b/docs/sql/functions/aggregates.md index 9838c977b02..f63a209bbab 100644 --- a/docs/sql/functions/aggregates.md +++ b/docs/sql/functions/aggregates.md @@ -128,8 +128,8 @@ The table below shows the available general aggregate functions. | [`fsum(arg)`](#fsumarg) | Calculates the sum using a more accurate floating point summation (Kahan Sum). | | [`geomean(arg)`](#geomeanarg) | Calculates the geometric mean of all non-null values in `arg`. | | [`histogram(arg)`](#histogramarg) | Returns a `MAP` of key-value pairs representing buckets and counts. | -| [`histogram(arg, boundaries)`](#histogramargboundaries) | Returns a `MAP` of key-value pairs representing the provided upper `boundaries` and counts of elements in the corresponding left-open and right-closed partition of the datatype. A boundary at the largest value of the datatype is automatically added when elements larger than all provided `boundaries` appear, see [`is_histogram_other_bin`]({% link docs/sql/functions/utility.md %}#is_histogram_other_binarg). Boundaries may be provided, e.g., via [`equi_width_bins`]({% link docs/sql/functions/utility.md %}#equi_width_binsminmaxbincountnice). | -| [`histogram_exact(arg, elements)`](#histogram_exactargelements) | Returns a `MAP` of key-value pairs representing the requested elements and their counts. A catch-all element specific to the data-type is automatically added to count other elements when they appear, see [`is_histogram_other_bin`]({% link docs/sql/functions/utility.md %}#is_histogram_other_binarg). | +| [`histogram(arg, boundaries)`](#histogramarg-boundaries) | Returns a `MAP` of key-value pairs representing the provided upper `boundaries` and counts of elements in the corresponding left-open and right-closed partition of the datatype. A boundary at the largest value of the datatype is automatically added when elements larger than all provided `boundaries` appear, see [`is_histogram_other_bin`]({% link docs/sql/functions/utility.md %}#is_histogram_other_binarg). Boundaries may be provided, e.g., via [`equi_width_bins`]({% link docs/sql/functions/utility.md %}#equi_width_binsminmaxbincountnice). | +| [`histogram_exact(arg, elements)`](#histogram_exactarg-elements) | Returns a `MAP` of key-value pairs representing the requested elements and their counts. A catch-all element specific to the data-type is automatically added to count other elements when they appear, see [`is_histogram_other_bin`]({% link docs/sql/functions/utility.md %}#is_histogram_other_binarg). | | [`last(arg)`](#lastarg) | Returns the last value of a column. This function is [affected by ordering](#order-by-clause-in-aggregate-functions). | | [`list(arg)`](#listarg) | Returns a `LIST` containing all the values of a column. This function is [affected by ordering](#order-by-clause-in-aggregate-functions). | | [`max(arg)`](#maxarg) | Returns the maximum value present in `arg`. | diff --git a/docs/sql/functions/utility.md b/docs/sql/functions/utility.md index 1f5fb68e300..783459ee1ef 100644 --- a/docs/sql/functions/utility.md +++ b/docs/sql/functions/utility.md @@ -24,7 +24,7 @@ The functions below are difficult to categorize into specific function types and | [`current_setting('setting_name')`](#current_settingsetting_name) | Return the current value of the configuration setting. | | [`currval('sequence_name')`](#currvalsequence_name) | Return the current value of the sequence. Note that `nextval` must be called at least once prior to calling `currval`. | | [`error(message)`](#errormessage) | Throws the given error `message`. | -| [`equi_width_bins(min, max, bincount, nice := false)`](#equi_width_binsminmaxbincountnice) | Returns the upper boundaries of a partition of the interval `[min, max]` into `bin_count` equal-sized subintervals (for use with, e.g., [`histogram`]({% link docs/sql/functions/aggregates.md %}#histogramargboundaries)). If `nice = true`, then `min`, `max`, and `bincount` may be adjusted to produce more aesthetically pleasing results. | +| [`equi_width_bins(min, max, bincount, nice := false)`](#equi_width_binsmin-max-bincount-nice--false) | Returns the upper boundaries of a partition of the interval `[min, max]` into `bin_count` equal-sized subintervals (for use with, e.g., [`histogram`]({% link docs/sql/functions/aggregates.md %}#histogramargboundaries)). If `nice = true`, then `min`, `max`, and `bincount` may be adjusted to produce more aesthetically pleasing results. | | [`force_checkpoint(database)`](#force_checkpointdatabase) | Synchronize WAL with file for (optional) database interrupting transactions. | | [`gen_random_uuid()`](#gen_random_uuid) | Alias of `uuid`. Return a random UUID similar to this: `eeccb8c5-9943-b2bb-bb5e-222f4e14b687`. | | [`getenv(var)`](#getenvvar) | Returns the value of the environment variable `var`. Only available in the [command line client]({% link docs/api/cli/overview.md %}). |