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::CreateViewInfo Struct Reference
Inheritance diagram for duckdb::CreateViewInfo:
Collaboration diagram for duckdb::CreateViewInfo:

Public Member Functions

 CreateViewInfo (SchemaCatalogEntry &schema, string view_name)
 CreateViewInfo (string catalog_p, string schema_p, string view_name)
unique_ptr< CreateInfo > Copy () const override
DUCKDB_API void Serialize (Serializer &serializer) const override
string ToString () const override
Public Member Functions inherited from duckdb::CreateInfo
 CreateInfo (CatalogType type, string schema=DEFAULT_SCHEMA, string catalog_p=INVALID_CATALOG)
DUCKDB_API void CopyProperties (CreateInfo &other) const
virtual DUCKDB_API unique_ptr< AlterInfo > GetAlterInfo () const
 Generates an alter statement from the create statement - used for OnCreateConflict::ALTER_ON_CONFLICT.
DUCKDB_API string GetCreatePrefix (const string &entry) const
 Returns a string like "CREATE (OR REPLACE) (TEMPORARY) <entry> (IF NOT EXISTS) " for TABLE/VIEW/TYPE/MACRO.
Public Member Functions inherited from duckdb::ParseInfo
 ParseInfo (ParseInfoType info_type)
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static DUCKDB_API unique_ptr< CreateViewInfo > FromSelect (ClientContext &context, unique_ptr< CreateViewInfo > info)
 Gets a bound CreateViewInfo object from a SELECT statement and a view name, schema name, etc.
static DUCKDB_API unique_ptr< CreateViewInfo > FromCreateView (ClientContext &context, SchemaCatalogEntry &schema, const string &sql)
 Gets a bound CreateViewInfo object from a CREATE VIEW statement.
static DUCKDB_API unique_ptr< SelectStatement > ParseSelect (const string &sql)
 Parse a SELECT statement from a SQL string.
static DUCKDB_API unique_ptr< CreateInfo > Deserialize (Deserializer &deserializer)
Static Public Member Functions inherited from duckdb::CreateInfo
static unique_ptr< CreateInfo > Deserialize (Deserializer &deserializer)
Static Public Member Functions inherited from duckdb::ParseInfo
static unique_ptr< ParseInfo > Deserialize (Deserializer &deserializer)
static string QualifierToString (const string &catalog, const string &schema, const string &name)
static string TypeToString (CatalogType type)

Public Attributes

string view_name
 View name.
vector< string > aliases
 Aliases of the view.
vector< LogicalType > types
 Return types.
vector< string > names
 Names of the query.
unordered_map< string, Value > column_comments_map
 Comments on columns of the query. Note: vector can be empty when no comments are set.
unique_ptr< SelectStatement > query
 The SelectStatement of the view.
Public Attributes inherited from duckdb::CreateInfo
CatalogType type
 The to-be-created catalog type.
string catalog
 The catalog name of the entry.
string schema
 The schema name of the entry.
OnCreateConflict on_conflict
 What to do on create conflict.
bool temporary
 Whether or not the entry is temporary.
bool internal
 Whether or not the entry is an internal entry.
string sql
 The SQL string of the CREATE statement.
LogicalDependencyList dependencies
 The inherent dependencies of the created entry.
Value comment
 User provided comment.
InsertionOrderPreservingMap< string > tags
 Key-value tags with additional metadata.
Public Attributes inherited from duckdb::ParseInfo
ParseInfoType info_type

Private Member Functions

 CreateViewInfo (vector< string > names, vector< Value > comments, unordered_map< string, Value > column_comments)
vector< Value > GetColumnCommentsList () const

Additional Inherited Members

Static Public Attributes inherited from duckdb::CreateInfo
static constexpr const ParseInfoType TYPE = ParseInfoType::CREATE_INFO

Constructor & Destructor Documentation

◆ CreateViewInfo() [1/4]

duckdb::CreateViewInfo::CreateViewInfo ( )
339866 : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
339867}

◆ CreateViewInfo() [2/4]

duckdb::CreateViewInfo::CreateViewInfo ( SchemaCatalogEntry & schema,
string view_name )
339874 : CreateViewInfo(schema.catalog.GetName(), schema.name, std::move(view_name)) {
339875}
string schema
The schema name of the entry.
Definition duckdb.hpp:28162
string view_name
View name.
Definition duckdb.cpp:6639

◆ CreateViewInfo() [3/4]

duckdb::CreateViewInfo::CreateViewInfo ( string catalog_p,
string schema_p,
string view_name )
339869 : CreateInfo(CatalogType::VIEW_ENTRY, std::move(schema_p), std::move(catalog_p)),
339870 view_name(std::move(view_name_p)) {
339871}

