Skip to content

misc(native): Fix lint issues in presto_cpp types/ directory#27194

Merged
amitkdutta merged 1 commit intoprestodb:masterfrom
amitkdutta:export-D94156498
Feb 24, 2026
Merged

misc(native): Fix lint issues in presto_cpp types/ directory#27194
amitkdutta merged 1 commit intoprestodb:masterfrom
amitkdutta:export-D94156498

Conversation

@amitkdutta
Copy link
Copy Markdown
Contributor

@amitkdutta amitkdutta commented Feb 24, 2026

Summary:
Fix CLANGTIDY and INFERMINICPP lint warnings across the types/ directory:

TestUtils.cpp:

  • Replace broad boost includes (string.hpp, filesystem.hpp) with specific headers
  • Add missing #include
  • Remove unused using namespace std;
  • Remove meaningless const qualifier on return-by-value types
  • Replace redundant .c_str() with .string() on boost::filesystem::current_path()
  • Add noexcept to function declarations and definitions

TestUtils.h:

  • Add #pragma once header guard
  • Add missing #include <string>
  • Remove const from return types and add noexcept

TypeParser.cpp:

  • Remove unused includes: boost/algorithm/string.hpp and iostream
  • Fix include ordering (self-header first)
  • Use starts_with() instead of find() == 0 (modernize-use-starts-ends-with)

TypeParser.h:

  • Add missing #include <string> and #include <unordered_map>

PrestoTaskId.h:

  • Add missing #include <cstdint>, #include <vector>
  • Fix include ordering (standard, then third-party, then project)

PrestoToVeloxQueryPlan.cpp:

  • Fix unnecessary copies: use const auto& for statisticsOutputVariables and nodeSpecOrdering
== NO RELEASE NOTE ==

Summary by Sourcery

Resolve static analysis and lint warnings in the presto_cpp types module and associated tests.

Enhancements:

  • Tighten includes, header guards, and noexcept usage in TestUtils utilities and TypeParser interfaces to satisfy modern C++ and linting requirements.
  • Adjust include ordering and add missing standard library headers in type-related components, including PrestoTaskId and TypeParser, for clearer dependencies and portability.
  • Reduce unnecessary copying in PrestoToVeloxQueryPlan by binding to const references for existing aggregation and ordering structures.

Tests:

  • Update TestUtils test helpers to use more precise includes, noexcept declarations, and simplified filesystem string handling while removing unused constructs.

@amitkdutta amitkdutta requested review from a team as code owners February 24, 2026 01:26
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Feb 24, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 24, 2026

Reviewer's Guide

This PR resolves CLANGTIDY and INFERMINICPP lint warnings in the Presto native types module by tightening includes, modernizing string and filesystem usage, fixing function signatures (removing meaningless const and adding noexcept), and avoiding unnecessary copies in query plan conversion code.

Class diagram for updated TypeParser and query plan converter usage

classDiagram
class TypeParser {
  +parse(text string) velox_TypePtr
}

class SystemConfig {
  +instance() SystemConfigPtr
  +charNToVarcharImplicitCast() bool
}

class VeloxQueryPlanConverterBase {
  +generateOutputVariables(statisticsAggregation StatisticsAggregationPtr, outputVariables vector_Variable) vector_Variable
  +toSortFieldsAndOrders(orderingScheme OrderingSchemePtr) void
}

class StatisticsAggregation {
  +outputVariables vector_Variable
  +groupingVariables vector_Variable
}

class OrderingScheme {
  +orderBy vector_VariableSortOrderPair
}

class vector_Variable
class vector_VariableSortOrderPair

TypeParser --> SystemConfig : uses
VeloxQueryPlanConverterBase --> StatisticsAggregation : reads_by_const_reference
VeloxQueryPlanConverterBase --> OrderingScheme : reads_by_const_reference
StatisticsAggregation --> vector_Variable : contains
OrderingScheme --> vector_VariableSortOrderPair : contains
Loading

File-Level Changes

Change Details Files
Clean up TestUtils utilities to satisfy lint rules and modern C++ practices.
  • Replace broad Boost string and filesystem includes with specific headers and add missing include.
  • Remove unused using-directive and meaningless const qualifiers on functions returning std::string by value.
  • Change boost::filesystem::current_path() usage from .c_str() to .string() and add noexcept to utility function declarations and definitions.
presto-native-execution/presto_cpp/main/types/tests/TestUtils.cpp
presto-native-execution/presto_cpp/main/types/tests/TestUtils.h
Fix missing or misordered includes in type- and task-related headers and implementation files.
  • Add #pragma once and missing standard library includes in TestUtils.h and TypeParser.h.
  • Introduce explicit and includes in PrestoTaskId.h and reorder includes to follow standard, third-party, then project conventions.
  • Reorder includes in TypeParser.cpp so the self-header comes first and group other project headers afterward.
