From 1cfed8ceeffa0ef6087eeb46e11eab641699908c Mon Sep 17 00:00:00 2001 From: xiyang Date: Tue, 14 Nov 2023 21:54:27 +0800 Subject: [PATCH] clean --- src/binder/bind/bind_copy.cpp | 6 ++--- src/binder/bind/copy/bind_copy_rdf_graph.cpp | 5 ++--- src/include/catalog/property.h | 6 ----- src/planner/plan/plan_copy.cpp | 22 +++++++++---------- src/processor/map/CMakeLists.txt | 1 - src/processor/map/map_copy_from.cpp | 17 +++++++------- src/processor/map/map_partitioner.cpp | 12 ---------- test/test_files/copy/copy_partial_column.test | 11 +++++++++- 8 files changed, 33 insertions(+), 47 deletions(-) delete mode 100644 src/processor/map/map_partitioner.cpp diff --git a/src/binder/bind/bind_copy.cpp b/src/binder/bind/bind_copy.cpp index 2b0fb10e64..5f7fd99db5 100644 --- a/src/binder/bind/bind_copy.cpp +++ b/src/binder/bind/bind_copy.cpp @@ -161,10 +161,8 @@ std::unique_ptr Binder::bindCopyRelFrom(const parser::Statement& catalog.getReadOnlyVersion()->getTableSchema(relTableSchema->getDstTableID()); auto srcKey = columns[0]; auto dstKey = columns[1]; - auto srcNodeID = - createVariable(std::string(InternalKeyword::SRC_OFFSET), LogicalTypeID::INT64); - auto dstNodeID = - createVariable(std::string(InternalKeyword::DST_OFFSET), LogicalTypeID::INT64); + auto srcNodeID = createVariable(std::string(InternalKeyword::SRC_OFFSET), LogicalTypeID::INT64); + auto dstNodeID = createVariable(std::string(InternalKeyword::DST_OFFSET), LogicalTypeID::INT64); auto extraCopyRelInfo = std::make_unique( srcTableSchema, dstTableSchema, srcNodeID, dstNodeID, srcKey, dstKey); auto boundCopyFromInfo = std::make_unique( diff --git a/src/binder/bind/copy/bind_copy_rdf_graph.cpp b/src/binder/bind/copy/bind_copy_rdf_graph.cpp index 123f43b76d..dfbbc4da02 100644 --- a/src/binder/bind/copy/bind_copy_rdf_graph.cpp +++ b/src/binder/bind/copy/bind_copy_rdf_graph.cpp @@ -85,9 +85,8 @@ std::unique_ptr Binder::bindCopyRdfRelFrom(const Statement& /*st std::make_unique(func, std::move(bindData), columns, offset); auto extraInfo = std::make_unique(columns[0], columns[2]); expression_vector columnsToCopy = {columns[0], columns[2], offset, columns[1]}; - auto boundCopyFromInfo = - std::make_unique(tableSchema, std::move(boundFileScanInfo), - containsSerial, std::move(extraInfo)); + auto boundCopyFromInfo = std::make_unique( + tableSchema, std::move(boundFileScanInfo), containsSerial, std::move(extraInfo)); return std::make_unique(std::move(boundCopyFromInfo)); } diff --git a/src/include/catalog/property.h b/src/include/catalog/property.h index 5cae857462..3574453d71 100644 --- a/src/include/catalog/property.h +++ b/src/include/catalog/property.h @@ -11,12 +11,6 @@ namespace catalog { class Property { public: - // TODO: these should be guarded as reserved property names. - // static constexpr std::string_view REL_FROM_PROPERTY_NAME = "_from_"; - // static constexpr std::string_view REL_TO_PROPERTY_NAME = "_to_"; - // static constexpr std::string_view REL_SRC_OFFSET_NAME = "_src_offset_"; - // static constexpr std::string_view REL_DST_OFFSET_NAME = "_nbr_offset_"; - Property(std::string name, std::unique_ptr dataType) : Property{std::move(name), std::move(dataType), common::INVALID_PROPERTY_ID, common::INVALID_TABLE_ID} {} diff --git a/src/planner/plan/plan_copy.cpp b/src/planner/plan/plan_copy.cpp index 23f5804a19..aa44794984 100644 --- a/src/planner/plan/plan_copy.cpp +++ b/src/planner/plan/plan_copy.cpp @@ -51,19 +51,17 @@ static void appendPartitioner(BoundCopyFromInfo* copyFromInfo, LogicalPlan& plan payloads.push_back(extraInfo->srcOffset); payloads.push_back(extraInfo->dstOffset); // Partitioner for FWD direction rel data. - infos.push_back( - std::make_unique(extraInfo->srcOffset, payloads, - tableSchema->isSingleMultiplicityInDirection(RelDataDirection::FWD) ? - ColumnDataFormat::REGULAR : - ColumnDataFormat::CSR, - tableSchema)); + infos.push_back(std::make_unique(extraInfo->srcOffset, payloads, + tableSchema->isSingleMultiplicityInDirection(RelDataDirection::FWD) ? + ColumnDataFormat::REGULAR : + ColumnDataFormat::CSR, + tableSchema)); // Partitioner for BWD direction rel data. - infos.push_back( - std::make_unique(extraInfo->dstOffset, payloads, - tableSchema->isSingleMultiplicityInDirection(RelDataDirection::BWD) ? - ColumnDataFormat::REGULAR : - ColumnDataFormat::CSR, - tableSchema)); + infos.push_back(std::make_unique(extraInfo->dstOffset, payloads, + tableSchema->isSingleMultiplicityInDirection(RelDataDirection::BWD) ? + ColumnDataFormat::REGULAR : + ColumnDataFormat::CSR, + tableSchema)); } break; default: { KU_UNREACHABLE; diff --git a/src/processor/map/CMakeLists.txt b/src/processor/map/CMakeLists.txt index f4837d0140..e78fa24c77 100644 --- a/src/processor/map/CMakeLists.txt +++ b/src/processor/map/CMakeLists.txt @@ -33,7 +33,6 @@ add_library(kuzu_processor_mapper map_merge.cpp map_multiplicity_reducer.cpp map_order_by.cpp - map_partitioner.cpp map_path_property_probe.cpp map_projection.cpp map_recursive_extend.cpp diff --git a/src/processor/map/map_copy_from.cpp b/src/processor/map/map_copy_from.cpp index a33517da43..72eb919488 100644 --- a/src/processor/map/map_copy_from.cpp +++ b/src/processor/map/map_copy_from.cpp @@ -41,7 +41,8 @@ static void getNodeColumnsInCopyOrder( } } -static void getRelColumnNamesInCopyOrder(TableSchema* tableSchema, std::vector& columnNames, logical_types_t& columnTypes) { +static void getRelColumnNamesInCopyOrder( + TableSchema* tableSchema, std::vector& columnNames, logical_types_t& columnTypes) { columnNames.emplace_back(InternalKeyword::SRC_OFFSET); columnNames.emplace_back(InternalKeyword::DST_OFFSET); columnNames.emplace_back(InternalKeyword::ROW_OFFSET); @@ -53,7 +54,6 @@ static void getRelColumnNamesInCopyOrder(TableSchema* tableSchema, std::vectorgetName()); columnTypes.push_back(properties[i]->getDataType()->copy()); } - } static std::shared_ptr matchColumnExpression( @@ -68,7 +68,8 @@ static std::shared_ptr matchColumnExpression( return nullptr; } -static std::vector getColumnDataPositions(const std::vector& columnNames, const expression_vector& inputColumns, const Schema& fSchema) { +static std::vector getColumnDataPositions(const std::vector& columnNames, + const expression_vector& inputColumns, const Schema& fSchema) { std::vector columnPositions; for (auto& columnName : columnNames) { auto expr = matchColumnExpression(inputColumns, columnName); @@ -103,14 +104,15 @@ std::unique_ptr PlanMapper::mapCopyNodeFrom(LogicalOperator* l getNodeColumnsInCopyOrder(tableSchema, columnNames, columnTypes); std::vector columnNamesExcludingSerial; for (auto i = 0u; i < columnNames.size(); ++i) { - if (columnTypes[i]->getLogicalTypeID()==common::LogicalTypeID::SERIAL) { - continue ; + if (columnTypes[i]->getLogicalTypeID() == common::LogicalTypeID::SERIAL) { + continue; } columnNamesExcludingSerial.push_back(columnNames[i]); } auto inputColumns = copyFromInfo->fileScanInfo->columns; inputColumns.push_back(copyFromInfo->fileScanInfo->offset); - auto columnPositions = getColumnDataPositions(columnNamesExcludingSerial, inputColumns, *outFSchema); + auto columnPositions = + getColumnDataPositions(columnNamesExcludingSerial, inputColumns, *outFSchema); sharedState->columnTypes = std::move(columnTypes); auto info = std::make_unique(std::move(columnPositions), nodeTable, tableSchema->tableName, copyFromInfo->containsSerial, storageManager.compressionEnabled()); @@ -145,8 +147,7 @@ std::unique_ptr PlanMapper::mapPartitioner(LogicalOperator* lo std::vector columnNames; logical_types_t columnTypes; getRelColumnNamesInCopyOrder(info->tableSchema, columnNames, columnTypes); - auto columnPositions = getColumnDataPositions(columnNames, - info->payloads, *outFSchema); + auto columnPositions = getColumnDataPositions(columnNames, info->payloads, *outFSchema); infos.push_back(std::make_unique(keyPos, columnPositions, std::move(columnTypes), PartitionerFunctions::partitionRelData)); } diff --git a/src/processor/map/map_partitioner.cpp b/src/processor/map/map_partitioner.cpp deleted file mode 100644 index 1d80759344..0000000000 --- a/src/processor/map/map_partitioner.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// -//#include "processor/plan_mapper.h" -// -// using namespace kuzu::planner; -// -// namespace kuzu { -// namespace processor { -// -// -// -//} // namespace processor -//} // namespace kuzu diff --git a/test/test_files/copy/copy_partial_column.test b/test/test_files/copy/copy_partial_column.test index 5126563f8b..b1d4ac7eff 100644 --- a/test/test_files/copy/copy_partial_column.test +++ b/test/test_files/copy/copy_partial_column.test @@ -34,9 +34,18 @@ 4|1946-08-25 19:07:22||2021-06-30|10 years 5 months 13:00:00.000024|[2huh9y89fsfw23,23nsihufhw723]|{locations: ['paris'], transfer: {day: 2000-01-01, amount: [20,5000]}} cool stuff found|1946-08-25 19:07:22||1950-05-14|00:23:00|[fwehu9h9832wewew,23u9h989sdfsss]|{locations: ['paris'], transfer: {day: 2011-05-01, amount: [2000,5340]}} matthew perry|2012-12-11 20:07:22||1950-05-14|20 years 30 days 48:00:00|[fwh9y81232uisuiehuf,ewnuihxy8dyf232]|{locations: ['vancouver'], transfer: {day: 2020-01-01, amount: [120,50]}} +-STATEMENT CREATE REL TABLE knows3 (FROM person TO person, a INT16, notes UNION(firstmet DATE, type INT16, comment STRING), + meetTime TIMESTAMP,nullDouble DOUBLE, date DATE, validInterval INTERVAL, comments STRING[], + summary STRUCT(locations STRING[], transfer STRUCT(day DATE, amount INT64[])), MANY_MANY); +---- ok +-STATEMENT COPY knows3 (meetTime, date, validInterval, comments, summary) FROM "${KUZU_ROOT_DIRECTORY}/dataset/tinysnb/eKnows.csv" ; +---- error +Binder exception: Number of columns mismatch. Expected 7 but got 8. +-STATEMENT COPY knows3 (meetTime, date, validInterval, comments, summary, dummy) FROM "${KUZU_ROOT_DIRECTORY}/dataset/tinysnb/eKnows.csv" ; +---- error +Binder exception: Table knows3 does not contain column dummy. -CASE NodePartialColumnsTest --SKIP -LOG AllPartialColumns -STATEMENT CREATE NODE TABLE tableOfTypes2 (id INT64, int64Column INT64, doubleColumn DOUBLE, booleanColumn BOOLEAN, dateColumn DATE, timestampColumn TIMESTAMP, stringColumn STRING,