diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs index 31c075721..fd6794abc 100644 --- a/.lintstagedrc.mjs +++ b/.lintstagedrc.mjs @@ -48,16 +48,14 @@ function pytestStagedContent(paths, productPath) { // Instead of the plugin, we could use a placeholder test that always or conditionally passes. // Whether tests pass or fail, the container is removed, // but the CONTENT container and associated volume will remain until the next run. - // Note: the docker run -t flag is required to allocate a pseudo-TTY for the container--required for opening influxctl OAuth URLs. - `docker run --rm -t \ - --label tag=influxdata-docs \ - --label stage=test \ - --name ${TEST} \ - --env-file ${productPath}/.env.test \ - --volumes-from ${CONTENT} \ - --mount type=bind,src=./test/shared,dst=/shared \ - --mount type=volume,source=test-tmp,target=/app/iot-starter \ - influxdata-docs/pytest --codeblocks --suppress-no-test-exit-code --exitfirst ${productPath}/`, + // Note: TTY is required for the container to open influxctl OAuth URLs in the host browser. + `docker run --tty=true --label tag=influxdata-docs --label stage=test \ + --name ${TEST} \ + --env-file ${productPath}/.env.test \ + --volumes-from ${CONTENT} \ + --mount type=bind,src=./test/shared,dst=/shared \ + --mount type=volume,source=test-tmp,target=/app/iot-starter \ + influxdata-docs/pytest --codeblocks --suppress-no-test-exit-code --exitfirst ${productPath}/`, ]; } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b93ebb0a..031707ba1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,12 +77,17 @@ scripts configured in `.husky/pre-commit`, including linting and tests for your **We strongly recommend running linting and tests**, but you can skip them (and avoid installing dependencies) -by including the `--no-verify` flag with your commit--for example, enter the following command in your terminal: +by including the `HUSKY=0` environment variable or the `--no-verify` flag with +your commit--for example: ```sh git commit -m "" --no-verify ``` +```sh +HUSKY=0 git commit +``` + For more options, see the [Husky documentation](https://typicode.github.io/husky/how-to.html#skipping-git-hooks). ### Set up test scripts and credentials diff --git a/content/influxdb/cloud-dedicated/query-data/influxql/basic-query.md b/content/influxdb/cloud-dedicated/query-data/influxql/basic-query.md index 1b6a1b779..13f1611aa 100644 --- a/content/influxdb/cloud-dedicated/query-data/influxql/basic-query.md +++ b/content/influxdb/cloud-dedicated/query-data/influxql/basic-query.md @@ -25,20 +25,29 @@ following clauses: {{< req type="key" >}} -- {{< req "\*">}} `SELECT`: Specify fields, tags, and calculations to return from a - measurement or use the wildcard alias (`*`) to select all fields and tags - from a measurement. It requires at least one - [field key](/influxdb/cloud-dedicated/reference/glossary/#field-key) or the wildcard alias (`*`). - For more information, see [Notable SELECT statement behaviors](/influxdb/cloud-dedicated/reference/influxql/select/#notable-select-statement-behaviors). -- {{< req "\*">}} `FROM`: Specify the [measurement](/influxdb/cloud-dedicated/reference/glossary/#measurement) to query from. -It requires one or more comma-delimited [measurement expressions](/influxdb/cloud-dedicated/reference/influxql/select/#measurement_expression). +- {{< req "\*">}} `SELECT`: Specify fields, tags, and calculations to return + from a [table](/influxdb/cloud-dedicated/reference/glossary/#table) or use the + wildcard alias (`*`) to select all fields and tags from a table. It requires + at least one + [field key](/influxdb/cloud-dedicated/reference/glossary/#field-key) or the + wildcard alias (`*`). For more information, see + [Notable SELECT statement behaviors](/influxdb/cloud-dedicated/reference/influxql/select/#notable-select-statement-behaviors). +- {{< req "\*">}} `FROM`: Specify the + [table](/influxdb/cloud-dedicated/reference/glossary/#table) to query from. + + It requires one or more comma-delimited + [measurement expressions](/influxdb/cloud-dedicated/reference/influxql/select/#measurement_expression). + - `WHERE`: Filter data based on -[field values](/influxdb/cloud-dedicated/reference/glossary/#field), -[tag values](/influxdb/cloud-dedicated/reference/glossary/#tag), or -[timestamps](/influxdb/cloud-dedicated/reference/glossary/#timestamp). Only return data that meets the specified conditions--for example, falls within - a time range, contains specific tag values, or contains a field value outside a specified range. + [field values](/influxdb/cloud-dedicated/reference/glossary/#field), + [tag values](/influxdb/cloud-dedicated/reference/glossary/#tag), or + [timestamps](/influxdb/cloud-dedicated/reference/glossary/#timestamp). Only + return data that meets the specified conditions--for example, falls within a + time range, contains specific tag values, or contains a field value outside a + specified range. {{% influxdb/custom-timestamps %}} + ```sql SELECT temp, @@ -49,21 +58,28 @@ WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z' ``` + {{% /influxdb/custom-timestamps %}} ## Result set -If at least one row satisfies the query, {{% product-name %}} returns row data in the query result set. -If a query uses a `GROUP BY` clause, the result set includes the following: +If at least one row satisfies the query, {{% product-name %}} returns row data +in the query result set. +If a query uses a `GROUP BY` clause, the result set +includes the following: - Columns listed in the query's `SELECT` clause - A `time` column that contains the timestamp for the record or the group -- An `iox::measurement` column that contains the record's measurement (table) name -- Columns listed in the query's `GROUP BY` clause; each row in the result set contains the values used for grouping +- An `iox::measurement` column that contains the record's + [table](/influxdb/cloud-dedicated/reference/glossary/#table) name +- Columns listed in the query's `GROUP BY` clause; each row in the result set + contains the values used for grouping ### GROUP BY result columns -If a query uses `GROUP BY` and the `WHERE` clause doesn't filter by time, then groups are based on the [default time range](/influxdb/cloud-dedicated/reference/influxql/group-by/#default-time-range). +If a query uses `GROUP BY` and the `WHERE` clause doesn't filter by time, then +groups are based on the +[default time range](/influxdb/cloud-dedicated/reference/influxql/group-by/#default-time-range). ## Basic query examples @@ -75,9 +91,10 @@ If a query uses `GROUP BY` and the `WHERE` clause doesn't filter by time, then g - [Alias queried fields and tags](#alias-queried-fields-and-tags) {{% note %}} + #### Sample data -The following examples use the +The following examples use the [Get started home sensor data](/influxdb/cloud-dedicated/reference/sample-data/#get-started-home-sensor-data). To run the example queries and return results, [write the sample data](/influxdb/cloud-dedicated/reference/sample-data/#write-the-home-sensor-data-to-influxdb) @@ -89,12 +106,14 @@ to your {{% product-name %}} database before running the example queries. - Use the `SELECT` clause to specify what tags and fields to return. Specify at least one field key. To return all tags and fields, use the wildcard alias (`*`). -- Specify the measurement to query in the `FROM` clause. -- Specify time boundaries in the `WHERE` clause. - Include time-based predicates that compare the value of the `time` column to a timestamp. +- Specify the [table](/influxdb/cloud-dedicated/reference/glossary/#table) to + query in the `FROM` clause. +- Specify time boundaries in the `WHERE` clause. Include time-based predicates + that compare the value of the `time` column to a timestamp. Use the `AND` logical operator to chain multiple predicates together. {{% influxdb/custom-timestamps %}} + ```sql SELECT * FROM home @@ -102,13 +121,13 @@ WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T12:00:00Z' ``` + {{% /influxdb/custom-timestamps %}} Query time boundaries can be relative or absolute. {{< expand-wrapper >}} {{% expand "Query with relative time boundaries" %}} - To query data from relative time boundaries, compare the value of the `time` column to a timestamp calculated by subtracting an interval from a timestamp. Use `now()` to return the timestamp for the current time (UTC). @@ -119,7 +138,7 @@ Use `now()` to return the timestamp for the current time (UTC). SELECT * FROM home WHERE time >= now() - 30d ``` -##### Query one day of data data from a week ago +##### Query one day of data from a week ago ```sql SELECT * @@ -128,16 +147,18 @@ WHERE time >= now() - 7d AND time <= now() - 6d ``` + {{% /expand %}} {{% expand "Query with absolute time boundaries" %}} -To query data from absolute time boundaries, compare the value of the `time` column -to a timestamp literal. -Use the `AND` logical operator to chain together multiple predicates and define -both start and stop boundaries for the query. +To query data from absolute time boundaries, compare the value of the `time` +column to a timestamp literal. +Use the `AND` logical operator to chain together +multiple predicates and define both start and stop boundaries for the query. {{% influxdb/custom-timestamps %}} + ```sql SELECT * @@ -147,6 +168,7 @@ WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z' ``` + {{% /influxdb/custom-timestamps %}} {{% /expand %}} @@ -156,8 +178,8 @@ WHERE To query data without time boundaries, do not include any time-based predicates in your `WHERE` clause. -If a time range is not defined in the `WHERE` clause, the default time range is -the Unix epoch (`1970-01-01T00:00:00Z`) to _now_. +If a time range is not defined in the `WHERE` clause, +the default time range is the Unix epoch (`1970-01-01T00:00:00Z`) to _now_. {{% warn %}} Querying data _without time bounds_ can return an unexpected amount of data. @@ -172,8 +194,8 @@ SELECT * FROM home To query specific fields, include them in the `SELECT` clause. If querying multiple fields or tags, comma-delimit each. -If a field or tag key includes special characters or spaces or is case-sensitive, -wrap the key in _double-quotes_. +If a field or tag key includes special characters or spaces or is +case-sensitive, wrap the key in _double-quotes_. ```sql SELECT time, room, temp, hum FROM home @@ -181,10 +203,12 @@ SELECT time, room, temp, hum FROM home ### Query fields based on tag values -- In the `SELECT` clause, include fields you want to query and tags you want to base conditions on. -- In the `WHERE` clause, include predicates that compare the tag identifier to a string literal. - Use [logical operators](/influxdb/cloud-dedicated/reference/influxql/where/#logical-operators) to chain multiple predicates together and apply - multiple conditions. +- In the `SELECT` clause, include fields you want to query and tags you want to + base conditions on. +- In the `WHERE` clause, include predicates that compare the tag identifier to a + string literal. Use + [logical operators](/influxdb/cloud-dedicated/reference/influxql/where/#logical-operators) + to chain multiple predicates together and apply multiple conditions. ```sql SELECT * FROM home WHERE room = 'Kitchen' @@ -193,9 +217,12 @@ SELECT * FROM home WHERE room = 'Kitchen' ### Query points based on field values - In the `SELECT` clause, include fields you want to query. -- In the `WHERE` clause, include predicates that compare the field identifier to a value or expression. - Use [logical operators](/influxdb/cloud-dedicated/reference/influxql/where/#logical-operators) (`AND`, `OR`) to chain multiple predicates together - and apply multiple conditions. +- In the `WHERE` clause, include predicates that compare the field identifier to + a value or expression. + Use + [logical operators](/influxdb/cloud-dedicated/reference/influxql/where/#logical-operators) + (`AND`, `OR`) to chain multiple predicates together and apply multiple + conditions. ```sql SELECT co, time FROM home WHERE co >= 10 OR co <= -10 @@ -204,13 +231,17 @@ SELECT co, time FROM home WHERE co >= 10 OR co <= -10 ### Alias queried fields and tags To alias or rename fields and tags that you query, use the `AS` clause. -After the tag, field, or expression you want to alias, pass `AS` followed by the alias name as an identifier (wrap in double quotes (`"`) if the alias includes spaces or special characters)--for example: +After the tag, field, or expression you want to alias, pass `AS` followed by the +alias name as an identifier (wrap in double quotes (`"`) if the alias includes +spaces or special characters)--for example: ```sql SELECT temp AS temperature, hum AS "humidity (%)" FROM home ``` {{% note %}} -When aliasing columns in **InfluxQL**, use the `AS` clause and an [identifier](/influxdb/cloud-dedicated/reference/influxql/#identifiers). -When [aliasing columns in **SQL**](/influxdb/cloud-dedicated/query-data/sql/basic-query/#alias-queried-fields-and-tags), you can use the `AS` clause to define the alias, but it isn't necessary. +When aliasing columns in **InfluxQL**, use the `AS` clause and an +[identifier](/influxdb/cloud-dedicated/reference/influxql/#identifiers). When +[aliasing columns in **SQL**](/influxdb/cloud-dedicated/query-data/sql/basic-query/#alias-queried-fields-and-tags), +you can use the `AS` clause to define the alias, but it isn't necessary. {{% /note %}} diff --git a/content/influxdb/clustered/query-data/influxql/basic-query.md b/content/influxdb/clustered/query-data/influxql/basic-query.md index d4126cce1..db9d336a8 100644 --- a/content/influxdb/clustered/query-data/influxql/basic-query.md +++ b/content/influxdb/clustered/query-data/influxql/basic-query.md @@ -25,20 +25,29 @@ following clauses: {{< req type="key" >}} -- {{< req "\*">}} `SELECT`: Specify fields, tags, and calculations to return from a - measurement or use the wildcard alias (`*`) to select all fields and tags - from a measurement. It requires at least one - [field key](/influxdb/clustered/reference/glossary/#field-key) or the wildcard alias (`*`). - For more information, see [Notable SELECT statement behaviors](/influxdb/clustered/reference/influxql/select/#notable-select-statement-behaviors). -- {{< req "\*">}} `FROM`: Specify the [measurement](/influxdb/clustered/reference/glossary/#measurement) to query from. -It requires one or more comma-delimited [measurement expressions](/influxdb/clustered/reference/influxql/select/#measurement_expression). +- {{< req "\*">}} `SELECT`: Specify fields, tags, and calculations to return + from a [table](/influxdb/clustered/reference/glossary/#table) or use the + wildcard alias (`*`) to select all fields and tags from a table. It requires + at least one + [field key](/influxdb/clustered/reference/glossary/#field-key) or the + wildcard alias (`*`). For more information, see + [Notable SELECT statement behaviors](/influxdb/clustered/reference/influxql/select/#notable-select-statement-behaviors). +- {{< req "\*">}} `FROM`: Specify the + [table](/influxdb/clustered/reference/glossary/#table) to query from. + + It requires one or more comma-delimited + [measurement expressions](/influxdb/clustered/reference/influxql/select/#measurement_expression). + - `WHERE`: Filter data based on -[field values](/influxdb/clustered/reference/glossary/#field), -[tag values](/influxdb/clustered/reference/glossary/#tag), or -[timestamps](/influxdb/clustered/reference/glossary/#timestamp). Only return data that meets the specified conditions--for example, falls within - a time range, contains specific tag values, or contains a field value outside a specified range. + [field values](/influxdb/clustered/reference/glossary/#field), + [tag values](/influxdb/clustered/reference/glossary/#tag), or + [timestamps](/influxdb/clustered/reference/glossary/#timestamp). Only + return data that meets the specified conditions--for example, falls within a + time range, contains specific tag values, or contains a field value outside a + specified range. {{% influxdb/custom-timestamps %}} + ```sql SELECT temp, @@ -49,21 +58,28 @@ WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z' ``` + {{% /influxdb/custom-timestamps %}} ## Result set -If at least one row satisfies the query, {{% product-name %}} returns row data in the query result set. -If a query uses a `GROUP BY` clause, the result set includes the following: +If at least one row satisfies the query, {{% product-name %}} returns row data +in the query result set. +If a query uses a `GROUP BY` clause, the result set +includes the following: - Columns listed in the query's `SELECT` clause - A `time` column that contains the timestamp for the record or the group -- An `iox::measurement` column that contains the record's measurement (table) name -- Columns listed in the query's `GROUP BY` clause; each row in the result set contains the values used for grouping +- An `iox::measurement` column that contains the record's + [table](/influxdb/clustered/reference/glossary/#table) name +- Columns listed in the query's `GROUP BY` clause; each row in the result set + contains the values used for grouping ### GROUP BY result columns -If a query uses `GROUP BY` and the `WHERE` clause doesn't filter by time, then groups are based on the [default time range](/influxdb/clustered/reference/influxql/group-by/#default-time-range). +If a query uses `GROUP BY` and the `WHERE` clause doesn't filter by time, then +groups are based on the +[default time range](/influxdb/clustered/reference/influxql/group-by/#default-time-range). ## Basic query examples @@ -75,9 +91,10 @@ If a query uses `GROUP BY` and the `WHERE` clause doesn't filter by time, then g - [Alias queried fields and tags](#alias-queried-fields-and-tags) {{% note %}} + #### Sample data -The following examples use the +The following examples use the [Get started home sensor data](/influxdb/clustered/reference/sample-data/#get-started-home-sensor-data). To run the example queries and return results, [write the sample data](/influxdb/clustered/reference/sample-data/#write-the-home-sensor-data-to-influxdb) @@ -89,12 +106,14 @@ to your {{% product-name %}} database before running the example queries. - Use the `SELECT` clause to specify what tags and fields to return. Specify at least one field key. To return all tags and fields, use the wildcard alias (`*`). -- Specify the measurement to query in the `FROM` clause. -- Specify time boundaries in the `WHERE` clause. - Include time-based predicates that compare the value of the `time` column to a timestamp. +- Specify the [table](/influxdb/clustered/reference/glossary/#table) to + query in the `FROM` clause. +- Specify time boundaries in the `WHERE` clause. Include time-based predicates + that compare the value of the `time` column to a timestamp. Use the `AND` logical operator to chain multiple predicates together. {{% influxdb/custom-timestamps %}} + ```sql SELECT * FROM home @@ -102,6 +121,7 @@ WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T12:00:00Z' ``` + {{% /influxdb/custom-timestamps %}} Query time boundaries can be relative or absolute. @@ -119,7 +139,8 @@ Use `now()` to return the timestamp for the current time (UTC). SELECT * FROM home WHERE time >= now() - 30d ``` -##### Query one day of data data from a week ago +##### Query one day of data from a week ago + ```sql SELECT * FROM home @@ -127,16 +148,18 @@ WHERE time >= now() - 7d AND time <= now() - 6d ``` + {{% /expand %}} {{% expand "Query with absolute time boundaries" %}} -To query data from absolute time boundaries, compare the value of the `time` column -to a timestamp literal. -Use the `AND` logical operator to chain together multiple predicates and define -both start and stop boundaries for the query. +To query data from absolute time boundaries, compare the value of the `time` +column to a timestamp literal. +Use the `AND` logical operator to chain together +multiple predicates and define both start and stop boundaries for the query. {{% influxdb/custom-timestamps %}} + ```sql SELECT * @@ -146,6 +169,7 @@ WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z' ``` + {{% /influxdb/custom-timestamps %}} {{% /expand %}} @@ -155,8 +179,8 @@ WHERE To query data without time boundaries, do not include any time-based predicates in your `WHERE` clause. -If a time range is not defined in the `WHERE` clause, the default time range is -the Unix epoch (`1970-01-01T00:00:00Z`) to _now_. +If a time range is not defined in the `WHERE` clause, +the default time range is the Unix epoch (`1970-01-01T00:00:00Z`) to _now_. {{% warn %}} Querying data _without time bounds_ can return an unexpected amount of data. @@ -171,8 +195,8 @@ SELECT * FROM home To query specific fields, include them in the `SELECT` clause. If querying multiple fields or tags, comma-delimit each. -If a field or tag key includes special characters or spaces or is case-sensitive, -wrap the key in _double-quotes_. +If a field or tag key includes special characters or spaces or is +case-sensitive, wrap the key in _double-quotes_. ```sql SELECT time, room, temp, hum FROM home @@ -180,10 +204,12 @@ SELECT time, room, temp, hum FROM home ### Query fields based on tag values -- In the `SELECT` clause, include fields you want to query and tags you want to base conditions on. -- In the `WHERE` clause, include predicates that compare the tag identifier to a string literal. - Use [logical operators](/influxdb/clustered/reference/influxql/where/#logical-operators) to chain multiple predicates together and apply - multiple conditions. +- In the `SELECT` clause, include fields you want to query and tags you want to + base conditions on. +- In the `WHERE` clause, include predicates that compare the tag identifier to a + string literal. Use + [logical operators](/influxdb/clustered/reference/influxql/where/#logical-operators) + to chain multiple predicates together and apply multiple conditions. ```sql SELECT * FROM home WHERE room = 'Kitchen' @@ -192,9 +218,12 @@ SELECT * FROM home WHERE room = 'Kitchen' ### Query points based on field values - In the `SELECT` clause, include fields you want to query. -- In the `WHERE` clause, include predicates that compare the field identifier to a value or expression. - Use [logical operators](/influxdb/clustered/reference/influxql/where/#logical-operators) (`AND`, `OR`) to chain multiple predicates together - and apply multiple conditions. +- In the `WHERE` clause, include predicates that compare the field identifier to + a value or expression. + Use + [logical operators](/influxdb/clustered/reference/influxql/where/#logical-operators) + (`AND`, `OR`) to chain multiple predicates together and apply multiple + conditions. ```sql SELECT co, time FROM home WHERE co >= 10 OR co <= -10 @@ -203,15 +232,17 @@ SELECT co, time FROM home WHERE co >= 10 OR co <= -10 ### Alias queried fields and tags To alias or rename fields and tags that you query, use the `AS` clause. -After the tag, field, or expression you want to alias, pass `AS` followed by the alias name as an identifier (wrap in double quotes (`"`) if the alias includes spaces or special characters)--for example: +After the tag, field, or expression you want to alias, pass `AS` followed by the +alias name as an identifier (wrap in double quotes (`"`) if the alias includes +spaces or special characters)--for example: ```sql SELECT temp AS temperature, hum AS "humidity (%)" FROM home ``` {{% note %}} -When aliasing columns in **InfluxQL**, use the `AS` clause and an [identifier](/influxdb/clustered/reference/influxql/#identifiers). -When [aliasing columns in **SQL**](/influxdb/clustered/query-data/sql/basic-query/#alias-queried-fields-and-tags), you can use the `AS` clause to define the alias, but it isn't necessary. +When aliasing columns in **InfluxQL**, use the `AS` clause and an +[identifier](/influxdb/clustered/reference/influxql/#identifiers). When +[aliasing columns in **SQL**](/influxdb/clustered/query-data/sql/basic-query/#alias-queried-fields-and-tags), +you can use the `AS` clause to define the alias, but it isn't necessary. {{% /note %}} - - diff --git a/test/src/prepare-content.sh b/test/src/prepare-content.sh index a41d4b6d4..42ed5dfe9 100644 --- a/test/src/prepare-content.sh +++ b/test/src/prepare-content.sh @@ -52,6 +52,7 @@ function substitute_placeholders { /os.getenv("DATABASE_TOKEN")/! s/DATABASE_TOKEN/$INFLUX_TOKEN/g; /os.getenv("DATABASE_NAME")/! s/DATABASE_NAME/$INFLUX_DATABASE/g; s/--id DBRP_ID/--id $INFLUX_DBRP_ID/g; + s/example-db/$INFLUX_DATABASE/g; s/get-started/$INFLUX_DATABASE/g; /os.getenv("MANAGEMENT_TOKEN")/! s/MANAGEMENT_TOKEN/$MANAGEMENT_TOKEN/g; /os.getenv("ORG_ID")/! s/ORG_ID/$INFLUX_ORG/g;