MaterializeInc / terraform-provider-materialize

A Terraform provider for Materialize
https://registry.terraform.io/providers/MaterializeInc/materialize
Mozilla Public License 2.0
11 stars 8 forks source link

Add Support for Custom Partitioning in Kafka Sinks via `PARTITION BY` #652

Open bobbyiliev opened 1 week ago

bobbyiliev commented 1 week ago

Feature request

Materialize has recently added support for custom partitioning in Kafka sinks using the PARTITION BY clause. This allows users to partition data based on specific columns, such as customer ID, ensuring that related data (e.g., orders for the same customer) are grouped into the same partition. This is particularly useful when working with upsert semantics to retain only the latest state of each record in a Kafka topic.

Proposed Solution

resource "materialize_sink_kafka" "orders_kafka_sink" {
  name         = "orders_sink"
  kafka_connection {
    name = "kafka_connection"
  }
  topic        = "orders_topic"

  partition_by = ["customer_id"]  # New feature request

  # Additional configuration...
}

References

benesch commented 1 week ago

One quick note: PARTITION BY accepts any SQL expression, not just column names. I don’t think it changes things for you too much, as you’ll still want to take the expression as a string, but you won’t want to escape it as an identifier like you normally would.