Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::StatementVerifier Class Reference
Inheritance diagram for duckdb::StatementVerifier:
Collaboration diagram for duckdb::StatementVerifier:

Public Member Functions

 StatementVerifier (VerificationType type, string name, unique_ptr< SQLStatement > statement_p, optional_ptr< case_insensitive_map_t< BoundParameterData > > values)
 StatementVerifier (unique_ptr< SQLStatement > statement_p, optional_ptr< case_insensitive_map_t< BoundParameterData > > values)
void CheckExpressions (const StatementVerifier &other) const
 Check whether expressions in this verifier and the other verifier match.
void CheckExpressions () const
 Check whether expressions within this verifier match.
virtual bool Run (ClientContext &context, const string &query, const std::function< unique_ptr< QueryResult >(const string &, unique_ptr< SQLStatement >, optional_ptr< case_insensitive_map_t< BoundParameterData > >)> &run)
 Run the select statement and store the result.
string CompareResults (const StatementVerifier &other)
 Compare this verifier's results with another verifier.
virtual bool RequireEquality () const
virtual bool DisableOptimizer () const
virtual bool DisableOperatorCaching () const
virtual bool ForceExternal () const
virtual bool ForceFetchRow () const

Static Public Member Functions

static unique_ptr< StatementVerifier > Create (VerificationType type, const SQLStatement &statement_p, optional_ptr< case_insensitive_map_t< BoundParameterData > > values)

Public Attributes

const VerificationType type
const string name
unique_ptr< SQLStatement > statement
optional_ptr< SelectStatement > select_statement
optional_ptr< case_insensitive_map_t< BoundParameterData > > parameters
const vector< unique_ptr< ParsedExpression > > & select_list
unique_ptr< MaterializedQueryResult > materialized_result

Private Member Functions

const vector< unique_ptr< ParsedExpression > > & GetSelectList (QueryNode &node)

Private Attributes

const vector< unique_ptr< ParsedExpression > > empty_select_list = {}

Constructor & Destructor Documentation

◆ StatementVerifier() [1/2]

duckdb::StatementVerifier::StatementVerifier ( VerificationType type,
string name,
unique_ptr< SQLStatement > statement_p,
optional_ptr< case_insensitive_map_t< BoundParameterData > > values )
448745 : type(type), name(std::move(name)), statement(std::move(statement_p)),
448746 select_statement(statement->type == StatementType::SELECT_STATEMENT ? &statement->Cast<SelectStatement>()
448747 : nullptr),
448748 parameters(parameters_p),
448749 select_list(select_statement ? GetSelectList(*select_statement->node) : empty_select_list) {
448750}

◆ StatementVerifier() [2/2]

duckdb::StatementVerifier::StatementVerifier ( unique_ptr< SQLStatement > statement_p,
optional_ptr< case_insensitive_map_t< BoundParameterData > > values )
explicit
448754 : StatementVerifier(VerificationType::ORIGINAL, "Original", std::move(statement_p), parameters) {
448755}

◆ ~StatementVerifier()

duckdb::StatementVerifier::~StatementVerifier ( )
virtualnoexcept
448757 {
448758}

Member Function Documentation

◆ Create()

unique_ptr< StatementVerifier > duckdb::StatementVerifier::Create ( VerificationType type,
const SQLStatement & statement_p,
optional_ptr< case_insensitive_map_t< BoundParameterData > > values )
static
448762 {
448763 switch (type) {
448764 case VerificationType::COPIED:
448765 return CopiedStatementVerifier::Create(statement_p, parameters);
448766 case VerificationType::DESERIALIZED:
448767 return DeserializedStatementVerifier::Create(statement_p, parameters);
448768 case VerificationType::PARSED:
448769 return ParsedStatementVerifier::Create(statement_p, parameters);
448770 case VerificationType::UNOPTIMIZED:
448771 return UnoptimizedStatementVerifier::Create(statement_p, parameters);
448772 case VerificationType::NO_OPERATOR_CACHING:
448773 return NoOperatorCachingVerifier::Create(statement_p, parameters);
448774 case VerificationType::PREPARED:
448775 return PreparedStatementVerifier::Create(statement_p, parameters);
448776 case VerificationType::EXTERNAL:
448777 return ExternalStatementVerifier::Create(statement_p, parameters);
448778 case VerificationType::EXPLAIN:
448779 return ExplainStatementVerifier::Create(statement_p, parameters);
448780 case VerificationType::FETCH_ROW_AS_SCAN:
448781 return FetchRowVerifier::Create(statement_p, parameters);
448782 case VerificationType::INVALID:
448783 default:
448784 throw InternalException("Invalid statement verification type!");
448785 }
448786}

◆ CheckExpressions() [1/2]

void duckdb::StatementVerifier::CheckExpressions ( const StatementVerifier & other) const

Check whether expressions in this verifier and the other verifier match.

448788 {
448789 // Only the original statement should check other statements
448790 D_ASSERT(type == VerificationType::ORIGINAL);
448791
448792 // Check equality
448793 if (other.RequireEquality() && select_statement) {
448794 D_ASSERT(select_statement->Equals(*other.select_statement));
448795 }
448796
448797#ifdef DEBUG
448798 // Now perform checking on the expressions
448799 D_ASSERT(select_list.size() == other.select_list.size());
448800 const auto expr_count = select_list.size();
448801 if (other.RequireEquality()) {
448802 for (idx_t i = 0; i < expr_count; i++) {
448803 // Run the ToString, to verify that it doesn't crash
448804 select_list[i]->ToString();
448805
448806 if (select_list[i]->HasSubquery()) {
448807 continue;
448808 }
448809
448810 // Check that the expressions are equivalent
448811 D_ASSERT(select_list[i]->Equals(*other.select_list[i]));
448812 // Check that the hashes are equivalent too
448813 D_ASSERT(select_list[i]->Hash() == other.select_list[i]->Hash());
448814
448815 other.select_list[i]->Verify();
448816 }
448817 }
448818#endif
448819}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ CheckExpressions() [2/2]

