OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ForeignDataWrapperFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
20 #include "ForeignDataWrapper.h"
22 
23 namespace foreign_storage {
24 class UserMapping;
25 
26 bool is_s3_uri(const std::string& file_path);
27 
31 bool is_valid_source_type(const import_export::CopyParams& copy_params);
32 
34 
47 std::tuple<std::unique_ptr<foreign_storage::ForeignServer>,
48  std::unique_ptr<foreign_storage::UserMapping>,
49  std::unique_ptr<foreign_storage::ForeignTable>>
50 create_proxy_fsi_objects(const std::string& copy_from_source,
51  const import_export::CopyParams& copy_params,
52  const int db_id,
53  const TableDescriptor* table,
54  const int32_t user_id);
55 
60 std::tuple<std::unique_ptr<foreign_storage::ForeignServer>,
61  std::unique_ptr<foreign_storage::UserMapping>,
62  std::unique_ptr<foreign_storage::ForeignTable>>
63 create_proxy_fsi_objects(const std::string& copy_from_source,
64  const import_export::CopyParams& copy_params,
65  const TableDescriptor* table);
66 
72  static constexpr char const* CSV = "DELIMITED_FILE";
73  static constexpr char const* PARQUET = "PARQUET_FILE";
74  static constexpr char const* REGEX_PARSER = "REGEX_PARSED_FILE";
75  static constexpr char const* INTERNAL_CATALOG = "INTERNAL_CATALOG";
76  static constexpr char const* INTERNAL_MEMORY_STATS = "INTERNAL_MEMORY_STATS";
77  static constexpr char const* INTERNAL_STORAGE_STATS = "INTERNAL_STORAGE_STATS";
78 
79  static constexpr std::array<char const*, 3> INTERNAL_DATA_WRAPPERS{
83 
84  static constexpr std::array<std::string_view, 6> supported_data_wrapper_types{
85  PARQUET,
86  CSV,
91 };
92 
94  public:
99  static std::unique_ptr<ForeignDataWrapper> create(const std::string& data_wrapper_type,
100  const int db_id,
101  const ForeignTable* foreign_table);
102 
103  static std::unique_ptr<UserMapping> createUserMappingProxyIfApplicable(
104  const int db_id,
105  const int user_id,
106  const std::string& file_path,
107  const import_export::CopyParams& copy_params,
108  const ForeignServer* server);
109 
110  static std::unique_ptr<ForeignServer> createForeignServerProxy(
111  const int db_id,
112  const int user_id,
113  const std::string& file_path,
114  const import_export::CopyParams& copy_params);
115 
116  static std::unique_ptr<ForeignTable> createForeignTableProxy(
117  const int db_id,
118  const TableDescriptor* table,
119  const std::string& file_path,
120  const import_export::CopyParams& copy_params,
121  const ForeignServer* server);
122 
126  static std::unique_ptr<ForeignDataWrapper> createForImport(
127  const std::string& data_wrapper_type,
128  const int db_id,
129  const ForeignTable* foreign_table,
130  const UserMapping* user_mapping);
131 
132  static std::unique_ptr<ForeignDataWrapper> createForGeneralImport(
133  const std::string& data_wrapper_type,
134  const int db_id,
135  const ForeignTable* foreign_table,
136  const UserMapping* user_mapping);
137 
144  const std::string& data_wrapper_type,
145  const ForeignTable* foreign_table = nullptr);
146 
150  static void validateDataWrapperType(const std::string& data_wrapper_type);
151 
152  private:
153  static std::map<std::string, std::unique_ptr<ForeignDataWrapper>>
155 };
156 } // namespace foreign_storage
static const ForeignDataWrapper & createForValidation(const std::string &data_wrapper_type, const ForeignTable *foreign_table=nullptr)
static std::unique_ptr< ForeignDataWrapper > createForImport(const std::string &data_wrapper_type, const int db_id, const ForeignTable *foreign_table, const UserMapping *user_mapping)
static constexpr std::array< char const *, 3 > INTERNAL_DATA_WRAPPERS
static constexpr char const * REGEX_PARSER
static std::unique_ptr< ForeignDataWrapper > create(const std::string &data_wrapper_type, const int db_id, const ForeignTable *foreign_table)
static constexpr char const * INTERNAL_STORAGE_STATS
static constexpr char const * INTERNAL_CATALOG
std::tuple< std::unique_ptr< foreign_storage::ForeignServer >, std::unique_ptr< foreign_storage::UserMapping >, std::unique_ptr< foreign_storage::ForeignTable > > create_proxy_fsi_objects(const std::string &copy_from_source, const import_export::CopyParams &copy_params, const int db_id, const TableDescriptor *table, const int32_t user_id)
Create proxy fsi objects for use outside FSI.
static std::map< std::string, std::unique_ptr< ForeignDataWrapper > > validation_data_wrappers_
static void validateDataWrapperType(const std::string &data_wrapper_type)
Encapsulates an enumeration of foreign data wrapper type strings.
bool is_valid_source_type(const import_export::CopyParams &copy_params)
bool is_s3_uri(const std::string &file_path)
static constexpr std::array< std::string_view, 6 > supported_data_wrapper_types
void validate_regex_parser_options(const import_export::CopyParams &copy_params)
static std::unique_ptr< ForeignServer > createForeignServerProxy(const int db_id, const int user_id, const std::string &file_path, const import_export::CopyParams &copy_params)
static constexpr char const * INTERNAL_MEMORY_STATS
static std::unique_ptr< ForeignTable > createForeignTableProxy(const int db_id, const TableDescriptor *table, const std::string &file_path, const import_export::CopyParams &copy_params, const ForeignServer *server)
static constexpr char const * CSV
static constexpr char const * PARQUET
static std::unique_ptr< ForeignDataWrapper > createForGeneralImport(const std::string &data_wrapper_type, const int db_id, const ForeignTable *foreign_table, const UserMapping *user_mapping)
static std::unique_ptr< UserMapping > createUserMappingProxyIfApplicable(const int db_id, const int user_id, const std::string &file_path, const import_export::CopyParams &copy_params, const ForeignServer *server)