misc(native): Clean up SystemConnector: fix fragile statics, macro hygiene, const-correctness, and switch safety#27251
Merged
amitkdutta merged 1 commit intoprestodb:masterfrom Mar 3, 2026
Conversation
…giene, const-correctness, and switch safety Summary: Several code quality issues in SystemConnector accumulated over time: **B1: Fix std::move from static local vectors in taskSchema()** `kTaskColumnNames` and `kTaskColumnTypes` were mutable `static` vectors that got `std::move`d into the `ROW()` constructor. After the first call, these vectors would be in a moved-from (empty) state. The code worked by accident because `kTaskSchema` is also static and initialized once, but it was fragile and confusing. Replaced with a single `static const RowTypePtr` constructed directly. **B2: Fix macro copy-by-value and add #undef** `SET_TASK_COLUMN` and `SET_TASK_FMT_COLUMN` macros copied `task` (shared_ptr) and `taskInfo` (TaskInfo struct) by value on every loop iteration. Changed to `const auto&` references with `[[maybe_unused]]` since each macro expansion may use only one of the two variables. Added `#undef` after use. **B4: Add const to SystemSplit accessors** `schemaName()` and `tableName()` returned `const std::string&` but were not `const`-qualified, preventing use on `const SystemSplit&`. **B5: Add default case to getTaskResults() switch** The switch over `TaskColumnEnum` had no `default` clause. Adding a new column enum without updating the switch would silently skip population. Added `default: VELOX_UNREACHABLE()`. Differential Revision: D95012494
Contributor
Reviewer's GuideRefactors SystemConnector task schema construction and task population macros to be safer and more efficient, improves const-correctness of SystemSplit accessors, and hardens the task results switch with an explicit unreachable default. Class diagram for updated SystemConnector componentsclassDiagram
class SystemTableHandle {
+RowTypePtr taskSchema() const
}
class SystemDataSource {
+RowVectorPtr getTaskResults()
+std::optional~RowVectorPtr~ next(uint64_t size, ContinueFuture& future)
}
class SystemSplit {
+SystemSplit(const std::string& schemaName, const std::string& tableName)
+const std::string& schemaName() const
+const std::string& tableName() const
-std::string schemaName_
-std::string tableName_
}
SystemDataSource ..> SystemSplit : uses_splits
SystemTableHandle ..> SystemDataSource : defines_schema_for
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
gggrace14
approved these changes
Mar 3, 2026
This was referenced Mar 31, 2026
15 tasks
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.
Summary:
Several code quality issues in SystemConnector accumulated over time:
B1: Fix std::move from static local vectors in taskSchema()
kTaskColumnNamesandkTaskColumnTypeswere mutablestaticvectors that gotstd::moved into theROW()constructor. After the first call, these vectors would be in a moved-from (empty) state. The code worked by accident becausekTaskSchemais also static and initialized once, but it was fragile and confusing. Replaced with a singlestatic const RowTypePtrconstructed directly.B2: Fix macro copy-by-value and add #undef
SET_TASK_COLUMNandSET_TASK_FMT_COLUMNmacros copiedtask(shared_ptr) andtaskInfo(TaskInfo struct) by value on every loop iteration. Changed toconst auto&references with[[maybe_unused]]since each macro expansion may use only one of the two variables. Added#undefafter use.B4: Add const to SystemSplit accessors
schemaName()andtableName()returnedconst std::string&but were notconst-qualified, preventing use onconst SystemSplit&.B5: Add default case to getTaskResults() switch
The switch over
TaskColumnEnumhad nodefaultclause. Adding a new column enum without updating the switch would silently skip population. Addeddefault: VELOX_UNREACHABLE().Summary by Sourcery
Improve SystemConnector code safety and const-correctness for task metadata handling.
Bug Fixes:
Enhancements: