Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Nov 14, 2023
1 parent 1713ef7 commit 1cfed8c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 47 deletions.
6 changes: 2 additions & 4 deletions src/binder/bind/bind_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ std::unique_ptr<BoundStatement> 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<ExtraBoundCopyRelInfo>(
srcTableSchema, dstTableSchema, srcNodeID, dstNodeID, srcKey, dstKey);
auto boundCopyFromInfo = std::make_unique<BoundCopyFromInfo>(
Expand Down
5 changes: 2 additions & 3 deletions src/binder/bind/copy/bind_copy_rdf_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ std::unique_ptr<BoundStatement> Binder::bindCopyRdfRelFrom(const Statement& /*st
std::make_unique<BoundFileScanInfo>(func, std::move(bindData), columns, offset);
auto extraInfo = std::make_unique<ExtraBoundCopyRdfRelInfo>(columns[0], columns[2]);
expression_vector columnsToCopy = {columns[0], columns[2], offset, columns[1]};
auto boundCopyFromInfo =
std::make_unique<BoundCopyFromInfo>(tableSchema, std::move(boundFileScanInfo),
containsSerial, std::move(extraInfo));
auto boundCopyFromInfo = std::make_unique<BoundCopyFromInfo>(
tableSchema, std::move(boundFileScanInfo), containsSerial, std::move(extraInfo));
return std::make_unique<BoundCopyFrom>(std::move(boundCopyFromInfo));
}

Expand Down
6 changes: 0 additions & 6 deletions src/include/catalog/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<common::LogicalType> dataType)
: Property{std::move(name), std::move(dataType), common::INVALID_PROPERTY_ID,
common::INVALID_TABLE_ID} {}
Expand Down
22 changes: 10 additions & 12 deletions src/planner/plan/plan_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogicalPartitionerInfo>(extraInfo->srcOffset, payloads,
tableSchema->isSingleMultiplicityInDirection(RelDataDirection::FWD) ?
ColumnDataFormat::REGULAR :
ColumnDataFormat::CSR,
tableSchema));
infos.push_back(std::make_unique<LogicalPartitionerInfo>(extraInfo->srcOffset, payloads,
tableSchema->isSingleMultiplicityInDirection(RelDataDirection::FWD) ?
ColumnDataFormat::REGULAR :
ColumnDataFormat::CSR,
tableSchema));
// Partitioner for BWD direction rel data.
infos.push_back(
std::make_unique<LogicalPartitionerInfo>(extraInfo->dstOffset, payloads,
tableSchema->isSingleMultiplicityInDirection(RelDataDirection::BWD) ?
ColumnDataFormat::REGULAR :
ColumnDataFormat::CSR,
tableSchema));
infos.push_back(std::make_unique<LogicalPartitionerInfo>(extraInfo->dstOffset, payloads,
tableSchema->isSingleMultiplicityInDirection(RelDataDirection::BWD) ?
ColumnDataFormat::REGULAR :
ColumnDataFormat::CSR,
tableSchema));
} break;
default: {
KU_UNREACHABLE;
Expand Down
1 change: 0 additions & 1 deletion src/processor/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions src/processor/map/map_copy_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ static void getNodeColumnsInCopyOrder(
}
}

static void getRelColumnNamesInCopyOrder(TableSchema* tableSchema, std::vector<std::string>& columnNames, logical_types_t& columnTypes) {
static void getRelColumnNamesInCopyOrder(
TableSchema* tableSchema, std::vector<std::string>& columnNames, logical_types_t& columnTypes) {
columnNames.emplace_back(InternalKeyword::SRC_OFFSET);
columnNames.emplace_back(InternalKeyword::DST_OFFSET);
columnNames.emplace_back(InternalKeyword::ROW_OFFSET);
Expand All @@ -53,7 +54,6 @@ static void getRelColumnNamesInCopyOrder(TableSchema* tableSchema, std::vector<s
columnNames.push_back(properties[i]->getName());
columnTypes.push_back(properties[i]->getDataType()->copy());
}

}

static std::shared_ptr<Expression> matchColumnExpression(
Expand All @@ -68,7 +68,8 @@ static std::shared_ptr<Expression> matchColumnExpression(
return nullptr;
}

static std::vector<DataPos> getColumnDataPositions(const std::vector<std::string>& columnNames, const expression_vector& inputColumns, const Schema& fSchema) {
static std::vector<DataPos> getColumnDataPositions(const std::vector<std::string>& columnNames,
const expression_vector& inputColumns, const Schema& fSchema) {
std::vector<DataPos> columnPositions;
for (auto& columnName : columnNames) {
auto expr = matchColumnExpression(inputColumns, columnName);
Expand Down Expand Up @@ -103,14 +104,15 @@ std::unique_ptr<PhysicalOperator> PlanMapper::mapCopyNodeFrom(LogicalOperator* l
getNodeColumnsInCopyOrder(tableSchema, columnNames, columnTypes);
std::vector<std::string> 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<CopyNodeInfo>(std::move(columnPositions), nodeTable,
tableSchema->tableName, copyFromInfo->containsSerial, storageManager.compressionEnabled());
Expand Down Expand Up @@ -145,8 +147,7 @@ std::unique_ptr<PhysicalOperator> PlanMapper::mapPartitioner(LogicalOperator* lo
std::vector<std::string> 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<PartitioningInfo>(keyPos, columnPositions,
std::move(columnTypes), PartitionerFunctions::partitionRelData));
}
Expand Down
12 changes: 0 additions & 12 deletions src/processor/map/map_partitioner.cpp

This file was deleted.

11 changes: 10 additions & 1 deletion test/test_files/copy/copy_partial_column.test
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1cfed8c

Please sign in to comment.