Skip to content

Commit 0ff5e8a

Browse files
authored
Merge pull request #991 from Altinity/backports/25.6/82301_awsglue_filter_columns_response
Antalya 25.6: Backport of ClickHouse#82301 - Filter columns in response from AWSGlue
2 parents b141e64 + 5a47bd0 commit 0ff5e8a

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/Databases/DataLake/GlueCatalog.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ void GlueCatalog::getTableMetadata(
288288
{
289289
const auto column_params = column.GetParameters();
290290
bool can_be_nullable = column_params.contains("iceberg.field.optional") && column_params.at("iceberg.field.optional") == "true";
291+
292+
/// Skip field if it's not "current" (for example Renamed). No idea how someone can utilize "non current fields" but for some reason
293+
/// they are returned by Glue API. So if you do "RENAME COLUMN a to new_a" glue will return two fields: a and new_a.
294+
/// And a will be marked as "non current" field.
295+
if (column_params.contains("iceberg.field.current") && column_params.at("iceberg.field.current") == "false")
296+
continue;
297+
291298
schema.push_back({column.GetName(), getType(column.GetType(), can_be_nullable)});
292299
}
293300
result.setSchema(schema);

tests/integration/test_database_glue/test.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,43 @@ def test_hide_sensitive_info(started_cluster):
345345
)
346346
assert "SECRET_1" not in node.query(f"SHOW CREATE DATABASE {CATALOG_NAME}")
347347
assert "SECRET_2" not in node.query(f"SHOW CREATE DATABASE {CATALOG_NAME}")
348+
349+
350+
def test_select_after_rename(started_cluster):
351+
node = started_cluster.instances["node1"]
352+
353+
test_ref = f"test_list_tables_{uuid.uuid4()}"
354+
table_name = f"{test_ref}_table"
355+
root_namespace = f"{test_ref}_namespace"
356+
357+
namespaces_to_create = [
358+
root_namespace,
359+
f"{root_namespace}_A",
360+
f"{root_namespace}_B",
361+
f"{root_namespace}_C",
362+
]
363+
364+
catalog = load_catalog_impl(started_cluster)
365+
366+
for namespace in namespaces_to_create:
367+
catalog.create_namespace(namespace)
368+
assert len(catalog.list_tables(namespace)) == 0
369+
370+
for namespace in namespaces_to_create:
371+
table = create_table(catalog, namespace, table_name)
372+
373+
num_rows = 10
374+
df = generate_arrow_data(num_rows)
375+
table.append(df)
376+
377+
create_clickhouse_glue_database(started_cluster, node, CATALOG_NAME)
378+
379+
expected = DEFAULT_CREATE_TABLE.format(CATALOG_NAME, namespace, table_name)
380+
assert expected == node.query(
381+
f"SHOW CREATE TABLE {CATALOG_NAME}.`{namespace}.{table_name}`"
382+
)
383+
384+
with table.update_schema() as update:
385+
update.rename_column("bid", "new_bid")
386+
387+
print(node.query(f"SELECT * FROM {CATALOG_NAME}.`{namespace}.{table_name}`"))

0 commit comments

Comments
 (0)