From 6758f3f645fd6677fcf9339498f42f4f59a4b5c4 Mon Sep 17 00:00:00 2001 From: David Sisson Date: Mon, 29 Jan 2024 19:28:12 -0800 Subject: [PATCH] Ran clang tidy. --- src/substrait/textplan/SymbolTable.h | 4 +++- src/substrait/textplan/SymbolTablePrinter.h | 2 +- .../converter/InitialPlanProtoVisitor.cpp | 12 ++++-------- .../textplan/converter/PipelineVisitor.cpp | 15 ++++++--------- .../textplan/converter/PipelineVisitor.h | 2 +- src/substrait/textplan/converter/Tool.cpp | 4 ++-- .../textplan/parser/SubstraitPlanVisitor.cpp | 3 +-- src/substrait/textplan/tests/RoundtripTest.cpp | 5 ++--- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/substrait/textplan/SymbolTable.h b/src/substrait/textplan/SymbolTable.h index 67acb78a..0347e82a 100644 --- a/src/substrait/textplan/SymbolTable.h +++ b/src/substrait/textplan/SymbolTable.h @@ -174,7 +174,9 @@ class SymbolTable { std::unordered_set types) const; [[nodiscard]] const SymbolInfo* lookupSymbolByParentQueryAndType( - const Location& location, int index, SymbolType type) const; + const Location& location, + int index, + SymbolType type) const; [[nodiscard]] const SymbolInfo& nthSymbolByType(uint32_t n, SymbolType type) const; diff --git a/src/substrait/textplan/SymbolTablePrinter.h b/src/substrait/textplan/SymbolTablePrinter.h index f23e3a4d..e4020a1f 100644 --- a/src/substrait/textplan/SymbolTablePrinter.h +++ b/src/substrait/textplan/SymbolTablePrinter.h @@ -4,8 +4,8 @@ #include -#include "SymbolTable.h" #include "SubstraitErrorListener.h" +#include "SymbolTable.h" namespace substrait::proto { class Expression; diff --git a/src/substrait/textplan/converter/InitialPlanProtoVisitor.cpp b/src/substrait/textplan/converter/InitialPlanProtoVisitor.cpp index 8f11c5c5..2b783996 100644 --- a/src/substrait/textplan/converter/InitialPlanProtoVisitor.cpp +++ b/src/substrait/textplan/converter/InitialPlanProtoVisitor.cpp @@ -149,20 +149,16 @@ std::any InitialPlanProtoVisitor::visitExpression( const ::substrait::proto::Rel* subqueryRelation; switch (expression.subquery().subquery_type_case()) { case ::substrait::proto::Expression_Subquery::kScalar: - subqueryRelation = - &expression.subquery().scalar().input(); + subqueryRelation = &expression.subquery().scalar().input(); break; case ::substrait::proto::Expression_Subquery::kInPredicate: - subqueryRelation = - &expression.subquery().in_predicate().haystack(); + subqueryRelation = &expression.subquery().in_predicate().haystack(); break; case ::substrait::proto::Expression_Subquery::kSetPredicate: - subqueryRelation = - &expression.subquery().set_predicate().tuples(); + subqueryRelation = &expression.subquery().set_predicate().tuples(); break; case ::substrait::proto::Expression_Subquery::kSetComparison: - subqueryRelation = - &expression.subquery().set_comparison().right(); + subqueryRelation = &expression.subquery().set_comparison().right(); break; case ::substrait::proto::Expression_Subquery::SUBQUERY_TYPE_NOT_SET: errorListener_->addError("Subquery type not set."); diff --git a/src/substrait/textplan/converter/PipelineVisitor.cpp b/src/substrait/textplan/converter/PipelineVisitor.cpp index 70a6c63a..8ffd1d6e 100644 --- a/src/substrait/textplan/converter/PipelineVisitor.cpp +++ b/src/substrait/textplan/converter/PipelineVisitor.cpp @@ -18,20 +18,16 @@ std::any PipelineVisitor::visitExpression( const ::substrait::proto::Rel* subqueryRelation; switch (expression.subquery().subquery_type_case()) { case ::substrait::proto::Expression_Subquery::kScalar: - subqueryRelation = - &expression.subquery().scalar().input(); + subqueryRelation = &expression.subquery().scalar().input(); break; case ::substrait::proto::Expression_Subquery::kInPredicate: - subqueryRelation = - &expression.subquery().in_predicate().haystack(); + subqueryRelation = &expression.subquery().in_predicate().haystack(); break; case ::substrait::proto::Expression_Subquery::kSetPredicate: - subqueryRelation = - &expression.subquery().set_predicate().tuples(); + subqueryRelation = &expression.subquery().set_predicate().tuples(); break; case ::substrait::proto::Expression_Subquery::kSetComparison: - subqueryRelation = - &expression.subquery().set_comparison().right(); + subqueryRelation = &expression.subquery().set_comparison().right(); break; case ::substrait::proto::Expression_Subquery::SUBQUERY_TYPE_NOT_SET: // No need to raise as this would have been exposed earlier. @@ -44,7 +40,8 @@ std::any PipelineVisitor::visitExpression( auto subquerySymbol = symbolTable_->lookupSymbolByLocationAndType( PROTO_LOCATION(*subqueryRelation), SymbolType::kRelation); - auto currentRelationData = ANY_CAST(std::shared_ptr, currentRelationScope_->blob); + auto currentRelationData = + ANY_CAST(std::shared_ptr, currentRelationScope_->blob); currentRelationData->subQueryPipelines.push_back(subquerySymbol); // Populate the start of the pipeline for easy later access. diff --git a/src/substrait/textplan/converter/PipelineVisitor.h b/src/substrait/textplan/converter/PipelineVisitor.h index 5fe4a810..6e4da2fe 100644 --- a/src/substrait/textplan/converter/PipelineVisitor.h +++ b/src/substrait/textplan/converter/PipelineVisitor.h @@ -20,7 +20,7 @@ class PipelineVisitor : public BasePlanProtoVisitor { private: std::any visitExpression( - const ::substrait::proto::Expression& expression) override; + const ::substrait::proto::Expression& expression) override; std::any visitRelation(const ::substrait::proto::Rel& relation) override; diff --git a/src/substrait/textplan/converter/Tool.cpp b/src/substrait/textplan/converter/Tool.cpp index 8c22bb24..49dc43d3 100644 --- a/src/substrait/textplan/converter/Tool.cpp +++ b/src/substrait/textplan/converter/Tool.cpp @@ -23,8 +23,8 @@ void convertPlanToText(const char* filename) { auto result = parseBinaryPlan(*planOrError); SubstraitErrorListener errorListener; - auto textResult = SymbolTablePrinter::outputToText(result.getSymbolTable(), - &errorListener); + auto textResult = + SymbolTablePrinter::outputToText(result.getSymbolTable(), &errorListener); result.addErrors(errorListener.getErrorMessages()); auto errors = result.getAllErrors(); if (!errors.empty()) { diff --git a/src/substrait/textplan/parser/SubstraitPlanVisitor.cpp b/src/substrait/textplan/parser/SubstraitPlanVisitor.cpp index 67fcc49f..041c563a 100644 --- a/src/substrait/textplan/parser/SubstraitPlanVisitor.cpp +++ b/src/substrait/textplan/parser/SubstraitPlanVisitor.cpp @@ -314,8 +314,7 @@ std::any SubstraitPlanVisitor::visitRelation_type( {"aggregate", RelationType::kAggregate}, {"sort", RelationType::kSort}, {"filter", RelationType::kFilter}, - {"set", RelationType::kSet} - }; + {"set", RelationType::kSet}}; auto it = relationTypeMap.find(id); if (it != relationTypeMap.end()) { return it->second; diff --git a/src/substrait/textplan/tests/RoundtripTest.cpp b/src/substrait/textplan/tests/RoundtripTest.cpp index 89068d28..2ccc7176 100644 --- a/src/substrait/textplan/tests/RoundtripTest.cpp +++ b/src/substrait/textplan/tests/RoundtripTest.cpp @@ -82,9 +82,8 @@ TEST_P(RoundTripBinaryToTextFixture, RoundTrip) { auto textSymbols = textResult.getSymbolTable().getSymbols(); SubstraitErrorListener errorListener; - std::string outputText = - SymbolTablePrinter::outputToText(textResult.getSymbolTable(), - &errorListener); + std::string outputText = SymbolTablePrinter::outputToText( + textResult.getSymbolTable(), &errorListener); textResult.addErrors(errorListener.getErrorMessages()); ASSERT_THAT(textResult, ParsesOk())