Databricks C++ SDK 0.2.4
Interact with Databricks via an SDK
Loading...
Searching...
No Matches
unity_catalog_types.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <map>
5#include <vector>
6#include <cstdint>
7#include <optional>
8#include <nlohmann/json_fwd.hpp>
9
10namespace databricks {
11
12 /**
13 * @brief Enumeration of catalog types
14 */
15 enum class CatalogTypeEnum {
16 MANAGED_CATALOG, ///< Databricks-managed catalog
17 EXTERNAL_CATALOG, ///< External catalog (e.g., AWS Glue, Azure)
18 SYSTEM_CATALOG, ///< System catalog
19 UNKNOWN ///< Unknown catalog type
20 };
21
22 /**
23 * @brief Parse a catalog type string into CatalogTypeEnum
24 * @param type_str String representation of the catalog type
25 * @return CatalogTypeEnum corresponding to the string
26 */
27 CatalogTypeEnum parse_catalog_type(const std::string& type_str);
28
29 /**
30 * @brief Convert CatalogTypeEnum to string representation
31 * @param type CatalogTypeEnum value
32 * @return String representation of the catalog type
33 */
35
36 /**
37 * @brief Enumeration of table types
38 */
39 enum class TableTypeEnum {
40 MANAGED, ///< Managed table
41 EXTERNAL, ///< External table
42 VIEW, ///< View
43 MATERIALIZED_VIEW, ///< Materialized view
44 STREAMING_TABLE, ///< Streaming table
45 UNKNOWN ///< Unknown table type
46 };
47
48 /**
49 * @brief Parse a table type string into TableTypeEnum
50 * @param type_str String representation of the table type
51 * @return TableTypeEnum corresponding to the string
52 */
53 TableTypeEnum parse_table_type(const std::string& type_str);
54
55 /**
56 * @brief Convert TableTypeEnum to string representation
57 * @param type TableTypeEnum value
58 * @return String representation of the table type
59 */
61
62 /**
63 * @brief Represents a Unity Catalog catalog
64 *
65 * Catalogs are the top-level container for organizing data objects in Unity Catalog.
66 */
67 struct CatalogInfo {
68 std::string name; ///< Name of the catalog
69 std::string comment; ///< User-provided description
70 std::string owner; ///< Owner of the catalog
71 std::string catalog_type; ///< Type of catalog (MANAGED_CATALOG, etc.)
72 uint64_t created_at = 0; ///< Unix timestamp in milliseconds when created
73 uint64_t updated_at = 0; ///< Unix timestamp in milliseconds when last updated
74 std::string metastore_id; ///< ID of the metastore containing this catalog
75 std::string full_name; ///< Full name of the catalog
76 std::map<std::string, std::string> properties; ///< Catalog properties/metadata
77 std::optional<std::string> storage_root; ///< Storage root location (for external catalogs)
78 std::optional<std::string> storage_location; ///< Storage location (for managed catalogs)
79 };
80
81 /**
82 * @brief Represents a Unity Catalog schema
83 *
84 * Schemas are containers for tables, views, and functions within a catalog.
85 */
86 struct SchemaInfo {
87 std::string name; ///< Name of the schema
88 std::string catalog_name; ///< Parent catalog name
89 std::string comment; ///< User-provided description
90 std::string owner; ///< Owner of the schema
91 uint64_t created_at = 0; ///< Unix timestamp in milliseconds when created
92 uint64_t updated_at = 0; ///< Unix timestamp in milliseconds when last updated
93 std::string metastore_id; ///< ID of the metastore containing this schema
94 std::string full_name; ///< Full name (catalog.schema)
95 std::map<std::string, std::string> properties; ///< Schema properties/metadata
96 std::optional<std::string> storage_root; ///< Storage root location
97 std::optional<std::string> storage_location; ///< Storage location
98 };
99
100 /**
101 * @brief Represents column information
102 */
103 struct ColumnInfo {
104 std::string name; ///< Column name
105 std::string type_text; ///< Data type as text
106 std::string type_name; ///< Type name (e.g., INT, STRING)
107 int position = 0; ///< Ordinal position in table
108 std::string comment; ///< Column description
109 bool nullable = true; ///< Whether column can be null
110 std::optional<std::string> partition_index; ///< Partition index if partitioned
111 };
112
113 /**
114 * @brief Represents a Unity Catalog table
115 *
116 * Tables are the primary data storage objects in Unity Catalog.
117 */
118 struct TableInfo {
119 std::string name; ///< Table name
120 std::string catalog_name; ///< Parent catalog name
121 std::string schema_name; ///< Parent schema name
122 std::string table_type; ///< Type of table (MANAGED, EXTERNAL, VIEW, etc.)
123 std::string data_source_format; ///< Format (DELTA, PARQUET, CSV, etc.)
124 std::string comment; ///< User-provided description
125 std::string owner; ///< Owner of the table
126 uint64_t created_at = 0; ///< Unix timestamp in milliseconds when created
127 uint64_t updated_at = 0; ///< Unix timestamp in milliseconds when last updated
128 std::string metastore_id; ///< ID of the metastore containing this table
129 std::string full_name; ///< Full name (catalog.schema.table)
130 std::optional<std::string> storage_location; ///< Storage location
131 std::map<std::string, std::string> properties; ///< Table properties/metadata
132 std::vector<ColumnInfo> columns; ///< Column definitions
133 std::optional<std::string> view_definition; ///< SQL definition for views
134 std::optional<uint64_t> table_id; ///< Unique table identifier
135 };
136
137 /**
138 * @brief Configuration for creating a catalog
139 */
141 std::string name; ///< Name of the catalog (required)
142 std::string comment; ///< User-provided description
143 std::map<std::string, std::string> properties; ///< Catalog properties/metadata
144 std::optional<std::string> storage_root; ///< Storage root location
145 };
146
147 /**
148 * @brief Configuration for updating a catalog
149 */
151 std::string name; ///< Name of the catalog (required)
152 std::optional<std::string> new_name; ///< New name for the catalog
153 std::optional<std::string> comment; ///< Updated description
154 std::optional<std::string> owner; ///< New owner
155 std::map<std::string, std::string> properties; ///< Updated properties
156 };
157
158 /**
159 * @brief Configuration for creating a schema
160 */
162 std::string name; ///< Name of the schema (required)
163 std::string catalog_name; ///< Parent catalog name (required)
164 std::string comment; ///< User-provided description
165 std::map<std::string, std::string> properties; ///< Schema properties/metadata
166 std::optional<std::string> storage_root; ///< Storage root location
167 };
168
169 /**
170 * @brief Configuration for updating a schema
171 */
173 std::string full_name; ///< Full name (catalog.schema) (required)
174 std::optional<std::string> new_name; ///< New name for the schema
175 std::optional<std::string> comment; ///< Updated description
176 std::optional<std::string> owner; ///< New owner
177 std::map<std::string, std::string> properties; ///< Updated properties
178 };
179
180 // ==================== JSON SERIALIZATION ====================
181
182 /**
183 * @brief Convert CreateCatalogRequest to JSON
184 */
185 void to_json(nlohmann::json& j, const CreateCatalogRequest& req);
186
187 /**
188 * @brief Convert UpdateCatalogRequest to JSON
189 */
190 void to_json(nlohmann::json& j, const UpdateCatalogRequest& req);
191
192 /**
193 * @brief Convert CreateSchemaRequest to JSON
194 */
195 void to_json(nlohmann::json& j, const CreateSchemaRequest& req);
196
197 /**
198 * @brief Convert UpdateSchemaRequest to JSON
199 */
200 void to_json(nlohmann::json& j, const UpdateSchemaRequest& req);
201
202} // namespace databricks
CatalogTypeEnum parse_catalog_type(const std::string &type_str)
Parse a catalog type string into CatalogTypeEnum.
TableTypeEnum parse_table_type(const std::string &type_str)
Parse a table type string into TableTypeEnum.
std::string table_type_to_string(TableTypeEnum type)
Convert TableTypeEnum to string representation.
std::string catalog_type_to_string(CatalogTypeEnum type)
Convert CatalogTypeEnum to string representation.
CatalogTypeEnum
Enumeration of catalog types.
@ MANAGED_CATALOG
Databricks-managed catalog.
@ SYSTEM_CATALOG
System catalog.
@ EXTERNAL_CATALOG
External catalog (e.g., AWS Glue, Azure)
@ UNKNOWN
Unknown or unrecognized state.
void to_json(nlohmann::json &j, const CreateCatalogRequest &req)
Convert CreateCatalogRequest to JSON.
TableTypeEnum
Enumeration of table types.
@ EXTERNAL
External table.
@ MATERIALIZED_VIEW
Materialized view.
@ STREAMING_TABLE
Streaming table.
@ MANAGED
Managed table.
Represents a Unity Catalog catalog.
uint64_t created_at
Unix timestamp in milliseconds when created.
std::string owner
Owner of the catalog.
std::optional< std::string > storage_location
Storage location (for managed catalogs)
uint64_t updated_at
Unix timestamp in milliseconds when last updated.
std::string comment
User-provided description.
std::string catalog_type
Type of catalog (MANAGED_CATALOG, etc.)
std::string full_name
Full name of the catalog.
std::optional< std::string > storage_root
Storage root location (for external catalogs)
std::map< std::string, std::string > properties
Catalog properties/metadata.
std::string name
Name of the catalog.
std::string metastore_id
ID of the metastore containing this catalog.
Represents column information.
int position
Ordinal position in table.
bool nullable
Whether column can be null.
std::string type_name
Type name (e.g., INT, STRING)
std::string comment
Column description.
std::string name
Column name.
std::string type_text
Data type as text.
std::optional< std::string > partition_index
Partition index if partitioned.
Configuration for creating a catalog.
std::string comment
User-provided description.
std::map< std::string, std::string > properties
Catalog properties/metadata.
std::string name
Name of the catalog (required)
std::optional< std::string > storage_root
Storage root location.
Configuration for creating a schema.
std::string comment
User-provided description.
std::optional< std::string > storage_root
Storage root location.
std::string catalog_name
Parent catalog name (required)
std::map< std::string, std::string > properties
Schema properties/metadata.
std::string name
Name of the schema (required)
Represents a Unity Catalog schema.
std::map< std::string, std::string > properties
Schema properties/metadata.
std::string name
Name of the schema.
std::string comment
User-provided description.
uint64_t updated_at
Unix timestamp in milliseconds when last updated.
std::optional< std::string > storage_location
Storage location.
std::string metastore_id
ID of the metastore containing this schema.
std::string catalog_name
Parent catalog name.
uint64_t created_at
Unix timestamp in milliseconds when created.
std::string full_name
Full name (catalog.schema)
std::string owner
Owner of the schema.
std::optional< std::string > storage_root
Storage root location.
Represents a Unity Catalog table.
std::optional< std::string > storage_location
Storage location.
std::string data_source_format
Format (DELTA, PARQUET, CSV, etc.)
std::vector< ColumnInfo > columns
Column definitions.
std::string table_type
Type of table (MANAGED, EXTERNAL, VIEW, etc.)
uint64_t updated_at
Unix timestamp in milliseconds when last updated.
std::string schema_name
Parent schema name.
std::string comment
User-provided description.
std::optional< std::string > view_definition
SQL definition for views.
std::map< std::string, std::string > properties
Table properties/metadata.
std::string catalog_name
Parent catalog name.
std::string owner
Owner of the table.
std::string name
Table name.
std::string full_name
Full name (catalog.schema.table)
std::optional< uint64_t > table_id
Unique table identifier.
std::string metastore_id
ID of the metastore containing this table.
uint64_t created_at
Unix timestamp in milliseconds when created.
Configuration for updating a catalog.
std::optional< std::string > new_name
New name for the catalog.
std::map< std::string, std::string > properties
Updated properties.
std::string name
Name of the catalog (required)
std::optional< std::string > comment
Updated description.
std::optional< std::string > owner
New owner.
Configuration for updating a schema.
std::optional< std::string > comment
Updated description.
std::string full_name
Full name (catalog.schema) (required)
std::optional< std::string > new_name
New name for the schema.
std::optional< std::string > owner
New owner.
std::map< std::string, std::string > properties
Updated properties.