Skip to content

Commit

Permalink
example doc improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Lawrence <[email protected]>
  • Loading branch information
slawr committed Aug 6, 2024
1 parent b7b47cb commit c9183fc
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions examples/vehicle-speed-downsample-iotdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ In this How-To we will use the IoTDB CLI client to send SQL commands on its comm
~~~
### Down-sample the data
In the previous steps we imported the dataset `vehicle_speed_rl_dataset.csv` into the timeseries ``root.test2.vin123test.`Vehicle.Speed` `` in IoTDB. Now we will down-sample the timeseries using an SQL query and the `Sample` function. The queries will be executed in the IoTDB CLI client.
In the previous steps we imported the dataset `vehicle_speed_rl_dataset.csv` into the timeseries `` root.test2.vin123test.`Vehicle.Speed` `` in IoTDB. Now we will down-sample the timeseries using an SQL query and the `Sample` function. The queries will be executed in the IoTDB CLI client.
SQL queries have a wide range of optional clauses to determine the data that is processed. For example, you can limit the query to a specific time range to isolate a specific journey for the [example scenario](#example-scenario-journey-analysis) at the start of this document.
SQL queries can contain a wide range of optional clauses to determine the data that is processed. For example, you can limit the query to a specific time range to isolate a specific journey for the [example scenario](#example-scenario-journey-analysis) at the start of this document.
Two simple examples are used to illustrate:
1. `SELECT SAMPLE FROM <ts1>`: down-sample timeseries ts1 and return the result
2. `SELECT SAMPLE INTO <ts2> FROM <ts1>` down-sample series ts1 and place the result INTO series ts2.
For this How-To we will concentrate on using two simple query statements:
1. `SELECT SAMPLE() FROM <ts1>` which down-samples timeseries ts1 and returns the result
2. `SELECT SAMPLE() INTO <ts2> FROM <ts1>` which down-samples timeseries ts1 and places the result *INTO* timeseries ts2.
#### Example query 1: return the result of down-sampling to 100 samples
SQL query to down-sample to 100 samples:
#### Example query 1: Down-sample to 100 samples and return the result
SQL query to down-sample timeseries `` root.test2.vin123test.`Vehicle.Speed` `` to 100 samples and return the result:
~~~sql
select sample(`Vehicle.Speed`,'method'='triangle','k'='100') from root.test2.vin123test
Expand Down Expand Up @@ -288,21 +288,21 @@ IoTDB>
#### Example query 2: Down-sample and store result in new timeseries
The IoTDB SQL syntax provides the `INTO` clause which stores the result in a new timeseries. This is very useful for internal ETL/ELT (Extract, Transform, Load) style operations. For example this could be used to prepare the end of day upload of data described in the [example scenario](#example-scenario-journey-analysis) at the start of this document.

Extend the example 1 SQL query to place the result in a new timeseries `speed_upload`:
Extend the example 1 SQL query statement to place the result in a new timeseries `root.test2.vin123test.speed_upload`:
~~~sql
select sample(`Vehicle.Speed`,'method'='triangle','k'='100') into root.test2(speed_upload) from root.test2.vin123test
select sample(`Vehicle.Speed`,'method'='triangle','k'='100') into root.test2.vin123test(speed_upload) from root.test2.vin123test
~~~

Example query result:
Example IoTDB CLI client query result:
~~~sql
IoTDB> select sample(`Vehicle.Speed`,'method'='triangle','k'='100') into root.test2(speed_upload) from root.test2.vin123test
+-----------------------------------------------------------------------------+-----------------------+-------+
| SourceColumn| TargetTimeseries|Written|
+-----------------------------------------------------------------------------+-----------------------+-------+
|sample(root.test2.vin123test.`Vehicle.Speed`, "method"="triangle", "k"="100")|root.test2.speed_upload| 100|
+-----------------------------------------------------------------------------+-----------------------+-------+
IoTDB> select sample(`Vehicle.Speed`,'method'='triangle','k'='100') into root.test2.vin123test(speed_upload) from root.test2.vin123test
+-----------------------------------------------------------------------------+----------------------------------+-------+
| SourceColumn| TargetTimeseries|Written|
+-----------------------------------------------------------------------------+----------------------------------+-------+
|sample(root.test2.vin123test.`Vehicle.Speed`, "method"="triangle", "k"="100")|root.test2.vin123test.speed_upload| 100|
+-----------------------------------------------------------------------------+----------------------------------+-------+
Total line number = 1
It costs 0.076s
It costs 0.028s
~~~

### Suggested next steps
Expand Down

0 comments on commit c9183fc

Please sign in to comment.