-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Alter column and timeseries datatype with ANSI SQL statement #16027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Alter column and timeseries datatype with ANSI SQL statement #16027
Conversation
# Conflicts: # iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java # pom.xml
# Conflicts: # integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppDataNodeConfig.java # integration-test/src/main/java/org/apache/iotdb/it/env/remote/config/RemoteDataNodeConfig.java # integration-test/src/main/java/org/apache/iotdb/itbase/env/DataNodeConfig.java # iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java # iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/column/TsTableColumnSchema.java # pom.xml
# Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
# Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunk.java
# Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
# Conflicts: # integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBSetSystemStatusTableIT.java
(cherry picked from commit ea9f726)
# Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/modification/ModificationFile.java
# Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertRowNode.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunk.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunkGroup.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedPageReader.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
# Conflicts: # iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java # iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AlignedWritableMemChunkGroup.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/WritableMemChunkGroup.java
# Conflicts: # integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java # iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/receiver/protocol/IoTDBConfigNodeReceiver.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/performer/impl/FastCompactionPerformer.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/performer/impl/ReadChunkCompactionPerformer.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/executor/fast/FastNonAlignedSeriesCompactionExecutor.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/IWritableMemChunkGroup.java # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java # pom.xml
Fix the problem that valueChunkMetadata get wrong datatype so that can't generate valid statistics object in the switch code block cause by newChunkMetadata set the property value of TsDataType
# Conflicts: # iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanVisitor.java
…ccumulator query among tree and table model.
...gration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterColumnTypeIT.java
Outdated
Show resolved
Hide resolved
...gration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBAlterColumnTypeIT.java
Show resolved
Hide resolved
integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterTimeSeriesTypeIT.java
Show resolved
Hide resolved
integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java
Outdated
Show resolved
Hide resolved
iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
Outdated
Show resolved
Hide resolved
...de/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java
Outdated
Show resolved
Hide resolved
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
Outdated
Show resolved
Hide resolved
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
Outdated
Show resolved
Hide resolved
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
Outdated
Show resolved
Hide resolved
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
Show resolved
Hide resolved
…nstead of AlterTimeSeriesStatement, can resolve other alter timeseries statement can run normally.
…a type cause by AlterTimeSeriesDataTypeProcedure won't run.
Repair all accumulator query logics about TEXT、STRING、BLOB on IoTDBAlterColumnTypeIT; Remove unuseful and incorrect code
| // if (newType == TSDataType.STRING | ||
| // || newType == TSDataType.TEXT | ||
| // || newType == TSDataType.BLOB) { | ||
| // expectedValue[1] = 999; | ||
| // } else if (newType == TSDataType.BOOLEAN) { | ||
| // expectedValue = new int[] {19700102, 19721021, 19700102, 19721021}; | ||
| // } | ||
| if (newType != TSDataType.BOOLEAN) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
| "select first(s1),last(s1) from construct_and_alter_column_type"); | ||
| RowRecord rec = dataSet.next(); | ||
| while (rec != null) { | ||
| System.out.println(rec.getFields().toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
.../src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
Outdated
Show resolved
Hide resolved
| import org.apache.iotdb.confignode.rpc.thrift.TCreateFunctionReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TCreatePipePluginReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TCreateTableViewReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TCreateTopicReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TCreateTriggerReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRemoveReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRemoveResp; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDatabaseSchema; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDeactivateSchemaTemplateReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDeleteDatabasesReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDeleteLogicalViewReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDeleteTableDeviceReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDeleteTableDeviceResp; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDeleteTimeSeriesReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDescTableResp; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDropCQReq; | ||
| import org.apache.iotdb.confignode.rpc.thrift.TDropFunctionReq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should throw an exception
| } else { | ||
| // not support | ||
| throw new InterruptedException("AlterTimeSeriesTask is not support"); | ||
| throw new InterruptedException("Not support current statement"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnsupportedOperationException
| throw new InterruptedException( | ||
| String.format( | ||
| "Data type cannot be null executing the statement that alter timeseries %s set data type", | ||
| alterTimeSeriesStatement.getPath().getFullPath())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IllegalArgumentException
| private TSDataType parseDataTypeAttribute(IoTDBSqlParser.AttributeValueContext ctx) { | ||
| TSDataType dataType = null; | ||
| if (ctx != null) { | ||
| String dataTypeString = parseAttributeValue(ctx); | ||
| try { | ||
| dataType = TSDataType.valueOf(dataTypeString); | ||
| if (TSDataType.UNKNOWN.equals(dataType) || TSDataType.VECTOR.equals(dataType)) { | ||
| throw new SemanticException(String.format("Unsupported datatype: %s", dataTypeString)); | ||
| } | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary to catch and rethrow the same exception.
| if (dataTypeColumnClassMap.get(originalDataType) == null | ||
| || dataTypeColumnClassMap.get(dataType) == null) { | ||
| return false; | ||
| } | ||
| return dataTypeColumnClassMap.get(originalDataType) == dataTypeColumnClassMap.get(dataType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objects.equals(dataTypeColumnClassMap.get(originalDataType), dataTypeColumnClassMap.get(dataType))
CHN doc:
https://timechor.feishu.cn/docx/AugedrYLqoybsbxzgEZc2eTinTg?from=from_copylink
IoTDB> alter timeseries root.db.battery.b0.current SET DATA TYPE DOUBLE;
Msg: The statement is executed successfully.
IoTDB> show timeseries root.db.battery.b0.current;
+--------------------------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
| Timeseries|Alias|Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType|
+--------------------------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
|root.db.battery.b0.current| null| root.db| DOUBLE| GORILLA| LZ4|null| null| null| null| BASE|
+--------------------------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
Total line number = 1
It costs 0.043s
IoTDB> alter timeseries root.db.battery.b0.current SET DATA TYPE STRING;
Msg: The statement is executed successfully.
IoTDB> show timeseries root.db.battery.b0.current;
+--------------------------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
| Timeseries|Alias|Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType|
+--------------------------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
|root.db.battery.b0.current| null| root.db| STRING| GORILLA| LZ4|null| null| null| null| BASE|
+--------------------------+-----+--------+--------+--------+-----------+----+----------+--------+------------------+--------+
Total line number = 1
It costs 0.009s