[Feat] Add table less query for table model#17437
Open
FearfulTomcat27 wants to merge 3 commits intoapache:masterfrom
Open
[Feat] Add table less query for table model#17437FearfulTomcat27 wants to merge 3 commits intoapache:masterfrom
FearfulTomcat27 wants to merge 3 commits intoapache:masterfrom
Conversation
- Handle cases without a FROM clause in QueryPlanner, returning a plan that includes ValuesNodes - TableOperatorGenerator supports null values and queries without a FROM clause, generating the corresponding ValuesOperator - Added support for accessing and overriding ValuesNode in UnaliasSymbolReferences - Added a new getOutputSymbols method to the ValuesNode class to expose the list of output symbols - Added relevant package imports to support the new types and node processing logic
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for table-model SQL queries without a FROM clause by introducing an implicit single-row source in the relational planner and enabling execution/optimization to handle it, plus an integration test.
Changes:
- Update relational planning to produce a
ValuesNode(1 row) whenFROMis absent. - Extend optimizer (
UnaliasSymbolReferences) and plan node (ValuesNode) to expose/migrate output symbols forValuesNode. - Update table execution planning to generate a
ValuesOperatorthat can emit the implicit single row for no-FROMqueries; add IT coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/QueryPlanner.java | Plans no-FROM queries as a single-row ValuesNode source. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/UnaliasSymbolReferences.java | Adds unalias rewriting support for ValuesNode. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/ValuesNode.java | Implements getOutputSymbols() so planner/optimizers can treat ValuesNode consistently. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java | Generates a non-empty ValuesOperator for the implicit single-row source case. |
| integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBComplexQueryIT.java | Adds an integration test for table-less queries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...tion-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBComplexQueryIT.java
Outdated
Show resolved
Hide resolved
JackieTien97
requested changes
Apr 13, 2026
...anode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
Outdated
Show resolved
Hide resolved
Comment on lines
+4412
to
+4413
| // No-FROM query (e.g. SELECT 1+1): produce rowCount rows with no value columns so that the | ||
| // upstream ProjectNode can evaluate expressions once per row. |
Contributor
There was a problem hiding this comment.
if (node.getRowCount() == 1) {
....
} else {
throw new IllegalArgumentException(...);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for SQL queries without a
FROMclause (table-less queries) in the IoTDB query engine, along with corresponding tests and necessary planning and execution logic updates. The changes ensure that expressions such asSELECT 1+1,SELECT sin(1), orSELECT COUNT(*)can be parsed, planned, and executed correctly, producing the expected single-row results even when no table is specified.Key changes include:
Support for Table-less (No-FROM) Queries:
QueryPlanner.java) to generate aValuesNodewith a single row when aSELECTstatement does not have aFROMclause, enabling implicit single-row semantics for such queries.TableOperatorGenerator.java) to correctly produce aValuesOperatorwith the appropriate number of rows and columns for no-FROM queries, using aRunLengthEncodedColumnto simulate the required rows.Testing:
testTableLessQuery) inIoTDBComplexQueryIT.javato verify correct behavior for queries without aFROMclause, including arithmetic, function, formatting, and aggregation expressions.Planner and Optimizer Enhancements:
getOutputSymbolsinValuesNodeto support symbol mapping and output column handling in the planner.UnaliasSymbolReferences.java) to handleValuesNode, ensuring correct symbol mapping and row transformation in the optimization pipeline.Dependency and Import Updates:
ValuesNode,InternalTypeManager, andRunLengthEncodedColumn. [1] [2] [3] [4]