◆ CreateViewInfo() [4/4]

duckdb::CreateViewInfo::CreateViewInfo ( vector< string > names,
vector< Value > comments,
unordered_map< string, Value > column_comments )
private
339978 : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA), names(std::move(names_p)),
339979 column_comments_map(std::move(column_comments_p)) {
339980 if (comments.empty()) {
339981 return;
339982 }
339983 if (!column_comments_map.empty()) {
339984 throw SerializationException("Either column_comments or column_comments_map should be provided, not both");
339985 }
339986 for (idx_t i = 0; i < comments.size(); i++) {
339987 if (comments[i].IsNull()) {
339988 continue;
339989 }
339990 column_comments_map[names[i]] = std::move(comments[i]);
339991 }
339992}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
unordered_map< string, Value > column_comments_map
Comments on columns of the query. Note: vector can be empty when no comments are set.
Definition duckdb.cpp:6647
vector< string > names
Names of the query.
Definition duckdb.cpp:6645

Member Function Documentation

◆ Copy()

unique_ptr< CreateInfo > duckdb::CreateViewInfo::Copy ( ) const
overridevirtual

Implements duckdb::CreateInfo.

339892 {
339893 auto result = make_uniq<CreateViewInfo>(catalog, schema, view_name);
339894 CopyProperties(*result);
339895 result->aliases = aliases;
339896 result->types = types;
339897 result->names = names;
339898 result->column_comments_map = column_comments_map;
339899 result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
339900 return std::move(result);
339901}
string catalog
The catalog name of the entry.
Definition duckdb.hpp:28160
vector< string > aliases
Aliases of the view.
Definition duckdb.cpp:6641
vector< LogicalType > types
Return types.
Definition duckdb.cpp:6643
unique_ptr< SelectStatement > query
The SelectStatement of the view.
Definition duckdb.cpp:6649

◆ FromSelect()

unique_ptr< CreateViewInfo > duckdb::CreateViewInfo::FromSelect ( ClientContext & context,
unique_ptr< CreateViewInfo > info )
static

Gets a bound CreateViewInfo object from a SELECT statement and a view name, schema name, etc.

339915 {
339916 D_ASSERT(info);
339917 D_ASSERT(!info->view_name.empty());
339918 D_ASSERT(!info->sql.empty());
339919 D_ASSERT(!info->query);
339920
339921 info->query = ParseSelect(info->sql);
339922 return info;
339923}
static DUCKDB_API unique_ptr< SelectStatement > ParseSelect(const string &sql)
Parse a SELECT statement from a SQL string.
Definition duckdb.cpp:339903
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromCreateView()

unique_ptr< CreateViewInfo > duckdb::CreateViewInfo::FromCreateView ( ClientContext & context,
SchemaCatalogEntry & schema,
const string & sql )
static

Gets a bound CreateViewInfo object from a CREATE VIEW statement.

339926 {
339927 D_ASSERT(!sql.empty());
339928
339929 // parse the SQL statement
339930 Parser parser;
339931 parser.ParseQuery(sql);
339932
339933 if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::CREATE_STATEMENT) {
339934 throw BinderException(
339935 "Failed to create view from SQL string - \"%s\" - statement did not contain a single CREATE VIEW statement",
339936 sql);
339937 }
339938 auto &create_statement = parser.statements[0]->Cast<CreateStatement>();
339939 if (create_statement.info->type != CatalogType::VIEW_ENTRY) {
339940 throw BinderException(
339941 "Failed to create view from SQL string - \"%s\" - view did not contain a CREATE VIEW statement", sql);
339942 }
339943
339944 auto result = unique_ptr_cast<CreateInfo, CreateViewInfo>(std::move(create_statement.info));
339945 result->catalog = schema.ParentCatalog().GetName();
339946 result->schema = schema.name;
339947
339948 auto view_binder = Binder::CreateBinder(context);
339949 view_binder->BindCreateViewInfo(*result);
339950
339951 return result;
339952}
string sql
The SQL string of the CREATE statement.
Definition duckdb.hpp:28170

◆ ParseSelect()

unique_ptr< SelectStatement > duckdb::CreateViewInfo::ParseSelect ( const string & sql)
static

Parse a SELECT statement from a SQL string.

339903 {
339904 Parser parser;
339905 parser.ParseQuery(sql);
339906 if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::SELECT_STATEMENT) {
339907 throw BinderException(
339908 "Failed to create view from SQL string - \"%s\" - statement did not contain a single SELECT statement",
339909 sql);
339910 }
339911 D_ASSERT(parser.statements.size() == 1 && parser.statements[0]->type == StatementType::SELECT_STATEMENT);
339912 return unique_ptr_cast<SQLStatement, SelectStatement>(std::move(parser.statements[0]));
339913}
Here is the caller graph for this function:

