28 namespace foreign_storage {
42 return (update_mode !=
options.end() &&
63 const auto& data_wrapper_options =
67 for (
const auto& [key, value] : options_map) {
70 throw std::runtime_error{
"Invalid foreign table option \"" + key +
"\"."};
76 auto update_type_entry =
78 CHECK(update_type_entry != options.end());
79 auto update_type_value = update_type_entry->second;
82 std::string error_message =
86 throw std::runtime_error{error_message};
89 auto refresh_timing_entry =
91 CHECK(refresh_timing_entry != options.end());
92 if (
auto refresh_timing_value = refresh_timing_entry->second;
95 if (start_date_entry == options.end()) {
97 " option must be provided for scheduled refreshes."};
99 auto start_date_time = dateTimeParse<kTIMESTAMP>(start_date_entry->second, 0);
101 if (start_date_time < current_time) {
103 " cannot be a past date time."};
107 if (interval_entry != options.end()) {
108 std::string interval_types{
"HD"};
110 interval_types +=
"S";
112 boost::regex interval_regex{
"^\\d{1,}[" + interval_types +
"]$",
113 boost::regex::extended | boost::regex::icase};
114 if (!boost::regex_match(interval_entry->second, interval_regex)) {
115 throw std::runtime_error{
"Invalid value provided for the " +
120 throw std::runtime_error{
"Invalid value provided for the " +
135 CHECK(json_options.IsObject());
136 for (
auto itr = json_options.MemberBegin(); itr != json_options.MemberEnd(); ++itr) {
137 auto key =
to_upper(itr->name.GetString());
140 options_map[key] =
to_upper(itr->value.GetString());
142 options_map[key] = itr->value.GetString();
149 const auto& data_wrapper_options =
154 for (
const auto& [key, value] : options_map) {
157 throw std::runtime_error{std::string(
"Altering foreign table option \"") + key +
158 "\" is not currently supported."};
bool contains(const T &container, const U &element)
virtual const std::set< std::string > getAlterableTableOptions() const
void validateDataWrapperOptions() const
static const ForeignDataWrapper * createForValidation(const std::string &data_wrapper_type, const ForeignTable *foreign_table=nullptr)
static const std::set< const char * > supported_options
void validateAlterOptions(const OptionsMap &options_map) const
Verifies that the given options map only contains options that can be legally altered.
void initializeOptions()
Creates an empty option map for the table. Verifies that the required option keys are present and tha...
void validateOptionValues() const
Verifies the values for mapped options are valid.
virtual const std::set< std::string_view > & getSupportedTableOptions() const =0
void validateSupportedOptionKeys(const OptionsMap &options_map) const
Verifies that the options_map contains the keys required by a foreign table; including those specifie...
static constexpr const char * MANUAL_REFRESH_TIMING_TYPE
virtual void validateTableOptions(const ForeignTable *foreign_table) const =0
static OptionsMap createOptionsMap(const rapidjson::Value &json_options)
Creates an options map from given options. Converts options that must be upper case appropriately...
static constexpr const char * REFRESH_START_DATE_TIME_KEY
static constexpr const char * REFRESH_UPDATE_TYPE_KEY
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)
static constexpr const char * REFRESH_INTERVAL_KEY
void validateRefreshOptionValues() const
bool isAppendMode() const
Checks if the table is in append mode.
void validateSchema(const std::list< ColumnDescriptor > &columns) const
Verifies the schema is supported by this foreign table.
static const std::set< const char * > alterable_options
bool g_enable_seconds_refresh
static constexpr const char * ALL_REFRESH_UPDATE_TYPE
std::string data_wrapper_type
static constexpr const char * APPEND_REFRESH_UPDATE_TYPE
const ForeignServer * foreign_server
static constexpr const char * REFRESH_TIMING_TYPE_KEY
std::map< std::string, std::string, std::less<>> OptionsMap
static int64_t getCurrentTime()
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE
virtual void validateSchema(const std::list< ColumnDescriptor > &columns) const
static const std::set< const char * > upper_case_options