Skip to content

Commit

Permalink
do some renaming to ColumnMapping from NameMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed Dec 13, 2024
1 parent 1c9ff9a commit 18f3953
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
55 changes: 28 additions & 27 deletions src/common/multi_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ MultiFileReader::InitializeGlobalState(ClientContext &context, const MultiFileRe
return nullptr;
}

void MultiFileReader::CreateMappingByName(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data, const MultiFileReaderBindData &bind_data,
const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state) {
void MultiFileReader::CreateColumnMappingByName(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state) {
// we have expected types: create a map of name -> column index
case_insensitive_map_t<idx_t> name_map;
for (idx_t col_idx = 0; col_idx < local_columns.size(); col_idx++) {
Expand All @@ -334,7 +334,7 @@ void MultiFileReader::CreateMappingByName(const string &file_name,
auto global_id = global_idx.GetPrimaryIndex();
if (global_id >= global_columns.size()) {
throw InternalException(
"MultiFileReader::CreateMappingByName - global_id is out of range in global_types for this file");
"MultiFileReader::CreateColumnMappingByName - global_id is out of range in global_types for this file");
}
auto &global_name = global_columns[global_id].name;
auto entry = name_map.find(global_name);
Expand Down Expand Up @@ -375,13 +375,13 @@ void MultiFileReader::CreateMappingByName(const string &file_name,
reader_data.empty_columns = reader_data.column_indexes.empty();
}

void MultiFileReader::CreateMappingByFieldId(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data, const MultiFileReaderBindData &bind_data,
const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state) {
void MultiFileReader::CreateColumnMappingByFieldId(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state) {
#ifdef DEBUG
//! Make sure the global columns have field_ids to match on
for (auto &column : global_columns) {
Expand Down Expand Up @@ -464,21 +464,22 @@ void MultiFileReader::CreateMappingByFieldId(const string &file_name,
reader_data.empty_columns = reader_data.column_ids.empty();
}

void MultiFileReader::CreateNameMapping(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids, MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state) {
void MultiFileReader::CreateColumnMapping(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data, const MultiFileReaderBindData &bind_data,
const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state) {
switch (bind_data.mapping) {
case MultiFileReaderColumnMappingMode::BY_NAME: {
CreateMappingByName(file_name, local_columns, global_columns, global_column_ids, reader_data, bind_data,
initial_file, global_state);
CreateColumnMappingByName(file_name, local_columns, global_columns, global_column_ids, reader_data, bind_data,
initial_file, global_state);
break;
}
case MultiFileReaderColumnMappingMode::BY_FIELD_ID: {
CreateMappingByFieldId(file_name, local_columns, global_columns, global_column_ids, reader_data, bind_data,
initial_file, global_state);
CreateColumnMappingByFieldId(file_name, local_columns, global_columns, global_column_ids, reader_data,
bind_data, initial_file, global_state);
break;
}
default: {
Expand All @@ -495,8 +496,8 @@ void MultiFileReader::CreateMapping(const string &file_name,
const MultiFileReaderBindData &bind_data,
optional_ptr<MultiFileReaderGlobalState> global_state) {
// copy global columns and inject any different defaults
CreateNameMapping(file_name, local_columns, global_columns, global_column_ids, reader_data, bind_data, initial_file,
global_state);
CreateColumnMapping(file_name, local_columns, global_columns, global_column_ids, reader_data, bind_data,
initial_file, global_state);
CreateFilterMap(global_columns, filters, reader_data, global_state);
}

Expand Down
28 changes: 15 additions & 13 deletions src/include/duckdb/common/multi_file_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,24 +368,26 @@ struct MultiFileReader {
TableFunctionPartitionInput &input);

protected:
virtual void CreateNameMapping(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids, MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state);
virtual void CreateMappingByFieldId(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids, MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state);
virtual void CreateMappingByName(const string &file_name,
virtual void CreateColumnMapping(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids, MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state);
virtual void CreateColumnMappingByFieldId(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data,
const MultiFileReaderBindData &bind_data, const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state);
virtual void CreateColumnMappingByName(const string &file_name,
const vector<MultiFileReaderColumnDefinition> &local_columns,
const vector<MultiFileReaderColumnDefinition> &global_columns,
const vector<ColumnIndex> &global_column_ids,
MultiFileReaderData &reader_data, const MultiFileReaderBindData &bind_data,
const string &initial_file,
optional_ptr<MultiFileReaderGlobalState> global_state);

//! Used in errors to report which function is using this MultiFileReader
string function_name;
Expand Down

0 comments on commit 18f3953

Please sign in to comment.