void duckdb::StatementVerifier::CheckExpressions ( ) const

Check whether expressions within this verifier match.

448821 {
448822#ifdef DEBUG
448823 D_ASSERT(type == VerificationType::ORIGINAL);
448824 // Perform additional checking within the expressions
448825 const auto expr_count = select_list.size();
448826 for (idx_t outer_idx = 0; outer_idx < expr_count; outer_idx++) {
448827 auto hash = select_list[outer_idx]->Hash();
448828 for (idx_t inner_idx = 0; inner_idx < expr_count; inner_idx++) {
448829 auto hash2 = select_list[inner_idx]->Hash();
448830 if (hash != hash2) {
448831 // if the hashes are not equivalent, the expressions should not be equivalent
448832 D_ASSERT(!select_list[outer_idx]->Equals(*select_list[inner_idx]));
448833 }
448834 }
448835 }
448836#endif
448837}

◆ Run()

bool duckdb::StatementVerifier::Run ( ClientContext & context,
const string & query,
const std::function< unique_ptr< QueryResult >(const string &, unique_ptr< SQLStatement >, optional_ptr< case_insensitive_map_t< BoundParameterData > >)> & run )
virtual

Run the select statement and store the result.

Reimplemented in duckdb::PreparedStatementVerifier.

448842 {
448843 bool failed = false;
448844
448845 context.interrupted = false;
448846 context.config.enable_optimizer = !DisableOptimizer();
448847 context.config.enable_caching_operators = !DisableOperatorCaching();
448848 context.config.force_external = ForceExternal();
448849 context.config.force_fetch_row = ForceFetchRow();
448850 try {
448851 auto result = run(query, std::move(statement), parameters);
448852 if (result->HasError()) {
448853 failed = true;
448854 }
448855 materialized_result = unique_ptr_cast<QueryResult, MaterializedQueryResult>(std::move(result));
448856 } catch (std::exception &ex) {
448857 failed = true;
448858 materialized_result = make_uniq<MaterializedQueryResult>(ErrorData(ex));
448859 }
448860 context.interrupted = false;
448861
448862 return failed;
448863}

◆ CompareResults()

string duckdb::StatementVerifier::CompareResults ( const StatementVerifier & other)

Compare this verifier's results with another verifier.

448865 {
448866 D_ASSERT(type == VerificationType::ORIGINAL);
448867 string error;
448868 if (materialized_result->HasError() != other.materialized_result->HasError()) { // LCOV_EXCL_START
448869 string result = other.name + " statement differs from original result!\n";
448870 result += "Original Result:\n" + materialized_result->ToString();
448871 result += other.name + ":\n" + other.materialized_result->ToString();
448872 return result;
448873 } // LCOV_EXCL_STOP
448874 if (materialized_result->HasError()) {
448875 return "";
448876 }
448877 if (!ColumnDataCollection::ResultEquals(materialized_result->Collection(), other.materialized_result->Collection(),
448878 error)) { // LCOV_EXCL_START
448879 string result = other.name + " statement differs from original result!\n";
448880 result += "Original Result:\n" + materialized_result->ToString();
448881 result += other.name + ":\n" + other.materialized_result->ToString();
448882 result += "\n\n---------------------------------\n" + error;
448883 return result;
448884 } // LCOV_EXCL_STOP
448885
448886 return "";
448887}
static bool ResultEquals(const ColumnDataCollection &left, const ColumnDataCollection &right, string &error_message, bool ordered=false)
Definition duckdb.cpp:115741
Here is the call graph for this function:

◆ RequireEquality()

virtual bool duckdb::StatementVerifier::RequireEquality ( ) const
inlinevirtual
61911 {
61912 return true;
61913 }

◆ DisableOptimizer()

virtual bool duckdb::StatementVerifier::DisableOptimizer ( ) const
inlinevirtual
61915 {
61916 return false;
61917 }

◆ DisableOperatorCaching()

virtual bool duckdb::StatementVerifier::DisableOperatorCaching ( ) const
inlinevirtual
61919 {
61920 return false;
61921 }

◆ ForceExternal()

virtual bool duckdb::StatementVerifier::ForceExternal ( ) const
inlinevirtual
61923 {
61924 return false;
61925 }

◆ ForceFetchRow()

virtual bool duckdb::StatementVerifier::ForceFetchRow ( ) const
inlinevirtual
61927 {
61928 return false;
61929 }

◆ GetSelectList()

const vector< unique_ptr< ParsedExpression > > & duckdb::StatementVerifier::GetSelectList ( QueryNode & node)
private
448732 {
448733 switch (node.type) {
448734 case QueryNodeType::SELECT_NODE:
448735 return node.Cast<SelectNode>().select_list;
448736 case QueryNodeType::SET_OPERATION_NODE:
448737 return GetSelectList(*node.Cast<SetOperationNode>().children[0]);
448738 default:
448739 return empty_select_list;
448740 }
448741}

Member Data Documentation

◆ empty_select_list

const vector<unique_ptr<ParsedExpression> > duckdb::StatementVerifier::empty_select_list = {}
private
61941{};

The documentation for this class was generated from the following file: