Skip to content

Commit beddeec

Browse files
committed
add alter datatype from 2082 to timecho
1 parent 110d7df commit beddeec

24 files changed

Lines changed: 359 additions & 37 deletions

File tree

src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Total line number = 1
302302

303303
### 1.5 Update Tables
304304

305-
Used to update a table, including adding or deleting columns and configuring table properties.
305+
Used to update a table, including adding or deleting columns, modify column type (V2.0.8) and configuring table properties.
306306

307307
**Syntax:**
308308

@@ -313,13 +313,18 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
313313
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
314314
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
315315
| COMMENT ON COLUMN tableName.column IS 'column_comment'
316+
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
316317
```
317318

318319
**Note::**
319320

320321
1. The `SET PROPERTIES` operation currently only supports configuring the `TTL` property of a table
321322
2. The delete column function only supports deleting the ATTRIBUTE and FILD columns, and the TAG column does not support deletion.
322323
3. The modified comment will overwrite the original comment. If null is specified, the previous comment will be erased.
324+
4. Since version V2.0.8, modifying the data type of a column is supported. Currently, only columns with Category type FIELD can be modified.
325+
326+
* If the time series is concurrently deleted during the modification process, an error will be reported.
327+
* The new data type must be compatible with the original type. The specific compatibility is shown in the following table:
323328

324329
**Example:**
325330

@@ -329,6 +334,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
329334
ALTER TABLE table1 set properties TTL=3600
330335
COMMENT ON TABLE table1 IS 'table1'
331336
COMMENT ON COLUMN table1.a IS null
337+
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
332338
```
333339

334340
### 1.6 Delete Tables

src/UserGuide/Master/Table/SQL-Manual/SQL-Metadata-Operations_timecho.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
310310
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
311311
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
312312
| COMMENT ON COLUMN tableName.column IS 'column_comment'
313+
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
313314
```
314315

315316
**Examples:**
@@ -320,6 +321,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
320321
ALTER TABLE table1 set properties TTL=3600
321322
COMMENT ON TABLE table1 IS 'table1'
322323
COMMENT ON COLUMN table1.a IS null
324+
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
323325
```
324326

325327
### 2.6 Drop Table

src/UserGuide/Master/Table/User-Manual/Tree-to-Table_timecho.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ AS root.db.**
141141
### 2.2 Modifying a Table View
142142
#### 2.2.1 Syntax Definition
143143

144-
The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, deleting columns, setting the view's TTL property, and adding comments via COMMENT.
144+
The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, modifying FIELD column data type (supported since V2.0.8), deleting columns, setting the view's TTL property, and adding comments via COMMENT.
145145

146146
```SQL
147147
-- Rename view
@@ -156,6 +156,9 @@ viewColumnDefinition
156156
-- Rename a column in the view
157157
ALTER VIEW [IF EXISTS] viewName RENAME COLUMN [IF EXISTS] oldName TO newName
158158

159+
-- Modify the data type of a FIELD column
160+
ALTER VIEW [IF EXISTS] viewName ALTER COLUMN [IF EXISTS] columnName SET DATA TYPE new_type
161+
159162
-- Delete a column from the view
160163
ALTER VIEW [IF EXISTS] viewName DROP COLUMN [IF EXISTS] columnName
161164

@@ -171,6 +174,21 @@ COMMENT ON COLUMN qualifiedName '.' column=identifier IS (string | NULL) #commen
171174
1. The `SET PROPERTIES`operation currently only supports configuring the TTL property for the table view.
172175
2. The `DROP COLUMN`function only supports deleting FIELD columns; TAG columns cannot be deleted.
173176
3. Modifying the comment will overwrite the original comment. If set to `null`, the previous comment will be erased.
177+
4. When modifying the data type of a FIELD column, the new data type must be compatible with the original type. The specific compatibility is shown in the following table:
178+
179+
| Original Type | Convertible To Type |
180+
|---------------|----------------------------------------------|
181+
| INT32 | INT64, FLOAT, DOUBLE, TIMESTAMP, STRING, TEXT |
182+
| INT64 | TIMESTAMP, DOUBLE, STRING, TEXT |
183+
| FLOAT | DOUBLE, STRING, TEXT |
184+
| DOUBLE | STRING, TEXT |
185+
| BOOLEAN | STRING, TEXT |
186+
| TEXT | BLOB, STRING |
187+
| STRING | TEXT, BLOB |
188+
| BLOB | STRING, TEXT |
189+
| DATE | STRING, TEXT |
190+
| TIMESTAMP | INT64, DOUBLE, STRING, TEXT |
191+
174192
#### 2.2.3 Usage Examples
175193

176194
```SQL
@@ -183,6 +201,9 @@ ALTER VIEW IF EXISTS tableview ADD COLUMN IF NOT EXISTS temperature float field
183201
-- Rename a column in the view
184202
ALTER VIEW IF EXISTS tableview RENAME COLUMN IF EXISTS temperature TO temp
185203

