docs(cli): update table guide with query verification example

pull/6002/head
meelahme 2025-04-30 22:27:57 -07:00
parent 87cb0566ab
commit 88ec6af7a4
3 changed files with 85 additions and 9 deletions

View File

@ -55,11 +55,11 @@ You can use the following environment variables to set command options:
## Prerequisites
Before creating a distinct value cache, you must:
- Create a [database](/influxdb3/version/reference/cli/influxdb3/create/database/).
1. Create a [database](/influxdb3/version/reference/cli/influxdb3/create/database/).
- Create a [table](/influxdb3/version/reference/cli/influxdb3/create/table/) with the columns you want to cache.
2. Create a [table](/influxdb3/version/reference/cli/influxdb3/create/table/) with the columns you want to cache.
- Have a valid authentication token.
3. Have a valid authentication token.
## Examples

View File

@ -6,7 +6,10 @@ The `influxdb3 create last_cache` command creates a new last value cache.
<!--pytest.mark.skip-->
```bash
influxdb3 create last_cache [OPTIONS] --database <DATABASE_NAME> --table <TABLE> [CACHE_NAME]
influxdb3 create last_cache [OPTIONS] \
--database <DATABASE_NAME> \
--table <TABLE_NAME> \
[CACHE_NAME]
```
## Arguments
@ -40,9 +43,21 @@ You can use the following environment variables to set command options:
| `INFLUXDB3_DATABASE_NAME` | `--database` |
| `INFLUXDB3_AUTH_TOKEN` | `--token` |
## Prerequisites
Before creating a last value cache, you must:
Before creating a distinct value cache, you must:
1. Create a [database](/influxdb3/version/reference/cli/influxdb3/create/database/).
2. Create a [table](/influxdb3/version/reference/cli/influxdb3/create/table/) with the columns you want to cache.
3. Have a valid authentication token.
## Examples
### Create a last value cache
### Generic syntax
{{% code-placeholders "(DATABASE|TABLE|CACHE)_NAME (TAG_COLUMN|FIELD_COLUMN)" %}}
@ -57,12 +72,50 @@ influxdb3 create last_cache \
CACHE_NAME
```
{{% /code-placeholders %}}
In the example above, replace the following:
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: Database name
- {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}}: Table name
- {{% code-placeholder-key %}}`TAG_COLUMN`{{% /code-placeholder-key %}}: Column to use as the key in the cache
- {{% code-placeholder-key %}}`FIELD_COLUMN`{{% /code-placeholder-key %}}: Column to store as the value in the cache
- {{% code-placeholder-key %}}`CACHE_NAME`{{% /code-placeholder-key %}}: Optional name for the last value cache
- {{% code-placeholder-key %}}`CACHE_NAME`{{% /code-placeholder-key %}}: Optional name for the last value cache
## Create a basic last value cache for one column
Use this example to create a simple cache for a single key and value column:
<!--pytest.mark.skip-->
```bash
influxdb3 create last_cache \
--database my_test_db \
--table my_sensor_table \
--key-columns room \
--value-columns temp \
my_temp_cache
```
<!--pytest.mark.skip-->
## Create a last value cache with multiple keys and values
This example shows how to configure a more complex cache:
```bash
influxdb3 create last_cache \
--database my_test_db \
--table my_sensor_table \
--key-columns room,sensor_id \
--value-columns temp,hum \
--count 10 \
--ttl 1h \
my_sensor_cache
```
{{% /code-placeholders %}}
## Common pitfalls
- All specified key and value columns must exist in the table schema.
- Tokens must be passed with `--token` unless set via environment variable.
- If not specified, default values are used for `--count` and `--ttl`.

View File

@ -90,6 +90,8 @@ influxdb3 create table \
Use the following command to confirm that your table was created:
<!--pytest.mark.skip-->
```bash
influxdb3 query \
--database DATABASE_NAME \
@ -97,7 +99,28 @@ influxdb3 query \
"SHOW TABLES"
```
If successful, youll see a list of tables in the specified database, including the new one.
If successful, youll see a list of tables in the specified database, including the new one. The expected output should look similar to:
<!--pytest.mark.skip-->
```bash
+---------------+--------------------+----------------------------+------------+
| table_catalog | table_schema | table_name | table_type |
+---------------+--------------------+----------------------------+------------+
| public | iox | my_sensor_table | BASE TABLE |
| public | system | distinct_caches | BASE TABLE |
| public | system | last_caches | BASE TABLE |
| public | system | parquet_files | BASE TABLE |
| public | system | processing_engine_logs | BASE TABLE |
| public | system | processing_engine_triggers | BASE TABLE |
| public | system | queries | BASE TABLE |
| public | information_schema | tables | VIEW |
| public | information_schema | views | VIEW |
| public | information_schema | columns | VIEW |
| public | information_schema | df_settings | VIEW |
| public | information_schema | schemata | VIEW |
+---------------+--------------------+----------------------------+------------+
```
>[!Note]
> The `SHOW TABLES SQL` query must be run using the influxdb3 query CLI.