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::QueryResult Class Referenceabstract

#include <duckdb.hpp>

Inheritance diagram for duckdb::QueryResult:
Collaboration diagram for duckdb::QueryResult:

Classes

class  QueryResultIterator
 The row-based query result iterator. Invoking the. More...
 
class  QueryResultRow
 

Public Types

using iterator = QueryResultIterator
 

Public Member Functions

DUCKDB_API QueryResult (QueryResultType type, StatementType statement_type, StatementProperties properties, vector< LogicalType > types, vector< string > names, ClientProperties client_properties)
 Creates a successful query result with the specified names and types.
 
DUCKDB_API QueryResult (QueryResultType type, ErrorData error)
 Creates an unsuccessful query result with error condition.
 
template<class TARGET >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 
DUCKDB_API const string & ColumnName (idx_t index) const
 Returns the name of the column for the given index.
 
DUCKDB_API unique_ptr< DataChunkFetch ()
 
DUCKDB_API unique_ptr< DataChunkFetchRaw ()
 
virtual DUCKDB_API string ToString ()=0
 Converts the QueryResult to a string.
 
virtual DUCKDB_API string ToBox (ClientContext &context, const BoxRendererConfig &config)
 Converts the QueryResult to a box-rendered string.
 
DUCKDB_API void Print ()
 Prints the QueryResult to the console.
 
DUCKDB_API bool Equals (QueryResult &other)
 
bool TryFetch (unique_ptr< DataChunk > &result, ErrorData &error)
 
iterator begin ()
 
iterator end ()
 
- Public Member Functions inherited from duckdb::BaseQueryResult
DUCKDB_API BaseQueryResult (QueryResultType type, StatementType statement_type, StatementProperties properties, vector< LogicalType > types, vector< string > names)
 Creates a successful query result with the specified names and types.
 
DUCKDB_API BaseQueryResult (QueryResultType type, ErrorData error)
 Creates an unsuccessful query result with error condition.
 
DUCKDB_API void ThrowError (const string &prepended_message="") const
 
DUCKDB_API void SetError (ErrorData error)
 
DUCKDB_API bool HasError () const
 
DUCKDB_API const ExceptionType & GetErrorType () const
 
DUCKDB_API const std::string & GetError () const
 
DUCKDB_API ErrorDataGetErrorObject ()
 
DUCKDB_API idx_t ColumnCount ()
 

Static Public Member Functions

static void DeduplicateColumns (vector< string > &names)
 Deduplicate column names for interop with external libraries.
 

Public Attributes

ClientProperties client_properties
 Properties from the client context.
 
unique_ptr< QueryResultnext
 The next result (if any)
 
- Public Attributes inherited from duckdb::BaseQueryResult
QueryResultType type
 The type of the result (MATERIALIZED or STREAMING)
 
StatementType statement_type
 The type of the statement that created this result.
 
StatementProperties properties
 Properties of the statement.
 
vector< LogicalTypetypes
 The SQL types of the result.
 
vector< string > names
 The names of the result.
 

Protected Member Functions

virtual DUCKDB_API unique_ptr< DataChunkFetchInternal ()=0
 
DUCKDB_API string HeaderToString ()
 

Private Member Functions

 QueryResult (const QueryResult &)=delete
 

Additional Inherited Members

- Protected Attributes inherited from duckdb::BaseQueryResult
bool success
 Whether or not execution was successful.
 
ErrorData error
 The error (in case execution was not successful)
 

Detailed Description

The QueryResult object holds the result of a query. It can either be a MaterializedQueryResult, in which case the result contains the entire result set, or a StreamQueryResult in which case the Fetch method can be called to incrementally fetch data from the database.

Member Function Documentation

◆ Cast() [1/2]

template<class TARGET >
TARGET & duckdb::QueryResult::Cast ( )
inline
19561 {
19562 if (type != TARGET::TYPE) {
19563 throw InternalException("Failed to cast query result to type - query result type mismatch");
19564 }
19565 return reinterpret_cast<TARGET &>(*this);
19566 }
QueryResultType type
The type of the result (MATERIALIZED or STREAMING)
Definition duckdb.hpp:19516

◆ Cast() [2/2]

template<class TARGET >
const TARGET & duckdb::QueryResult::Cast ( ) const
inline
19569 {
19570 if (type != TARGET::TYPE) {
19571 throw InternalException("Failed to cast query result to type - query result type mismatch");
19572 }
19573 return reinterpret_cast<const TARGET &>(*this);
19574 }

◆ Fetch()

DUCKDB_API unique_ptr< DataChunk > duckdb::QueryResult::Fetch ( )

Fetches a DataChunk of normalized (flat) vectors from the query result. Returns nullptr if there are no more results to fetch.

◆ FetchRaw()

DUCKDB_API unique_ptr< DataChunk > duckdb::QueryResult::FetchRaw ( )

Fetches a DataChunk from the query result. The vectors are not normalized and hence any vector types can be returned.

◆ ToString()

virtual DUCKDB_API string duckdb::QueryResult::ToString ( )
pure virtual

◆ ToBox()

virtual DUCKDB_API string duckdb::QueryResult::ToBox ( ClientContext context,
const BoxRendererConfig config 
)
virtual

Converts the QueryResult to a box-rendered string.

Reimplemented in duckdb::MaterializedQueryResult.

◆ Equals()

DUCKDB_API bool duckdb::QueryResult::Equals ( QueryResult other)

Returns true if the two results are identical; false otherwise. Note that this method is destructive; it calls Fetch() until both results are exhausted. The data in the results will be lost.

◆ TryFetch()

bool duckdb::QueryResult::TryFetch ( unique_ptr< DataChunk > &  result,
ErrorData error 
)
inline
19599 {
19600 try {
19601 result = Fetch();
19602 return success;
19603 } catch (std::exception &ex) {
19604 error = ErrorData(ex);
19605 return false;
19606 } catch (...) {
19607 error = ErrorData("Unknown error in Fetch");
19608 return false;
19609 }
19610 }
ErrorData error
The error (in case execution was not successful)
Definition duckdb.hpp:19539
bool success
Whether or not execution was successful.
Definition duckdb.hpp:19537
DUCKDB_API unique_ptr< DataChunk > Fetch()

◆ begin()

iterator duckdb::QueryResult::begin ( )
inline
19698 { // NOLINT: match stl API
19699 return QueryResultIterator(this);
19700 }

◆ end()

iterator duckdb::QueryResult::end ( )
inline
19701 { // NOLINT: match stl API
19702 return QueryResultIterator(nullptr);
19703 }

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