204+
-- Modify the data type of a FIELD column
205+
ALTER VIEW IF EXISTS tableview ALTER COLUMN IF EXISTS temperature SET DATA TYPE double
206+
186207
-- Delete a column from the view
187208
ALTER VIEW IF EXISTS tableview DROP COLUMN IF EXISTS temp
188209

src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,43 @@ You can set different datatype, encoding, and compression for the timeseries in
409409

410410
It is also supported to set an alias, tag, and attribute for aligned timeseries.
411411

412-
### 2.3 Delete Timeseries
412+
### 2.3 Modifying Timseries Data Types
413+
414+
Starting from version V2.0.8, modifying the data type of a timeseries via SQL statements is supported.
415+
416+
Syntax definition:
417+
418+
```SQL
419+
ALTER TIMESERIES fullPath SET DATA TYPE newType=type
420+
```
421+
422+
Notes:
423+
424+
* If the timeseries is concurrently deleted during the modification process, an error will be reported.
425+
426+
* The new data type must be compatible with the original type. The specific compatibility is shown in the following table:
427+
428+
| Original Type |Convertible To Type |
429+
| ----------- | ----------------------------------------------- |
430+
| INT32 | INT64, FLOAT, DOUBLE, TIMESTAMP, STRING, TEXT |
431+
| INT64 | TIMESTAMP, DOUBLE, STRING, TEXT |
432+
| FLOAT | DOUBLE, STRING, TEXT |
433+
| DOUBLE | STRING, TEXT |
434+
| BOOLEAN | STRING, TEXT |
435+
| TEXT | BLOB, STRING |
436+
| STRING | TEXT, BLOB |
437+
| BLOB | STRING, TEXT |
438+
| DATE | STRING, TEXT |
439+
| TIMESTAMP | INT64, DOUBLE, STRING, TEXT |
440+
441+
Usage example:
442+
443+
```SQL
444+
ALTER TIMESERIES root.ln.wf01.wt01.temperature set data type DOUBLE
445+
```
446+
447+
448+
### 2.4 Delete Timeseries
413449

414450
To delete the timeseries we created before, we are able to use `(DELETE | DROP) TimeSeries <PathPattern>` statement.
415451

@@ -422,7 +458,7 @@ IoTDB> delete timeseries root.ln.wf02.*
422458
IoTDB> drop timeseries root.ln.wf02.*
423459
```
424460

425-
### 2.4 Show Timeseries
461+
### 2.5 Show Timeseries
426462

427463
* SHOW LATEST? TIMESERIES pathPattern? whereClause? limitClause?
428464

@@ -566,7 +602,7 @@ It costs 0.004s
566602
It is worth noting that when the queried path does not exist, the system will return no timeseries.
567603

568604

569-
### 2.5 Count Timeseries
605+
### 2.6 Count Timeseries
570606

571607
IoTDB is able to use `COUNT TIMESERIES <Path>` to count the number of timeseries matching the path. SQL statements are as follows:
572608

@@ -651,7 +687,7 @@ It costs 0.002s
651687

652688
> Note: The path of timeseries is just a filter condition, which has no relationship with the definition of level.
653689
654-
### 2.6 Active Timeseries Query
690+
### 2.7 Active Timeseries Query
655691
By adding WHERE time filter conditions to the existing SHOW/COUNT TIMESERIES, we can obtain time series with data within the specified time range.
656692

657693
It is important to note that in metadata queries with time filters, views are not considered; only the time series actually stored in the TsFile are taken into account.
@@ -691,7 +727,7 @@ IoTDB> count timeseries where time >= 15000 and time < 16000;
691727
+-----------------+
692728
```
693729
Regarding the definition of active time series, data that can be queried normally is considered active, meaning time series that have been inserted but deleted are not included.
694-
### 2.7 Tag and Attribute Management
730+
### 2.8 Tag and Attribute Management
695731

696732
We can also add an alias, extra tag and attribute information while creating one timeseries.
697733

src/UserGuide/Master/Tree/SQL-Manual/Keywords.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
- TRIGGER
209209
- TRIGGERS
210210
- TTL
211+
- TYPE
211212
- UNLINK
212213
- UNLOAD
213214
- UNSET

src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,16 @@ error: encoding TS_2DIFF does not support BOOLEAN
142142
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT , longitude FLOAT)
143143
```
144144

145-
### 2.3 Delete Timeseries
145+
### 2.3 Modify Timeseries Data Type
146+
147+
> Supported since V2.0.8
148+
149+
```SQL
150+
ALTER TIMESERIES root.ln.wf01.wt01.temperature set data type DOUBLE
151+
```
152+
153+
154+
### 2.4 Delete Timeseries
146155

147156
```sql
148157
IoTDB> delete timeseries root.ln.wf01.wt01.status
@@ -151,7 +160,7 @@ IoTDB> delete timeseries root.ln.wf02.*
151160
IoTDB> drop timeseries root.ln.wf02.*
152161
```
153162

154-
### 2.4 Show Timeseries
163+
### 2.5 Show Timeseries
155164

156165
```sql
157166
IoTDB> show timeseries root.**
@@ -161,7 +170,7 @@ IoTDB> show timeseries root.ln.** where timeseries contains 'wf01.wt'
161170
IoTDB> show timeseries root.ln.** where dataType=FLOAT
162171
```
163172

164-
### 2.5 Count Timeseries
173+
### 2.6 Count Timeseries
165174

166175
```sql
167176
IoTDB > COUNT TIMESERIES root.**
@@ -178,7 +187,7 @@ IoTDB > COUNT TIMESERIES root.ln.** GROUP BY LEVEL=2
178187
IoTDB > COUNT TIMESERIES root.ln.wf01.* GROUP BY LEVEL=2
179188
```
180189

181-
### 2.6 Tag and Attribute Management
190+
### 2.7 Tag and Attribute Management
182191

183192
```sql
184193
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)

src/UserGuide/latest-Table/Basic-Concept/Table-Management_timecho.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Total line number = 1
302302

303303
### 1.5 Update Tables
304304

305-
Used to update a table, including adding or deleting columns and configuring table properties.
305+
Used to update a table, including adding or deleting columns, modify column type (V2.0.8) and configuring table properties.
306306

307307
**Syntax:**
308308

@@ -313,13 +313,18 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
313313
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
314314
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
315315
| COMMENT ON COLUMN tableName.column IS 'column_comment'
316+
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
316317
```
317318

318319
**Note::**
319320

320321
1. The `SET PROPERTIES` operation currently only supports configuring the `TTL` property of a table
321322
2. The delete column function only supports deleting the ATTRIBUTE and FILD columns, and the TAG column does not support deletion.
322323
3. The modified comment will overwrite the original comment. If null is specified, the previous comment will be erased.
324+
4. Since version V2.0.8, modifying the data type of a column is supported. Currently, only columns with Category type FIELD can be modified.
325+
326+
* If the time series is concurrently deleted during the modification process, an error will be reported.
327+
* The new data type must be compatible with the original type. The specific compatibility is shown in the following table:
323328

324329
**Example:**
325330

@@ -329,6 +334,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
329334
ALTER TABLE table1 set properties TTL=3600
330335
COMMENT ON TABLE table1 IS 'table1'
331336
COMMENT ON COLUMN table1.a IS null
337+
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
332338
```
333339

