From 65faebb701a492a99bb5a6df43754269fc94a0ee Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 10 Feb 2025 09:42:48 -0700 Subject: [PATCH] Add 'last_cache' and 'distinct_cache' SQL functions (#5828) * add last_value and distinct_value sql functions * fixed cache function names --- .../core/reference/sql/functions/cache.md | 17 ++++++ .../reference/sql/functions/cache.md | 17 ++++++ .../influxdb3-sample-data/sample-data.md | 10 ++-- .../shared/sql-reference/functions/cache.md | 56 +++++++++++++++++++ 4 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 content/influxdb3/core/reference/sql/functions/cache.md create mode 100644 content/influxdb3/enterprise/reference/sql/functions/cache.md create mode 100644 content/shared/sql-reference/functions/cache.md diff --git a/content/influxdb3/core/reference/sql/functions/cache.md b/content/influxdb3/core/reference/sql/functions/cache.md new file mode 100644 index 000000000..c56aa4cfd --- /dev/null +++ b/content/influxdb3/core/reference/sql/functions/cache.md @@ -0,0 +1,17 @@ +--- +title: SQL cache functions +list_title: Cache functions +description: > + Retrieve cached data from {{< product-name >}} caches. +menu: + influxdb3_core: + name: Cache + parent: sql-functions +weight: 311 + +source: /shared/sql-reference/functions/cache.md +--- + + diff --git a/content/influxdb3/enterprise/reference/sql/functions/cache.md b/content/influxdb3/enterprise/reference/sql/functions/cache.md new file mode 100644 index 000000000..e1656ee44 --- /dev/null +++ b/content/influxdb3/enterprise/reference/sql/functions/cache.md @@ -0,0 +1,17 @@ +--- +title: SQL cache functions +list_title: Cache functions +description: > + Retrieve cached data from {{< product-name >}} caches. +menu: + influxdb3_enterprise: + name: Cache + parent: sql-functions +weight: 311 + +source: /shared/sql-reference/functions/cache.md +--- + + diff --git a/content/shared/influxdb3-sample-data/sample-data.md b/content/shared/influxdb3-sample-data/sample-data.md index fb0442044..82ce645c6 100644 --- a/content/shared/influxdb3-sample-data/sample-data.md +++ b/content/shared/influxdb3-sample-data/sample-data.md @@ -25,7 +25,7 @@ to ##### Schema -- home (measurement) +- home (table) - **tags**: - room - Kitchen @@ -208,7 +208,7 @@ to ##### Schema -- home_actions (measurement) +- home_actions (table) - **tags**: - room - Kitchen @@ -336,7 +336,7 @@ series use cases that involve seasonality. ##### Schema -- weather (measurement) +- weather (table) - **tags**: - location - Concord @@ -430,7 +430,7 @@ The Bitcoin price sample dataset provides Bitcoin prices from ##### Schema -- bitcoin (measurement) +- bitcoin (table) - **tags**: - code - EUR @@ -518,7 +518,7 @@ transformation functions. ##### Schema -- numbers (measurement) +- numbers (table) - **fields** - a (float between -1 and 1) - b (float between -3 and 3) diff --git a/content/shared/sql-reference/functions/cache.md b/content/shared/sql-reference/functions/cache.md new file mode 100644 index 000000000..f4e33b914 --- /dev/null +++ b/content/shared/sql-reference/functions/cache.md @@ -0,0 +1,56 @@ + +The {{< product-name >}} SQL implementation supports the following functions +that return data from {{< product-name >}} caches. + +- [distinct_cache](#distinct_cache) +- [last_cache](#last_cache) + +## distinct_cache + +Returns data from an {{< product-name >}} distinct value cache. + +```sql +distinct_cache(table_name, cache_name) +``` + +#### Arguments + +- **table_name**: Name of the table associated with the distinct value cache + _(formatted as a string literal)_. +- **datatype**: Name of the the distinct value cache to query + _(formatted as a string literal)_. + +{{< expand-wrapper >}} +{{% expand "View `distinct_cache` query example" %}} + +```sql +SELECT * FROM distinct_cache('example_table', 'exampleCacheName') +``` + +{{% /expand %}} +{{< /expand-wrapper >}} + +## last_cache + +Returns data from an {{< product-name >}} last value cache. + +```sql +last_cache(table_name, cache_name) +``` + +#### Arguments + +- **table_name**: Name of the table associated with the last value cache + _(formatted as a string literal)_. +- **datatype**: Name of the the last value cache to query + _(formatted as a string literal)_. + +{{< expand-wrapper >}} +{{% expand "View `last_cache` query example" %}} + +```sql +SELECT * FROM last_cache('example_table', 'exampleCacheName') +``` + +{{% /expand %}} +{{< /expand-wrapper >}}