Skip to content

Commit 3d4bfec

Browse files
authored
Merge pull request #822 from Altinity/feature/antalya/deltalake_alias_iceberg
2 parents ff42c3a + 414da71 commit 3d4bfec

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

src/Databases/DataLake/DataLakeConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace DataLake
88
{
99

1010
static constexpr auto DATABASE_ENGINE_NAME = "DataLakeCatalog";
11+
static constexpr auto DATABASE_ALIAS_NAME = "Iceberg";
1112
static constexpr std::string_view FILE_PATH_PREFIX = "file:/";
1213

1314
/// Some catalogs (Unity or Glue) may store not only Iceberg/DeltaLake tables but other kinds of "tables"

src/Databases/DataLake/DatabaseDataLake.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ void registerDatabaseDataLake(DatabaseFactory & factory)
572572
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Engine `{}` must have arguments", database_engine_name);
573573
}
574574

575+
if (database_engine_name == "Iceberg" && catalog_type != DatabaseDataLakeCatalogType::ICEBERG_REST)
576+
{
577+
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Engine `Iceberg` must have `rest` catalog type only");
578+
}
579+
575580
for (auto & engine_arg : engine_args)
576581
engine_arg = evaluateConstantExpressionOrIdentifierAsLiteral(engine_arg, args.context);
577582

@@ -637,6 +642,7 @@ void registerDatabaseDataLake(DatabaseFactory & factory)
637642
std::move(engine_for_tables));
638643
};
639644
factory.registerDatabase("DataLakeCatalog", create_fn, { .supports_arguments = true, .supports_settings = true });
645+
factory.registerDatabase("Iceberg", create_fn, { .supports_arguments = true, .supports_settings = true });
640646
}
641647

642648
}

src/Parsers/ASTSetQuery.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ void ASTSetQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & format,
9494
return true;
9595
}
9696

97-
if (DataLake::DATABASE_ENGINE_NAME == state.create_engine_name)
97+
if (DataLake::DATABASE_ENGINE_NAME == state.create_engine_name
98+
|| DataLake::DATABASE_ALIAS_NAME == state.create_engine_name)
9899
{
99100
if (DataLake::SETTINGS_TO_HIDE.contains(change.name))
100101
{

tests/integration/test_database_iceberg/test.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070

7171
DEFAULT_SORT_ORDER = SortOrder(SortField(source_id=2, transform=IdentityTransform()))
7272

73+
AVAILABLE_ENGINES = ["DataLakeCatalog", "Iceberg"]
74+
7375

7476
def list_namespaces():
7577
response = requests.get(f"{BASE_URL_LOCAL}/namespaces")
@@ -120,7 +122,7 @@ def generate_record():
120122

121123

122124
def create_clickhouse_iceberg_database(
123-
started_cluster, node, name, additional_settings={}
125+
started_cluster, node, name, additional_settings={}, engine='DataLakeCatalog'
124126
):
125127
settings = {
126128
"catalog_type": "rest",
@@ -134,7 +136,7 @@ def create_clickhouse_iceberg_database(
134136
f"""
135137
DROP DATABASE IF EXISTS {name};
136138
SET allow_experimental_database_iceberg=true;
137-
CREATE DATABASE {name} ENGINE = DataLakeCatalog('{BASE_URL}', 'minio', '{minio_secret_key}')
139+
CREATE DATABASE {name} ENGINE = {engine}('{BASE_URL}', 'minio', '{minio_secret_key}')
138140
SETTINGS {",".join((k+"="+repr(v) for k, v in settings.items()))}
139141
"""
140142
)
@@ -180,7 +182,8 @@ def started_cluster():
180182
cluster.shutdown()
181183

182184

183-
def test_list_tables(started_cluster):
185+
@pytest.mark.parametrize("engine", AVAILABLE_ENGINES)
186+
def test_list_tables(started_cluster, engine):
184187
node = started_cluster.instances["node1"]
185188

186189
root_namespace = f"clickhouse_{uuid.uuid4()}"
@@ -211,7 +214,7 @@ def test_list_tables(started_cluster):
211214
for namespace in [namespace_1, namespace_2]:
212215
assert len(catalog.list_tables(namespace)) == 0
213216

214-
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME)
217+
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME, engine=engine)
215218

216219
tables_list = ""
217220
for table in namespace_1_tables:
@@ -246,7 +249,8 @@ def test_list_tables(started_cluster):
246249
)
247250

