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::Connection Class Reference

#include <duckdb.hpp>

Collaboration diagram for duckdb::Connection:

Public Member Functions

DUCKDB_API Connection (DuckDB &database)
 
DUCKDB_API Connection (DatabaseInstance &database)
 
 Connection (const Connection &other)=delete
 
Connectionoperator= (const Connection &)=delete
 
DUCKDB_API Connection (Connection &&other) noexcept
 enable move constructors
 
DUCKDB_API Connectionoperator= (Connection &&) noexcept
 
DUCKDB_API string GetProfilingInformation (ProfilerPrintFormat format=ProfilerPrintFormat::QUERY_TREE)
 Returns query profiling information for the current query.
 
DUCKDB_API optional_ptr< ProfilingNodeGetProfilingTree ()
 Returns the first node of the query profiling tree.
 
DUCKDB_API void Interrupt ()
 Interrupt execution of the current query.
 
DUCKDB_API double GetQueryProgress ()
 Get query progress of current query.
 
DUCKDB_API void EnableProfiling ()
 Enable query profiling.
 
DUCKDB_API void DisableProfiling ()
 Disable query profiling.
 
DUCKDB_API void EnableQueryVerification ()
 Enable aggressive verification/testing of queries, should only be used in testing.
 
DUCKDB_API void DisableQueryVerification ()
 
DUCKDB_API void ForceParallelism ()
 Force parallel execution, even for smaller tables. Should only be used in testing.
 
DUCKDB_API unique_ptr< QueryResultSendQuery (const string &query, QueryParameters query_parameters=QueryResultOutputType::ALLOW_STREAMING)
 
DUCKDB_API unique_ptr< QueryResultSendQuery (unique_ptr< SQLStatement > statement, QueryParameters query_parameters=QueryResultOutputType::ALLOW_STREAMING)
 
DUCKDB_API unique_ptr< MaterializedQueryResultQuery (const string &query)
 
DUCKDB_API unique_ptr< MaterializedQueryResultQuery (unique_ptr< SQLStatement > statement, QueryResultMemoryType memory_type=QueryResultMemoryType::IN_MEMORY)
 
template<typename... ARGS>
unique_ptr< QueryResultQuery (const string &query, ARGS... args)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, QueryParameters query_parameters=QueryResultOutputType::FORCE_MATERIALIZED)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (unique_ptr< SQLStatement > statement, QueryParameters query_parameters=QueryResultOutputType::FORCE_MATERIALIZED)
 Issues a query to the database and returns a Pending Query Result.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (unique_ptr< SQLStatement > statement, case_insensitive_map_t< BoundParameterData > &named_values, QueryParameters query_parameters=QueryResultOutputType::FORCE_MATERIALIZED)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, case_insensitive_map_t< BoundParameterData > &named_values, QueryParameters query_parameters=QueryResultOutputType::FORCE_MATERIALIZED)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, vector< Value > &values, QueryParameters query_parameters=QueryResultOutputType::FORCE_MATERIALIZED)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, PendingQueryParameters parameters)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (unique_ptr< SQLStatement > statement, vector< Value > &values, QueryParameters query_parameters=QueryResultOutputType::FORCE_MATERIALIZED)
 
DUCKDB_API unique_ptr< PreparedStatementPrepare (const string &query)
 Prepare the specified query, returning a prepared statement object.
 
DUCKDB_API unique_ptr< PreparedStatementPrepare (unique_ptr< SQLStatement > statement)
 Prepare the specified statement, returning a prepared statement object.
 
DUCKDB_API unique_ptr< TableDescriptionTableInfo (const string &database_name, const string &schema_name, const string &table_name)
 Get the table info of a specific table, or nullptr if it cannot be found.
 
DUCKDB_API unique_ptr< TableDescriptionTableInfo (const string &schema_name, const string &table_name)
 Get the table info of a specific table, or nullptr if it cannot be found. Uses INVALID_CATALOG.
 
DUCKDB_API unique_ptr< TableDescriptionTableInfo (const string &table_name)
 
DUCKDB_API vector< unique_ptr< SQLStatement > > ExtractStatements (const string &query)
 Extract a set of SQL statements from a specific query.
 
