Skip to content

Commit abf85a9

Browse files
committed
Add upstream mysql and postgres table names
PR change requests
1 parent b9bf9ea commit abf85a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1832
-278
lines changed

compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
- --system-parameter-default=max_clusters=100
2020
- --system-parameter-default=max_sources=100
2121
- --system-parameter-default=max_aws_privatelink_connections=10
22+
- --system-parameter-default=enable_create_table_from_source=on
2223
- --all-features
2324
environment:
2425
MZ_NO_TELEMETRY: 1
@@ -48,6 +49,7 @@ services:
4849
- --system-parameter-default=max_sources=100
4950
- --system-parameter-default=max_aws_privatelink_connections=10
5051
- --system-parameter-default=transaction_isolation=serializable
52+
- --system-parameter-default=enable_create_table_from_source=on
5153
- --all-features
5254
environment:
5355
MZ_NO_TELEMETRY: 1

docs/data-sources/source_reference.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "materialize_source_reference Data Source - terraform-provider-materialize"
4+
subcategory: ""
5+
description: |-
6+
The materialize_source_reference data source retrieves a list of available upstream references for a given Materialize source. These references represent potential tables that can be created based on the source, but they do not necessarily indicate references the source is already ingesting. This allows users to see all upstream data that could be materialized into tables.
7+
---
8+
9+
# materialize_source_reference (Data Source)
10+
11+
The `materialize_source_reference` data source retrieves a list of *available* upstream references for a given Materialize source. These references represent potential tables that can be created based on the source, but they do not necessarily indicate references the source is already ingesting. This allows users to see all upstream data that could be materialized into tables.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "materialize_source_reference" "source_references" {
17+
source_id = materialize_source_mysql.test.id
18+
}
19+
20+
output "source_references" {
21+
value = data.materialize_source_reference.my_source_references.references
22+
}
23+
```
24+
25+
<!-- schema generated by tfplugindocs -->
26+
## Schema
27+
28+
### Required
29+
30+
- `source_id` (String) The ID of the source to get references for
31+
32+
### Optional
33+
34+
- `region` (String) The region in which the resource is located.
35+
36+
### Read-Only
37+
38+
- `id` (String) The ID of this resource.
39+
- `references` (List of Object) The source references (see [below for nested schema](#nestedatt--references))
40+
41+
<a id="nestedatt--references"></a>
42+
### Nested Schema for `references`
43+
44+
Read-Only:
45+
46+
- `columns` (List of String)
47+
- `name` (String)
48+
- `namespace` (String)
49+
- `source_database_name` (String)
50+
- `source_name` (String)
51+
- `source_schema_name` (String)
52+
- `source_type` (String)
53+
- `updated_at` (String)

docs/guides/materialize_source_table.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
# Source versioning: migrating to `materialize_source_table_{source}` Resource
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
# template file: templates/guides/materialize_source_table.md.tmpl
4+
page_title: "Source Table Migration Guide"
5+
subcategory: ""
6+
description: |-
7+
Guide for migrating to the new materialize_source_table_{source_type} resources.
8+
---
9+
10+
# Source versioning: migrating to `materialize_source_table_{source_type}` Resource
211

312
In previous versions of the Materialize Terraform provider, source tables were defined within the source resource itself and were considered subsources of the source rather than separate entities.
413

5-
This guide will walk you through the process of migrating your existing source table definitions to the new `materialize_source_table_{source}` resource.
14+
This guide will walk you through the process of migrating your existing source table definitions to the new `materialize_source_table_{source_type}` resource.
615

7-
For each source type (e.g., MySQL, Postgres, etc.), you will need to create a new `materialize_source_table_{source}` resource for each table that was previously defined within the source resource. This ensures that the tables are preserved during the migration process. For Kafka sources, you will need to create at least one `materialize_source_table_kafka` table to hold data for the kafka topic.
16+
For each MySQL and Postgres source, you will need to create a new `materialize_source_table_{source_type}` resource for each table that was previously defined within the source resource. This ensures that the tables are preserved during the migration process. For Kafka sources, you will need to create a `materialize_source_table_kafka` table with the same name as the kafka source to contain the data for the kafka topic.
817

918
## Old Approach
1019

@@ -54,15 +63,15 @@ resource "materialize_source_kafka" "example_source_kafka_format_text" {
5463

5564
## New Approach
5665

57-
The new approach separates source definitions and table definitions. You will now create the source without specifying the tables, and then define each table using the `materialize_source_table_{source}` resource.
66+
The new approach separates source definitions and table definitions. You will now create the source without specifying the tables, and then define each table using the `materialize_source_table_{source_type}` resource.
5867

5968
## Manual Migration Process
6069

61-
This manual migration process requires users to create new source tables using the new `materialize_source_table_{source}` resource and then remove the old ones. We'll cover examples for both MySQL and Kafka sources.
70+
This manual migration process requires users to create new source tables using the new `materialize_source_table_{source_type}` resource and then remove the old ones. We'll cover examples for both MySQL and Kafka sources.
6271

63-
### Step 1: Define `materialize_source_table_{source}` Resources
72+
### Step 1: Define `materialize_source_table_{source_type}` Resources
6473

65-
Before making any changes to your existing source resources, create new `materialize_source_table_{source}` resources for each table that is currently defined within your sources.
74+
Before making any changes to your existing source resources, create new `materialize_source_table_{source_type}` resources for each table that is currently defined within your sources.
6675

6776
#### MySQL Example:
6877

@@ -109,11 +118,11 @@ resource "materialize_source_table_kafka" "kafka_table_from_source" {
109118

110119
### Step 2: Apply the Changes
111120

112-
Run `terraform plan` and `terraform apply` to create the new `materialize_source_table_{source}` resources.
121+
Run `terraform plan` and `terraform apply` to create the new `materialize_source_table_{source_type}` resources.
113122

114123
### Step 3: Remove Table Blocks from Source Resources
115124

116-
Once the new `materialize_source_table_{source}` resources are successfully created, remove all the deprecated and table-specific attributes from your source resources.
125+
Once the new `materialize_source_table_{source_type}` resources are successfully created, remove all the deprecated and table-specific attributes from your source resources.
117126

118127
#### MySQL Example:
119128

@@ -167,9 +176,7 @@ resource "materialize_source_kafka" "kafka_source" {
167176
}
168177
```
169178