248251

249-
def test_many_namespaces(started_cluster):
252+
@pytest.mark.parametrize("engine", AVAILABLE_ENGINES)
253+
def test_many_namespaces(started_cluster, engine):
250254
node = started_cluster.instances["node1"]
251255
root_namespace_1 = f"A_{uuid.uuid4()}"
252256
root_namespace_2 = f"B_{uuid.uuid4()}"
@@ -267,7 +271,7 @@ def test_many_namespaces(started_cluster):
267271
for table in tables:
268272
create_table(catalog, namespace, table)
269273

270-
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME)
274+
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME, engine=engine)
271275

272276
for namespace in namespaces:
273277
for table in tables:
@@ -279,7 +283,8 @@ def test_many_namespaces(started_cluster):
279283
)
280284

281285

282-
def test_select(started_cluster):
286+
@pytest.mark.parametrize("engine", AVAILABLE_ENGINES)
287+
def test_select(started_cluster, engine):
283288
node = started_cluster.instances["node1"]
284289

285290
test_ref = f"test_list_tables_{uuid.uuid4()}"
@@ -307,7 +312,7 @@ def test_select(started_cluster):
307312
df = pa.Table.from_pylist(data)
308313
table.append(df)
309314

310-
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME)
315+
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME, engine=engine)
311316

312317
expected = DEFAULT_CREATE_TABLE.format(CATALOG_NAME, namespace, table_name)
313318
assert expected == node.query(
@@ -319,7 +324,8 @@ def test_select(started_cluster):
319324
)
320325

321326

322-
def test_hide_sensitive_info(started_cluster):
327+
@pytest.mark.parametrize("engine", AVAILABLE_ENGINES)
328+
def test_hide_sensitive_info(started_cluster, engine):
323329
node = started_cluster.instances["node1"]
324330

325331
test_ref = f"test_hide_sensitive_info_{uuid.uuid4()}"
@@ -337,6 +343,7 @@ def test_hide_sensitive_info(started_cluster):
337343
node,
338344
CATALOG_NAME,
339345
additional_settings={"catalog_credential": "SECRET_1"},
346+
engine=engine,
340347
)
341348
assert "SECRET_1" not in node.query(f"SHOW CREATE DATABASE {CATALOG_NAME}")
342349

@@ -345,11 +352,13 @@ def test_hide_sensitive_info(started_cluster):
345352
node,
346353
CATALOG_NAME,
347354
additional_settings={"auth_header": "SECRET_2"},
355+
engine=engine,
348356
)
349357
assert "SECRET_2" not in node.query(f"SHOW CREATE DATABASE {CATALOG_NAME}")
350358

351359

352-
def test_tables_with_same_location(started_cluster):
360+
@pytest.mark.parametrize("engine", AVAILABLE_ENGINES)
361+
def test_tables_with_same_location(started_cluster, engine):
353362
node = started_cluster.instances["node1"]
354363

355364
test_ref = f"test_tables_with_same_location_{uuid.uuid4()}"
@@ -380,7 +389,7 @@ def record(key):
380389
df = pa.Table.from_pylist(data)
381390
table_2.append(df)
382391

383-
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME)
392+
create_clickhouse_iceberg_database(started_cluster, node, CATALOG_NAME, engine=engine)
384393

385394
assert 'aaa\naaa\naaa' == node.query(f"SELECT symbol FROM {CATALOG_NAME}.`{namespace}.{table_name}`").strip()
386395
assert 'bbb\nbbb\nbbb' == node.query(f"SELECT symbol FROM {CATALOG_NAME}.`{namespace}.{table_name_2}`").strip()

0 commit comments

Comments
 (0)