Skip to content

Commit

Permalink
Fix create compile
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Jul 13, 2023
1 parent b0c645d commit bff542e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
13 changes: 12 additions & 1 deletion src/binder/bind/bind_updating_clause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,23 @@ std::unique_ptr<BoundCreateNode> Binder::bindCreateNode(
auto primaryKey = nodeTableSchema->getPrimaryKey();
std::shared_ptr<Expression> primaryKeyExpression;
std::vector<expression_pair> setItems;
for (auto& property : catalog.getReadOnlyVersion()->getNodeProperties(nodeTableID)) {
if (collection.hasKeyVal(node, property.name)) {
setItems.emplace_back(collection.getKeyVal(node, property.name));
} else {
auto propertyExpression =
expressionBinder.bindNodePropertyExpression(*node, property.name);
auto nullExpression = expressionBinder.createNullLiteralExpression();
nullExpression = ExpressionBinder::implicitCastIfNecessary(
nullExpression, propertyExpression->dataType);
setItems.emplace_back(std::move(propertyExpression), std::move(nullExpression));
}
}
for (auto& [key, val] : collection.getKeyVals(node)) {
auto propertyExpression = static_pointer_cast<PropertyExpression>(key);
if (propertyExpression->getPropertyID(nodeTableID) == primaryKey.propertyID) {
primaryKeyExpression = val;
}
setItems.emplace_back(key, val);
}
if (nodeTableSchema->getPrimaryKey().dataType.getLogicalTypeID() != LogicalTypeID::SERIAL &&
primaryKeyExpression == nullptr) {
Expand Down
4 changes: 0 additions & 4 deletions src/catalog/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ const Property& CatalogContent::getRelProperty(
throw CatalogException("Cannot find rel property " + propertyName + ".");
}

std::vector<Property> CatalogContent::getAllNodeProperties(table_id_t tableID) const {
return nodeTableSchemas.at(tableID)->getAllNodeProperties();
}

void CatalogContent::dropTableSchema(table_id_t tableID) {
auto tableSchema = getTableSchema(tableID);
if (tableSchema->isNodeTable) {
Expand Down
6 changes: 4 additions & 2 deletions src/include/catalog/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ class CatalogContent {
const Property& getRelProperty(
common::table_id_t tableID, const std::string& propertyName) const;

std::vector<Property> getAllNodeProperties(common::table_id_t tableID) const;
inline const std::vector<Property>& getNodeProperties(common::table_id_t tableID) const {
return nodeTableSchemas.at(tableID)->getProperties();
}
inline const std::vector<Property>& getRelProperties(common::table_id_t tableID) const {
return relTableSchemas.at(tableID)->properties;
return relTableSchemas.at(tableID)->getProperties();
}
inline std::vector<common::table_id_t> getNodeTableIDs() const {
std::vector<common::table_id_t> nodeTableIDs;
Expand Down
4 changes: 1 addition & 3 deletions src/include/catalog/catalog_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct TableSchema {
return std::any_of(properties.begin(), properties.end(),
[&propertyName](const Property& property) { return property.name == propertyName; });
}

inline const std::vector<Property>& getProperties() const { return properties; }
inline void addProperty(std::string propertyName, common::LogicalType dataType) {
properties.emplace_back(
std::move(propertyName), std::move(dataType), increaseNextPropertyID(), tableID);
Expand Down Expand Up @@ -102,8 +102,6 @@ struct NodeTableSchema : TableSchema {

inline Property getPrimaryKey() const { return properties[primaryKeyPropertyID]; }

inline std::vector<Property> getAllNodeProperties() const { return properties; }

// TODO(Semih): When we support updating the schemas, we need to update this or, we need
// a more robust mechanism to keep track of which property is the primary key (e.g., store this
// information with the property). This is an idx, not an ID, so as the columns/properties of
Expand Down
2 changes: 1 addition & 1 deletion src/main/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ std::string Connection::getNodePropertyNames(const std::string& tableName) {
auto tableID = catalog->getReadOnlyVersion()->getTableID(tableName);
auto primaryKeyPropertyID =
catalog->getReadOnlyVersion()->getNodeTableSchema(tableID)->getPrimaryKey().propertyID;
for (auto& property : catalog->getReadOnlyVersion()->getAllNodeProperties(tableID)) {
for (auto& property : catalog->getReadOnlyVersion()->getNodeProperties(tableID)) {
result +=
"\t" + property.name + " " + LogicalTypeUtils::dataTypeToString(property.dataType);
result += property.propertyID == primaryKeyPropertyID ? "(PRIMARY KEY)\n" : "\n";
Expand Down
5 changes: 2 additions & 3 deletions src/processor/result/factorized_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,9 @@ void FactorizedTable::setOverflowColNull(
// TODO(Guodong): change this function to not use dataChunkPos in ColumnSchema.
uint64_t FactorizedTable::computeNumTuplesToAppend(
const std::vector<ValueVector*>& vectorsToAppend) const {
assert(!vectorsToAppend.empty());
auto unflatDataChunkPos = -1ul;
auto numTuplesToAppend = 0ul;
auto numTuplesToAppend = 1ul;
for (auto i = 0u; i < vectorsToAppend.size(); i++) {
// If the caller tries to append an unflat vector to a flat column in the
// factorizedTable, the factorizedTable needs to flatten that vector.
Expand All @@ -365,8 +366,6 @@ uint64_t FactorizedTable::computeNumTuplesToAppend(
}
unflatDataChunkPos = tableSchema->getColumn(i)->getDataChunkPos();
numTuplesToAppend = vectorsToAppend[i]->state->selVector->selectedSize;
} else {
numTuplesToAppend = 1;
}
}
return numTuplesToAppend;
Expand Down
2 changes: 1 addition & 1 deletion src/storage/store/node_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NodeTable::NodeTable(NodesStatisticsAndDeletedIDs* nodesStatisticsAndDeletedIDs,
std::unordered_map<common::property_id_t, std::unique_ptr<Column>> NodeTable::initializeColumns(
WAL* wal, kuzu::storage::BufferManager* bm, NodeTableSchema* nodeTableSchema) {
std::unordered_map<common::property_id_t, std::unique_ptr<Column>> propertyColumns;
for (auto& property : nodeTableSchema->getAllNodeProperties()) {
for (auto& property : nodeTableSchema->getProperties()) {
propertyColumns[property.propertyID] = ColumnFactory::getColumn(
StorageUtils::getNodePropertyColumnStructureIDAndFName(wal->getDirectory(), property),
property.dataType, bm, wal);
Expand Down
6 changes: 3 additions & 3 deletions test/test_files/tck/match/match1.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Binder exception: No node table exists in database.

# Matching nodes using multiple labels
-CASE Scenario3
-SKIP
-STATEMENT CREATE NODE TABLE A(ID SERIAL, PRIMARY KEY(ID));
---- ok
-STATEMENT CREATE NODE TABLE B(ID SERIAL, PRIMARY KEY(ID));
Expand All @@ -34,8 +33,9 @@ Binder exception: No node table exists in database.
-STATEMENT CREATE (:A), (:B), (:C);
---- ok
-STATEMENT MATCH (a:A:B) RETURN a;
---- 1
1
---- 2
{_ID: 0:0, _LABEL: A, ID: 0}
{_ID: 1:0, _LABEL: B, ID: 0}

# Simple node inlnie property predicate
-CASE Scenario4
Expand Down

0 comments on commit bff542e

Please sign in to comment.