Uploaded image for project: 'Apache IoTDB'
  1. Apache IoTDB
  2. IOTDB-1233

Support SQL of aligned timeseries and schema template

    XMLWordPrintableJSON

Details

    • 2021-11-Tian

    Description

      We should support SQL of aligned timeseries and schema templates and support converting related SQL to physical plans.

      Schema Statement

      • Create Aligned Timeseries Statement
        CREATE ALIGNED TIMESERIES vectorFullPath WITH vectorAttributeClauses
        
        vectorFullPath
        : ROOT (DOT nodeNameWithoutStar)* LR_BRACKET nodeNameWithoutStar (COMMA nodeNameWithoutStar)* RR_BRACKET
        
        vectorAttributeClauses
        : DATATYPE OPERATOR_EQ LR_BRACKET dataType (COMMA dataType)* RR_BRACKET (COMMA ENCODING OPERATOR_EQ RR_BRACKET encoding (COMMA encoding)* RR_BRACKET)? 
          (COMMA (COMPRESSOR | COMPRESSION) OPERATOR_EQ compressor)?
        

        e.g.

        CREATE ALIGNED TIMESERIES root.sg.d1.vector1(s1,s2) WITH DATATYPE=(FLOAT,INT32), ENCODING=(RLE,GORILLA), COMPRESSOR=SNAPPY
        
      • Delete Aligned Timeseries Statement (IOTDB-1361
        Is SQL the same as univariable time series?
        Is it support deleting part of aligned timeseies?
      • Show/Count Timeseries Statement
        IoTDB> show timeseries
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        |             timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        | root.sg1.d1.vector1.s1| null|    root.sg_1|   FLOAT|     RLE|     SNAPPY|null|      null|
        | root.sg1.d1.vector1.s2| null|    root.sg_1|   INT32| GORILLA|     SNAPPY|null|      null|
        | root.sg1.d1.vector2.s1| null|    root.sg_1|   INT64|     RLE|     SNAPPY|null|      null|
        | root.sg1.d1.vector2.s2| null|    root.sg_1|   INT32|     RLE|     SNAPPY|null|      null|
        |         root.sg1.d1.s1| null|     root.sg1|   INT64|     RLE|     SNAPPY|null|      null|
        |         root.sg1.d1.s2| null|     root.sg1|   INT64|     RLE|     SNAPPY|null|      null|
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+

         How to distinguish aligned timeseries?

        IoTDB> show timeseries root.sg1.d1
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        |             timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        | root.sg1.d1.vector1.s1| null|    root.sg_1|   FLOAT|     RLE|     SNAPPY|null|      null|
        | root.sg1.d1.vector1.s2| null|    root.sg_1|   INT32| GORILLA|     SNAPPY|null|      null|
        | root.sg1.d1.vector2.s1| null|    root.sg_1|   INT64|     RLE|     SNAPPY|null|      null|
        | root.sg1.d1.vector2.s2| null|    root.sg_1|   INT32|     RLE|     SNAPPY|null|      null|
        |         root.sg1.d1.s1| null|     root.sg1|   INT64|     RLE|     SNAPPY|null|      null|
        |         root.sg1.d1.s2| null|     root.sg1|   INT64|     RLE|     SNAPPY|null|      null|
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        IoTDB> show timeseries root.sg1.d1.vector1
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        |             timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
        | root.sg1.d1.vector1.s1| null|    root.sg_1|   FLOAT|     RLE|     SNAPPY|null|      null|
        | root.sg1.d1.vector1.s2| null|    root.sg_1|   INT32| GORILLA|     SNAPPY|null|      null|
        +-----------------------+-----+-------------+--------+--------+-----------+----+----------+
      • Create Schema Template Statement
        CREATE SCHEMA TEMPLATE templateName=ID LR_BRACKET (templateItem|vectorTemplateItem)
         (COMMA (templateItem|vectorTemplateItem))* RR_BRACKET
        
        templateItem
        :LR_BRACKET nodeNameWithoutStar  WITH attributeClauses RR_BRACKET
        
        vectorTemplateItem
        :LR_BRACKET nodeNameWithoutStar LR_BRACKET nodeNameWithoutStar (COMMA nodeNameWithoutStar)*  RR_BRACKET WITH vectorAttributeClauses RR_BRACKET
        

        e.g.

        CREATE SCHEMA TEMPLATE temp1(
          (s1 WITH DATATYPE=INT32, ENCODING=GORILLA, COMPRESSOR=SNAPPY),
          (s2 WITH DATATYPE=FLOAT, ENCODING=RLE)
        )
        
        CREATE SCHEMA TEMPLATE temp2(
          (vector1(s1, s2) ALIGNED WITH DATATYPE=(FLOAT,INT32), ENCODING=(GORILLA,RLE), COMPRESSOR=SNAPPY),
          (s3 WITH DATATYPE=FLOAT, ENCODING=RLE)
        )
        
      • Set Schema Template Statement
        SET SCHEMA TEMPLATE templateName=ID TO prefixPath
        

        e.g.

        SET SCHEMA TEMPLATE temp1 TO root.sg1.d1
        
      • Unset SchemaTemplate Statement (IOTDB-1627)
        UNSET SCHEMA TEMPLATE templateName=ID FROM prefixPath
        

        e.g.

        UNSET SCHEMA TEMPLATE temp1 FROM root.sg1.d1
      • Drop Schema Template Statement
        DROP SCHEMA TEMPLATE templateName=ID
        

        e.g.

        DROP SCHEMA TEMPLATE temp1
      • Show All Device Template Statement
        SHOW SCHEMA TEMPLATES
        

        e.g.

        IoTDB> SHOW SCHEMA TEMPLATES
        +--------+-----------+--------+--------+------------+
        |template|measurement|dataType|encoding|  compressor|
        +--------+-----------+--------+--------+------------+
        |   temp1|         s1|   INT32| GORILLA|      SNAPPY|
        |   temp1|         s2|   FLOAT|     RLE|UNCOMPRESSED|
        |   temp2| vector1.s1|   FLOAT| GORILLA|      SNAPPY|
        |   temp2| vector1.s2|   INT32|     RLE|      SNAPPY|
        |   temp2|         s3|   FLOAT|     RLE|UNCOMPRESSED|
        +--------+-----------+--------+--------+------------+
        

      Data Management Statement

      • Insert Record Statement
        e.g.
        INSERT INTO root.sg.d1.vector1(time, s1, s2) VALUES(1, 1, 2.0)
        INSERT INTO root.sg.d1.vector1(time, s1) VALUES(1, 1)
        INSERT INTO root.sg.d1(time, s1, s2, s3) VALUES(1, 1, 2.0, 2.0)
        INSERT INTO root.sg.d1(time, s1, s3) VALUES(1, 1, 2.0, 2.0)
        INSERT INTO root.sg.d1(time, vector1, s3) VALUES(1, (1, 2.0), 2.0)
        INSERT INTO root.sg.d1(time, vector1(s1, s2), s3) VALUES(1, (1, 2.0), 2.0)
        INSERT INTO root.sg.d1(time, vector1(s1), s3) VALUES(1, (1), 2.0)
        INSERT INTO root.sg.d1(time, vector1(s1), s3) VALUES(1, 1, 2.0)
        

        Error:

        INSERT INTO root.sg.d1(time, (s1, s2), s3) VALUES(1, (1, 2.0), 2.0)
      • Delete Record Statement
        e.g.
        DELETE FROM root.sg1.d1.vector1 where time < XXXX
        DELETE FROM root.sg1.d1.vector1.s1 where time < XXXX
        

      Attachments

        Issue Links

          Activity

            People

              liuminghui Minghui Liu
              sunzesong Zesong Sun
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 8h
                  8h
                  Remaining:
                  Remaining Estimate - 8h
                  8h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified