Node Name in Path

Node name is a special identifier, it can also be wildcard * and **. When creating timeseries, node name can not be wildcard. In query statment, you can use wildcard to match one or more nodes of path.

Wildcard

* represents one node. For example, root.vehicle.*.sensor1 represents a 4-node path which is prefixed with root.vehicle and suffixed with sensor1.

** represents (*)+, which is one or more nodes of *. For example, root.vehicle.device1.** represents all paths prefixed by root.vehicle.device1 with nodes num greater than or equal to 4, like root.vehicle.device1.*, root.vehicle.device1.*.*, root.vehicle.device1.*.*.*, etc; root.vehicle.**.sensor1 represents a path which is prefixed with root.vehicle and suffixed with sensor1 and has at least 4 nodes.

As * can also be used in expressions of select clause to represent multiplication, below are examples to help you better understand the usage of * :

  1. # create timeseries root.sg.`a*b`
  2. create timeseries root.sg.`a*b` with datatype=FLOAT,encoding=PLAIN;
  3. # As described in Identifier part, a*b should be quoted.
  4. # "create timeseries root.sg.a*b with datatype=FLOAT,encoding=PLAIN" is wrong.
  5. # create timeseries root.sg.a
  6. create timeseries root.sg.a with datatype=FLOAT,encoding=PLAIN;
  7. # create timeseries root.sg.b
  8. create timeseries root.sg.b with datatype=FLOAT,encoding=PLAIN;
  9. # query data of root.sg.`a*b`
  10. select `a*b` from root.sg
  11. # Header of result dataset
  12. |Time|root.sg.a*b|
  13. # multiplication of root.sg.a and root.sg.b
  14. select a*b from root.sg
  15. # Header of result dataset
  16. |Time|root.sg.a * root.sg.b|

Identifier

When node name is not wildcard, it is a identifier, which means the constraints on it is the same as described in Identifier part.

  • Create timeseries statement:
  1. # Node name contains special characters like ` and .,all nodes of this timeseries are: ["root","sg","www.`baidu.com"]
  2. create timeseries root.sg.`www.baidu.com`.a with datatype=FLOAT,encoding=PLAIN;
  3. # Node name is a real number.
  4. create timeseries root.sg.`111` with datatype=FLOAT,encoding=PLAIN;

After executing above statments, execute “show timeseries”,below is the result:

  1. +---------------------------+-----+-------------+--------+--------+-----------+----+----------+
  2. | timeseries|alias|database|dataType|encoding|compression|tags|attributes|
  3. +---------------------------+-----+-------------+--------+--------+-----------+----+----------+
  4. | root.sg.`111`.a| null| root.sg| FLOAT| PLAIN| SNAPPY|null| null|
  5. |root.sg.`www.baidu.com`.a| null| root.sg| FLOAT| PLAIN| SNAPPY|null| null|
  6. +---------------------------+-----+-------------+--------+--------+-----------+----+----------+
  • Insert statment:
  1. # Node name contains special characters like . and `
  2. insert into root.sg.`www.baidu.com`(timestamp, a) values(1, 2);
  3. # Node name is a real number.
  4. insert into root.sg(timestamp, `111`) values (1, 2);
  • Query statement:
  1. # Node name contains special characters like . and `
  2. select a from root.sg.`www.baidu.com`;
  3. # Node name is a real number.
  4. select `111` from root.sg

Results:

  1. # select a from root.sg.`www.baidu.com`
  2. +-----------------------------+---------------------------+
  3. | Time|root.sg.`www.baidu.com`.a|
  4. +-----------------------------+---------------------------+
  5. |1970-01-01T08:00:00.001+08:00| 2.0|
  6. +-----------------------------+---------------------------+
  7. # select `111` from root.sg
  8. +-----------------------------+-----------+
  9. | Time|root.sg.111|
  10. +-----------------------------+-----------+
  11. |1970-01-01T08:00:00.001+08:00| 2.0|
  12. +-----------------------------+-----------+