DUCKDB_API unique_ptr< LogicalOperatorExtractPlan (const string &query)
 Extract the logical plan that corresponds to a query.
 
DUCKDB_API void Append (TableDescription &description, ColumnDataCollection &collection)
 Appends a ColumnDataCollection to the described table.
 
DUCKDB_API shared_ptr< RelationTable (const string &tname)
 Returns a relation that produces a table from this connection.
 
DUCKDB_API shared_ptr< RelationTable (const string &schema_name, const string &table_name)
 
DUCKDB_API shared_ptr< RelationTable (const string &catalog_name, const string &schema_name, const string &table_name)
 
DUCKDB_API shared_ptr< RelationView (const string &tname)
 Returns a relation that produces a view from this connection.
 
DUCKDB_API shared_ptr< RelationView (const string &schema_name, const string &table_name)
 
DUCKDB_API shared_ptr< RelationTableFunction (const string &tname)
 Returns a relation that calls a specified table function.
 
DUCKDB_API shared_ptr< RelationTableFunction (const string &tname, const vector< Value > &values, const named_parameter_map_t &named_parameters)
 
DUCKDB_API shared_ptr< RelationTableFunction (const string &tname, const vector< Value > &values)
 
DUCKDB_API shared_ptr< RelationValues (const vector< vector< Value > > &values)
 Returns a relation that produces values.
 
DUCKDB_API shared_ptr< RelationValues (vector< vector< unique_ptr< ParsedExpression > > > &&values)
 
DUCKDB_API shared_ptr< RelationValues (const vector< vector< Value > > &values, const vector< string > &column_names, const string &alias="values")
 
DUCKDB_API shared_ptr< RelationValues (const string &values)
 
DUCKDB_API shared_ptr< RelationValues (const string &values, const vector< string > &column_names, const string &alias="values")
 
DUCKDB_API shared_ptr< RelationReadCSV (const string &csv_file)
 Reads CSV file.
 
DUCKDB_API shared_ptr< RelationReadCSV (const vector< string > &csv_input, named_parameter_map_t &&options)
 
DUCKDB_API shared_ptr< RelationReadCSV (const string &csv_input, named_parameter_map_t &&options)
 
DUCKDB_API shared_ptr< RelationReadCSV (const string &csv_file, const vector< string > &columns)
 
DUCKDB_API shared_ptr< RelationReadParquet (const string &parquet_file, bool binary_as_string)
 Reads Parquet file.
 
DUCKDB_API shared_ptr< RelationRelationFromQuery (const string &query, const string &alias="queryrelation", const string &error="Expected a single SELECT statement")
 Returns a relation from a query.
 
DUCKDB_API shared_ptr< RelationRelationFromQuery (unique_ptr< SelectStatement > select_stmt, const string &alias="queryrelation", const string &query="")
 
DUCKDB_API void BeginTransaction ()
 
DUCKDB_API void Commit ()
 
DUCKDB_API void Rollback ()
 
DUCKDB_API void SetAutoCommit (bool auto_commit)
 
DUCKDB_API bool IsAutoCommit ()
 
DUCKDB_API bool HasActiveTransaction ()
 
DUCKDB_API unordered_set< string > GetTableNames (const string &query, const bool qualified=false)
 
template<typename TR , typename... ARGS>
void CreateScalarFunction (const string &name, TR(*udf_func)(ARGS...))
 
template<typename TR , typename... ARGS>
void CreateScalarFunction (const string &name, vector< LogicalType > args, LogicalType ret_type, TR(*udf_func)(ARGS...))
 
template<typename TR , typename... ARGS>
void CreateVectorizedFunction (const string &name, scalar_function_t udf_func, LogicalType varargs=LogicalType::INVALID)
 
void CreateVectorizedFunction (const string &name, vector< LogicalType > args, LogicalType ret_type, scalar_function_t udf_func, LogicalType varargs=LogicalType::INVALID)
 
template<typename UDF_OP , typename STATE , typename TR , typename TA >
void CreateAggregateFunction (const string &name)
 
template<typename UDF_OP , typename STATE , typename TR , typename TA , typename TB >
void CreateAggregateFunction (const string &name)
 
template<typename UDF_OP , typename STATE , typename TR , typename TA >
void CreateAggregateFunction (const string &name, LogicalType ret_type, LogicalType input_type_a)
 
