You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sh...@apache.org on 2026/06/15 02:48:31 UTC

(iotdb) branch read_tsfile_table_function updated (80fce1a741d -> f06a3648d01)

This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a change to branch read_tsfile_table_function
in repository https://gitbox.apache.org/repos/asf/iotdb.git


    from 80fce1a741d add memory control
     new 96b1077b2b7 remove seralize/deserialize from ReadTsFileTableFunction
     new 5e7bc0af915 fix mem control
     add c5240154a70 Clarify RemoveDataNode single-replica error and add diagnostics for the no-available-RegionGroup race (#17878)
     add a725ded2471 Fix overflow edge cases in query utilities (#17875)
     add 90cc0279a17 support calculation point project with calc-graph of fuzzy search by graph name or description (#17905)
     add 69c0b18a83f Fix pipe logger format handling (#17900)
     add feaeaa6ca71 Fix partial insert handling for null measurements (#17879)
     add 41393abf9f6 Only send table deletion to related region groups (#17896)
     add a440038f1e5 Support EXPLAIN FORMAT JSON for Table Model (#17430)
     add aa7b275318c Pipe: Optimize pipe logging with shared PipePeriodicalLogReducer (#17887)
     add dbc4d4a27b6 Fix -pw without password may take incorrect args (#17914)
     add e7bc4926df0 Support legacy pipe receiver requests (#17901)
     add d328639dd0f Move query state machine support to calc commons (#17912)
     add 283bce2f34c Cache non-exist timeseries metadata to reduce IO (#16606)
     add 1a3548e6fa6 Add cache for single measurement validation (#17899)
     add 3853d380fc1 Fix driver scheduler ready queue reservation leak (#17919)
     add e9e3dd63199 Refactor some method and PlanNodeType (#17918)
     add 72e72dd2c4e Upgrade minimum JDK to 17 and migrate JavaX to Jakarta (#17859)
     new d32ac2b3139 Merge branch 'iotdb_master' into read_tsfile_table_function
     new f06a3648d01 refactor

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .claude/settings.json => .codex/hooks.json         |   0
 .github/workflows/compile-check.yml                |  67 --
 .github/workflows/daily-it.yml                     |   4 +-
 .github/workflows/daily-ut.yml                     |  15 +-
 .github/workflows/multi-language-client.yml        |  15 +
 .gitignore                                         |   2 +-
 CLAUDE.md                                          |   2 +-
 CONTRIBUTING.md                                    |   2 +-
 Jenkinsfile                                        |   2 +-
 LICENSE-binary                                     |  43 +-
 README.md                                          |   4 +-
 README_ZH.md                                       |   4 +-
 dependencies.json                                  | 318 ++++----
 example/jdbc/pom.xml                               |   4 +-
 example/pipe-count-point-processor/pom.xml         |   4 +-
 example/pom.xml                                    |   4 +-
 external-service-impl/mqtt/pom.xml                 |   4 +-
 external-service-impl/pom.xml                      |   4 +-
 external-service-impl/rest-openapi/pom.xml         |  28 +-
 external-service-impl/rest/pom.xml                 |  20 +-
 .../java/org/apache/iotdb/rest/RestService.java    |   8 +-
 .../rest/protocol/filter/ApiOriginFilter.java      |  15 +-
 .../rest/protocol/filter/AuthorizationFilter.java  |  36 +-
 .../rest/protocol/filter/BasicSecurityContext.java |   2 +-
 .../protocol/handler/AuthorizationHandler.java     |   4 +-
 .../rest/protocol/impl/PingApiServiceImpl.java     |   4 +-
 .../table/v1/handler/ExceptionHandler.java         |   2 +-
 .../table/v1/handler/QueryDataSetHandler.java      |   2 +-
 .../protocol/table/v1/impl/RestApiServiceImpl.java |   4 +-
 .../rest/protocol/v1/handler/ExceptionHandler.java |   2 +-
 .../protocol/v1/handler/QueryDataSetHandler.java   |   2 +-
 .../protocol/v1/impl/GrafanaApiServiceImpl.java    |   4 +-
 .../rest/protocol/v1/impl/RestApiServiceImpl.java  |   4 +-
 .../rest/protocol/v2/handler/ExceptionHandler.java |   2 +-
 .../rest/protocol/v2/handler/FastLastHandler.java  |   2 +-
 .../protocol/v2/handler/QueryDataSetHandler.java   |   3 +-
 .../protocol/v2/impl/GrafanaApiServiceImpl.java    |   4 +-
 .../rest/protocol/v2/impl/RestApiServiceImpl.java  |   4 +-
 .../iotdb/it/env/cluster/config/MppBaseConfig.java |   3 +-
 .../it/env/cluster/config/MppCommonConfig.java     |   7 +
 .../env/cluster/config/MppSharedCommonConfig.java  |   7 +
 .../it/env/remote/config/RemoteCommonConfig.java   |   5 +
 .../org/apache/iotdb/itbase/env/CommonConfig.java  |   2 +
 .../iotdb/cli/it/ExplainJsonCliOutputIT.java       | 345 +++++++++
 .../removedatanode/IoTDBRemoveLastDataNodeIT.java  | 111 +++
 .../it/IoTDBSyntaxConventionStringLiteralIT.java   |   2 +-
 ...DBSingleMeasurementCheckCachePerformanceIT.java | 207 +++++
 .../db/it/schema/IoTDBAlterTimeSeriesTypeIT.java   |   2 +-
 .../IoTDBPipeTsFileDecompositionWithModsIT.java    |  24 +-
 .../manual/IoTDBPipeTypeConversionISessionIT.java  |   2 +-
 .../it/insertquery/IoTDBInsertQueryIT.java         |   4 +-
 .../it/query/recent/IoTExplainJsonFormatIT.java    | 855 +++++++++++++++++++++
 .../it/schema/IoTDBAlterColumnTypeIT.java          |   2 +-
 .../java/org/apache/iotdb/cli/AbstractCli.java     |  46 +-
 .../java/org/apache/iotdb/cli/AbstractCliTest.java |  83 +-
 iotdb-client/client-cpp/README.md                  |   5 +-
 iotdb-client/client-cpp/pom.xml                    |   8 +-
 iotdb-client/jdbc/README.md                        |   4 +-
 .../src/test/resources/iotdb-common.properties     |   2 +-
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4   |   9 +
 iotdb-core/calc-commons/pom.xml                    |   5 +
 .../org/apache/iotdb/calc/i18n/CalcMessages.java   |  10 +
 .../org/apache/iotdb/calc/i18n/CalcMessages.java   |   9 +
 .../fill/filter/FixedIntervalFillFilter.java       |  10 +-
 .../relational/aggregation/ExtremeAccumulator.java |  32 +-
 .../grouped/GroupedExtremeAccumulator.java         |  70 +-
 .../queue/IndexedBlockingReserveQueue.java         |  36 +-
 .../calc/plan/planner/TableOperatorGenerator.java  |  98 ++-
 .../fill/filter/FixedIntervalFillFilterTest.java   |  18 +-
 .../aggregation/ExtremeAccumulatorTest.java        | 150 ++++
 .../iotdb/confignode/i18n/ManagerMessages.java     |   8 +-
 .../iotdb/confignode/i18n/ProcedureMessages.java   |   5 +
 .../iotdb/confignode/i18n/ManagerMessages.java     |  14 +-
 .../iotdb/confignode/i18n/ProcedureMessages.java   |   5 +
 .../confignode/conf/ConfigNodeDescriptor.java      |  10 +-
 .../consensus/response/cq/ShowCQResp.java          |   2 +-
 .../externalservice/ShowExternalServiceResp.java   |   2 +-
 .../balancer/router/leader/HashLeaderBalancer.java |   2 +-
 .../manager/partition/PartitionManager.java        |  18 +
 .../agent/runtime/PipeConfigNodeRuntimeAgent.java  |  17 +-
 .../pipe/agent/task/PipeConfigNodeSubtask.java     |  21 +-
 .../pipe/coordinator/runtime/PipeMetaSyncer.java   |  26 +-
 .../runtime/heartbeat/PipeHeartbeatParser.java     |  43 +-
 .../runtime/heartbeat/PipeHeartbeatScheduler.java  |   7 +-
 .../pipe/coordinator/task/PipeTaskCoordinator.java |   8 +-
 .../coordinator/task/PipeTaskCoordinatorLock.java  |  10 +-
 .../receiver/protocol/IoTDBConfigNodeReceiver.java |   4 +-
 .../schema/ClusterSchemaQuotaStatistics.java       |   2 +-
 .../confignode/persistence/pipe/PipeTaskInfo.java  |   9 +-
 .../mnode/container/ConfigMNodeContainer.java      |   2 +-
 .../procedure/env/ConfigNodeProcedureEnv.java      |   7 +-
 .../procedure/env/RemoveDataNodeHandler.java       |  52 +-
 .../runtime/PipeHandleLeaderChangeProcedure.java   |  36 +-
 .../runtime/PipeHandleMetaChangeProcedure.java     |  33 +-
 .../impl/pipe/runtime/PipeMetaSyncProcedure.java   |   6 +-
 .../impl/region/CreateRegionGroupsProcedure.java   |  10 +-
 .../router/leader/HashLeaderBalancerTest.java      |  65 ++
 .../pipe/sink/PipeConfigNodeThriftRequestTest.java | 212 +++++
 iotdb-core/consensus/pom.xml                       |   4 +-
 .../iot/client/AsyncIoTConsensusServiceClient.java |   2 +-
 iotdb-core/datanode/pom.xml                        |   8 +-
 .../iotdb/db/i18n/DataNodeQueryMessages.java       |   9 -
 .../iotdb/db/i18n/DataNodeQueryMessages.java       |   9 -
 .../org/apache/iotdb/db/audit/DNAuditLogger.java   |   2 +-
 .../apache/iotdb/db/conf/DataNodeMemoryConfig.java |  18 +
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |   2 +-
 .../iotdb/db/conf/rest/IoTDBRestServiceConfig.java |   2 +-
 .../agent/runtime/PipeDataNodeRuntimeAgent.java    |  14 +-
 .../db/pipe/event/common/PipeInsertionEvent.java   |   2 +-
 .../tablet/parser/TabletInsertionEventParser.java  | 123 ++-
 .../scan/AlignedSinglePageWholeChunkReader.java    |   2 +-
 .../parser/scan/SinglePageWholeChunkReader.java    |   2 +-
 .../downsampling/changing/ChangingValueFilter.java |  20 +-
 .../sdt/SwingingDoorTrendingFilter.java            |  19 +-
 .../tumbling/TumblingTimeSamplingProcessor.java    |   7 +-
 .../exchange/sender/TwoStageAggregateSender.java   |   2 +-
 .../protocol/thrift/IoTDBDataNodeReceiver.java     |   6 +-
 .../statement/PipeConvertedInsertRowStatement.java |   9 +
 .../resource/log/PipePeriodicalLogReducer.java     |  93 ---
 .../resource/memory/InsertNodeMemoryEstimator.java |  15 +-
 .../resource/memory/PipeDynamicMemoryBlock.java    |   2 +-
 .../tsfile/PipeTsFileResourceSegmentLock.java      |  10 +-
 .../request/PipeTransferTabletRawReq.java          |  89 ++-
 .../pipe/sink/util/TabletStatementConverter.java   |  31 +-
 .../db/queryengine/common/MPPQueryContext.java     |  10 +
 .../db/queryengine/execution/StateMachine.java     |   8 +-
 .../execution/aggregation/ExtremeAccumulator.java  |  32 +-
 .../SlidingWindowAggregatorFactory.java            |  36 +-
 .../execution/operator/ExplainAnalyzeOperator.java |  70 +-
 .../ExternalTsFileAggTableScanOperator.java        |   3 +-
 .../ExternalTsFileTableScanOperator.java           |   3 +-
 .../execution/operator/window/SessionWindow.java   |  24 +-
 .../operator/window/SessionWindowManager.java      |   2 +-
 .../execution/schedule/DriverScheduler.java        |  15 +-
 .../multilevelqueue/MultilevelPriorityQueue.java   |  10 +
 .../execution/schedule/task/DriverTask.java        |  13 +
 .../execution/schedule/task/DriverTaskId.java      |   2 +-
 .../metric/DriverSchedulerMetricSet.java           |  13 +
 .../iotdb/db/queryengine/plan/Coordinator.java     |  17 +-
 .../db/queryengine/plan/analyze/AnalyzeUtils.java  |  34 +-
 .../plan/analyze/schema/NormalSchemaFetcher.java   |   4 +-
 .../plan/execution/config/ConfigExecution.java     |   2 +-
 .../TableModelStatementMemorySourceVisitor.java    |  54 +-
 .../plan/expression/unary/InExpression.java        |   2 +-
 .../planner/DataNodeTableOperatorGenerator.java    |   9 +-
 .../plan/AbstractFragmentParallelPlanner.java      |   3 +-
 .../planner/plan/node/PlanGraphJsonPrinter.java    | 225 ++++++
 .../metadata/read/LevelTimeSeriesCountNode.java    |   2 +-
 .../node/metadata/read/TimeSeriesCountNode.java    |   2 +-
 .../metadata/read/TimeSeriesSchemaScanNode.java    |   2 +-
 .../plan/planner/plan/node/write/InsertNode.java   |  70 +-
 .../planner/plan/node/write/InsertRowNode.java     | 216 ++++--
 .../plan/node/write/InsertRowsOfOneDeviceNode.java |   5 +-
 .../planner/plan/node/write/InsertTabletNode.java  | 351 ++++++---
 .../plan/node/write/RelationalInsertRowNode.java   |  63 +-
 .../plan/node/write/RelationalInsertRowsNode.java  |  45 +-
 .../node/write/RelationalInsertTabletNode.java     | 111 ++-
 .../relational/analyzer/StatementAnalyzer.java     |   2 +
 .../readTsFile/ExternalTsFileQueryDataSource.java  |  28 +-
 .../readTsFile/ExternalTsFileQueryResource.java    |  14 +-
 .../tvf/readTsFile/ReadTsFileTableFunction.java    | 294 +------
 .../tvf/readTsFile/TsFileSchemaCollector.java      | 287 +++++++
 .../fetcher/cache/TreeDeviceNormalSchema.java      |   4 +-
 .../cache/TreeDeviceSchemaCacheManager.java        |   9 +-
 .../plan/relational/planner/CteMaterializer.java   |   1 +
 .../plan/relational/planner/RelationPlanner.java   |  25 +-
 .../relational/planner/TableLogicalPlanner.java    |   3 +-
 .../distribute/TableDistributedPlanner.java        |  16 +-
 ...ithUncorrelatedScalarSubqueryReconstructor.java |   2 +
 .../planner/node/ExplainAnalyzeNode.java           |  39 +-
 .../optimizations/UnaliasSymbolReferences.java     |   3 +-
 .../plan/relational/sql/ast/Explain.java           |  28 +-
 .../plan/relational/sql/ast/ExplainAnalyze.java    |  37 +-
 ...versalVisitor.java => ExplainOutputFormat.java} |  22 +-
 .../plan/relational/sql/ast/InsertRow.java         |   5 +-
 .../plan/relational/sql/ast/InsertRows.java        |  14 +-
 .../plan/relational/sql/ast/InsertTablet.java      |  13 +-
 .../plan/relational/sql/ast/PipeEnriched.java      |   2 +-
 .../relational/sql/ast/WrappedInsertStatement.java |  22 +-
 .../plan/relational/sql/parser/AstBuilder.java     |  35 +-
 .../plan/statement/crud/InsertBaseStatement.java   | 210 +++--
 .../plan/statement/crud/InsertRowStatement.java    | 128 ++-
 .../crud/InsertRowsOfOneDeviceStatement.java       |  12 +
 .../plan/statement/crud/InsertTabletStatement.java | 161 +++-
 .../FragmentInstanceStatisticsJsonDrawer.java      | 372 +++++++++
 .../logfile/FakeCRC32Deserializer.java             |   3 +-
 .../schemaregion/logfile/SchemaLogReader.java      |   2 +-
 .../mem/mnode/container/MemMNodeContainer.java     |   2 +-
 .../mnode/container/CachedMNodeContainer.java      |   3 +-
 .../buffer/TimeSeriesMetadataCache.java            |  43 +-
 .../db/storageengine/dataregion/DataRegion.java    |   3 +-
 .../compaction/schedule/CompactionWorker.java      |   2 +-
 .../dataregion/memtable/AbstractMemTable.java      | 120 +--
 .../memtable/AbstractWritableMemChunk.java         |  17 +
 .../memtable/AlignedWritableMemChunk.java          |   7 +-
 .../dataregion/memtable/TsFileProcessor.java       | 162 ++--
 .../dataregion/memtable/WritableMemChunk.java      |   7 +-
 .../dataregion/memtable/WritableMemChunkGroup.java |   2 +-
 .../dataregion/snapshot/SnapshotLoader.java        |  15 +
 .../consensus/ConsensusLogToTabletConverter.java   |  70 +-
 .../SubscriptionPipeEventBatchSegmentLock.java     |   4 +-
 .../db/trigger/executor/TriggerFireVisitor.java    |  53 +-
 .../java/org/apache/iotdb/db/utils/MemUtils.java   |  71 +-
 .../pipe/event/PipeTabletInsertionEventTest.java   |  81 ++
 .../changing/ChangingValueFilterTest.java          |  55 ++
 .../sdt/SwingingDoorTrendingFilterTest.java        |  56 ++
 .../TumblingTimeSamplingProcessorTest.java         | 192 +++++
 .../PipeConvertedInsertRowStatementTest.java       |  55 ++
 .../memory/InsertNodeMemoryEstimatorTest.java      |  12 +
 .../tsfile/PipeTsFileResourceSegmentLockTest.java  |  71 ++
 .../pipe/sink/PipeDataNodeThriftRequestTest.java   | 505 ++++++++++++
 .../sink/util/TabletStatementConverterTest.java    |  64 ++
 .../execution/aggregation/AccumulatorTest.java     |  46 ++
 .../SlidingWindowAggregatorFactoryTest.java}       |  25 +-
 .../operator/ExplainAnalyzeOperatorTest.java       |  96 +++
 .../operator/window/SessionWindowTest.java         |  70 ++
 .../schedule/DefaultDriverSchedulerTest.java       |  41 +
 .../queryengine/plan/analyze/AnalyzeUtilsTest.java |  74 ++
 ...TableModelStatementMemorySourceVisitorTest.java |  88 +++
 .../planner/node/PlanGraphJsonPrinterTest.java     | 573 ++++++++++++++
 .../planner/node/write/InsertRowNodeSerdeTest.java | 127 +++
 .../node/write/InsertRowsNodeSerdeTest.java        |  35 +
 .../write/InsertRowsOfOneDeviceNodeSerdeTest.java  |  34 +
 .../node/write/InsertTabletNodeSerdeTest.java      | 130 ++++
 .../planner/node/write/WritePlanNodeSplitTest.java |  41 +
 .../write/InsertNodeIsMeasurementFailedTest.java   | 255 ++++++
 .../relational/planner/CteMaterializerTest.java    |   1 +
 .../plan/relational/planner/CteSubqueryTest.java   |   1 +
 .../plan/relational/sql/ExplainFormatTest.java     | 186 +++++
 .../crud/InsertStatementPartialInsertTest.java     | 320 ++++++++
 .../FragmentInstanceStatisticsJsonDrawerTest.java  | 594 ++++++++++++++
 .../buffer/TimeSeriesMetadataCacheTest.java        | 280 +++++++
 .../storageengine/dataregion/DataRegionTest.java   |  30 +-
 .../AbstractMemTablePartialInsertTest.java         | 113 +++
 .../memtable/MemChunkDeserializeTest.java          |  23 +
 .../dataregion/memtable/TsFileProcessorTest.java   | 172 +++++
 .../ConsensusLogToTabletConverterTest.java         |  58 ++
 ...SubscriptionPipeEventBatchSegmentLockTest.java} |  34 +-
 .../org/apache/iotdb/db/utils/MemUtilsTest.java    | 127 +++
 .../src/test/resources/iotdb-common.properties     |   2 +-
 .../src/test/resources/iotdb-system.properties     |   2 +-
 .../conf/iotdb-system.properties.template          |  13 +-
 .../async/AsyncAINodeInternalServiceClient.java    |   2 +-
 .../AsyncConfigNodeInternalServiceClient.java      |   2 +-
 .../async/AsyncDataNodeExternalServiceClient.java  |   2 +-
 .../async/AsyncDataNodeInternalServiceClient.java  |   2 +-
 .../AsyncDataNodeMPPDataExchangeServiceClient.java |   2 +-
 .../async/AsyncIoTConsensusV2ServiceClient.java    |   2 +-
 .../async/AsyncPipeDataTransferServiceClient.java  |   2 +-
 .../apache/iotdb/commons/conf/CommonConfig.java    |  10 +
 .../iotdb/commons/conf/CommonDescriptor.java       |   9 +
 .../commons/pipe/resource/log/PipeLogger.java      |  18 +-
 .../resource/log/PipePeriodicalLogReducer.java     |  76 ++
 .../thrift/request/PipeTransferFileSealReqV2.java  |   8 +
 .../plan/planner/plan/node/PlanNodeType.java       |   2 +
 .../schema/table/InsertNodeMeasurementInfo.java    |   9 +-
 .../org/apache/iotdb/commons/utils/PathUtils.java  |  56 +-
 .../commons/pipe/resource/PipeLoggerTest.java      |  83 ++
 .../common/PipeTransferSliceReqBuilderTest.java    |  32 +
 .../thrift/request/PipeRequestTypeTest.java        |  61 ++
 .../request/PipeTransferCompressedReqTest.java     | 112 +++
 .../request/PipeTransferFileSealReqV2Test.java     |  65 ++
 .../table/InsertNodeMeasurementInfoTest.java       |  83 ++
 .../db/relational/grammar/sql/RelationalSql.g4     |   4 +-
 library-udf/pom.xml                                |   4 +-
 pom.xml                                            | 117 ++-
 scripts/conf/confignode-env.sh                     |  61 +-
 scripts/conf/datanode-env.sh                       |  70 +-
 scripts/sbin/start-cli.sh                          |  13 +-
 scripts/sbin/windows/start-cli.bat                 |  23 +-
 scripts/sbin/windows/start-confignode.bat          |  20 +-
 scripts/sbin/windows/start-datanode.bat            |  19 +-
 scripts/tools/ops/health_check.sh                  |   2 +-
 scripts/tools/windows/ops/health_check.bat         |   4 +-
 274 files changed, 11584 insertions(+), 1866 deletions(-)
 copy .claude/settings.json => .codex/hooks.json (100%)
 delete mode 100644 .github/workflows/compile-check.yml
 create mode 100644 integration-test/src/test/java/org/apache/iotdb/cli/it/ExplainJsonCliOutputIT.java
 create mode 100644 integration-test/src/test/java/org/apache/iotdb/confignode/it/removedatanode/IoTDBRemoveLastDataNodeIT.java
 create mode 100644 integration-test/src/test/java/org/apache/iotdb/db/it/performance/IoTDBSingleMeasurementCheckCachePerformanceIT.java
 create mode 100644 integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTExplainJsonFormatIT.java
 copy iotdb-client/service-rpc/src/test/java/org/apache/iotdb/rpc/TSStatusCodeTest.java => iotdb-core/calc-commons/src/test/java/org/apache/iotdb/calc/execution/operator/process/fill/filter/FixedIntervalFillFilterTest.java (60%)
 create mode 100644 iotdb-core/calc-commons/src/test/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/ExtremeAccumulatorTest.java
 create mode 100644 iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/load/balancer/router/leader/HashLeaderBalancerTest.java
 delete mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/log/PipePeriodicalLogReducer.java
 create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/PlanGraphJsonPrinter.java
 create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/TsFileSchemaCollector.java
 copy iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/{DefaultExpressionTraversalVisitor.java => ExplainOutputFormat.java} (67%)
 create mode 100644 iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/statistics/FragmentInstanceStatisticsJsonDrawer.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/processor/downsampling/changing/ChangingValueFilterTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/processor/downsampling/sdt/SwingingDoorTrendingFilterTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/processor/downsampling/tumbling/TumblingTimeSamplingProcessorTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/receiver/transform/statement/PipeConvertedInsertRowStatementTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/resource/tsfile/PipeTsFileResourceSegmentLockTest.java
 copy iotdb-core/{confignode/src/test/java/org/apache/iotdb/confignode/manager/ClusterSchemaManagerTest.java => datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/slidingwindow/SlidingWindowAggregatorFactoryTest.java} (52%)
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/ExplainAnalyzeOperatorTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/window/SessionWindowTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/execution/memory/TableModelStatementMemorySourceVisitorTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/planner/node/PlanGraphJsonPrinterTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ExplainFormatTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertStatementPartialInsertTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/statistics/FragmentInstanceStatisticsJsonDrawerTest.java
 create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/buffer/TimeSeriesMetadataCacheTest.java
 copy iotdb-core/{node-commons/src/test/java/org/apache/iotdb/commons/utils/JVMCommonUtilsTest.java => datanode/src/test/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeEventBatchSegmentLockTest.java} (50%)
 create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/resource/log/PipePeriodicalLogReducer.java
 create mode 100644 iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/resource/PipeLoggerTest.java
 create mode 100644 iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/sink/payload/thrift/request/PipeRequestTypeTest.java
 create mode 100644 iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/sink/payload/thrift/request/PipeTransferCompressedReqTest.java
 create mode 100644 iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/sink/payload/thrift/request/PipeTransferFileSealReqV2Test.java
 create mode 100644 iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/schema/table/InsertNodeMeasurementInfoTest.java


(iotdb) 01/04: remove seralize/deserialize from ReadTsFileTableFunction

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch read_tsfile_table_function
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 96b1077b2b7305c81b285a4ddbbf41823f3b6ef9
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Thu Jun 11 16:11:27 2026 +0800

    remove seralize/deserialize from ReadTsFileTableFunction
---
 .../tvf/readTsFile/ReadTsFileTableFunction.java    | 62 ++--------------------
 1 file changed, 4 insertions(+), 58 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java
index 26f7143595d..bb8e8a81483 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java
@@ -45,8 +45,6 @@ import org.apache.tsfile.write.schema.MeasurementSchema;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -477,41 +475,14 @@ public class ReadTsFileTableFunction implements TableFunction {
 
     @Override
     public byte[] serialize() {
-      ByteBuffer buffer = ByteBuffer.allocate(calculateSerializeSize());
-      writeString(buffer, tableName);
-      buffer.putInt(tsFilePaths.size());
-      tsFilePaths.forEach(path -> writeString(buffer, path));
-      buffer.putInt(outputColumnNames.size());
-      for (int i = 0; i < outputColumnNames.size(); i++) {
-        writeString(buffer, outputColumnNames.get(i));
-        buffer.put(outputColumnTypes.get(i).getType());
-        buffer.put(outputColumnCategories.get(i).getCategory());
-      }
-      return buffer.array();
+      throw new UnsupportedOperationException(
+          "ReadTsFileTableFunctionHandle does not support serialization");
     }
 
     @Override
     public void deserialize(byte[] bytes) {
-      ByteBuffer buffer = ByteBuffer.wrap(bytes);
-      tableName = readString(buffer);
-      int size = buffer.getInt();
-      List<String> paths = new ArrayList<>(size);
-      for (int i = 0; i < size; i++) {
-        paths.add(readString(buffer));
-      }
-      tsFilePaths = Collections.unmodifiableList(paths);
-      size = buffer.getInt();
-      List<String> columnNames = new ArrayList<>(size);
-      List<Type> columnTypes = new ArrayList<>(size);
-      List<TsTableColumnCategory> columnCategories = new ArrayList<>(size);
-      for (int i = 0; i < size; i++) {
-        columnNames.add(readString(buffer));
-        columnTypes.add(Type.valueOf(buffer.get()));
-        columnCategories.add(TsTableColumnCategory.deserialize(buffer.get()));
-      }
-      outputColumnNames = Collections.unmodifiableList(columnNames);
-      outputColumnTypes = Collections.unmodifiableList(columnTypes);
-      outputColumnCategories = Collections.unmodifiableList(columnCategories);
+      throw new UnsupportedOperationException(
+          "ReadTsFileTableFunctionHandle does not support deserialization");
     }
 
     @Override
@@ -530,30 +501,5 @@ public class ReadTsFileTableFunction implements TableFunction {
           + outputColumnCategories
           + '}';
     }
-
-    private int calculateSerializeSize() {
-      int size = Integer.BYTES + tableName.getBytes(StandardCharsets.UTF_8).length;
-      size += Integer.BYTES;
-      for (String path : tsFilePaths) {
-        size += Integer.BYTES + path.getBytes(StandardCharsets.UTF_8).length;
-      }
-      size += Integer.BYTES;
-      for (String columnName : outputColumnNames) {
-        size += Integer.BYTES + columnName.getBytes(StandardCharsets.UTF_8).length + 2 * Byte.BYTES;
-      }
-      return size;
-    }
-
-    private static void writeString(ByteBuffer buffer, String value) {
-      byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
-      buffer.putInt(bytes.length);
-      buffer.put(bytes);
-    }
-
-    private static String readString(ByteBuffer buffer) {
-      byte[] bytes = new byte[buffer.getInt()];
-      buffer.get(bytes);
-      return new String(bytes, StandardCharsets.UTF_8);
-    }
   }
 }


(iotdb) 03/04: Merge branch 'iotdb_master' into read_tsfile_table_function

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch read_tsfile_table_function
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit d32ac2b3139268c273712ee304189823484827f0
Merge: 5e7bc0af915 72e72dd2c4e
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Fri Jun 12 11:20:28 2026 +0800

    Merge branch 'iotdb_master' into read_tsfile_table_function

 .codex/hooks.json                                  |  17 +
 .github/workflows/compile-check.yml                |  67 --
 .github/workflows/daily-it.yml                     |   4 +-
 .github/workflows/daily-ut.yml                     |  15 +-
 .github/workflows/multi-language-client.yml        |  15 +
 .gitignore                                         |   2 +-
 CLAUDE.md                                          |   2 +-
 CONTRIBUTING.md                                    |   2 +-
 Jenkinsfile                                        |   2 +-
 LICENSE-binary                                     |  43 +-
 README.md                                          |   4 +-
 README_ZH.md                                       |   4 +-
 dependencies.json                                  | 318 ++++----
 example/jdbc/pom.xml                               |   4 +-
 example/pipe-count-point-processor/pom.xml         |   4 +-
 example/pom.xml                                    |   4 +-
 external-service-impl/mqtt/pom.xml                 |   4 +-
 external-service-impl/pom.xml                      |   4 +-
 external-service-impl/rest-openapi/pom.xml         |  28 +-
 external-service-impl/rest/pom.xml                 |  20 +-
 .../java/org/apache/iotdb/rest/RestService.java    |   8 +-
 .../rest/protocol/filter/ApiOriginFilter.java      |  15 +-
 .../rest/protocol/filter/AuthorizationFilter.java  |  36 +-
 .../rest/protocol/filter/BasicSecurityContext.java |   2 +-
 .../protocol/handler/AuthorizationHandler.java     |   4 +-
 .../rest/protocol/impl/PingApiServiceImpl.java     |   4 +-
 .../table/v1/handler/ExceptionHandler.java         |   2 +-
 .../table/v1/handler/QueryDataSetHandler.java      |   2 +-
 .../protocol/table/v1/impl/RestApiServiceImpl.java |   4 +-
 .../rest/protocol/v1/handler/ExceptionHandler.java |   2 +-
 .../protocol/v1/handler/QueryDataSetHandler.java   |   2 +-
 .../protocol/v1/impl/GrafanaApiServiceImpl.java    |   4 +-
 .../rest/protocol/v1/impl/RestApiServiceImpl.java  |   4 +-
 .../rest/protocol/v2/handler/ExceptionHandler.java |   2 +-
 .../rest/protocol/v2/handler/FastLastHandler.java  |   2 +-
 .../protocol/v2/handler/QueryDataSetHandler.java   |   3 +-
 .../protocol/v2/impl/GrafanaApiServiceImpl.java    |   4 +-
 .../rest/protocol/v2/impl/RestApiServiceImpl.java  |   4 +-
 .../iotdb/it/env/cluster/config/MppBaseConfig.java |   3 +-
 .../it/env/cluster/config/MppCommonConfig.java     |   7 +
 .../env/cluster/config/MppSharedCommonConfig.java  |   7 +
 .../it/env/remote/config/RemoteCommonConfig.java   |   5 +
 .../org/apache/iotdb/itbase/env/CommonConfig.java  |   2 +
 .../iotdb/cli/it/ExplainJsonCliOutputIT.java       | 345 +++++++++
 .../removedatanode/IoTDBRemoveLastDataNodeIT.java  | 111 +++
 .../it/IoTDBSyntaxConventionStringLiteralIT.java   |   2 +-
 ...DBSingleMeasurementCheckCachePerformanceIT.java | 207 +++++
 .../db/it/schema/IoTDBAlterTimeSeriesTypeIT.java   |   2 +-
 .../IoTDBPipeTsFileDecompositionWithModsIT.java    |  24 +-
 .../manual/IoTDBPipeTypeConversionISessionIT.java  |   2 +-
 .../it/insertquery/IoTDBInsertQueryIT.java         |   4 +-
 .../it/query/recent/IoTExplainJsonFormatIT.java    | 855 +++++++++++++++++++++
 .../it/schema/IoTDBAlterColumnTypeIT.java          |   2 +-
 .../java/org/apache/iotdb/cli/AbstractCli.java     |  46 +-
 .../java/org/apache/iotdb/cli/AbstractCliTest.java |  83 +-
 iotdb-client/client-cpp/README.md                  |   5 +-
 iotdb-client/client-cpp/pom.xml                    |   8 +-
 iotdb-client/jdbc/README.md                        |   4 +-
 .../src/test/resources/iotdb-common.properties     |   2 +-
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4   |   9 +
 iotdb-core/calc-commons/pom.xml                    |   5 +
 .../org/apache/iotdb/calc/i18n/CalcMessages.java   |  10 +
 .../org/apache/iotdb/calc/i18n/CalcMessages.java   |   9 +
 .../fill/filter/FixedIntervalFillFilter.java       |  10 +-
 .../relational/aggregation/ExtremeAccumulator.java |  32 +-
 .../grouped/GroupedExtremeAccumulator.java         |  70 +-
 .../queue/IndexedBlockingReserveQueue.java         |  36 +-
 .../calc/plan/planner/TableOperatorGenerator.java  |  98 ++-
 .../fill/filter/FixedIntervalFillFilterTest.java}  |  24 +-
 .../aggregation/ExtremeAccumulatorTest.java        | 150 ++++
 .../iotdb/confignode/i18n/ManagerMessages.java     |   8 +-
 .../iotdb/confignode/i18n/ProcedureMessages.java   |   5 +
 .../iotdb/confignode/i18n/ManagerMessages.java     |  14 +-
 .../iotdb/confignode/i18n/ProcedureMessages.java   |   5 +
 .../confignode/conf/ConfigNodeDescriptor.java      |  10 +-
 .../consensus/response/cq/ShowCQResp.java          |   2 +-
 .../externalservice/ShowExternalServiceResp.java   |   2 +-
 .../balancer/router/leader/HashLeaderBalancer.java |   2 +-
 .../manager/partition/PartitionManager.java        |  18 +
 .../agent/runtime/PipeConfigNodeRuntimeAgent.java  |  17 +-
 .../pipe/agent/task/PipeConfigNodeSubtask.java     |  21 +-
 .../pipe/coordinator/runtime/PipeMetaSyncer.java   |  26 +-
 .../runtime/heartbeat/PipeHeartbeatParser.java     |  43 +-
 .../runtime/heartbeat/PipeHeartbeatScheduler.java  |   7 +-
 .../pipe/coordinator/task/PipeTaskCoordinator.java |   8 +-
 .../coordinator/task/PipeTaskCoordinatorLock.java  |  10 +-
 .../receiver/protocol/IoTDBConfigNodeReceiver.java |   4 +-
 .../schema/ClusterSchemaQuotaStatistics.java       |   2 +-
 .../confignode/persistence/pipe/PipeTaskInfo.java  |   9 +-
 .../mnode/container/ConfigMNodeContainer.java      |   2 +-
 .../procedure/env/ConfigNodeProcedureEnv.java      |   7 +-
 .../procedure/env/RemoveDataNodeHandler.java       |  52 +-
 .../runtime/PipeHandleLeaderChangeProcedure.java   |  36 +-
 .../runtime/PipeHandleMetaChangeProcedure.java     |  33 +-
 .../impl/pipe/runtime/PipeMetaSyncProcedure.java   |   6 +-
 .../impl/region/CreateRegionGroupsProcedure.java   |  10 +-
 .../router/leader/HashLeaderBalancerTest.java      |  65 ++
 .../pipe/sink/PipeConfigNodeThriftRequestTest.java | 212 +++++
 iotdb-core/consensus/pom.xml                       |   4 +-
 .../iot/client/AsyncIoTConsensusServiceClient.java |   2 +-
 iotdb-core/datanode/pom.xml                        |   8 +-
 .../iotdb/db/i18n/DataNodeQueryMessages.java       |   9 -
 .../iotdb/db/i18n/DataNodeQueryMessages.java       |   9 -
 .../org/apache/iotdb/db/audit/DNAuditLogger.java   |   2 +-
 .../apache/iotdb/db/conf/DataNodeMemoryConfig.java |  18 +
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |   2 +-
 .../iotdb/db/conf/rest/IoTDBRestServiceConfig.java |   2 +-
 .../agent/runtime/PipeDataNodeRuntimeAgent.java    |  14 +-
 .../db/pipe/event/common/PipeInsertionEvent.java   |   2 +-
 .../tablet/parser/TabletInsertionEventParser.java  | 123 ++-
 .../scan/AlignedSinglePageWholeChunkReader.java    |   2 +-
 .../parser/scan/SinglePageWholeChunkReader.java    |   2 +-
 .../downsampling/changing/ChangingValueFilter.java |  20 +-
 .../sdt/SwingingDoorTrendingFilter.java            |  19 +-
 .../tumbling/TumblingTimeSamplingProcessor.java    |   7 +-
 .../exchange/sender/TwoStageAggregateSender.java   |   2 +-
 .../protocol/thrift/IoTDBDataNodeReceiver.java     |   6 +-
 .../statement/PipeConvertedInsertRowStatement.java |   9 +
 .../resource/log/PipePeriodicalLogReducer.java     |  93 ---
 .../resource/memory/InsertNodeMemoryEstimator.java |  15 +-
 .../resource/memory/PipeDynamicMemoryBlock.java    |   2 +-
 .../tsfile/PipeTsFileResourceSegmentLock.java      |  10 +-
 .../request/PipeTransferTabletRawReq.java          |  89 ++-
 .../pipe/sink/util/TabletStatementConverter.java   |  31 +-
 .../db/queryengine/common/MPPQueryContext.java     |  10 +
 .../db/queryengine/execution/StateMachine.java     |   8 +-
 .../execution/aggregation/ExtremeAccumulator.java  |  32 +-
 .../SlidingWindowAggregatorFactory.java            |  36 +-
 .../execution/operator/ExplainAnalyzeOperator.java |  70 +-
 .../execution/operator/window/SessionWindow.java   |  24 +-
 .../operator/window/SessionWindowManager.java      |   2 +-
 .../execution/schedule/DriverScheduler.java        |  15 +-
 .../multilevelqueue/MultilevelPriorityQueue.java   |  10 +
 .../execution/schedule/task/DriverTask.java        |  13 +
 .../execution/schedule/task/DriverTaskId.java      |   2 +-
 .../metric/DriverSchedulerMetricSet.java           |  13 +
 .../iotdb/db/queryengine/plan/Coordinator.java     |  17 +-
 .../db/queryengine/plan/analyze/AnalyzeUtils.java  |  34 +-
 .../plan/analyze/schema/NormalSchemaFetcher.java   |   4 +-
 .../plan/execution/config/ConfigExecution.java     |   2 +-
 .../TableModelStatementMemorySourceVisitor.java    |  54 +-
 .../plan/expression/unary/InExpression.java        |   2 +-
 .../planner/DataNodeTableOperatorGenerator.java    |   9 +-
 .../plan/AbstractFragmentParallelPlanner.java      |   3 +-
 .../planner/plan/node/PlanGraphJsonPrinter.java    | 225 ++++++
 .../metadata/read/LevelTimeSeriesCountNode.java    |   2 +-
 .../node/metadata/read/TimeSeriesCountNode.java    |   2 +-
 .../metadata/read/TimeSeriesSchemaScanNode.java    |   2 +-
 .../plan/planner/plan/node/write/InsertNode.java   |  70 +-
 .../planner/plan/node/write/InsertRowNode.java     | 216 ++++--
 .../plan/node/write/InsertRowsOfOneDeviceNode.java |   5 +-
 .../planner/plan/node/write/InsertTabletNode.java  | 351 ++++++---
 .../plan/node/write/RelationalInsertRowNode.java   |  63 +-
 .../plan/node/write/RelationalInsertRowsNode.java  |  45 +-
 .../node/write/RelationalInsertTabletNode.java     | 111 ++-
 .../relational/analyzer/StatementAnalyzer.java     |   2 +
 .../fetcher/cache/TreeDeviceNormalSchema.java      |   4 +-
 .../cache/TreeDeviceSchemaCacheManager.java        |   9 +-
 .../plan/relational/planner/CteMaterializer.java   |   1 +
 .../plan/relational/planner/RelationPlanner.java   |  25 +-
 .../relational/planner/TableLogicalPlanner.java    |   3 +-
 .../distribute/TableDistributedPlanner.java        |  16 +-
 ...ithUncorrelatedScalarSubqueryReconstructor.java |   2 +
 .../planner/node/ExplainAnalyzeNode.java           |  39 +-
 .../optimizations/UnaliasSymbolReferences.java     |   3 +-
 .../plan/relational/sql/ast/Explain.java           |  28 +-
 .../plan/relational/sql/ast/ExplainAnalyze.java    |  37 +-
 .../relational/sql/ast/ExplainOutputFormat.java}   |  32 +-
 .../plan/relational/sql/ast/InsertRow.java         |   5 +-
 .../plan/relational/sql/ast/InsertRows.java        |  14 +-
 .../plan/relational/sql/ast/InsertTablet.java      |  13 +-
 .../plan/relational/sql/ast/PipeEnriched.java      |   2 +-
 .../relational/sql/ast/WrappedInsertStatement.java |  22 +-
 .../plan/relational/sql/parser/AstBuilder.java     |  35 +-
 .../plan/statement/crud/InsertBaseStatement.java   | 210 +++--
 .../plan/statement/crud/InsertRowStatement.java    | 128 ++-
 .../crud/InsertRowsOfOneDeviceStatement.java       |  12 +
 .../plan/statement/crud/InsertTabletStatement.java | 161 +++-
 .../FragmentInstanceStatisticsJsonDrawer.java      | 372 +++++++++
 .../logfile/FakeCRC32Deserializer.java             |   3 +-
 .../schemaregion/logfile/SchemaLogReader.java      |   2 +-
 .../mem/mnode/container/MemMNodeContainer.java     |   2 +-
 .../mnode/container/CachedMNodeContainer.java      |   3 +-
 .../buffer/TimeSeriesMetadataCache.java            |  43 +-
 .../db/storageengine/dataregion/DataRegion.java    |   3 +-
 .../compaction/schedule/CompactionWorker.java      |   2 +-
 .../dataregion/memtable/AbstractMemTable.java      | 120 +--
 .../memtable/AbstractWritableMemChunk.java         |  17 +
 .../memtable/AlignedWritableMemChunk.java          |   7 +-
 .../dataregion/memtable/TsFileProcessor.java       | 162 ++--
 .../dataregion/memtable/WritableMemChunk.java      |   7 +-
 .../dataregion/memtable/WritableMemChunkGroup.java |   2 +-
 .../dataregion/snapshot/SnapshotLoader.java        |  15 +
 .../consensus/ConsensusLogToTabletConverter.java   |  70 +-
 .../SubscriptionPipeEventBatchSegmentLock.java     |   4 +-
 .../db/trigger/executor/TriggerFireVisitor.java    |  53 +-
 .../java/org/apache/iotdb/db/utils/MemUtils.java   |  71 +-
 .../pipe/event/PipeTabletInsertionEventTest.java   |  81 ++
 .../changing/ChangingValueFilterTest.java          |  55 ++
 .../sdt/SwingingDoorTrendingFilterTest.java        |  56 ++
 .../TumblingTimeSamplingProcessorTest.java         | 192 +++++
 .../PipeConvertedInsertRowStatementTest.java       |  55 ++
 .../memory/InsertNodeMemoryEstimatorTest.java      |  12 +
 .../tsfile/PipeTsFileResourceSegmentLockTest.java  |  71 ++
 .../pipe/sink/PipeDataNodeThriftRequestTest.java   | 505 ++++++++++++
 .../sink/util/TabletStatementConverterTest.java    |  64 ++
 .../execution/aggregation/AccumulatorTest.java     |  46 ++
 .../SlidingWindowAggregatorFactoryTest.java        |  41 +
 .../operator/ExplainAnalyzeOperatorTest.java       |  96 +++
 .../operator/window/SessionWindowTest.java         |  70 ++
 .../schedule/DefaultDriverSchedulerTest.java       |  41 +
 .../queryengine/plan/analyze/AnalyzeUtilsTest.java |  74 ++
 ...TableModelStatementMemorySourceVisitorTest.java |  88 +++
 .../planner/node/PlanGraphJsonPrinterTest.java     | 573 ++++++++++++++
 .../planner/node/write/InsertRowNodeSerdeTest.java | 127 +++
 .../node/write/InsertRowsNodeSerdeTest.java        |  35 +
 .../write/InsertRowsOfOneDeviceNodeSerdeTest.java  |  34 +
 .../node/write/InsertTabletNodeSerdeTest.java      | 130 ++++
 .../planner/node/write/WritePlanNodeSplitTest.java |  41 +
 .../write/InsertNodeIsMeasurementFailedTest.java   | 255 ++++++
 .../relational/planner/CteMaterializerTest.java    |   1 +
 .../plan/relational/planner/CteSubqueryTest.java   |   1 +
 .../plan/relational/sql/ExplainFormatTest.java     | 186 +++++
 .../crud/InsertStatementPartialInsertTest.java     | 320 ++++++++
 .../FragmentInstanceStatisticsJsonDrawerTest.java  | 594 ++++++++++++++
 .../buffer/TimeSeriesMetadataCacheTest.java        | 280 +++++++
 .../storageengine/dataregion/DataRegionTest.java   |  30 +-
 .../AbstractMemTablePartialInsertTest.java         | 113 +++
 .../memtable/MemChunkDeserializeTest.java          |  23 +
 .../dataregion/memtable/TsFileProcessorTest.java   | 172 +++++
 .../ConsensusLogToTabletConverterTest.java         |  58 ++
 .../SubscriptionPipeEventBatchSegmentLockTest.java |  50 ++
 .../org/apache/iotdb/db/utils/MemUtilsTest.java    | 127 +++
 .../src/test/resources/iotdb-common.properties     |   2 +-
 .../src/test/resources/iotdb-system.properties     |   2 +-
 .../conf/iotdb-system.properties.template          |  13 +-
 .../async/AsyncAINodeInternalServiceClient.java    |   2 +-
 .../AsyncConfigNodeInternalServiceClient.java      |   2 +-
 .../async/AsyncDataNodeExternalServiceClient.java  |   2 +-
 .../async/AsyncDataNodeInternalServiceClient.java  |   2 +-
 .../AsyncDataNodeMPPDataExchangeServiceClient.java |   2 +-
 .../async/AsyncIoTConsensusV2ServiceClient.java    |   2 +-
 .../async/AsyncPipeDataTransferServiceClient.java  |   2 +-
 .../apache/iotdb/commons/conf/CommonConfig.java    |  10 +
 .../iotdb/commons/conf/CommonDescriptor.java       |   9 +
 .../commons/pipe/resource/log/PipeLogger.java      |  18 +-
 .../resource/log/PipePeriodicalLogReducer.java     |  76 ++
 .../thrift/request/PipeTransferFileSealReqV2.java  |   8 +
 .../plan/planner/plan/node/PlanNodeType.java       |   2 +
 .../schema/table/InsertNodeMeasurementInfo.java    |   9 +-
 .../org/apache/iotdb/commons/utils/PathUtils.java  |  56 +-
 .../commons/pipe/resource/PipeLoggerTest.java      |  83 ++
 .../common/PipeTransferSliceReqBuilderTest.java    |  32 +
 .../thrift/request/PipeRequestTypeTest.java        |  61 ++
 .../request/PipeTransferCompressedReqTest.java     | 112 +++
 .../request/PipeTransferFileSealReqV2Test.java     |  65 ++
 .../table/InsertNodeMeasurementInfoTest.java       |  83 ++
 .../db/relational/grammar/sql/RelationalSql.g4     |   4 +-
 library-udf/pom.xml                                |   4 +-
 pom.xml                                            | 117 ++-
 scripts/conf/confignode-env.sh                     |  61 +-
 scripts/conf/datanode-env.sh                       |  70 +-
 scripts/sbin/start-cli.sh                          |  13 +-
 scripts/sbin/windows/start-cli.bat                 |  23 +-
 scripts/sbin/windows/start-confignode.bat          |  20 +-
 scripts/sbin/windows/start-datanode.bat            |  19 +-
 scripts/tools/ops/health_check.sh                  |   2 +-
 scripts/tools/windows/ops/health_check.bat         |   4 +-
 268 files changed, 11339 insertions(+), 1547 deletions(-)

diff --cc iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
index 68d2de1c2a7,6ef5804fac8..a19e72f41dd
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/MPPQueryContext.java
@@@ -41,7 -39,7 +41,8 @@@ import org.apache.iotdb.db.queryengine.
  import org.apache.iotdb.db.queryengine.plan.analyze.TypeProvider;
  import org.apache.iotdb.db.queryengine.plan.analyze.lock.SchemaLockType;
  import org.apache.iotdb.db.queryengine.plan.planner.memory.NotThreadSafeMemoryReservationManager;
 +import org.apache.iotdb.db.queryengine.plan.relational.function.tvf.readTsFile.ExternalTsFileQueryResource;
+ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ExplainOutputFormat;
  import org.apache.iotdb.db.queryengine.statistics.QueryPlanStatistics;
  
  import com.google.common.collect.ImmutableList;


(iotdb) 04/04: refactor

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch read_tsfile_table_function
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit f06a3648d01112e2cb8b418b87b30d0589057150
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Mon Jun 15 10:48:04 2026 +0800

    refactor
---
 .../readTsFile/ExternalTsFileQueryResource.java    |   1 +
 .../tvf/readTsFile/ReadTsFileTableFunction.java    | 232 +----------------
 .../tvf/readTsFile/TsFileSchemaCollector.java      | 287 +++++++++++++++++++++
 3 files changed, 297 insertions(+), 223 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java
index 9e3208a7251..49de26e2dff 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java
@@ -459,6 +459,7 @@ public class ExternalTsFileQueryResource implements AutoCloseable {
         currentDeviceOffsetMap.put(tsFileResource, deviceOffset);
       }
       currentDeviceQueryDataSource = new QueryDataSource(Collections.emptyList(), unseqResources);
+      currentDeviceQueryDataSource.setSingleDevice(true);
       return true;
     }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java
index bb8e8a81483..e027ffd3cf1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ReadTsFileTableFunction.java
@@ -35,31 +35,19 @@ import org.apache.iotdb.udf.api.relational.table.specification.ParameterSpecific
 import org.apache.iotdb.udf.api.relational.table.specification.ScalarParameterSpecification;
 import org.apache.iotdb.udf.api.type.Type;
 
-import org.apache.tsfile.common.conf.TSFileConfig;
-import org.apache.tsfile.enums.ColumnCategory;
-import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.file.metadata.TableSchema;
-import org.apache.tsfile.read.TsFileSequenceReader;
 import org.apache.tsfile.write.schema.IMeasurementSchema;
-import org.apache.tsfile.write.schema.MeasurementSchema;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.apache.iotdb.commons.schema.table.TsTable.TIME_COLUMN_NAME;
 
 /** Reads one or more TsFiles as a table function source. */
 public class ReadTsFileTableFunction implements TableFunction {
@@ -83,23 +71,25 @@ public class ReadTsFileTableFunction implements TableFunction {
     List<String> tsFilePaths =
         parseTsFilePaths(getRequiredStringArgument(arguments, PATHS_PARAMETER_NAME));
     checkTsFilePathsAreOutsideDataDirs(tsFilePaths);
-    TsFileSchemaCollection schemaCollection =
-        collectTsFilesAndResolveSchema(tableName.isEmpty() ? null : tableName, tsFilePaths);
-    if (schemaCollection.mergedTableSchema == null) {
+    TsFileSchemaCollector schemaCollector =
+        new TsFileSchemaCollector(tableName.isEmpty() ? null : tableName);
+    schemaCollector.collect(tsFilePaths);
+    TableSchema mergedTableSchema = schemaCollector.getMergedTableSchema();
+    if (mergedTableSchema == null) {
       throw new UDFArgumentNotValidException(
           tableName.isEmpty()
               ? "No table schema found in TsFiles"
               : "No table schema found for table " + tableName + " in TsFiles");
     }
-    DescribedSchema outputSchema = convertToDescribedSchema(schemaCollection.mergedTableSchema);
+    DescribedSchema outputSchema = convertToDescribedSchema(mergedTableSchema);
 
     ReadTsFileTableFunctionHandle handle =
         new ReadTsFileTableFunctionHandle(
-            schemaCollection.tableName,
-            schemaCollection.tsFiles.stream()
+            schemaCollector.getTableName(),
+            schemaCollector.getTsFiles().stream()
                 .map(File::getAbsolutePath)
                 .collect(Collectors.toList()),
-            schemaCollection.mergedTableSchema.getColumnTypes().stream()
+            mergedTableSchema.getColumnTypes().stream()
                 .map(TsTableColumnCategory::fromTsFileColumnCategory)
                 .collect(Collectors.toList()),
             outputSchema);
@@ -186,210 +176,6 @@ public class ReadTsFileTableFunction implements TableFunction {
     }
   }
 
-  private static TsFileSchemaCollection collectTsFilesAndResolveSchema(
-      String specifiedTableName, List<String> tsFilePaths) {
-    List<File> tsFiles = new ArrayList<>();
-    MergedTableSchemaBuilder schemaBuilder = null;
-    String resolvedTableName =
-        specifiedTableName == null ? null : specifiedTableName.toLowerCase(Locale.ENGLISH);
-    for (String tsFilePath : tsFilePaths) {
-      Path path = new File(tsFilePath).toPath();
-      if (!Files.exists(path)) {
-        throw new UDFArgumentNotValidException("TsFile path does not exist: " + tsFilePath);
-      }
-      try (Stream<Path> walkedPaths = Files.walk(path)) {
-        Iterator<Path> iterator = walkedPaths.filter(Files::isRegularFile).iterator();
-        while (iterator.hasNext()) {
-          Path filePath = iterator.next();
-          TableSchema tableSchema =
-              specifiedTableName == null
-                  ? tryInferTableSchema(filePath.toFile())
-                  : tryReadTableSchema(specifiedTableName, filePath.toFile());
-          if (tableSchema == null) {
-            continue;
-          }
-          String currentTableName = tableSchema.getTableName().toLowerCase(Locale.ENGLISH);
-          if (resolvedTableName == null) {
-            resolvedTableName = currentTableName;
-          } else if (!resolvedTableName.equals(currentTableName)) {
-            throw new UDFArgumentNotValidException(
-                String.format(
-                    "Cannot infer table name from TsFiles because multiple tables are found: %s and %s",
-                    resolvedTableName, currentTableName));
-          }
-          tsFiles.add(filePath.toFile());
-          if (schemaBuilder == null) {
-            schemaBuilder = new MergedTableSchemaBuilder(resolvedTableName, tableSchema);
-          } else {
-            schemaBuilder.merge(tableSchema);
-          }
-        }
-      } catch (IOException e) {
-        throw new UDFArgumentNotValidException("Failed to scan TsFile path: " + tsFilePath);
-      }
-    }
-    if (tsFiles.isEmpty()) {
-      throw new UDFArgumentNotValidException("No valid TsFiles found");
-    }
-    return new TsFileSchemaCollection(resolvedTableName, tsFiles, schemaBuilder.build());
-  }
-
-  private static TableSchema tryReadTableSchema(String tableName, File tsFile) {
-    if (!tsFile.canRead()) {
-      return null;
-    }
-    try (TsFileSequenceReader reader = new TsFileSequenceReader(tsFile.getAbsolutePath())) {
-      if (!reader.isComplete() || reader.readVersionNumber() != TSFileConfig.VERSION_NUMBER) {
-        return null;
-      }
-      Map<String, TableSchema> tableSchemaMap = reader.getTableSchemaMap();
-      return tableSchemaMap.get(tableName.toLowerCase(Locale.ENGLISH));
-    } catch (Exception e) {
-      return null;
-    }
-  }
-
-  private static TableSchema tryInferTableSchema(File tsFile) {
-    if (!tsFile.canRead()) {
-      return null;
-    }
-    try (TsFileSequenceReader reader = new TsFileSequenceReader(tsFile.getAbsolutePath())) {
-      if (!reader.isComplete() || reader.readVersionNumber() != TSFileConfig.VERSION_NUMBER) {
-        return null;
-      }
-      Map<String, TableSchema> tableSchemaMap = reader.getTableSchemaMap();
-      if (tableSchemaMap.isEmpty()) {
-        throw new UDFArgumentNotValidException(
-            "Cannot infer table name from TsFile because no table schema is found in "
-                + tsFile.getAbsolutePath());
-      }
-      if (tableSchemaMap.size() > 1) {
-        throw new UDFArgumentNotValidException(
-            "Cannot infer table name from TsFile because multiple tables are found in "
-                + tsFile.getAbsolutePath());
-      }
-      return tableSchemaMap.values().iterator().next();
-    } catch (UDFArgumentNotValidException e) {
-      throw e;
-    } catch (Exception e) {
-      return null;
-    }
-  }
-
-  private static class TsFileSchemaCollection {
-    private final String tableName;
-    private final List<File> tsFiles;
-    private final TableSchema mergedTableSchema;
-
-    private TsFileSchemaCollection(
-        String tableName, List<File> tsFiles, TableSchema mergedTableSchema) {
-      this.tableName = tableName;
-      this.tsFiles = tsFiles;
-      this.mergedTableSchema = mergedTableSchema;
-    }
-  }
-
-  private static class MergedTableSchemaBuilder {
-    private final String tableName;
-    private IMeasurementSchema timeColumnSchema;
-    private final List<IMeasurementSchema> tagColumnSchemas = new ArrayList<>();
-    private final Map<String, IMeasurementSchema> fieldColumnSchemaMap = new LinkedHashMap<>();
-
-    private MergedTableSchemaBuilder(String tableName, TableSchema tableSchema) {
-      this.tableName = tableName.toLowerCase(Locale.ENGLISH);
-      merge(tableSchema);
-    }
-
-    private void merge(TableSchema tableSchema) {
-      IMeasurementSchema currentTimeColumn = null;
-      List<IMeasurementSchema> currentTagColumns = new ArrayList<>();
-      List<IMeasurementSchema> currentFieldColumns = new ArrayList<>();
-      List<IMeasurementSchema> columnSchemas = tableSchema.getColumnSchemas();
-      List<ColumnCategory> columnCategories = tableSchema.getColumnTypes();
-
-      for (int i = 0; i < columnCategories.size(); i++) {
-        if (columnCategories.get(i) == ColumnCategory.TIME) {
-          if (currentTimeColumn != null) {
-            throw new UDFArgumentNotValidException(
-                "Multiple time columns found when merging table schema for table " + tableName);
-          }
-          currentTimeColumn = columnSchemas.get(i);
-        } else if (columnCategories.get(i) == ColumnCategory.TAG) {
-          currentTagColumns.add(columnSchemas.get(i));
-        } else if (columnCategories.get(i) == ColumnCategory.FIELD) {
-          currentFieldColumns.add(columnSchemas.get(i));
-        }
-      }
-
-      mergeTimeColumn(currentTimeColumn);
-      mergeTagColumns(currentTagColumns);
-      mergeFieldColumns(currentFieldColumns);
-    }
-
-    private void mergeTimeColumn(IMeasurementSchema currentTimeColumn) {
-      if (currentTimeColumn == null) {
-        return;
-      }
-      if (timeColumnSchema == null) {
-        timeColumnSchema = currentTimeColumn;
-        return;
-      }
-      if (!timeColumnSchema.getMeasurementName().equals(currentTimeColumn.getMeasurementName())
-          || currentTimeColumn.getType() != TSDataType.TIMESTAMP) {
-        throw new UDFArgumentNotValidException(
-            "Time column conflicts when merging table schema for table " + tableName);
-      }
-    }
-
-    private void mergeTagColumns(List<IMeasurementSchema> currentTagColumns) {
-      int prefixLength = Math.min(tagColumnSchemas.size(), currentTagColumns.size());
-      for (int i = 0; i < prefixLength; i++) {
-        if (!tagColumnSchemas
-            .get(i)
-            .getMeasurementName()
-            .equals(currentTagColumns.get(i).getMeasurementName())) {
-          throw new UDFArgumentNotValidException(
-              "Tag columns conflict when merging table schema for table " + tableName);
-        }
-      }
-      tagColumnSchemas.addAll(currentTagColumns.subList(prefixLength, currentTagColumns.size()));
-    }
-
-    private void mergeFieldColumns(List<IMeasurementSchema> currentFieldColumns) {
-      for (IMeasurementSchema fieldColumn : currentFieldColumns) {
-        String fieldName = fieldColumn.getMeasurementName().toLowerCase(Locale.ENGLISH);
-        IMeasurementSchema existingColumn = fieldColumnSchemaMap.get(fieldName);
-        if (existingColumn != null && existingColumn.getType() != fieldColumn.getType()) {
-          throw new UDFArgumentNotValidException(
-              "Field column "
-                  + fieldColumn.getMeasurementName()
-                  + " has conflicting data types when merging table schema for table "
-                  + tableName);
-        }
-        fieldColumnSchemaMap.putIfAbsent(fieldName, fieldColumn);
-      }
-    }
-
-    private TableSchema build() {
-      List<IMeasurementSchema> columnSchemas = new ArrayList<>();
-      List<ColumnCategory> columnCategories = new ArrayList<>();
-      columnSchemas.add(
-          timeColumnSchema == null
-              ? new MeasurementSchema(TIME_COLUMN_NAME, TSDataType.TIMESTAMP)
-              : timeColumnSchema);
-      columnCategories.add(ColumnCategory.TIME);
-      for (IMeasurementSchema tagColumnSchema : tagColumnSchemas) {
-        columnSchemas.add(tagColumnSchema);
-        columnCategories.add(ColumnCategory.TAG);
-      }
-      for (IMeasurementSchema fieldColumnSchema : fieldColumnSchemaMap.values()) {
-        columnSchemas.add(fieldColumnSchema);
-        columnCategories.add(ColumnCategory.FIELD);
-      }
-      return new TableSchema(tableName, columnSchemas, columnCategories);
-    }
-  }
-
   private static DescribedSchema convertToDescribedSchema(TableSchema tableSchema) {
     DescribedSchema.Builder builder = DescribedSchema.builder();
     for (IMeasurementSchema columnSchema : tableSchema.getColumnSchemas()) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/TsFileSchemaCollector.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/TsFileSchemaCollector.java
new file mode 100644
index 00000000000..aa2ccdeab8b
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/TsFileSchemaCollector.java
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.relational.function.tvf.readTsFile;
+
+import org.apache.iotdb.udf.api.exception.UDFArgumentNotValidException;
+
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.common.constant.TsFileConstant;
+import org.apache.tsfile.enums.ColumnCategory;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.file.metadata.TableSchema;
+import org.apache.tsfile.read.TsFileSequenceReader;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Stream;
+
+import static org.apache.iotdb.commons.schema.table.TsTable.TIME_COLUMN_NAME;
+
+final class TsFileSchemaCollector {
+  private final String specifiedTableName;
+  private String tableName;
+  private final List<File> tsFiles = new ArrayList<>();
+  private MergedTableSchemaBuilder schemaBuilder;
+  private TableSchema mergedTableSchema;
+
+  TsFileSchemaCollector(String specifiedTableName) {
+    this.specifiedTableName =
+        specifiedTableName == null ? null : specifiedTableName.toLowerCase(Locale.ENGLISH);
+    this.tableName = this.specifiedTableName;
+  }
+
+  void collect(List<String> tsFilePaths) {
+    for (String tsFilePath : tsFilePaths) {
+      Path path = new File(tsFilePath).toPath();
+      if (!Files.exists(path)) {
+        throw new UDFArgumentNotValidException("TsFile path does not exist: " + tsFilePath);
+      }
+      if (Files.isRegularFile(path)) {
+        TableSchema tableSchema = readTableSchema(specifiedTableName, path.toFile(), true);
+        collect(path.toFile(), tableSchema);
+        continue;
+      }
+      if (!Files.isDirectory(path)) {
+        throw new UDFArgumentNotValidException(
+            "TsFile path is neither a file nor a directory: " + tsFilePath);
+      }
+      collectFromDirectory(tsFilePath, path);
+    }
+    if (tsFiles.isEmpty()) {
+      throw new UDFArgumentNotValidException("No valid TsFiles found");
+    }
+  }
+
+  String getTableName() {
+    return tableName;
+  }
+
+  List<File> getTsFiles() {
+    return tsFiles;
+  }
+
+  TableSchema getMergedTableSchema() {
+    return mergedTableSchema;
+  }
+
+  private void collectFromDirectory(String tsFilePath, Path path) {
+    try (Stream<Path> walkedPaths = Files.walk(path)) {
+      Iterator<Path> iterator =
+          walkedPaths.filter(Files::isRegularFile).filter(this::hasTsFileSuffix).iterator();
+      while (iterator.hasNext()) {
+        Path filePath = iterator.next();
+        TableSchema tableSchema = readTableSchema(specifiedTableName, filePath.toFile(), false);
+        collect(filePath.toFile(), tableSchema);
+      }
+    } catch (IOException e) {
+      throw new UDFArgumentNotValidException("Failed to scan TsFile path: " + tsFilePath);
+    }
+  }
+
+  private boolean hasTsFileSuffix(Path filePath) {
+    Path fileName = filePath.getFileName();
+    return fileName != null && fileName.toString().endsWith(TsFileConstant.TSFILE_SUFFIX);
+  }
+
+  private void collect(File tsFile, TableSchema tableSchema) {
+    if (tableSchema == null) {
+      return;
+    }
+    String currentTableName = tableSchema.getTableName().toLowerCase(Locale.ENGLISH);
+    if (tableName == null) {
+      tableName = currentTableName;
+    } else if (!tableName.equals(currentTableName)) {
+      throw new UDFArgumentNotValidException(
+          String.format(
+              "Cannot infer table name from TsFiles because multiple tables are found: %s and %s",
+              tableName, currentTableName));
+    }
+    tsFiles.add(tsFile);
+    if (schemaBuilder == null) {
+      schemaBuilder = new MergedTableSchemaBuilder(tableName, tableSchema);
+    } else {
+      schemaBuilder.merge(tableSchema);
+    }
+    mergedTableSchema = schemaBuilder.build();
+  }
+
+  private TableSchema readTableSchema(
+      String specifiedTableName, File tsFile, boolean failOnInvalidTsFile) {
+    if (!tsFile.canRead()) {
+      if (failOnInvalidTsFile) {
+        throw invalidTsFileException(tsFile);
+      }
+      return null;
+    }
+    try (TsFileSequenceReader reader = new TsFileSequenceReader(tsFile.getAbsolutePath())) {
+      if (!isValidTsFile(reader)) {
+        if (failOnInvalidTsFile) {
+          throw invalidTsFileException(tsFile);
+        }
+        return null;
+      }
+      Map<String, TableSchema> tableSchemaMap = reader.getTableSchemaMap();
+      if (specifiedTableName != null) {
+        return tableSchemaMap.get(specifiedTableName.toLowerCase(Locale.ENGLISH));
+      }
+      if (tableSchemaMap.isEmpty()) {
+        throw new UDFArgumentNotValidException(
+            "Cannot infer table name from TsFile because no table schema is found in "
+                + tsFile.getAbsolutePath());
+      }
+      if (tableSchemaMap.size() > 1) {
+        throw new UDFArgumentNotValidException(
+            "Cannot infer table name from TsFile because multiple tables are found in "
+                + tsFile.getAbsolutePath());
+      }
+      return tableSchemaMap.values().iterator().next();
+    } catch (UDFArgumentNotValidException e) {
+      throw e;
+    } catch (Exception e) {
+      if (failOnInvalidTsFile) {
+        throw invalidTsFileException(tsFile);
+      }
+      return null;
+    }
+  }
+
+  private boolean isValidTsFile(TsFileSequenceReader reader) throws IOException {
+    return TSFileConfig.MAGIC_STRING.equals(reader.readHeadMagic())
+        && reader.readVersionNumber() == TSFileConfig.VERSION_NUMBER
+        && TSFileConfig.MAGIC_STRING.equals(reader.readTailMagic());
+  }
+
+  private UDFArgumentNotValidException invalidTsFileException(File tsFile) {
+    return new UDFArgumentNotValidException(
+        "File is not a valid TsFile: " + tsFile.getAbsolutePath());
+  }
+
+  private static class MergedTableSchemaBuilder {
+    private final String tableName;
+    private IMeasurementSchema timeColumnSchema;
+    private final List<IMeasurementSchema> tagColumnSchemas = new ArrayList<>();
+    private final Map<String, IMeasurementSchema> fieldColumnSchemaMap = new LinkedHashMap<>();
+
+    private MergedTableSchemaBuilder(String tableName, TableSchema tableSchema) {
+      this.tableName = tableName.toLowerCase(Locale.ENGLISH);
+      merge(tableSchema);
+    }
+
+    private void merge(TableSchema tableSchema) {
+      IMeasurementSchema currentTimeColumn = null;
+      List<IMeasurementSchema> currentTagColumns = new ArrayList<>();
+      List<IMeasurementSchema> currentFieldColumns = new ArrayList<>();
+      List<IMeasurementSchema> columnSchemas = tableSchema.getColumnSchemas();
+      List<ColumnCategory> columnCategories = tableSchema.getColumnTypes();
+
+      for (int i = 0; i < columnCategories.size(); i++) {
+        if (columnCategories.get(i) == ColumnCategory.TIME) {
+          if (currentTimeColumn != null) {
+            throw new UDFArgumentNotValidException(
+                "Multiple time columns found when merging table schema for table " + tableName);
+          }
+          currentTimeColumn = columnSchemas.get(i);
+        } else if (columnCategories.get(i) == ColumnCategory.TAG) {
+          currentTagColumns.add(columnSchemas.get(i));
+        } else if (columnCategories.get(i) == ColumnCategory.FIELD) {
+          currentFieldColumns.add(columnSchemas.get(i));
+        }
+      }
+
+      mergeTimeColumn(currentTimeColumn);
+      mergeTagColumns(currentTagColumns);
+      mergeFieldColumns(currentFieldColumns);
+    }
+
+    private void mergeTimeColumn(IMeasurementSchema currentTimeColumn) {
+      if (currentTimeColumn == null) {
+        return;
+      }
+      if (timeColumnSchema == null) {
+        timeColumnSchema = currentTimeColumn;
+        return;
+      }
+      if (!timeColumnSchema.getMeasurementName().equals(currentTimeColumn.getMeasurementName())
+          || currentTimeColumn.getType() != TSDataType.TIMESTAMP) {
+        throw new UDFArgumentNotValidException(
+            "Time column conflicts when merging table schema for table " + tableName);
+      }
+    }
+
+    private void mergeTagColumns(List<IMeasurementSchema> currentTagColumns) {
+      int prefixLength = Math.min(tagColumnSchemas.size(), currentTagColumns.size());
+      for (int i = 0; i < prefixLength; i++) {
+        if (!tagColumnSchemas
+            .get(i)
+            .getMeasurementName()
+            .equals(currentTagColumns.get(i).getMeasurementName())) {
+          throw new UDFArgumentNotValidException(
+              "Tag columns conflict when merging table schema for table " + tableName);
+        }
+      }
+      tagColumnSchemas.addAll(currentTagColumns.subList(prefixLength, currentTagColumns.size()));
+    }
+
+    private void mergeFieldColumns(List<IMeasurementSchema> currentFieldColumns) {
+      for (IMeasurementSchema fieldColumn : currentFieldColumns) {
+        String fieldName = fieldColumn.getMeasurementName().toLowerCase(Locale.ENGLISH);
+        IMeasurementSchema existingColumn = fieldColumnSchemaMap.get(fieldName);
+        if (existingColumn != null
+            && !existingColumn.getType().isCompatible(fieldColumn.getType())) {
+          throw new UDFArgumentNotValidException(
+              "Field column "
+                  + fieldColumn.getMeasurementName()
+                  + " has conflicting data types when merging table schema for table "
+                  + tableName);
+        }
+        fieldColumnSchemaMap.putIfAbsent(fieldName, fieldColumn);
+      }
+    }
+
+    private TableSchema build() {
+      List<IMeasurementSchema> columnSchemas = new ArrayList<>();
+      List<ColumnCategory> columnCategories = new ArrayList<>();
+      columnSchemas.add(
+          timeColumnSchema == null
+              ? new MeasurementSchema(TIME_COLUMN_NAME, TSDataType.TIMESTAMP)
+              : timeColumnSchema);
+      columnCategories.add(ColumnCategory.TIME);
+      for (IMeasurementSchema tagColumnSchema : tagColumnSchemas) {
+        columnSchemas.add(tagColumnSchema);
+        columnCategories.add(ColumnCategory.TAG);
+      }
+      for (IMeasurementSchema fieldColumnSchema : fieldColumnSchemaMap.values()) {
+        columnSchemas.add(fieldColumnSchema);
+        columnCategories.add(ColumnCategory.FIELD);
+      }
+      return new TableSchema(tableName, columnSchemas, columnCategories);
+    }
+  }
+}


(iotdb) 02/04: fix mem control

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch read_tsfile_table_function
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 5e7bc0af91559f7c67f2672c8b52399aae4da48c
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Fri Jun 12 11:10:56 2026 +0800

    fix mem control
---
 .../ExternalTsFileAggTableScanOperator.java        |  3 ++-
 .../ExternalTsFileTableScanOperator.java           |  3 ++-
 .../readTsFile/ExternalTsFileQueryDataSource.java  | 28 ++++------------------
 .../readTsFile/ExternalTsFileQueryResource.java    | 13 ++++++----
 4 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileAggTableScanOperator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileAggTableScanOperator.java
index f6e4a84fc75..a3e7566fc93 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileAggTableScanOperator.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileAggTableScanOperator.java
@@ -28,6 +28,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.function.tvf.readTsFile.E
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.AlignedDeviceEntry;
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
 import org.apache.iotdb.db.storageengine.dataregion.read.IQueryDataSource;
+import org.apache.iotdb.db.storageengine.dataregion.read.QueryDataSource;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
 
 import org.apache.tsfile.file.metadata.AbstractAlignedTimeSeriesMetadata;
@@ -118,7 +119,7 @@ public class ExternalTsFileAggTableScanOperator extends DefaultAggTableScanOpera
         && deviceEntries.get(currentDeviceIndex) != null;
   }
 
-  private ExternalTsFileQueryDataSource updateCurrentDeviceQueryDataSource() {
+  private QueryDataSource updateCurrentDeviceQueryDataSource() {
     try {
       if (!deviceTaskReader.nextDevice()) {
         throw new IllegalStateException(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileTableScanOperator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileTableScanOperator.java
index 73a9cb11ad5..59d072b1362 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileTableScanOperator.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/ExternalTsFileTableScanOperator.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.function.tvf.readTsFile.E
 import org.apache.iotdb.db.queryengine.plan.relational.function.tvf.readTsFile.ExternalTsFileQueryResource.DeviceTaskRunReader;
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
 import org.apache.iotdb.db.storageengine.dataregion.read.IQueryDataSource;
+import org.apache.iotdb.db.storageengine.dataregion.read.QueryDataSource;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
 
 import org.apache.tsfile.file.metadata.AbstractAlignedTimeSeriesMetadata;
@@ -105,7 +106,7 @@ public class ExternalTsFileTableScanOperator extends TableScanOperator {
     }
   }
 
-  private ExternalTsFileQueryDataSource updateCurrentDeviceQueryDataSource() {
+  private QueryDataSource updateCurrentDeviceQueryDataSource() {
     try {
       if (!deviceTaskReader.nextDevice()) {
         throw new IllegalStateException(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryDataSource.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryDataSource.java
index ac55a8cbfe2..fd18da081c7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryDataSource.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryDataSource.java
@@ -21,47 +21,29 @@ package org.apache.iotdb.db.queryengine.plan.relational.function.tvf.readTsFile;
 
 import org.apache.iotdb.db.storageengine.dataregion.read.IQueryDataSource;
 import org.apache.iotdb.db.storageengine.dataregion.read.QueryDataSource;
-import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
-
-import org.apache.tsfile.file.metadata.IDeviceID;
-import org.apache.tsfile.read.filter.basic.Filter;
 
 import java.util.Collections;
-import java.util.List;
 
 public class ExternalTsFileQueryDataSource extends QueryDataSource {
 
   private final ExternalTsFileQueryResource externalTsFileQueryResource;
 
   public ExternalTsFileQueryDataSource(ExternalTsFileQueryResource externalTsFileQueryResource) {
-    this(externalTsFileQueryResource, Collections.emptyList());
-  }
-
-  ExternalTsFileQueryDataSource(
-      ExternalTsFileQueryResource externalTsFileQueryResource,
-      List<TsFileResource> unseqResources) {
-    super(Collections.emptyList(), unseqResources);
+    super(Collections.emptyList(), Collections.emptyList());
     this.externalTsFileQueryResource = externalTsFileQueryResource;
   }
 
-  @Override
-  public IQueryDataSource clone() {
-    return new ExternalTsFileQueryDataSource(externalTsFileQueryResource, getUnseqResources());
-  }
-
   public ExternalTsFileQueryResource getExternalTsFileQueryResource() {
     return externalTsFileQueryResource;
   }
 
   @Override
-  public boolean isSeqSatisfied(
-      IDeviceID deviceID, int curIndex, Filter timeFilter, boolean debug) {
-    return true;
+  public IQueryDataSource clone() {
+    return new ExternalTsFileQueryDataSource(externalTsFileQueryResource);
   }
 
   @Override
-  public boolean isUnSeqSatisfied(
-      IDeviceID deviceID, int curIndex, Filter timeFilter, boolean debug) {
-    return true;
+  public boolean isEmpty() {
+    return externalTsFileQueryResource.getTsFileResources().isEmpty();
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java
index 74f39f73613..9e3208a7251 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/readTsFile/ExternalTsFileQueryResource.java
@@ -28,6 +28,7 @@ import org.apache.iotdb.db.queryengine.common.QueryId;
 import org.apache.iotdb.db.queryengine.execution.operator.source.relational.ExternalTsFileDeviceFilterVisitor;
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.AlignedDeviceEntry;
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
+import org.apache.iotdb.db.storageengine.dataregion.read.QueryDataSource;
 import org.apache.iotdb.db.storageengine.dataregion.read.control.FileReaderManager;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource;
 import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResourceStatus;
@@ -112,6 +113,7 @@ public class ExternalTsFileQueryResource implements AutoCloseable {
   public void collectDeviceEntries(
       SchemaFilter schemaFilter, Comparator<DeviceEntry> comparator, int partitionCount) {
     checkNotClosed();
+    acquireMemoryForTsFileReaders();
     ExternalTsFileDeviceFilterVisitor deviceFilterVisitor = new ExternalTsFileDeviceFilterVisitor();
     try (DeviceCollector deviceCollector = new DeviceCollector()) {
       createDeviceTaskPartitions(partitionCount);
@@ -139,6 +141,10 @@ public class ExternalTsFileQueryResource implements AutoCloseable {
     }
   }
 
+  private void acquireMemoryForTsFileReaders() {
+    queryContext.reserveMemoryForFrontEndImmediately((long) tsFilePaths.size() * 4 * 1024);
+  }
+
   public DeviceTaskRunReader getDeviceTaskRunReader(int partitionIndex) {
     checkNotClosed();
     DeviceTaskPartition partition = getDeviceTaskPartition(partitionIndex);
@@ -403,7 +409,7 @@ public class ExternalTsFileQueryResource implements AutoCloseable {
 
     private final PriorityQueue<DeviceTaskRunCursor> runCursors;
     private DeviceEntry currentDevice;
-    private ExternalTsFileQueryDataSource currentDeviceQueryDataSource;
+    private QueryDataSource currentDeviceQueryDataSource;
     private Map<TsFileResource, DeviceOffset> currentDeviceOffsetMap;
 
     private DeviceTaskRunReader(DeviceTaskPartition partition) throws IOException {
@@ -452,8 +458,7 @@ public class ExternalTsFileQueryResource implements AutoCloseable {
         unseqResources.add(tsFileResource);
         currentDeviceOffsetMap.put(tsFileResource, deviceOffset);
       }
-      currentDeviceQueryDataSource =
-          new ExternalTsFileQueryDataSource(ExternalTsFileQueryResource.this, unseqResources);
+      currentDeviceQueryDataSource = new QueryDataSource(Collections.emptyList(), unseqResources);
       return true;
     }
 
@@ -461,7 +466,7 @@ public class ExternalTsFileQueryResource implements AutoCloseable {
       return currentDevice;
     }
 
-    public ExternalTsFileQueryDataSource getCurrentDeviceQueryDataSource() {
+    public QueryDataSource getCurrentDeviceQueryDataSource() {
       return currentDeviceQueryDataSource;
     }