170-
In the `lifecycle` block, add the `ignore_changes` meta-argument to prevent Terraform from trying to update these attributes during subsequent applies, that way Terraform won't try to update these values based on incomplete information from the state as they will no longer be defined in the source resource itself but in the new `materialize_source_table_{source}` resources.
171-
172-
> Note: We will make the changes to those attributes a no-op, so the `ignore_changes` block will not be necessary.
179+
In the `lifecycle` block, add the `ignore_changes` meta-argument to prevent Terraform from trying to update these attributes during subsequent applies, that way Terraform won't try to update these values based on incomplete information from the state as they will no longer be defined in the source resource itself but in the new `materialize_source_table_{source_type}` resources.
173180

174181
### Step 4: Update Terraform State
175182

@@ -179,12 +186,18 @@ After removing the `table` blocks and the table/topic specific attributes from y
179186

180187
After applying the changes, verify that your tables are still correctly set up in Materialize by checking the table definitions using Materialize's SQL commands.
181188

189+
For a more detailed view of a specific table, you can use the `SHOW CREATE TABLE` command:
190+
191+
```sql
192+
SHOW CREATE TABLE materialize.public.mysql_table1_from_source;
193+
```
194+
182195
## Importing Existing Tables
183196

184197
To import existing tables into your Terraform state, use the following command:
185198

186199
```bash
187-
terraform import materialize_source_table_{source}.table_name <region>:<table_id>
200+
terraform import materialize_source_table_{source_type}.table_name <region>:<table_id>
188201
```
189202

190203
Replace `{source}` with the appropriate source type (e.g., `mysql`, `kafka`), `<region>` with the actual region, and `<table_id>` with the table ID.
@@ -227,4 +240,4 @@ After importing, you may need to manually update these ignored attributes in you
227240

228241
## Future Improvements
229242

230-
The Kafka and Webhooks sources are currently being implemented. Once these changes, the migration process will be updated to include them.
243+
Webhooks sources have not yet been migrated to the new model. Once this changes, the migration process will be updated to include them.

