Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datalake: assign field ids to dlq record type #24966

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/v/datalake/record_multiplexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,22 @@ record_multiplexer::handle_invalid_record(
}
}

auto record_type = key_value_translator{}.build_type(std::nullopt);
if (!load_res.value().fill_registered_ids(record_type.type)) {
// This shouldn't happen because we ensured the schema with the
// call to table_creator. Probably someone managed to change the
// table between two calls.
vlog(
_log.warn,
"expected to successfully fill field IDs for record {}",
offset);
co_return writer_error::parquet_conversion_error;
}

_invalid_record_writer = std::make_unique<partitioning_writer>(
*_writer_factory,
load_res.value().schema.schema_id,
key_value_translator{}.build_type(std::nullopt).type,
std::move(record_type.type),
std::move(load_res.value().partition_spec));
}

Expand Down
20 changes: 14 additions & 6 deletions tests/rptest/tests/datalake/datalake_dlq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ def test_no_dlq_table_for_key_value_mode(self, cloud_storage_type,

@cluster(num_nodes=4)
@matrix(cloud_storage_type=supported_storage_types(),
query_engine=[QueryEngineType.SPARK, QueryEngineType.TRINO])
query_engine=[QueryEngineType.SPARK, QueryEngineType.TRINO],
filesystem_catalog_mode=[True, False])
def test_dlq_table_for_invalid_records(self, cloud_storage_type,
query_engine):
query_engine,
filesystem_catalog_mode):
"""
Produce records with no schema to `value_schema_id_prefix` mode topic.
These records will fail translate and should be written to DLQ table.
Expand All @@ -249,7 +251,7 @@ def test_dlq_table_for_invalid_records(self, cloud_storage_type,

with DatalakeServices(self.test_ctx,
redpanda=self.redpanda,
filesystem_catalog_mode=True,
filesystem_catalog_mode=filesystem_catalog_mode,
include_query_engines=[query_engine]) as dl:
dl.create_iceberg_enabled_topic(
self.topic_name, iceberg_mode="value_schema_id_prefix")
Expand Down Expand Up @@ -297,17 +299,23 @@ def test_dlq_table_for_invalid_records(self, cloud_storage_type,

@cluster(num_nodes=4)
@matrix(cloud_storage_type=supported_storage_types(),
query_engine=[QueryEngineType.SPARK, QueryEngineType.TRINO])
query_engine=[QueryEngineType.SPARK, QueryEngineType.TRINO],
filesystem_catalog_mode=[True, False])
def test_dlq_table_for_mixed_records(self, cloud_storage_type,
query_engine):
query_engine,
filesystem_catalog_mode):
"""
Produce a mix of valid and invalid records to a `value_schema_id_prefix`
mode topic. Valid records should be written to the main table and
invalid records should be written to the DLQ table.

It is important to test with both filesystem catalog mode and w/o
because their behavior in assigning field ids is different and was
found to cause translation issues.
"""
with DatalakeServices(self.test_ctx,
redpanda=self.redpanda,
filesystem_catalog_mode=True,
filesystem_catalog_mode=filesystem_catalog_mode,
include_query_engines=[query_engine]) as dl:
dl.create_iceberg_enabled_topic(
self.topic_name, iceberg_mode="value_schema_id_prefix")
Expand Down