ADBC
Arrow 数据库连接性
正在加载...
正在搜索...
未找到匹配项
objects.h
1// 根据 Apache 软件基金会 (ASF) 的一个或多个
2// 贡献者许可协议获得许可。有关版权所有权的更多信息,请参见随本作品分发的 NOTICE 文件
3// 。ASF 根据 Apache 许可证 2.0 版(
4// “许可证”)向您许可此文件;除非符合
5// 许可证,否则您不得使用此文件。您可以在以下位置获取许可证的副本:
6//
7//
8//
9// http://apache.org/licenses/LICENSE-2.0
10//
11// 除非适用法律要求或书面同意,否则
12// 根据许可证分发的软件将按“原样”分发,
13// 不提供任何明示或暗示的保证或条件。有关管辖权限和限制的
14// 具体语言,请参阅许可证。
15//
16//
17
18#pragma once
19
20#include <optional>
21#include <string_view>
22#include <vector>
23
24#include <arrow-adbc/adbc.h>
26#include "driver/framework/type_fwd.h"
27
28namespace adbc::driver {
29
34
36Status MakeGetObjectsSchema(ArrowSchema* schema);
37
39enum class GetObjectsDepth {
40 kCatalogs,
41 kSchemas,
42 kTables,
43 kColumns,
44};
45
51 virtual ~GetObjectsHelper() = default;
52
53 struct Table {
54 std::string_view name;
55 std::string_view type;
56 };
57
58 struct ColumnXdbc {
59 std::optional<int16_t> xdbc_data_type;
60 std::optional<std::string_view> xdbc_type_name;
61 std::optional<int32_t> xdbc_column_size;
62 std::optional<int16_t> xdbc_decimal_digits;
63 std::optional<int16_t> xdbc_num_prec_radix;
64 std::optional<int16_t> xdbc_nullable;
65 std::optional<std::string_view> xdbc_column_def;
66 std::optional<int16_t> xdbc_sql_data_type;
67 std::optional<int16_t> xdbc_datetime_sub;
68 std::optional<int32_t> xdbc_char_octet_length;
69 std::optional<std::string_view> xdbc_is_nullable;
70 std::optional<std::string_view> xdbc_scope_catalog;
71 std::optional<std::string_view> xdbc_scope_schema;
72 std::optional<std::string_view> xdbc_scope_table;
73 std::optional<bool> xdbc_is_autoincrement;
74 std::optional<bool> xdbc_is_generatedcolumn;
75 };
76
77 struct Column {
78 std::string_view column_name;
79 int32_t ordinal_position;
80 std::optional<std::string_view> remarks;
81 std::optional<ColumnXdbc> xdbc;
82 };
83
85 std::optional<std::string_view> catalog;
86 std::optional<std::string_view> schema;
87 std::string_view table;
88 std::string_view column;
89 };
90
91 struct Constraint {
92 std::optional<std::string_view> name;
93 std::string_view type;
94 std::vector<std::string_view> column_names;
95 std::optional<std::vector<ConstraintUsage>> usage;
96 };
97
98 Status Close() { return status::Ok(); }
99
103 std::optional<std::string_view> catalog_filter,
104 std::optional<std::string_view> schema_filter,
105 std::optional<std::string_view> table_filter,
106 std::optional<std::string_view> column_filter,
107 const std::vector<std::string_view>& table_types) {
108 return status::NotImplemented("GetObjects");
109 }
110
111 virtual Status LoadCatalogs(std::optional<std::string_view> catalog_filter) {
112 return status::NotImplemented("GetObjects at depth = catalog");
113 };
114
115 virtual Result<std::optional<std::string_view>> NextCatalog() { return std::nullopt; }
116
117 virtual Status LoadSchemas(std::string_view catalog,
118 std::optional<std::string_view> schema_filter) {
119 return status::NotImplemented("GetObjects at depth = schema");
120 };
121
122 virtual Result<std::optional<std::string_view>> NextSchema() { return std::nullopt; }
123
124 virtual Status LoadTables(std::string_view catalog, std::string_view schema,
125 std::optional<std::string_view> table_filter,
126 const std::vector<std::string_view>& table_types) {
127 return status::NotImplemented("GetObjects at depth = table");
128 };
129
130 virtual Result<std::optional<Table>> NextTable() { return std::nullopt; }
131
132 virtual Status LoadColumns(std::string_view catalog, std::string_view schema,
133 std::string_view table,
134 std::optional<std::string_view> column_filter) {
135 return status::NotImplemented("GetObjects at depth = column");
136 };
137
138 virtual Result<std::optional<Column>> NextColumn() { return std::nullopt; }
139
140 virtual Result<std::optional<Constraint>> NextConstraint() { return std::nullopt; }
141};
142
146 std::optional<std::string_view> catalog_filter,
147 std::optional<std::string_view> schema_filter,
148 std::optional<std::string_view> table_filter,
149 std::optional<std::string_view> column_filter,
150 const std::vector<std::string_view>& table_types,
151 ArrowArrayStream* out);
152} // namespace adbc::driver
AdbcStatusCode + AdbcError 的包装器。
定义 status.h:43
GetObjectsDepth
GetObjects 级别。
定义 objects.h:39
Status MakeGetObjectsSchema(ArrowSchema *schema)
为 AdbcConnectionGetObjects() 创建 ArrowSchema。
Status BuildGetObjects(GetObjectsHelper *helper, GetObjectsDepth depth, std::optional< std::string_view > catalog_filter, std::optional< std::string_view > schema_filter, std::optional< std::string_view > table_filter, std::optional< std::string_view > column_filter, const std::vector< std::string_view > &table_types, ArrowArrayStream *out)
一个实现 GetObjects 的助手。 out/helper 的生命周期由调用者管理。
virtual Status Load(GetObjectsDepth depth, std::optional< std::string_view > catalog_filter, std::optional< std::string_view > schema_filter, std::optional< std::string_view > table_filter, std::optional< std::string_view > column_filter, const std::vector< std::string_view > &table_types)
获取所有需要的元数据。驱动程序可以延迟加载,但这给它一个加载数据的机会...
定义 objects.h:102
实现 GetObjects 的助手。
定义 objects.h:50