template<typename UDF_OP , typename STATE , typename TR , typename TA , typename TB >
void CreateAggregateFunction (const string &name, LogicalType ret_type, LogicalType input_type_a, LogicalType input_type_b)
 
void CreateAggregateFunction (const string &name, const vector< LogicalType > &arguments, const LogicalType &return_type, aggregate_size_t state_size, aggregate_initialize_t initialize, aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize, aggregate_simple_update_t simple_update=nullptr, bind_aggregate_function_t bind=nullptr, aggregate_destructor_t destructor=nullptr)
 

Public Attributes

shared_ptr< ClientContextcontext
 

Protected Attributes

connection_t connection_id
 Identified used to uniquely identify connections to the database.
 

Private Member Functions

unique_ptr< QueryResultQueryParamsRecursive (const string &query, vector< Value > &values)
 
template<typename T , typename... ARGS>
unique_ptr< QueryResultQueryParamsRecursive (const string &query, vector< Value > &values, T value, ARGS... args)
 

Detailed Description

A connection to a database. This represents a (client) connection that can be used to query the database.

Member Function Documentation

◆ SendQuery()

DUCKDB_API unique_ptr< QueryResult > duckdb::Connection::SendQuery ( const string &  query,
QueryParameters  query_parameters = QueryResultOutputType::ALLOW_STREAMING 
)

Issues a query to the database and returns a QueryResult. This result can be either a StreamQueryResult or a MaterializedQueryResult. The result can be stepped through with calls to Fetch(). Note that there can only be one active StreamQueryResult per Connection object. Calling SendQuery() will invalidate any previously existing StreamQueryResult.

◆ Query() [1/3]

DUCKDB_API unique_ptr< MaterializedQueryResult > duckdb::Connection::Query ( const string &  query)

Issues a query to the database and materializes the result (if necessary). Always returns a MaterializedQueryResult.

◆ Query() [2/3]

DUCKDB_API unique_ptr< MaterializedQueryResult > duckdb::Connection::Query ( unique_ptr< SQLStatement statement,
QueryResultMemoryType  memory_type = QueryResultMemoryType::IN_MEMORY 
)

Issues a query to the database and materializes the result (if necessary). Always returns a MaterializedQueryResult.

◆ Query() [3/3]

template<typename... ARGS>
unique_ptr< QueryResult > duckdb::Connection::Query ( const string &  query,
ARGS...  args 
)
inline
42340 {
42341 vector<Value> values;
42342 return QueryParamsRecursive(query, values, args...);
42343 }

◆ PendingQuery()

DUCKDB_API unique_ptr< PendingQueryResult > duckdb::Connection::PendingQuery ( const string &  query,
QueryParameters  query_parameters = QueryResultOutputType::FORCE_MATERIALIZED 
)

Issues a query to the database and returns a Pending Query Result. Note that "query" may only contain a single statement.

◆ TableInfo()

DUCKDB_API unique_ptr< TableDescription > duckdb::Connection::TableInfo ( const string &  table_name)

Get the table info of a specific table, or nullptr if it cannot be found. Uses INVALID_CATALOG and DEFAULT_SCHEMA.

◆ GetTableNames()

DUCKDB_API unordered_set< string > duckdb::Connection::GetTableNames ( const string &  query,
const bool  qualified = false 
)

Fetch the set of tables names of the query. Returns the fully qualified, escaped table names, if qualified is set to true, else returns the not qualified, not escaped table names.

◆ CreateScalarFunction() [1/2]

template<typename TR , typename... ARGS>
void duckdb::Connection::CreateScalarFunction ( const string &  name,
TR(*)(ARGS...)  udf_func 
)
inline
42439 {
42440 scalar_function_t function = UDFWrapper::CreateScalarFunction<TR, ARGS...>(name, udf_func);
42441 UDFWrapper::RegisterFunction<TR, ARGS...>(name, function, *context);
42442 }
std::function< void(DataChunk &, ExpressionState &, Vector &)> scalar_function_t
The scalar function type.
Definition duckdb.hpp:16489

◆ CreateScalarFunction() [2/2]

