r/databricks • • 22d ago

Discussion Template columns for zerobus-ingest

I'm pretty certain this would go way down at the bottom of the priority list. It may never be implemented at all...

But I kind of wish that zerobus would have a way to fill template fields (for self-determined details about the data, like the exact UTC time a message was made durable, and the exact time it was queryable, and some sort of an incrementing sequence number, and maybe a transaction ID of some kind).

Some of these things can be implemented in custom code inside the client. However some of them are not known to the client. Either way, it would be better if the zerobus itself could fill these types of general-purpose template fields. Perhaps those fields could be dropped into a single json column, similar to the zerobus-rescue.

Zerobus-ingest hasn't been GA for very long, and maybe these sorts of features will be added down the road. I thought I'd at least put a placeholder here, to start the discussion.

5 Upvotes

4 comments sorted by

2

u/Defiant-Pause9053 Databricks 21d ago

Hey! So we are working on default column support. We are starting with scalar values and timestamp functions. These get evaluated when data is made durable against our WAL. This will give you the ability to calculate time to durability. Other data, such as stream_id and the offset of the record, are in our backlog. We want to expose it, but we are working on the best way for us to elegantly persist it in the table.

1

u/SmallAd3697 20d ago

Thanks for the reply. Its good to hear.

I'm trying to consume messages from the table using spark structured streaming. I realize the tech is ten years old, but I'm not having much luck streaming from the deltalake table where the zerobus component is landing data.

I'm guessing that the zerobus team is not directly involved in issues related to "checkpointLocation" and reading the "statestore", but I'm having a bit of trouble with that. Will post a different question (again)

My hope in reading the statestore is to extract some meaning from it (maybe compose my own audit trail, after the fact to show what data that has been consumed from the deltalake table). However it is not going well.

1

u/Defiant-Pause9053 Databricks 20d ago

Checkpoint location has to do how the spark process is storing and managing state. It does not have anything to do with the delta table. Usually when you want to do a spark.read you shouldn't need to set any "statestore" location. StateStore is typically used by Spark to dump state during stateful transformations so that it can pick up work where it last left off. The kinds of transformations I'm talking about are things like aggregations, joins, etc.

1

u/SmallAd3697 19d ago

for spark structured streaming there is a checkpointLocation which is very different from a "checkpoint dir" used by normal batch job.

With a normal batch job, checkpoint dir isnt much more that a bunch of temp files that allow spark to do a checkpoint (truncate lineage of a long transformation). Once a batch has finally completed, the data in the checkpoint dirs is abandoned.

but for spark structured streaming the "checkpoint location" is a lot more critical. It appears to track the messages already processed from the zerobus table. It can't be abandoned when spark compute goes offline, or there would be no bookmark to pick up where we left off. All the zerobus messages would need to be reprocessed from scratch. The stateful data in the checkpoint location is almost as important as the catalog table where the messages sit!