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

Support otfMetadata in Kinesis firehose response metadata for iceberg table routing #576

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion events/firehose.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
KinesisFirehoseTransformedStateProcessingFailed = "ProcessingFailed"
)

// Constants used for otf operation for the record
const (
KinesisFirehoseOtfOperationInsert = "insert"

Check failure on line 30 in events/firehose.go

View workflow job for this annotation

GitHub Actions / run golangci-golint on the project

ST1003: const KinesisFirehoseOtfOperationInsert should be KinesisFirehoseOTFOperationInsert (stylecheck)
KinesisFirehoseOtfOperationUpdate = "update"

Check failure on line 31 in events/firehose.go

View workflow job for this annotation

GitHub Actions / run golangci-golint on the project

ST1003: const KinesisFirehoseOtfOperationUpdate should be KinesisFirehoseOTFOperationUpdate (stylecheck)
KinesisFirehoseOtfOperationDelete = "delete"

Check failure on line 32 in events/firehose.go

View workflow job for this annotation

GitHub Actions / run golangci-golint on the project

ST1003: const KinesisFirehoseOtfOperationDelete should be KinesisFirehoseOTFOperationDelete (stylecheck)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected type KinesisFirehoseOTFOperation string, like is done elsewhere for similar enum-likes in other events

)

type KinesisFirehoseResponse struct {
Records []KinesisFirehoseResponseRecord `json:"records"`
}
Expand All @@ -37,7 +44,14 @@
}

type KinesisFirehoseResponseRecordMetadata struct {
PartitionKeys map[string]string `json:"partitionKeys"`
PartitionKeys map[string]string `json:"partitionKeys"`
OTFMetadata KinesisFirehoseResponseOTFMetadata `json:"otfMetadata"`
}

type KinesisFirehoseResponseOTFMetadata struct {
DestinationTableName string `json:"destinationTableName"`
DestinationDatabaseName string `json:"destinationDatabaseName"`
Operation string `json:"operation"`
}

type KinesisFirehoseRecordMetadata struct {
Expand Down
19 changes: 17 additions & 2 deletions events/testdata/kinesis-firehose-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@
"recordId": "record1",
"result": "TRANSFORMED_STATE_OK",
"metadata": {
"partitionKeys": {}
"partitionKeys": {},
"otfMetadata": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does Firehose handle metadata with empty strings? Will this cause an error? IE, if I want to transform but not route, what happens?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without knowing Firehose's behavior, it'd be prudent to add 'omitempty' to the new struct tag

"destinationTableName": "",
"destinationDatabaseName": "",
"operation": ""
}
}
},
{
"data": "SGVsbG8gV29ybGQ=",
"recordId": "record2",
"result": "TRANSFORMED_STATE_DROPPED",
"metadata": {
"partitionKeys": {}
"partitionKeys": {},
"otfMetadata": {
"destinationTableName": "",
"destinationDatabaseName": "",
"operation": ""
}
}
},
{
Expand All @@ -24,6 +34,11 @@
"partitionKeys": {
"iamKey1": "iamValue1",
"iamKey2": "iamValue2"
},
"otfMetadata": {
"destinationTableName": "",
"destinationDatabaseName": "",
"operation": ""
}
}
}
Expand Down
Loading