15 namespace foreign_storage {
21 num_threads = std::stoi(opt.value());
30 const auto& options = foreign_server->
options;
31 for (
const auto& entry : options) {
33 throw std::runtime_error{
"Invalid foreign server option \"" + entry.first +
34 "\". Option must be one of the following: " +
40 throw std::runtime_error{
"Foreign server options must contain \"" +
STORAGE_TYPE_KEY +
46 "\" option value. Value must be one of the following: " +
51 throw std::runtime_error{
52 "Foreign server storage type value of \"" + std::string{
S3_STORAGE_TYPE} +
53 "\" is not allowed because FSI S3 support is currently disabled."};
65 const std::set<std::string_view>&
73 throw std::runtime_error{
"User mapping for the \"" + foreign_server->
data_wrapper_type +
74 "\" data wrapper can only be created for AWS S3 backed "
75 "foreign servers. AWS S3 support is currently disabled."};
78 const std::set<std::string_view>&
93 const std::optional<std::string>& subdirectory) {
95 const std::wstring str_to_cov{boost::filesystem::path::preferred_separator};
96 using convert_type = std::codecvt_utf8<wchar_t>;
97 std::wstring_convert<convert_type, wchar_t> converter;
98 std::string
separator = converter.to_bytes(str_to_cov);
100 const std::string separator{boost::filesystem::path::preferred_separator};
102 return std::regex_replace(
103 (base ? *base + separator :
"") + (subdirectory ? *subdirectory :
""),
104 std::regex{separator +
"{2,}"},
116 std::optional<std::string> base_path{};
122 const std::wstring str_to_cov{boost::filesystem::path::preferred_separator};
123 using convert_type = std::codecvt_utf8<wchar_t>;
124 std::wstring_convert<convert_type, wchar_t> converter;
125 std::string
separator = converter.to_bytes(str_to_cov);
127 const std::string separator{boost::filesystem::path::preferred_separator};
135 CHECK(file_path || base_path);
141 const std::string& table_name,
142 const std::string_view& file_path_key) {
143 std::stringstream ss;
144 ss <<
"No file_path found for Foreign Table \"" << table_name
145 <<
"\". Table must have either set a \"" << file_path_key <<
"\" option, or its "
146 <<
"parent server must have set a \"" << missing_path <<
"\" option.";
147 throw std::runtime_error(ss.str());
158 CHECK(storage_type) <<
"No storage type found in parent server. Server \""
159 << foreign_server->name <<
"\" is not valid.";
183 if (option.has_value()) {
184 if (
to_upper(option.value()) ==
"TRUE") {
186 }
else if (
to_upper(option.value()) ==
"FALSE") {
199 if (allow_file_roll_off.has_value()) {
200 if (allow_file_roll_off.value() && !foreign_table->
isAppendMode()) {
202 "\" option can only be set to 'true' for foreign tables "
203 "with append refresh updates."};
206 throw std::runtime_error{
208 "\" foreign table option. Value must be either 'true' or 'false'."};
214 if (allow_file_roll_off.has_value()) {
215 return allow_file_roll_off.value();
218 CHECK(option.has_value());
220 <<
" value: " << option.value();
232 REGEX_PATH_FILTER_KEY,
235 ALLOW_FILE_ROLL_OFF_KEY};
237 const std::set<std::string_view>
241 const std::set<std::string_view>
void throw_file_path_error(const std::string_view &missing_path, const std::string &table_name, const std::string_view &file_path_key)
const std::set< std::string_view > & getSupportedUserMappingOptions() const override
bool contains(const T &container, const U &element)
static void validateFilePathOptionKey(const ForeignTable *foreign_table)
static const std::array< std::string, 1 > supported_storage_types
static const std::string REGEX_PATH_FILTER_KEY
static shared::FilePathOptions getFilePathOptions(const ForeignTable *foreign_table)
const std::string FILE_SORT_REGEX_KEY
static const std::string LOCAL_FILE_STORAGE_TYPE
size_t get_num_threads(const ForeignTable &table)
void validate_sort_options(const FilePathOptions &options)
void validateUserMappingOptions(const UserMapping *user_mapping, const ForeignServer *foreign_server) const override
static const std::string FILE_PATH_KEY
static const std::string ALLOW_FILE_ROLL_OFF_KEY
static const std::set< std::string_view > supported_server_options_
void validateTableOptions(const ForeignTable *foreign_table) const override
static const std::set< std::string_view > supported_user_mapping_options_
static const std::string FILE_SORT_ORDER_BY_KEY
static const std::string STORAGE_TYPE_KEY
AbstractFileStorageDataWrapper()
const std::string FILE_SORT_ORDER_BY_KEY
static void validateFileRollOffOption(const ForeignTable *foreign_table)
std::string append_file_path(const std::optional< std::string > &base, const std::optional< std::string > &subdirectory)
std::optional< std::string > getOption(const std::string_view &key) const
size_t num_import_threads(const int32_t copy_params_threads)
bool isAppendMode() const
Checks if the table is in append mode.
void validate_allowed_file_path(const std::string &file_path, const DataTransferType data_transfer_type, const bool allow_wildcards)
const std::set< std::string_view > & getSupportedTableOptions() const override
static bool allowFileRollOff(const ForeignTable *foreign_table)
static const std::string BASE_PATH_KEY
std::optional< bool > get_file_roll_off_value(const ForeignTable *foreign_table)
std::string data_wrapper_type
static const std::string THREADS_KEY
void validateServerOptions(const ForeignServer *foreign_server) const override
const ForeignServer * foreign_server
static const std::string FILE_SORT_REGEX_KEY
static const std::set< std::string_view > supported_table_options_
const std::set< std::string > getAlterableTableOptions() const override
static std::string getFullFilePath(const ForeignTable *foreign_table)
Returns the path to the source file/dir of the table. Depending on options this may result from a con...
static void validateFilePath(const ForeignTable *foreign_table)
static const std::string S3_STORAGE_TYPE