forked from duckdb/duckdb-delta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6feb423
commit 7fb17d3
Showing
16 changed files
with
762 additions
and
8 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
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
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,79 @@ | ||
//===----------------------------------------------------------------------===// | ||
// DuckDB | ||
// | ||
// storage/delta_catalog.hpp | ||
// | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "duckdb/catalog/catalog.hpp" | ||
#include "duckdb/function/table_function.hpp" | ||
#include "duckdb/common/enums/access_mode.hpp" | ||
|
||
namespace duckdb { | ||
class DeltaSchemaEntry; | ||
|
||
struct DeltaCredentials { | ||
string endpoint; | ||
string token; | ||
|
||
// Not really part of the credentials, but required to query s3 tables | ||
string aws_region; | ||
}; | ||
|
||
class DeltaClearCacheFunction : public TableFunction { | ||
public: | ||
DeltaClearCacheFunction(); | ||
|
||
static void ClearCacheOnSetting(ClientContext &context, SetScope scope, Value ¶meter); | ||
}; | ||
|
||
class DeltaCatalog : public Catalog { | ||
public: | ||
explicit DeltaCatalog(AttachedDatabase &db_p, const string &internal_name, AccessMode access_mode); | ||
~DeltaCatalog(); | ||
|
||
string path; | ||
AccessMode access_mode; | ||
|
||
public: | ||
void Initialize(bool load_builtin) override; | ||
string GetCatalogType() override { | ||
return "delta"; | ||
} | ||
|
||
optional_ptr<CatalogEntry> CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) override; | ||
|
||
void ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) override; | ||
|
||
optional_ptr<SchemaCatalogEntry> GetSchema(CatalogTransaction transaction, const string &schema_name, | ||
OnEntryNotFound if_not_found, | ||
QueryErrorContext error_context = QueryErrorContext()) override; | ||
|
||
unique_ptr<PhysicalOperator> PlanInsert(ClientContext &context, LogicalInsert &op, | ||
unique_ptr<PhysicalOperator> plan) override; | ||
unique_ptr<PhysicalOperator> PlanCreateTableAs(ClientContext &context, LogicalCreateTable &op, | ||
unique_ptr<PhysicalOperator> plan) override; | ||
unique_ptr<PhysicalOperator> PlanDelete(ClientContext &context, LogicalDelete &op, | ||
unique_ptr<PhysicalOperator> plan) override; | ||
unique_ptr<PhysicalOperator> PlanUpdate(ClientContext &context, LogicalUpdate &op, | ||
unique_ptr<PhysicalOperator> plan) override; | ||
unique_ptr<LogicalOperator> BindCreateIndex(Binder &binder, CreateStatement &stmt, TableCatalogEntry &table, | ||
unique_ptr<LogicalOperator> plan) override; | ||
|
||
DatabaseSize GetDatabaseSize(ClientContext &context) override; | ||
|
||
bool InMemory() override; | ||
string GetDBPath() override; | ||
|
||
private: | ||
void DropSchema(ClientContext &context, DropInfo &info) override; | ||
|
||
private: | ||
unique_ptr<DeltaSchemaEntry> main_schema; | ||
string default_schema; | ||
}; | ||
|
||
} // namespace duckdb |
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,52 @@ | ||
//===----------------------------------------------------------------------===// | ||
// DuckDB | ||
// | ||
// storage/delta_schema_entry.hpp | ||
// | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp" | ||
#include "storage/delta_table_entry.hpp" | ||
|
||
#define DEFAULT_DELTA_TABLE "delta_table" | ||
|
||
namespace duckdb { | ||
class DeltaTransaction; | ||
|
||
class DeltaSchemaEntry : public SchemaCatalogEntry { | ||
public: | ||
DeltaSchemaEntry(Catalog &catalog, CreateSchemaInfo &info); | ||
~DeltaSchemaEntry() override; | ||
|
||
void LoadTable(CatalogTransaction& transaction); | ||
|
||
public: | ||
optional_ptr<CatalogEntry> CreateTable(CatalogTransaction transaction, BoundCreateTableInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateFunction(CatalogTransaction transaction, CreateFunctionInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateIndex(CatalogTransaction transaction, CreateIndexInfo &info, | ||
TableCatalogEntry &table) override; | ||
optional_ptr<CatalogEntry> CreateView(CatalogTransaction transaction, CreateViewInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateSequence(CatalogTransaction transaction, CreateSequenceInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateTableFunction(CatalogTransaction transaction, | ||
CreateTableFunctionInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateCopyFunction(CatalogTransaction transaction, | ||
CreateCopyFunctionInfo &info) override; | ||
optional_ptr<CatalogEntry> CreatePragmaFunction(CatalogTransaction transaction, | ||
CreatePragmaFunctionInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateCollation(CatalogTransaction transaction, CreateCollationInfo &info) override; | ||
optional_ptr<CatalogEntry> CreateType(CatalogTransaction transaction, CreateTypeInfo &info) override; | ||
void Alter(CatalogTransaction transaction, AlterInfo &info) override; | ||
void Scan(ClientContext &context, CatalogType type, const std::function<void(CatalogEntry &)> &callback) override; | ||
void Scan(CatalogType type, const std::function<void(CatalogEntry &)> &callback) override; | ||
void DropEntry(ClientContext &context, DropInfo &info) override; | ||
optional_ptr<CatalogEntry> GetEntry(CatalogTransaction transaction, CatalogType type, const string &name) override; | ||
|
||
private: | ||
// There is only 1 table in a delta catalog. | ||
unique_ptr<DeltaTableEntry> table; | ||
}; | ||
|
||
} // namespace duckdb |
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,35 @@ | ||
//===----------------------------------------------------------------------===// | ||
// DuckDB | ||
// | ||
// storage/delta_table_entry.hpp | ||
// | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp" | ||
#include "duckdb/parser/parsed_data/create_table_info.hpp" | ||
|
||
namespace duckdb { | ||
struct DeltaSnapshot; | ||
|
||
class DeltaTableEntry : public TableCatalogEntry { | ||
public: | ||
DeltaTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info); | ||
|
||
public: | ||
unique_ptr<BaseStatistics> GetStatistics(ClientContext &context, column_t column_id) override; | ||
|
||
TableFunction GetScanFunction(ClientContext &context, unique_ptr<FunctionData> &bind_data) override; | ||
|
||
TableStorageInfo GetStorageInfo(ClientContext &context) override; | ||
|
||
void BindUpdateConstraints(Binder &binder, LogicalGet &get, LogicalProjection &proj, LogicalUpdate &update, | ||
ClientContext &context) override; | ||
|
||
public: | ||
shared_ptr<DeltaSnapshot> snapshot; | ||
}; | ||
|
||
} // namespace duckdb |
Oops, something went wrong.