template<typename TR , typename... ARGS>
void duckdb::Connection::CreateScalarFunction ( const string &  name,
vector< LogicalType args,
LogicalType  ret_type,
TR(*)(ARGS...)  udf_func 
)
inline
42446 {
42447 scalar_function_t function = UDFWrapper::CreateScalarFunction<TR, ARGS...>(name, args, ret_type, udf_func);
42448 UDFWrapper::RegisterFunction(name, args, ret_type, function, *context);
42449 }

◆ CreateVectorizedFunction() [1/2]

template<typename TR , typename... ARGS>
void duckdb::Connection::CreateVectorizedFunction ( const string &  name,
scalar_function_t  udf_func,
LogicalType  varargs = LogicalType::INVALID 
)
inline
42453 {
42454 UDFWrapper::RegisterFunction<TR, ARGS...>(name, udf_func, *context, std::move(varargs));
42455 }

◆ CreateVectorizedFunction() [2/2]

void duckdb::Connection::CreateVectorizedFunction ( const string &  name,
vector< LogicalType args,
LogicalType  ret_type,
scalar_function_t  udf_func,
LogicalType  varargs = LogicalType::INVALID 
)
inline
42458 {
42459 UDFWrapper::RegisterFunction(name, std::move(args), std::move(ret_type), std::move(udf_func), *context,
42460 std::move(varargs));
42461 }

◆ CreateAggregateFunction() [1/5]

void duckdb::Connection::CreateAggregateFunction ( const string &  name)
inline
42465 {
42466 AggregateFunction function = UDFWrapper::CreateAggregateFunction<UDF_OP, STATE, TR, TA>(name);
42467 UDFWrapper::RegisterAggrFunction(function, *context);
42468 }

◆ CreateAggregateFunction() [2/5]

void duckdb::Connection::CreateAggregateFunction ( const string &  name)
inline
42471 {
42472 AggregateFunction function = UDFWrapper::CreateAggregateFunction<UDF_OP, STATE, TR, TA, TB>(name);
42473 UDFWrapper::RegisterAggrFunction(function, *context);
42474 }

◆ CreateAggregateFunction() [3/5]

void duckdb::Connection::CreateAggregateFunction ( const string &  name,
LogicalType  ret_type,
LogicalType  input_type_a 
)
inline
42477 {
42478 AggregateFunction function =
42479 UDFWrapper::CreateAggregateFunction<UDF_OP, STATE, TR, TA>(name, ret_type, input_type_a);
42480 UDFWrapper::RegisterAggrFunction(function, *context);
42481 }

◆ CreateAggregateFunction() [4/5]

void duckdb::Connection::CreateAggregateFunction ( const string &  name,
LogicalType  ret_type,
LogicalType  input_type_a,
LogicalType  input_type_b 
)
inline
42485 {
42486 AggregateFunction function =
42487 UDFWrapper::CreateAggregateFunction<UDF_OP, STATE, TR, TA, TB>(name, ret_type, input_type_a, input_type_b);
42488 UDFWrapper::RegisterAggrFunction(function, *context);
42489 }

◆ CreateAggregateFunction() [5/5]

void duckdb::Connection::CreateAggregateFunction ( const string &  name,
const vector< LogicalType > &  arguments,
const LogicalType return_type,
aggregate_size_t  state_size,
aggregate_initialize_t  initialize,
aggregate_update_t  update,
aggregate_combine_t  combine,
aggregate_finalize_t  finalize,
aggregate_simple_update_t  simple_update = nullptr,
bind_aggregate_function_t  bind = nullptr,
aggregate_destructor_t  destructor = nullptr 
)
inline
42497 {
42498 AggregateFunction function =
42499 UDFWrapper::CreateAggregateFunction(name, arguments, return_type, state_size, initialize, update, combine,
42500 finalize, simple_update, bind, destructor);
42501 UDFWrapper::RegisterAggrFunction(function, *context);
42502 }

◆ QueryParamsRecursive()

template<typename T , typename... ARGS>
unique_ptr< QueryResult > duckdb::Connection::QueryParamsRecursive ( const string &  query,
vector< Value > &  values,
value,
ARGS...  args 
)
inlineprivate
42513 {
42514 values.push_back(Value::CreateValue<T>(value));
42515 return QueryParamsRecursive(query, values, args...);
42516 }

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