ADBC
Arrow Database Connectivity
Toggle main menu visibility
Loading...
Searching...
No Matches
driver
framework
objects.h
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <optional>
21
#include <string_view>
22
#include <vector>
23
24
#include <
arrow-adbc/adbc.h
>
25
#include "
driver/framework/status.h
"
26
#include "driver/framework/type_fwd.h"
27
28
namespace
adbc::driver {
29
34
36
Status
MakeGetObjectsSchema
(ArrowSchema* schema);
37
39
enum class
GetObjectsDepth
{
40
kCatalogs,
41
kSchemas,
42
kTables,
43
kColumns,
44
};
45
50
struct
GetObjectsHelper
{
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
84
struct
ConstraintUsage
{
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
102
virtual
Status
Load
(
GetObjectsDepth
depth,
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
145
Status
BuildGetObjects
(
GetObjectsHelper
* helper,
GetObjectsDepth
depth,
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
adbc.h
adbc::driver::Status
A wrapper around AdbcStatusCode + AdbcError.
Definition
status.h:43
adbc::driver::GetObjectsDepth
GetObjectsDepth
The GetObjects level.
Definition
objects.h:39
adbc::driver::MakeGetObjectsSchema
Status MakeGetObjectsSchema(ArrowSchema *schema)
Create the ArrowSchema for AdbcConnectionGetObjects().
adbc::driver::BuildGetObjects
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)
A helper that implements GetObjects. The out/helper lifetime are caller-managed.
adbc::driver::GetObjectsHelper::Load
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)
Fetch all metadata needed. The driver is free to delay loading but this gives it a chance to load dat...
Definition
objects.h:102
adbc::driver::GetObjectsHelper
Helper to implement GetObjects.
Definition
objects.h:50
adbc::driver::GetObjectsHelper::Column
Definition
objects.h:77
adbc::driver::GetObjectsHelper::ColumnXdbc
Definition
objects.h:58
adbc::driver::GetObjectsHelper::Constraint
Definition
objects.h:91
adbc::driver::GetObjectsHelper::ConstraintUsage
Definition
objects.h:84
adbc::driver::GetObjectsHelper::Table
Definition
objects.h:53
status.h
Generated by
1.17.0