Skip to content

Commit

Permalink
Make property case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Aug 8, 2024
1 parent 6ab3e4b commit b7b603f
Show file tree
Hide file tree
Showing 81 changed files with 3,078 additions and 3,052 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ add_subdirectory(third_party)
if(${BUILD_KUZU})
add_definitions(-DKUZU_ROOT_DIRECTORY="${PROJECT_SOURCE_DIR}")
add_definitions(-DKUZU_CMAKE_VERSION="${CMAKE_PROJECT_VERSION}")
add_definitions(-DKUZU_EXTENSION_VERSION="0.5.1.3")
add_definitions(-DKUZU_EXTENSION_VERSION="0.5.1.4")

include_directories(src/include)

Expand Down
26 changes: 13 additions & 13 deletions extension/duckdb/src/duckdb_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ void DuckDBCatalog::createForeignTable(duckdb::Connection& con, const std::strin
BoundExtraCreateDuckDBTableInfo*>(info->extraInfo.get());
std::vector<common::LogicalType> columnTypes;
std::vector<std::string> columnNames;
for (auto& propertyInfo : extraInfo->propertyInfos) {
columnNames.push_back(propertyInfo.name);
columnTypes.push_back(propertyInfo.type.copy());
for (auto& definition : extraInfo->propertyDefinitions) {
columnNames.push_back(definition.getName());
columnTypes.push_back(definition.getType().copy());
}
DuckDBScanBindData bindData(getQuery(*info), std::move(columnTypes), std::move(columnNames),
std::bind(&DuckDBCatalog::getConnection, this, dbPath));
auto tableEntry = std::make_unique<catalog::DuckDBTableCatalogEntry>(tables.get(),
info->tableName, tableID, getScanFunction(std::move(bindData)));
for (auto& propertyInfo : extraInfo->propertyInfos) {
tableEntry->addProperty(propertyInfo.name, propertyInfo.type.copy(),
propertyInfo.defaultValue->copy());
for (auto& definition : extraInfo->propertyDefinitions) {
tableEntry->addProperty(definition);
}
tables->createEntry(&transaction::DUMMY_TRANSACTION, std::move(tableEntry));
}
Expand Down Expand Up @@ -116,17 +115,18 @@ static bool getTableInfo(duckdb::Connection& con, const std::string& tableName,
}

// TODO(Ziyi): Do u need to pass in `catalogName` here? Why not use the private field?
bool DuckDBCatalog::bindPropertyInfos(duckdb::Connection& con, const std::string& tableName,
const std::string& catalogName, std::vector<binder::PropertyInfo>& propertyInfos) {
bool DuckDBCatalog::bindPropertyDefinitions(duckdb::Connection& con, const std::string& tableName,
const std::string& catalogName, std::vector<binder::PropertyDefinition>& propertyDefinitions) {
std::vector<common::LogicalType> columnTypes;
std::vector<std::string> columnNames;
if (!getTableInfo(con, tableName, getDefaultSchemaName(), catalogName, columnTypes, columnNames,
skipUnsupportedTable)) {
return false;
}
for (auto i = 0u; i < columnNames.size(); i++) {
auto propertyInfo = binder::PropertyInfo(columnNames[i], columnTypes[i].copy());
propertyInfos.push_back(std::move(propertyInfo));
auto columnDefinition = binder::ColumnDefinition(columnNames[i], columnTypes[i].copy());
auto propertyDefinition = binder::PropertyDefinition(std::move(columnDefinition));
propertyDefinitions.push_back(std::move(propertyDefinition));
}
return true;
}
Expand All @@ -135,14 +135,14 @@ bool DuckDBCatalog::bindPropertyInfos(duckdb::Connection& con, const std::string
std::unique_ptr<binder::BoundCreateTableInfo> DuckDBCatalog::bindCreateTableInfo(
duckdb::Connection& con, const std::string& tableName, const std::string& dbPath,
const std::string& catalogName) {
std::vector<binder::PropertyInfo> propertyInfos;
if (!bindPropertyInfos(con, tableName, catalogName, propertyInfos)) {
std::vector<binder::PropertyDefinition> propertyDefinitions;
if (!bindPropertyDefinitions(con, tableName, catalogName, propertyDefinitions)) {
return nullptr;
}
return std::make_unique<binder::BoundCreateTableInfo>(common::TableType::FOREIGN, tableName,
common::ConflictAction::ON_CONFLICT_THROW,
std::make_unique<duckdb_extension::BoundExtraCreateDuckDBTableInfo>(dbPath, catalogName,
getDefaultSchemaName(), std::move(propertyInfos)));
getDefaultSchemaName(), std::move(propertyDefinitions)));
}

std::string DuckDBCatalog::getDefaultSchemaName() const {
Expand Down
10 changes: 5 additions & 5 deletions extension/duckdb/src/include/duckdb_catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ struct BoundExtraCreateDuckDBTableInfo : public binder::BoundExtraCreateTableInf
std::string schemaName;

BoundExtraCreateDuckDBTableInfo(std::string dbPath, std::string catalogName,
std::string schemaName, std::vector<binder::PropertyInfo> propertyInfos)
: BoundExtraCreateTableInfo{std::move(propertyInfos)}, dbPath{std::move(dbPath)},
std::string schemaName, std::vector<binder::PropertyDefinition> propertyDefinitions)
: BoundExtraCreateTableInfo{std::move(propertyDefinitions)}, dbPath{std::move(dbPath)},
catalogName{std::move(catalogName)}, schemaName{std::move(schemaName)} {}
BoundExtraCreateDuckDBTableInfo(const BoundExtraCreateDuckDBTableInfo& other)
: BoundExtraCreateTableInfo{copyVector(other.propertyInfos)}, dbPath{other.dbPath},
: BoundExtraCreateTableInfo{copyVector(other.propertyDefinitions)}, dbPath{other.dbPath},
catalogName{other.catalogName}, schemaName{other.schemaName} {}

std::unique_ptr<BoundExtraCreateCatalogEntryInfo> copy() const override {
Expand All @@ -44,8 +44,8 @@ class DuckDBCatalog : public extension::CatalogExtension {
void init() override;

protected:
bool bindPropertyInfos(duckdb::Connection& con, const std::string& tableName,
const std::string& catalogName, std::vector<binder::PropertyInfo>& propertyInfos);
bool bindPropertyDefinitions(duckdb::Connection& con, const std::string& tableName,
const std::string& catalogName, std::vector<binder::PropertyDefinition>& propertyDefinitions);

private:
virtual std::unique_ptr<binder::BoundCreateTableInfo> bindCreateTableInfo(
Expand Down
6 changes: 3 additions & 3 deletions extension/postgres/src/include/postgres_catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ struct BoundExtraCreatePostgresTableInfo final

BoundExtraCreatePostgresTableInfo(std::string pgConnectionStr, std::string dbPath,
std::string catalogName, std::string schemaName,
std::vector<binder::PropertyInfo> propertyInfos)
std::vector<binder::PropertyDefinition> propertyDefinitions)
: BoundExtraCreateDuckDBTableInfo{std::move(dbPath), std::move(catalogName),
std::move(schemaName), std::move(propertyInfos)},
std::move(schemaName), std::move(propertyDefinitions)},
pgConnectionStr{std::move(pgConnectionStr)} {}
BoundExtraCreatePostgresTableInfo(const BoundExtraCreatePostgresTableInfo& other)
: BoundExtraCreateDuckDBTableInfo{other.dbPath, other.catalogName, other.schemaName,
copyVector(other.propertyInfos)},
copyVector(other.propertyDefinitions)},
pgConnectionStr{other.pgConnectionStr} {}

std::unique_ptr<BoundExtraCreateCatalogEntryInfo> copy() const override {
Expand Down
6 changes: 3 additions & 3 deletions extension/postgres/src/postgres_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ std::string PostgresCatalog::getDefaultSchemaName() const {
std::unique_ptr<binder::BoundCreateTableInfo> PostgresCatalog::bindCreateTableInfo(
duckdb::Connection& con, const std::string& tableName, const std::string& dbPath,
const std::string& /*catalogName*/) {
std::vector<binder::PropertyInfo> propertyInfos;
if (!bindPropertyInfos(con, tableName, DEFAULT_CATALOG_NAME, propertyInfos)) {
std::vector<binder::PropertyDefinition> propertyDefinitions;
if (!bindPropertyDefinitions(con, tableName, DEFAULT_CATALOG_NAME, propertyDefinitions)) {
return nullptr;
}
auto extraCreatePostgresTableInfo = std::make_unique<BoundExtraCreatePostgresTableInfo>(dbPath,
"" /* dbPath */, DEFAULT_CATALOG_NAME, getDefaultSchemaName(), std::move(propertyInfos));
"" /* dbPath */, DEFAULT_CATALOG_NAME, getDefaultSchemaName(), std::move(propertyDefinitions));
return std::make_unique<binder::BoundCreateTableInfo>(common::TableType::FOREIGN, tableName,
common::ConflictAction::ON_CONFLICT_THROW, std::move(extraCreatePostgresTableInfo));
}
Expand Down
6 changes: 3 additions & 3 deletions extension/sqlite/src/include/sqlite_catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ struct BoundExtraCreateSqliteTableInfo final

BoundExtraCreateSqliteTableInfo(std::string pgConnectionStr, std::string dbPath,
std::string catalogName, std::string schemaName,
std::vector<binder::PropertyInfo> propertyInfos)
std::vector<binder::PropertyDefinition> propertyDefinitions)
: BoundExtraCreateDuckDBTableInfo{std::move(dbPath), std::move(catalogName),
std::move(schemaName), std::move(propertyInfos)},
std::move(schemaName), std::move(propertyDefinitions)},
pgConnectionStr{std::move(pgConnectionStr)} {}
BoundExtraCreateSqliteTableInfo(const BoundExtraCreateSqliteTableInfo& other)
: BoundExtraCreateDuckDBTableInfo{other.dbPath, other.catalogName, other.schemaName,
copyVector(other.propertyInfos)},
copyVector(other.propertyDefinitions)},
pgConnectionStr{other.pgConnectionStr} {}

std::unique_ptr<BoundExtraCreateCatalogEntryInfo> copy() const override {
Expand Down
6 changes: 3 additions & 3 deletions extension/sqlite/src/sqlite_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ std::string SqliteCatalog::getDefaultSchemaName() const {
std::unique_ptr<binder::BoundCreateTableInfo> SqliteCatalog::bindCreateTableInfo(
duckdb::Connection& con, const std::string& tableName, const std::string& dbPath,
const std::string& /*catalogName*/) {
std::vector<binder::PropertyInfo> propertyInfos;
if (!bindPropertyInfos(con, tableName, DEFAULT_CATALOG_NAME, propertyInfos)) {
std::vector<binder::PropertyDefinition> propertyDefinitions;
if (!bindPropertyDefinitions(con, tableName, DEFAULT_CATALOG_NAME, propertyDefinitions)) {
return nullptr;
}
auto extraCreateSqliteTableInfo = std::make_unique<BoundExtraCreateSqliteTableInfo>(dbPath,
"" /* dbPath */, DEFAULT_CATALOG_NAME, getDefaultSchemaName(), std::move(propertyInfos));
"" /* dbPath */, DEFAULT_CATALOG_NAME, getDefaultSchemaName(), std::move(propertyDefinitions));
return std::make_unique<binder::BoundCreateTableInfo>(common::TableType::FOREIGN, tableName,
common::ConflictAction::ON_CONFLICT_THROW, std::move(extraCreateSqliteTableInfo));
}
Expand Down
43 changes: 43 additions & 0 deletions extension/test_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
sqlite~test~test_files~sqlite.ScanSqliteTable /Users/xiyangfeng/kuzu/kuzu/extension/sqlite/test/test_files/sqlite.test
postgres~test~test_files~postgres.ScanPostgresTable /Users/xiyangfeng/kuzu/kuzu/extension/postgres/test/test_files/postgres.test
json~test~copy_to_json.TinySnbCopyToJSON /Users/xiyangfeng/kuzu/kuzu/extension/json/test/copy_to_json.test
json~test~tinysnb_json.JsonifyUnion /Users/xiyangfeng/kuzu/kuzu/extension/json/test/tinysnb_json.test
json~test~all_shortest_path_json.AllShortestPath /Users/xiyangfeng/kuzu/kuzu/extension/json/test/all_shortest_path_json.test
json~test~doc-examples.CopyFromTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/doc-examples.test
json~test~doc-examples.LoadFromTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/doc-examples.test
json~test~error.LoadFromError /Users/xiyangfeng/kuzu/kuzu/extension/json/test/error.test
json~test~example.JsonFunctionsSample /Users/xiyangfeng/kuzu/kuzu/extension/json/test/example.test
json~test~example.ExampleDoc /Users/xiyangfeng/kuzu/kuzu/extension/json/test/example.test
json~test~example.ExtractNotExistField /Users/xiyangfeng/kuzu/kuzu/extension/json/test/example.test
json~test~json_utils.JsonStructureTest2 /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.MinifyJsonTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonValidTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonStructureTest1 /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonKeysTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.ToJsonTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonContainsTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonArrayLengthTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonExtractTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~json_utils.JsonMergeTest /Users/xiyangfeng/kuzu/kuzu/extension/json/test/json_utils.test
json~test~tinysnb_all_shortest_path_json.AllShortestPath /Users/xiyangfeng/kuzu/kuzu/extension/json/test/tinysnb_all_shortest_path_json.test
json~test~scan_json.TinySNBSubset /Users/xiyangfeng/kuzu/kuzu/extension/json/test/scan_json.test
duckdb~test~test_files~duckdb.AttachDBWithoutLoadingExtension /Users/xiyangfeng/kuzu/kuzu/extension/duckdb/test/test_files/duckdb.test
duckdb~test~test_files~duckdb.ScanDuckdbDatabaseWithoutExt /Users/xiyangfeng/kuzu/kuzu/extension/duckdb/test/test_files/duckdb.test
duckdb~test~test_files~duckdb.InvalidUseDatabaseName /Users/xiyangfeng/kuzu/kuzu/extension/duckdb/test/test_files/duckdb.test
duckdb~test~test_files~duckdb.InvalidDuckDBDatabase /Users/xiyangfeng/kuzu/kuzu/extension/duckdb/test/test_files/duckdb.test
duckdb~test~test_files~duckdb.ScanDuckDBTable /Users/xiyangfeng/kuzu/kuzu/extension/duckdb/test/test_files/duckdb.test
httpfs~test~test_files~s3_glob.DISABLED_GlobS3Folder /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_glob.test
httpfs~test~test_files~s3_upload.DISABLED_UploadToS3 /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_upload.test
httpfs~test~test_files~s3_download.ScanFromDifferentAWSS3File /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_download.test
httpfs~test~test_files~s3_download.ScanFromUWS3File /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_download.test
httpfs~test~test_files~s3_download.DuplicateOption /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_download.test
httpfs~test~test_files~s3_download.S3Option /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_download.test
httpfs~test~test_files~s3_remote_database.UWS3RemoteDB /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/s3_remote_database.test
httpfs~test~test_files~http.AttachKuzuWithRelativePath /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.AttachDBWithNonEmptyWAL /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.AttachNotExistPath /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.AttachHTTPDatabase /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.ScanFromHTTPCSV /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.ScanFromHTTPS /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.CopyFromHTTPCSV /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
httpfs~test~test_files~http.ScanFromLargeFiles /Users/xiyangfeng/kuzu/kuzu/extension/httpfs/test/test_files/http.test
21 changes: 10 additions & 11 deletions scripts/antlr4/Cypher.g4
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ kU_IfNotExists
: IF SP NOT SP EXISTS ;

kU_CreateNodeTable
: CREATE SP NODE SP TABLE SP (kU_IfNotExists SP)? oC_SchemaName SP? '(' SP? kU_PropertyDefinitionsDDL SP? ( ',' SP? kU_CreateNodeConstraint ) SP? ')' ;
: CREATE SP NODE SP TABLE SP (kU_IfNotExists SP)? oC_SchemaName SP? '(' SP? kU_PropertyDefinitions SP? ( ',' SP? kU_CreateNodeConstraint ) SP? ')' ;

kU_CreateRelTable
: CREATE SP REL SP TABLE SP (kU_IfNotExists SP)? oC_SchemaName SP? '(' SP? kU_RelTableConnection SP? ( ',' SP? kU_PropertyDefinitionsDDL SP? )? ( ',' SP? oC_SymbolicName SP? )? ')' ;
: CREATE SP REL SP TABLE SP (kU_IfNotExists SP)? oC_SchemaName SP? '(' SP? kU_RelTableConnection SP? ( ',' SP? kU_PropertyDefinitions SP? )? ( ',' SP? oC_SymbolicName SP? )? ')' ;

kU_CreateRelTableGroup
: CREATE SP REL SP TABLE SP GROUP SP (kU_IfNotExists SP)? oC_SchemaName SP? '(' SP? kU_RelTableConnection ( SP? ',' SP? kU_RelTableConnection )+ SP? ( ',' SP? kU_PropertyDefinitionsDDL SP? )? ( ',' SP? oC_SymbolicName SP? )? ')' ;
: CREATE SP REL SP TABLE SP GROUP SP (kU_IfNotExists SP)? oC_SchemaName SP? '(' SP? kU_RelTableConnection ( SP? ',' SP? kU_RelTableConnection )+ SP? ( ',' SP? kU_PropertyDefinitions SP? )? ( ',' SP? oC_SymbolicName SP? )? ')' ;

kU_RelTableConnection
: FROM SP oC_SchemaName SP TO SP oC_SchemaName ;
Expand Down Expand Up @@ -379,14 +379,13 @@ kU_RenameTable
kU_RenameProperty
: RENAME SP oC_PropertyKeyName SP TO SP oC_PropertyKeyName ;

// TODO(Xiyang): Remove/rename kU_PropertyDefinitions & kU_PropertyDefinitionsDDL
kU_PropertyDefinitions : kU_PropertyDefinition ( SP? ',' SP? kU_PropertyDefinition )* ;
kU_ColumnDefinitions: kU_ColumnDefinition ( SP? ',' SP? kU_ColumnDefinition )* ;

kU_PropertyDefinition : oC_PropertyKeyName SP kU_DataType ;
kU_ColumnDefinition : oC_PropertyKeyName SP kU_DataType ;

kU_PropertyDefinitionsDDL : kU_PropertyDefinitionDDL ( SP? ',' SP? kU_PropertyDefinitionDDL )* ;
kU_PropertyDefinitions : kU_PropertyDefinition ( SP? ',' SP? kU_PropertyDefinition )* ;

kU_PropertyDefinitionDDL : oC_PropertyKeyName SP kU_DataType ( SP kU_Default )? ;
kU_PropertyDefinition : kU_ColumnDefinition ( SP kU_Default )? ;

kU_CreateNodeConstraint : PRIMARY SP KEY SP? '(' SP? oC_PropertyKeyName SP? ')' ;

Expand All @@ -395,8 +394,8 @@ DECIMAL: ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'C' | 'c' ) ( 'I' | 'i' ) ( 'M' | 'm' ) (
kU_DataType
: oC_SymbolicName
| kU_DataType kU_ListIdentifiers
| UNION SP? '(' SP? kU_PropertyDefinitions SP? ')'
| oC_SymbolicName SP? '(' SP? kU_PropertyDefinitions SP? ')'
| UNION SP? '(' SP? kU_ColumnDefinitions SP? ')'
| oC_SymbolicName SP? '(' SP? kU_ColumnDefinitions SP? ')'
| oC_SymbolicName SP? '(' SP? kU_DataType SP? ',' SP? kU_DataType SP? ')'
| DECIMAL SP? '(' SP? oC_IntegerLiteral SP? ',' SP? oC_IntegerLiteral SP? ')' ;

Expand Down Expand Up @@ -481,7 +480,7 @@ oC_ReadingClause
;

kU_LoadFrom
: LOAD ( SP WITH SP HEADERS SP? '(' SP? kU_PropertyDefinitions SP? ')' )? SP FROM SP kU_ScanSource (SP? kU_ParsingOptions)? (SP? oC_Where)? ;
: LOAD ( SP WITH SP HEADERS SP? '(' SP? kU_ColumnDefinitions SP? ')' )? SP FROM SP kU_ScanSource (SP? kU_ParsingOptions)? (SP? oC_Where)? ;

kU_InQueryCall
: ( kU_ProjectGraph SP? )? CALL SP oC_FunctionInvocation (SP? oC_Where)? ;
Expand Down
Loading

0 comments on commit b7b603f

Please sign in to comment.