-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement catalog cache for postgres scanner
- Loading branch information
1 parent
a0ee10e
commit 8af5da3
Showing
26 changed files
with
322 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "duckdb_catalog.h" | ||
|
||
namespace kuzu { | ||
namespace duckdb_scanner { | ||
|
||
common::table_id_t DuckDBCatalogContent::createForeignTable( | ||
const binder::BoundCreateTableInfo& info) { | ||
auto tableID = assignNextTableID(); | ||
auto extraInfo = common::ku_dynamic_cast<binder::BoundExtraCreateCatalogEntryInfo*, | ||
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); | ||
} | ||
DuckDBScanBindData bindData(common::stringFormat("SELECT * FROM {}", info.tableName), | ||
extraInfo->dbPath, std::move(columnTypes), std::move(columnNames)); | ||
auto tableEntry = std::make_unique<catalog::DuckDBTableCatalogEntry>( | ||
info.tableName, tableID, getScanFunction(std::move(bindData))); | ||
for (auto& propertyInfo : extraInfo->propertyInfos) { | ||
tableEntry->addProperty(propertyInfo.name, propertyInfo.type.copy()); | ||
} | ||
tables->createEntry(std::move(tableEntry)); | ||
return tableID; | ||
} | ||
|
||
} // namespace duckdb_scanner | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
extension/duckdb_scanner/src/duckdb_table_catalog_entry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "duckdb_table_catalog_entry.h" | ||
|
||
namespace kuzu { | ||
namespace catalog { | ||
|
||
DuckDBTableCatalogEntry::DuckDBTableCatalogEntry( | ||
std::string name, common::table_id_t tableID, function::TableFunction scanFunction) | ||
: TableCatalogEntry{CatalogEntryType::FOREIGN_TABLE_ENTRY, std::move(name), tableID}, | ||
scanFunction{std::move(scanFunction)} {} | ||
|
||
common::TableType DuckDBTableCatalogEntry::getTableType() const { | ||
return common::TableType::FOREIGN; | ||
} | ||
|
||
std::unique_ptr<CatalogEntry> DuckDBTableCatalogEntry::copy() const { | ||
return std::make_unique<DuckDBTableCatalogEntry>(*this); | ||
} | ||
|
||
} // namespace catalog | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "catalog/catalog_content.h" | ||
#include "catalog/catalog_entry/table_catalog_entry.h" | ||
#include "duckdb_scan.h" | ||
#include "duckdb_table_catalog_entry.h" | ||
|
||
namespace kuzu { | ||
namespace duckdb_scanner { | ||
|
||
struct BoundExtraCreateDuckDBTableInfo final : public binder::BoundExtraCreateTableInfo { | ||
std::string dbPath; | ||
|
||
BoundExtraCreateDuckDBTableInfo( | ||
std::string dbPath, std::vector<binder::PropertyInfo> propertyInfos) | ||
: BoundExtraCreateTableInfo{std::move(propertyInfos)}, dbPath{std::move(dbPath)} {} | ||
BoundExtraCreateDuckDBTableInfo(const BoundExtraCreateDuckDBTableInfo& other) | ||
: BoundExtraCreateTableInfo{copyVector(other.propertyInfos)}, dbPath{other.dbPath} {} | ||
|
||
std::unique_ptr<BoundExtraCreateCatalogEntryInfo> copy() const override { | ||
return std::make_unique<BoundExtraCreateDuckDBTableInfo>(*this); | ||
} | ||
}; | ||
|
||
class DuckDBCatalogContent : public catalog::CatalogContent { | ||
public: | ||
DuckDBCatalogContent() : catalog::CatalogContent{nullptr /* vfs */} {} | ||
|
||
common::table_id_t createForeignTable(const binder::BoundCreateTableInfo& info); | ||
}; | ||
|
||
} // namespace duckdb_scanner | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
extension/duckdb_scanner/src/include/duckdb_table_catalog_entry.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "catalog/catalog_entry/table_catalog_entry.h" | ||
#include "function/table_functions.h" | ||
|
||
namespace kuzu { | ||
namespace catalog { | ||
|
||
class DuckDBTableCatalogEntry final : public TableCatalogEntry { | ||
public: | ||
//===--------------------------------------------------------------------===// | ||
// constructors | ||
//===--------------------------------------------------------------------===// | ||
DuckDBTableCatalogEntry( | ||
std::string name, common::table_id_t tableID, function::TableFunction scanFunction); | ||
|
||
//===--------------------------------------------------------------------===// | ||
// getter & setter | ||
//===--------------------------------------------------------------------===// | ||
common::TableType getTableType() const override; | ||
function::TableFunction getScanFunction() override { return scanFunction; } | ||
|
||
//===--------------------------------------------------------------------===// | ||
// serialization & deserialization | ||
//===--------------------------------------------------------------------===// | ||
std::unique_ptr<CatalogEntry> copy() const override; | ||
|
||
private: | ||
function::TableFunction scanFunction; | ||
}; | ||
|
||
} // namespace catalog | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.