22 namespace foreign_storage {
25 if (value.length() > 1 && value[0] ==
'"' && value[value.length() - 1] ==
'"') {
26 return value.substr(1, value.length() - 2);
32 const std::string& keys_array,
33 const std::string& values_array) {
34 std::vector<std::string> keys;
36 std::vector<std::string> values;
38 if (keys.size() == values.size()) {
39 std::map<std::string, std::string> values_map;
40 for (
size_t i = 0; i < keys.size(); i++) {
50 std::string node_name;
60 std::vector<std::string_view>& parsed_columns_sv,
61 const std::string& value,
63 for (
size_t i = 0; i < count; i++) {
64 parsed_columns_str.emplace_back(value);
65 parsed_columns_sv.emplace_back(parsed_columns_str.back());
70 std::vector<std::string_view>& parsed_columns_sv,
71 const std::string& nonce,
75 auto dashboard_and_chart_id =
split(nonce,
"/");
76 if (dashboard_and_chart_id.size() == 2) {
77 auto dashboard_id_str = dashboard_and_chart_id[0];
78 int32_t dashboard_id{0};
79 if (dashboard_id_str ==
"null" ||
80 !(dashboard_id = std::atoi(dashboard_id_str.c_str()))) {
81 dashboard_id_str =
"";
86 std::string dashboard_name;
87 if (dashboard_id > 0) {
89 auto info_schema_catalog =
91 CHECK(info_schema_catalog);
93 info_schema_catalog->getMetadataForColumn(table_id,
"database_name");
94 CHECK(db_name_column);
95 CHECK_GT(db_name_column->columnId, 0);
96 CHECK_LE(
size_t(db_name_column->columnId), parsed_columns_str.size());
97 const auto& db_name = parsed_columns_str[db_name_column->columnId - 1];
102 if (sys_catalog.getMetadataForDB(db_name, db_metadata)) {
103 auto catalog = sys_catalog.getCatalog(db_metadata,
false);
104 auto dashboard = catalog->getMetadataForDashboard(dashboard_id);
106 dashboard_name = dashboard->dashboardName;
108 dashboard_name =
"<DELETED>";
113 auto chart_and_layer_id =
split(dashboard_and_chart_id[1],
"-");
114 add_column_value(parsed_columns_str, parsed_columns_sv, chart_and_layer_id[0]);
128 , foreign_table_(foreign_table)
132 const std::string& row_str,
133 const boost::regex& line_regex,
134 size_t logical_column_count,
135 std::vector<std::string>& parsed_columns_str,
136 std::vector<std::string_view>& parsed_columns_sv,
137 const std::string& file_path)
const {
138 CHECK(parsed_columns_str.empty());
139 CHECK(parsed_columns_sv.empty());
143 bool set_all_nulls{
false};
144 if (boost::regex_match(row_str, match, line_regex)) {
145 auto matched_column_count = match.size() - 1;
147 CHECK_GT(matched_column_count,
size_t(2));
148 for (
size_t i = 1; i < match.size() - 2; i++) {
153 match[matched_column_count].str());
154 static const std::array<std::string, 5> keys{
155 "query_str",
"client",
"nonce",
"execution_time_ms",
"total_time_ms"};
156 CHECK_EQ(logical_column_count, matched_column_count + keys.size());
157 for (
const auto& key : keys) {
158 auto it = values_map.find(key);
159 if (it == values_map.end()) {
160 if (key ==
"nonce") {
168 if (key ==
"nonce") {
179 CHECK_EQ(parsed_columns_str.size(), parsed_columns_sv.size());
181 parsed_columns_str.clear();
183 std::vector<std::string_view>(logical_column_count, std::string_view{});
184 set_all_nulls =
true;
186 CHECK_EQ(parsed_columns_sv.size(), logical_column_count) <<
"In row: " << row_str;
187 return set_all_nulls;
195 logical_column_count,
std::string get_node_name()
bool shouldRemoveNonMatches() const override
void add_nonce_values(std::vector< std::string > &parsed_columns_str, std::vector< std::string_view > &parsed_columns_sv, const std::string &nonce, int32_t table_id, int32_t db_id)
bool shouldTruncateStringValues() const override
LogFileBufferParser(const ForeignTable *foreign_table, int32_t db_id)
This file contains the class specification and related data structures for Catalog.
static SysCatalog & instance()
const ForeignTable * foreign_table_
void parse_string_array(const std::string &s, const import_export::CopyParams ©_params, std::vector< std::string > &string_vec, bool truncate_values)
Parses given string array and inserts into given vector of strings.
bool regexMatchColumns(const std::string &row_str, const boost::regex &line_regex, size_t logical_column_count, std::vector< std::string > &parsed_columns_str, std::vector< std::string_view > &parsed_columns_sv, const std::string &file_path) const override
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
int32_t g_distributed_leaf_idx
std::string remove_quotes(const std::string &value)
virtual bool regexMatchColumns(const std::string &row_str, const boost::regex &line_regex, size_t logical_column_count, std::vector< std::string > &parsed_columns_str, std::vector< std::string_view > &parsed_columns_sv, const std::string &file_path) const
std::map< std::string, std::string > create_map_from_arrays(const std::string &keys_array, const std::string &values_array)
void add_column_value(std::vector< std::string > &parsed_columns_str, std::vector< std::string_view > &parsed_columns_sv, const std::string &value, size_t count=1)