diff --git a/doc/user/data/examples/ingest_data/postgres/create_source_cloud.yml b/doc/user/data/examples/ingest_data/postgres/create_source_cloud.yml index 11ee30372f654..671f3b602db40 100644 --- a/doc/user/data/examples/ingest_data/postgres/create_source_cloud.yml +++ b/doc/user/data/examples/ingest_data/postgres/create_source_cloud.yml @@ -1,21 +1,56 @@ - name: "create-source" description: | + + + {{< tabs >}} + + {{< tab "Legacy Syntax">}} + Once you have created the connection, you can use the connection in the - [`CREATE SOURCE`](/sql/create-source/) command to connect to your PostgreSQL - instance and start ingesting data from the publication you created - [earlier](#2-create-a-publication-and-a-replication-user): + [`CREATE SOURCE`](/sql/create-source/postgres/) command to connect to your + PostgreSQL instance and start ingesting data from the publication you + created [earlier](#2-create-a-publication-and-a-replication-user): - code: | + ```mzsql CREATE SOURCE mz_source IN CLUSTER ingest_postgres FROM POSTGRES CONNECTION pg_connection (PUBLICATION 'mz_source') FOR ALL TABLES; + ``` -- name: "create-source-options" - description: | - By default, the source will be created in the active cluster; to use a different cluster, use the `IN CLUSTER` clause. - To ingest data from specific schemas or tables, use the `FOR SCHEMAS (,)` or `FOR TABLES (, )` options instead of `FOR ALL TABLES`. - - To handle [unsupported data types](#supported-types), use the `TEXT COLUMNS` or `EXCLUDE COLUMNS` options. + - To handle [unsupported data types](#supported-types), use the `TEXT + COLUMNS` or `EXCLUDE COLUMNS` options in the `CREATE SOURCE` statement. + + {{< /tab >}} + {{< tab "New Syntax">}} + + Once you have created the connection, you can: + - use the connection in the [`CREATE SOURCE`](/sql/create-source/postgres/) + command to connect to your PostgreSQL instance and + - use the source in the [`CREATE TABLE`](/sql/create-table/) to create the + tables in Materialize and start ingesting data from the publication you + created [earlier](#2-create-a-publication-and-a-replication-user): + + ```mzsql + -- Step 1: Create the source + CREATE SOURCE mz_source + IN CLUSTER ingest_postgres + FROM POSTGRES CONNECTION pg_connection (PUBLICATION 'mz_source'); + + -- Step 2: Create tables from the source + CREATE TABLE table1 FROM SOURCE mz_source (REFERENCE table1); + CREATE TABLE table2 FROM SOURCE mz_source (REFERENCE table2); + ``` + + - By default, the source will be created in the active cluster; to use a different cluster, use the `IN CLUSTER` clause. + - After creating the source, you can query `mz_internal.mz_source_references` to see available tables in the publication. + - Create individual tables using [`CREATE TABLE FROM SOURCE (REFERENCE )`](/sql/create-table/). + - To handle [unsupported data types](#supported-types), use `WITH (TEXT COLUMNS = [])` or `WITH (EXCLUDE COLUMNS = [])` in the [`CREATE TABLE`](/sql/create-table/) statement. + + {{< /tab >}} + {{< /tabs >}} - name: "schema-changes" description: |