Skip to content

Commit

Permalink
FInished renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ediril committed Jan 15, 2025
1 parent 1be2fa3 commit 63ef6e0
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 119 deletions.
12 changes: 6 additions & 6 deletions src/iceberg_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ static unique_ptr<Catalog> IcebergCatalogAttach(StorageExtensionInfo *storage_in

// TODO: Check catalog with name actually exists!

return make_uniq<UCCatalog>(db, info.path, access_mode, credentials);
return make_uniq<IBCatalog>(db, info.path, access_mode, credentials);
}

static unique_ptr<TransactionManager> CreateTransactionManager(StorageExtensionInfo *storage_info, AttachedDatabase &db,
Catalog &catalog) {
auto &ic_catalog = catalog.Cast<UCCatalog>();
return make_uniq<UCTransactionManager>(db, ic_catalog);
auto &ic_catalog = catalog.Cast<IBCatalog>();
return make_uniq<IBTransactionManager>(db, ic_catalog);
}

class UCCatalogStorageExtension : public StorageExtension {
class IBCatalogStorageExtension : public StorageExtension {
public:
UCCatalogStorageExtension() {
IBCatalogStorageExtension() {
attach = IcebergCatalogAttach;
create_transaction_manager = CreateTransactionManager;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ static void LoadInternal(DatabaseInstance &instance) {
SetCatalogSecretParameters(secret_function);
ExtensionUtil::RegisterFunction(instance, secret_function);

config.storage_extensions["iceberg"] = make_uniq<UCCatalogStorageExtension>();
config.storage_extensions["iceberg"] = make_uniq<IBCatalogStorageExtension>();
}

void IcebergExtension::Load(DuckDB &db) {
Expand Down
4 changes: 2 additions & 2 deletions src/include/catalog_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class IBTransaction;

enum class IBTypeAnnotation { STANDARD, CAST_TO_VARCHAR, NUMERIC_AS_DOUBLE, CTID, JSONB, FIXED_LENGTH_CHAR };

struct UCType {
struct IBType {
idx_t oid = 0;
IBTypeAnnotation info = IBTypeAnnotation::STANDARD;
vector<UCType> children;
vector<IBType> children;
};

class IBUtils {
Expand Down
12 changes: 6 additions & 6 deletions src/include/storage/ic_catalog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ struct IBCredentials {
string token;
};

class UCClearCacheFunction : public TableFunction {
class IBClearCacheFunction : public TableFunction {
public:
UCClearCacheFunction();
IBClearCacheFunction();

static void ClearCacheOnSetting(ClientContext &context, SetScope scope, Value &parameter);
};

class UCCatalog : public Catalog {
class IBCatalog : public Catalog {
public:
explicit UCCatalog(AttachedDatabase &db_p, const string &internal_name, AccessMode access_mode,
explicit IBCatalog(AttachedDatabase &db_p, const string &internal_name, AccessMode access_mode,
IBCredentials credentials);
~UCCatalog();
~IBCatalog();

string internal_name;
AccessMode access_mode;
Expand Down Expand Up @@ -73,7 +73,7 @@ class UCCatalog : public Catalog {
void DropSchema(ClientContext &context, DropInfo &info) override;

private:
UCSchemaSet schemas;
IBSchemaSet schemas;
string default_schema;
};

Expand Down
4 changes: 2 additions & 2 deletions src/include/storage/ic_catalog_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class IBCatalogSet {
bool is_loaded;
};

class UCInSchemaSet : public IBCatalogSet {
class IBInSchemaSet : public IBCatalogSet {
public:
UCInSchemaSet(IBSchemaEntry &schema);
IBInSchemaSet(IBSchemaEntry &schema);

optional_ptr<CatalogEntry> CreateEntry(unique_ptr<CatalogEntry> entry) override;

Expand Down
2 changes: 1 addition & 1 deletion src/include/storage/ic_schema_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IBSchemaEntry : public SchemaCatalogEntry {
IBCatalogSet &GetCatalogSet(CatalogType type);

private:
UCTableSet tables;
IBTableSet tables;
};

} // namespace duckdb
4 changes: 2 additions & 2 deletions src/include/storage/ic_schema_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace duckdb {
struct CreateSchemaInfo;

class UCSchemaSet : public IBCatalogSet {
class IBSchemaSet : public IBCatalogSet {
public:
explicit UCSchemaSet(Catalog &catalog);
explicit IBSchemaSet(Catalog &catalog);

public:
optional_ptr<CatalogEntry> CreateSchema(ClientContext &context, CreateSchemaInfo &info);
Expand Down
14 changes: 7 additions & 7 deletions src/include/storage/ic_table_entry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

namespace duckdb {

struct UCTableInfo {
UCTableInfo() {
struct IBTableInfo {
IBTableInfo() {
create_info = make_uniq<CreateTableInfo>();
}
UCTableInfo(const string &schema, const string &table) {
IBTableInfo(const string &schema, const string &table) {
create_info = make_uniq<CreateTableInfo>(string(), schema, table);
}
UCTableInfo(const SchemaCatalogEntry &schema, const string &table) {
IBTableInfo(const SchemaCatalogEntry &schema, const string &table) {
create_info = make_uniq<CreateTableInfo>((SchemaCatalogEntry &)schema, table);
}

Expand All @@ -25,10 +25,10 @@ struct UCTableInfo {
unique_ptr<CreateTableInfo> create_info;
};

class UCTableEntry : public TableCatalogEntry {
class IBTableEntry : public TableCatalogEntry {
public:
UCTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info);
UCTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, UCTableInfo &info);
IBTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateTableInfo &info);
IBTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, IBTableInfo &info);

unique_ptr<IBAPITable> table_data;

Expand Down
10 changes: 5 additions & 5 deletions src/include/storage/ic_table_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

namespace duckdb {
struct CreateTableInfo;
class UCResult;
class IBResult;
class IBSchemaEntry;

class UCTableSet : public UCInSchemaSet {
class IBTableSet : public IBInSchemaSet {
public:
explicit UCTableSet(IBSchemaEntry &schema);
explicit IBTableSet(IBSchemaEntry &schema);

public:
optional_ptr<CatalogEntry> CreateTable(ClientContext &context, BoundCreateTableInfo &info);

static unique_ptr<UCTableInfo> GetTableInfo(ClientContext &context, IBSchemaEntry &schema,
static unique_ptr<IBTableInfo> GetTableInfo(ClientContext &context, IBSchemaEntry &schema,
const string &table_name);
optional_ptr<CatalogEntry> RefreshTable(ClientContext &context, const string &table_name);

Expand All @@ -30,7 +30,7 @@ class UCTableSet : public UCInSchemaSet {
void AlterTable(ClientContext &context, AddColumnInfo &info);
void AlterTable(ClientContext &context, RemoveColumnInfo &info);

static void AddColumn(ClientContext &context, UCResult &result, UCTableInfo &table_info, idx_t column_offset = 0);
static void AddColumn(ClientContext &context, IBResult &result, IBTableInfo &table_info, idx_t column_offset = 0);
};

} // namespace duckdb
13 changes: 5 additions & 8 deletions src/include/storage/ic_transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,28 @@
#include "duckdb/transaction/transaction.hpp"

namespace duckdb {
class UCCatalog;
class IBCatalog;
class IBSchemaEntry;
class UCTableEntry;
class IBTableEntry;

enum class UCTransactionState { TRANSACTION_NOT_YET_STARTED, TRANSACTION_STARTED, TRANSACTION_FINISHED };
enum class IBTransactionState { TRANSACTION_NOT_YET_STARTED, TRANSACTION_STARTED, TRANSACTION_FINISHED };

class IBTransaction : public Transaction {
public:
IBTransaction(UCCatalog &ic_catalog, TransactionManager &manager, ClientContext &context);
IBTransaction(IBCatalog &ic_catalog, TransactionManager &manager, ClientContext &context);
~IBTransaction() override;

void Start();
void Commit();
void Rollback();

// UCConnection &GetConnection();
// unique_ptr<UCResult> Query(const string &query);
static IBTransaction &Get(ClientContext &context, Catalog &catalog);
AccessMode GetAccessMode() const {
return access_mode;
}

private:
// UCConnection connection;
UCTransactionState transaction_state;
IBTransactionState transaction_state;
AccessMode access_mode;
};

Expand Down
6 changes: 3 additions & 3 deletions src/include/storage/ic_transaction_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace duckdb {

class UCTransactionManager : public TransactionManager {
class IBTransactionManager : public TransactionManager {
public:
UCTransactionManager(AttachedDatabase &db_p, UCCatalog &ic_catalog);
IBTransactionManager(AttachedDatabase &db_p, IBCatalog &ic_catalog);

Transaction &StartTransaction(ClientContext &context) override;
ErrorData CommitTransaction(ClientContext &context, Transaction &transaction) override;
Expand All @@ -18,7 +18,7 @@ class UCTransactionManager : public TransactionManager {
void Checkpoint(ClientContext &context, bool force = false) override;

private:
UCCatalog &ic_catalog;
IBCatalog &ic_catalog;
mutex transaction_lock;
reference_map_t<Transaction, unique_ptr<IBTransaction>> transactions;
};
Expand Down
42 changes: 21 additions & 21 deletions src/storage/ic_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

namespace duckdb {

UCCatalog::UCCatalog(AttachedDatabase &db_p, const string &internal_name, AccessMode access_mode,
IBCatalog::IBCatalog(AttachedDatabase &db_p, const string &internal_name, AccessMode access_mode,
IBCredentials credentials)
: Catalog(db_p), internal_name(internal_name), access_mode(access_mode), credentials(std::move(credentials)),
schemas(*this) {
}

UCCatalog::~UCCatalog() = default;
IBCatalog::~IBCatalog() = default;

void UCCatalog::Initialize(bool load_builtin) {
void IBCatalog::Initialize(bool load_builtin) {
}

optional_ptr<CatalogEntry> UCCatalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) {
optional_ptr<CatalogEntry> IBCatalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) {
if (info.on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT) {
DropInfo try_drop;
try_drop.type = CatalogType::SCHEMA_ENTRY;
Expand All @@ -31,15 +31,15 @@ optional_ptr<CatalogEntry> UCCatalog::CreateSchema(CatalogTransaction transactio
return schemas.CreateSchema(transaction.GetContext(), info);
}

void UCCatalog::DropSchema(ClientContext &context, DropInfo &info) {
void IBCatalog::DropSchema(ClientContext &context, DropInfo &info) {
return schemas.DropEntry(context, info);
}

void UCCatalog::ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) {
void IBCatalog::ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) {
schemas.Scan(context, [&](CatalogEntry &schema) { callback(schema.Cast<IBSchemaEntry>()); });
}

optional_ptr<SchemaCatalogEntry> UCCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
optional_ptr<SchemaCatalogEntry> IBCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
OnEntryNotFound if_not_found, QueryErrorContext error_context) {
if (schema_name == DEFAULT_SCHEMA) {
if (default_schema.empty()) {
Expand All @@ -55,17 +55,17 @@ optional_ptr<SchemaCatalogEntry> UCCatalog::GetSchema(CatalogTransaction transac
return reinterpret_cast<SchemaCatalogEntry *>(entry.get());
}

bool UCCatalog::InMemory() {
bool IBCatalog::InMemory() {
return false;
}

string UCCatalog::GetDBPath() {
string IBCatalog::GetDBPath() {
return internal_name;
}



DatabaseSize UCCatalog::GetDatabaseSize(ClientContext &context) {
DatabaseSize IBCatalog::GetDatabaseSize(ClientContext &context) {
if (default_schema.empty()) {
throw InvalidInputException("Attempting to fetch the database size - but no database was provided "
"in the connection string");
Expand All @@ -74,29 +74,29 @@ DatabaseSize UCCatalog::GetDatabaseSize(ClientContext &context) {
return size;
}

void UCCatalog::ClearCache() {
void IBCatalog::ClearCache() {
schemas.ClearEntries();
}

unique_ptr<PhysicalOperator> UCCatalog::PlanInsert(ClientContext &context, LogicalInsert &op,
unique_ptr<PhysicalOperator> IBCatalog::PlanInsert(ClientContext &context, LogicalInsert &op,
unique_ptr<PhysicalOperator> plan) {
throw NotImplementedException("UCCatalog PlanInsert");
throw NotImplementedException("IBCatalog PlanInsert");
}
unique_ptr<PhysicalOperator> UCCatalog::PlanCreateTableAs(ClientContext &context, LogicalCreateTable &op,
unique_ptr<PhysicalOperator> IBCatalog::PlanCreateTableAs(ClientContext &context, LogicalCreateTable &op,
unique_ptr<PhysicalOperator> plan) {
throw NotImplementedException("UCCatalog PlanCreateTableAs");
throw NotImplementedException("IBCatalog PlanCreateTableAs");
}
unique_ptr<PhysicalOperator> UCCatalog::PlanDelete(ClientContext &context, LogicalDelete &op,
unique_ptr<PhysicalOperator> IBCatalog::PlanDelete(ClientContext &context, LogicalDelete &op,
unique_ptr<PhysicalOperator> plan) {
throw NotImplementedException("UCCatalog PlanDelete");
throw NotImplementedException("IBCatalog PlanDelete");
}
unique_ptr<PhysicalOperator> UCCatalog::PlanUpdate(ClientContext &context, LogicalUpdate &op,
unique_ptr<PhysicalOperator> IBCatalog::PlanUpdate(ClientContext &context, LogicalUpdate &op,
unique_ptr<PhysicalOperator> plan) {
throw NotImplementedException("UCCatalog PlanUpdate");
throw NotImplementedException("IBCatalog PlanUpdate");
}
unique_ptr<LogicalOperator> UCCatalog::BindCreateIndex(Binder &binder, CreateStatement &stmt, TableCatalogEntry &table,
unique_ptr<LogicalOperator> IBCatalog::BindCreateIndex(Binder &binder, CreateStatement &stmt, TableCatalogEntry &table,
unique_ptr<LogicalOperator> plan) {
throw NotImplementedException("UCCatalog BindCreateIndex");
throw NotImplementedException("IBCatalog BindCreateIndex");
}

} // namespace duckdb
4 changes: 2 additions & 2 deletions src/storage/ic_catalog_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ void IBCatalogSet::ClearEntries() {
is_loaded = false;
}

UCInSchemaSet::UCInSchemaSet(IBSchemaEntry &schema) : IBCatalogSet(schema.ParentCatalog()), schema(schema) {
IBInSchemaSet::IBInSchemaSet(IBSchemaEntry &schema) : IBCatalogSet(schema.ParentCatalog()), schema(schema) {
}

optional_ptr<CatalogEntry> UCInSchemaSet::CreateEntry(unique_ptr<CatalogEntry> entry) {
optional_ptr<CatalogEntry> IBInSchemaSet::CreateEntry(unique_ptr<CatalogEntry> entry) {
if (!entry->internal) {
entry->internal = schema.internal;
}
Expand Down
6 changes: 3 additions & 3 deletions src/storage/ic_clear_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void ClearUCCaches(ClientContext &context) {
if (catalog.GetCatalogType() != "iceberg") {
continue;
}
catalog.Cast<UCCatalog>().ClearCache();
catalog.Cast<IBCatalog>().ClearCache();
}
}

Expand All @@ -41,10 +41,10 @@ static void ClearCacheFunction(ClientContext &context, TableFunctionInput &data_
data.finished = true;
}

void UCClearCacheFunction::ClearCacheOnSetting(ClientContext &context, SetScope scope, Value &parameter) {
void IBClearCacheFunction::ClearCacheOnSetting(ClientContext &context, SetScope scope, Value &parameter) {
ClearUCCaches(context);
}

UCClearCacheFunction::UCClearCacheFunction() : TableFunction("pc_clear_cache", {}, ClearCacheFunction, ClearCacheBind) {
IBClearCacheFunction::IBClearCacheFunction() : TableFunction("pc_clear_cache", {}, ClearCacheFunction, ClearCacheBind) {
}
} // namespace duckdb
4 changes: 2 additions & 2 deletions src/storage/ic_schema_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ optional_ptr<CatalogEntry> IBSchemaEntry::CreateFunction(CatalogTransaction tran
throw BinderException("PC databases do not support creating functions");
}

void UCUnqualifyColumnRef(ParsedExpression &expr) {
void IBUnqualifyColumnRef(ParsedExpression &expr) {
if (expr.type == ExpressionType::COLUMN_REF) {
auto &colref = expr.Cast<ColumnRefExpression>();
auto name = std::move(colref.column_names.back());
colref.column_names = {std::move(name)};
return;
}
ParsedExpressionIterator::EnumerateChildren(expr, UCUnqualifyColumnRef);
ParsedExpressionIterator::EnumerateChildren(expr, IBUnqualifyColumnRef);
}

optional_ptr<CatalogEntry> IBSchemaEntry::CreateIndex(CatalogTransaction transaction, CreateIndexInfo &info,
Expand Down
Loading

0 comments on commit 63ef6e0

Please sign in to comment.