◆ Serialize()

void duckdb::CreateViewInfo::Serialize ( Serializer & serializer) const
overridevirtual

Reimplemented from duckdb::CreateInfo.

415833 {
415834 CreateInfo::Serialize(serializer);
415835 serializer.WritePropertyWithDefault<string>(200, "view_name", view_name);
415836 serializer.WritePropertyWithDefault<vector<string>>(201, "aliases", aliases);
415837 serializer.WritePropertyWithDefault<vector<LogicalType>>(202, "types", types);
415838 serializer.WritePropertyWithDefault<unique_ptr<SelectStatement>>(203, "query", query);
415839 serializer.WritePropertyWithDefault<vector<string>>(204, "names", names);
415840 if (!serializer.ShouldSerialize(7)) {
415841 serializer.WritePropertyWithDefault<vector<Value>>(205, "column_comments", GetColumnCommentsList());
415842 }
415843 if (serializer.ShouldSerialize(7)) {
415844 serializer.WritePropertyWithDefault<unordered_map<string, Value>>(206, "column_comments_map", column_comments_map, unordered_map<string, Value>());
415845 }
415846}

◆ Deserialize()

unique_ptr< CreateInfo > duckdb::CreateViewInfo::Deserialize ( Deserializer & deserializer)
static
415848 {
415849 auto view_name = deserializer.ReadPropertyWithDefault<string>(200, "view_name");
415850 auto aliases = deserializer.ReadPropertyWithDefault<vector<string>>(201, "aliases");
415851 auto types = deserializer.ReadPropertyWithDefault<vector<LogicalType>>(202, "types");
415852 auto query = deserializer.ReadPropertyWithDefault<unique_ptr<SelectStatement>>(203, "query");
415853 auto names = deserializer.ReadPropertyWithDefault<vector<string>>(204, "names");
415854 auto column_comments = deserializer.ReadPropertyWithDefault<vector<Value>>(205, "column_comments");
415855 auto column_comments_map = deserializer.ReadPropertyWithExplicitDefault<unordered_map<string, Value>>(206, "column_comments_map", unordered_map<string, Value>());
415856 auto result = duckdb::unique_ptr<CreateViewInfo>(new CreateViewInfo(std::move(names), std::move(column_comments), std::move(column_comments_map)));
415857 result->view_name = std::move(view_name);
415858 result->aliases = std::move(aliases);
415859 result->types = std::move(types);
415860 result->query = std::move(query);
415861 return std::move(result);
415862}

◆ ToString()

string duckdb::CreateViewInfo::ToString ( ) const
overridevirtual

Reimplemented from duckdb::CreateInfo.

339877 {
339878 string result = GetCreatePrefix("VIEW");
339879 result += QualifierToString(temporary ? "" : catalog, schema, view_name);
339880 if (!aliases.empty()) {
339881 result += " (";
339882 result += StringUtil::Join(aliases, aliases.size(), ", ",
339883 [](const string &name) { return KeywordHelper::WriteOptionallyQuoted(name); });
339884 result += ")";
339885 }
339886 result += " AS ";
339887 result += query->ToString();
339888 result += ";";
339889 return result;
339890}
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
Definition duckdb.cpp:109497
bool temporary
Whether or not the entry is temporary.
Definition duckdb.hpp:28166
DUCKDB_API string GetCreatePrefix(const string &entry) const
Returns a string like "CREATE (OR REPLACE) (TEMPORARY) <entry> (IF NOT EXISTS) " for TABLE/VIEW/TYPE/...
Definition duckdb.cpp:339436

◆ GetColumnCommentsList()

vector< Value > duckdb::CreateViewInfo::GetColumnCommentsList ( ) const
private
339954 {
339955 if (column_comments_map.empty()) {
339956 return vector<Value>();
339957 }
339958 if (names.empty()) {
339959 throw InternalException(
339960 "Attempting to serialize column comments using the legacy format, but view is not bound");
339961 }
339962 vector<Value> result;
339963 result.resize(names.size());
339964 for (auto &entry : column_comments_map) {
339965 auto it = std::find(names.begin(), names.end(), entry.first);
339966 if (it == names.end()) {
339967 throw InternalException(
339968 "While serializing comments for view \"%s\" - did not find column \"%s\" in list of names", view_name,
339969 entry.first);
339970 }
339971 result[NumericCast<idx_t>(it - names.begin())] = entry.second;
339972 }
339973 return result;
339974}

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