docs/resources/source_kafka.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ resource "materialize_source_kafka" "example_source_kafka" {
5656
- `cluster_name` (String) The cluster to maintain this source.
5757
- `comment` (String) Comment on an object in the database.
5858
- `database_name` (String) The identifier for the source database in Materialize. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
59-
- `envelope` (Block List, Max: 1, Deprecated) How Materialize should interpret records (e.g. append-only, upsert). Deprecated: Use the new materialize_source_table_kafka resource instead. (see [below for nested schema](#nestedblock--envelope))
59+
- `envelope` (Block List, Max: 1, Deprecated) How Materialize should interpret records (e.g. append-only, upsert). Deprecated: Use the new `materialize_source_table_kafka` resource instead. (see [below for nested schema](#nestedblock--envelope))
6060
- `expose_progress` (Block List, Max: 1) The name of the progress collection for the source. If this is not specified, the collection will be named `<src_name>_progress`. (see [below for nested schema](#nestedblock--expose_progress))
6161
- `format` (Block List, Max: 1) How to decode raw bytes from different formats into data structures Materialize can understand at runtime. (see [below for nested schema](#nestedblock--format))
62-
- `include_headers` (Boolean, Deprecated) Include message headers. Deprecated: Use the new materialize_source_table_kafka resource instead.
63-
- `include_headers_alias` (String, Deprecated) Provide an alias for the headers column. Deprecated: Use the new materialize_source_table_kafka resource instead.
64-
- `include_key` (Boolean, Deprecated) Include a column containing the Kafka message key. Deprecated: Use the new materialize_source_table_kafka resource instead.
65-
- `include_key_alias` (String, Deprecated) Provide an alias for the key column. Deprecated: Use the new materialize_source_table_kafka resource instead.
66-
- `include_offset` (Boolean, Deprecated) Include an offset column containing the Kafka message offset. Deprecated: Use the new materialize_source_table_kafka resource instead.
67-
- `include_offset_alias` (String, Deprecated) Provide an alias for the offset column. Deprecated: Use the new materialize_source_table_kafka resource instead.
68-
- `include_partition` (Boolean, Deprecated) Include a partition column containing the Kafka message partition. Deprecated: Use the new materialize_source_table_kafka resource instead.
69-
- `include_partition_alias` (String, Deprecated) Provide an alias for the partition column. Deprecated: Use the new materialize_source_table_kafka resource instead.
70-
- `include_timestamp` (Boolean, Deprecated) Include a timestamp column containing the Kafka message timestamp. Deprecated: Use the new materialize_source_table_kafka resource instead.
71-
- `include_timestamp_alias` (String, Deprecated) Provide an alias for the timestamp column. Deprecated: Use the new materialize_source_table_kafka resource instead.
62+
- `include_headers` (Boolean, Deprecated) Include message headers. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
63+
- `include_headers_alias` (String, Deprecated) Provide an alias for the headers column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
64+
- `include_key` (Boolean, Deprecated) Include a column containing the Kafka message key. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
65+
- `include_key_alias` (String, Deprecated) Provide an alias for the key column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
66+
- `include_offset` (Boolean, Deprecated) Include an offset column containing the Kafka message offset. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
67+
- `include_offset_alias` (String, Deprecated) Provide an alias for the offset column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
68+
- `include_partition` (Boolean, Deprecated) Include a partition column containing the Kafka message partition. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
69+
- `include_partition_alias` (String, Deprecated) Provide an alias for the partition column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
70+
- `include_timestamp` (Boolean, Deprecated) Include a timestamp column containing the Kafka message timestamp. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
71+
- `include_timestamp_alias` (String, Deprecated) Provide an alias for the timestamp column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
7272
- `key_format` (Block List, Max: 1) Set the key format explicitly. (see [below for nested schema](#nestedblock--key_format))
7373
- `ownership_role` (String) The owernship role of the object.
7474
- `region` (String) The region to use for the resource connection. If not set, the default region is used.

docs/resources/source_mysql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ resource "materialize_source_mysql" "test" {
5353
- `comment` (String) Comment on an object in the database.
5454
- `database_name` (String) The identifier for the source database in Materialize. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
5555
- `expose_progress` (Block List, Max: 1) The name of the progress collection for the source. If this is not specified, the collection will be named `<src_name>_progress`. (see [below for nested schema](#nestedblock--expose_progress))
56-
- `ignore_columns` (List of String, Deprecated) Ignore specific columns when reading data from MySQL. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new materialize_source_table_mysql resource instead.
56+
- `ignore_columns` (List of String, Deprecated) Ignore specific columns when reading data from MySQL. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new `materialize_source_table_mysql` resource instead.
5757
- `ownership_role` (String) The owernship role of the object.
5858
- `region` (String) The region to use for the resource connection. If not set, the default region is used.
5959
- `schema_name` (String) The identifier for the source schema in Materialize. Defaults to `public`.
60-
- `table` (Block Set, Deprecated) Specify the tables to be included in the source. Deprecated: Use the new materialize_source_table_mysql resource instead. (see [below for nested schema](#nestedblock--table))
61-
- `text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain MySQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new materialize_source_table_mysql resource instead.
60+
- `table` (Block Set, Deprecated) Specify the tables to be included in the source. Deprecated: Use the new `materialize_source_table_mysql` resource instead. (see [below for nested schema](#nestedblock--table))
61+
- `text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain MySQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new `materialize_source_table_mysql` resource instead.
6262

6363
### Read-Only
6464

docs/resources/source_postgres.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ resource "materialize_source_postgres" "example_source_postgres" {
6262
- `ownership_role` (String) The owernship role of the object.
6363
- `region` (String) The region to use for the resource connection. If not set, the default region is used.
6464
- `schema_name` (String) The identifier for the source schema in Materialize. Defaults to `public`.
65-
- `table` (Block Set, Deprecated) Creates subsources for specific tables in the Postgres connection. Deprecated: Use the new materialize_source_table_postgres resource instead. (see [below for nested schema](#nestedblock--table))
66-
- `text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain PostgreSQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new materialize_source_table_postgres resource instead.
65+
- `table` (Block Set, Deprecated) Creates subsources for specific tables in the Postgres connection. Deprecated: Use the new `materialize_source_table_postgres` resource instead. (see [below for nested schema](#nestedblock--table))
66+
- `text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain PostgreSQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new `materialize_source_table_postgres` resource instead.
6767

6868
### Read-Only
6969

0 commit comments

Comments
 (0)