334340
### 1.6 Delete Tables

src/UserGuide/latest-Table/SQL-Manual/SQL-Metadata-Operations_timecho.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
310310
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
311311
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
312312
| COMMENT ON COLUMN tableName.column IS 'column_comment'
313+
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
313314
```
314315

315316
**Examples:**
@@ -320,6 +321,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
320321
ALTER TABLE table1 set properties TTL=3600
321322
COMMENT ON TABLE table1 IS 'table1'
322323
COMMENT ON COLUMN table1.a IS null
324+
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
323325
```
324326

325327
### 2.6 Drop Table

src/UserGuide/latest-Table/User-Manual/Tree-to-Table_timecho.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ AS root.db.**
141141
### 2.2 Modifying a Table View
142142
#### 2.2.1 Syntax Definition
143143

144-
The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, deleting columns, setting the view's TTL property, and adding comments via COMMENT.
144+
The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, modifying FIELD column data type (supported since V2.0.8), deleting columns, setting the view's TTL property, and adding comments via COMMENT.
145145

146146
```SQL
147147
-- Rename view
@@ -156,6 +156,9 @@ viewColumnDefinition
156156
-- Rename a column in the view
157157
ALTER VIEW [IF EXISTS] viewName RENAME COLUMN [IF EXISTS] oldName TO newName
158158

159+
-- Modify the data type of a FIELD column
160+
ALTER VIEW [IF EXISTS] viewName ALTER COLUMN [IF EXISTS] columnName SET DATA TYPE new_type
161+
159162
-- Delete a column from the view
160163
ALTER VIEW [IF EXISTS] viewName DROP COLUMN [IF EXISTS] columnName
161164

@@ -171,6 +174,21 @@ COMMENT ON COLUMN qualifiedName '.' column=identifier IS (string | NULL) #commen
171174
1. The `SET PROPERTIES`operation currently only supports configuring the TTL property for the table view.
172175
2. The `DROP COLUMN`function only supports deleting FIELD columns; TAG columns cannot be deleted.
173176
3. Modifying the comment will overwrite the original comment. If set to `null`, the previous comment will be erased.
177+
4. When modifying the data type of a FIELD column, the new data type must be compatible with the original type. The specific compatibility is shown in the following table:
178+
179+
| Original Type | Convertible To Type |
180+
|---------------|----------------------------------------------|
181+
| INT32 | INT64, FLOAT, DOUBLE, TIMESTAMP, STRING, TEXT |
182+
| INT64 | TIMESTAMP, DOUBLE, STRING, TEXT |
183+
| FLOAT | DOUBLE, STRING, TEXT |
184+
| DOUBLE | STRING, TEXT |
185+
| BOOLEAN | STRING, TEXT |
186+
| TEXT | BLOB, STRING |
187+
| STRING | TEXT, BLOB |
188+
| BLOB | STRING, TEXT |
189+
| DATE | STRING, TEXT |
190+
| TIMESTAMP | INT64, DOUBLE, STRING, TEXT |
191+
174192
#### 2.2.3 Usage Examples
175193

176194
```SQL
@@ -183,6 +201,9 @@ ALTER VIEW IF EXISTS tableview ADD COLUMN IF NOT EXISTS temperature float field
183201
-- Rename a column in the view
184202
ALTER VIEW IF EXISTS tableview RENAME COLUMN IF EXISTS temperature TO temp
185203

204+
-- Modify the data type of a FIELD column
205+
ALTER VIEW IF EXISTS tableview ALTER COLUMN IF EXISTS temperature SET DATA TYPE double
206+
186207
-- Delete a column from the view
187208
ALTER VIEW IF EXISTS tableview DROP COLUMN IF EXISTS temp
188209

0 commit comments

Comments
 (0)