presto-native-execution/presto_cpp/main/types/tests/TestUtils.h
presto-native-execution/presto_cpp/main/types/TypeParser.h
presto-native-execution/presto_cpp/main/types/PrestoTaskId.h
presto-native-execution/presto_cpp/main/types/TypeParser.cpp
Modernize string handling and eliminate unnecessary copies in parsing and query-plan code.
  • Use std::string::starts_with instead of text.find(...) == 0 when checking char/CHAR prefixes in TypeParser::parse.
  • Bind statisticsAggregation->outputVariables and orderingScheme->orderBy as const references instead of copying vectors before iteration.
presto-native-execution/presto_cpp/main/types/TypeParser.cpp
presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The newly added noexcept qualifiers on getDataPath and applyClionDirFix look risky since these functions call APIs like boost::filesystem::current_path() and perform string allocations/concatenations that can throw; consider dropping noexcept or tightening the implementations to guarantee they truly cannot throw.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The newly added `noexcept` qualifiers on `getDataPath` and `applyClionDirFix` look risky since these functions call APIs like `boost::filesystem::current_path()` and perform string allocations/concatenations that can throw; consider dropping `noexcept` or tightening the implementations to guarantee they truly cannot throw.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

amitkdutta added a commit to amitkdutta/presto that referenced this pull request Feb 24, 2026
…b#27194)

Summary:

Fix CLANGTIDY and INFERMINICPP lint warnings across the types/ directory:

TestUtils.cpp:
- Replace broad boost includes (string.hpp, filesystem.hpp) with specific headers
- Add missing #include <string>
- Remove unused `using namespace std;`
- Remove meaningless `const` qualifier on return-by-value types
- Replace redundant `.c_str()` with `.string()` on boost::filesystem::current_path()
- Add `noexcept` to function declarations and definitions

TestUtils.h:
- Add `#pragma once` header guard
- Add missing `#include <string>`
- Remove `const` from return types and add `noexcept`

TypeParser.cpp:
- Remove unused includes: `boost/algorithm/string.hpp` and `iostream`
- Fix include ordering (self-header first)
- Use `starts_with()` instead of `find() == 0` (modernize-use-starts-ends-with)

TypeParser.h:
- Add missing `#include <string>` and `#include <unordered_map>`

PrestoTaskId.h:
- Add missing `#include <cstdint>`, `#include <vector>`
- Fix include ordering (standard, then third-party, then project)

PrestoToVeloxQueryPlan.cpp:
- Fix unnecessary copies: use `const auto&` for `statisticsOutputVariables` and `nodeSpecOrdering`

Differential Revision: D94156498
amitkdutta added a commit to amitkdutta/presto that referenced this pull request Feb 24, 2026
…b#27194)

Summary:

Fix CLANGTIDY and INFERMINICPP lint warnings across the types/ directory:

TestUtils.cpp:
- Replace broad boost includes (string.hpp, filesystem.hpp) with specific headers
- Add missing #include <string>
- Remove unused `using namespace std;`
- Remove meaningless `const` qualifier on return-by-value types
- Replace redundant `.c_str()` with `.string()` on boost::filesystem::current_path()
- Add `noexcept` to function declarations and definitions

TestUtils.h:
- Add `#pragma once` header guard
- Add missing `#include <string>`
- Remove `const` from return types and add `noexcept`

TypeParser.cpp:
- Remove unused includes: `boost/algorithm/string.hpp` and `iostream`
- Fix include ordering (self-header first)
- Use `starts_with()` instead of `find() == 0` (modernize-use-starts-ends-with)

TypeParser.h:
- Add missing `#include <string>` and `#include <unordered_map>`

PrestoTaskId.h:
- Add missing `#include <cstdint>`, `#include <vector>`
- Fix include ordering (standard, then third-party, then project)

PrestoToVeloxQueryPlan.cpp:
- Fix unnecessary copies: use `const auto&` for `statisticsOutputVariables` and `nodeSpecOrdering`

Differential Revision: D94156498
Summary:
Fix CLANGTIDY and INFERMINICPP lint warnings across the types/ directory:

TestUtils.cpp:
- Replace broad boost includes (string.hpp, filesystem.hpp) with specific headers
- Add missing #include <string>
- Remove unused `using namespace std;`
- Remove meaningless `const` qualifier on return-by-value types
- Replace redundant `.c_str()` with `.string()` on boost::filesystem::current_path()
- Add `noexcept` to function declarations and definitions

TestUtils.h:
- Add `#pragma once` header guard
- Add missing `#include <string>`
- Remove `const` from return types and add `noexcept`

TypeParser.cpp:
- Remove unused includes: `boost/algorithm/string.hpp` and `iostream`
- Fix include ordering (self-header first)
- Use `starts_with()` instead of `find() == 0` (modernize-use-starts-ends-with)

TypeParser.h:
- Add missing `#include <string>` and `#include <unordered_map>`

PrestoTaskId.h:
- Add missing `#include <cstdint>`, `#include <vector>`
- Fix include ordering (standard, then third-party, then project)

PrestoToVeloxQueryPlan.cpp:
- Fix unnecessary copies: use `const auto&` for `statisticsOutputVariables` and `nodeSpecOrdering`

Differential Revision: D94156498
@amitkdutta amitkdutta merged commit a626728 into prestodb:master Feb 24, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants