Skip to content
Merged
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
19 changes: 9 additions & 10 deletions doc/user/content/integrations/client-libraries/golang.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ Typically, you create sources, views, and indexes when deploying Materialize, bu

```go
createSourceSQL := `
CREATE SOURCE IF NOT EXISTS counter
FROM LOAD GENERATOR COUNTER
(TICK INTERVAL '500ms');
CREATE SOURCE IF NOT EXISTS auction
FROM LOAD GENERATOR AUCTION FOR ALL TABLES;
`

_, err = conn.Exec(ctx, createSourceSQL)
Expand All @@ -123,9 +122,9 @@ For more information, see [`CREATE SOURCE`](/sql/create-source/).

```go
createViewSQL := `
CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS
SELECT sum(counter)
FROM counter;
CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS
SELECT sum(amount)
FROM bids;
`

_, err = conn.Exec(ctx, createViewSQL)
Expand All @@ -150,7 +149,7 @@ if err != nil {
}
defer tx.Rollback(ctx)

_, err = tx.Exec(ctx, "DECLARE c CURSOR FOR SUBSCRIBE counter_sum")
_, err = tx.Exec(ctx, "DECLARE c CURSOR FOR SUBSCRIBE amount_sum")
if err != nil {
log.Fatal(err)
return
Expand Down Expand Up @@ -180,7 +179,7 @@ if err != nil {
}
```

The [SUBSCRIBE output format](/sql/subscribe/#output) of `subscribeResult` contains all of the columns of `counter_sum`, prepended with several additional columns that describe the nature of the update. When a row of a subscribed view is **updated,** two objects will show up in the result set:
The [SUBSCRIBE output format](/sql/subscribe/#output) of `subscribeResult` contains all of the columns of `amount_sum`, prepended with several additional columns that describe the nature of the update. When a row of a subscribed view is **updated,** two objects will show up in the result set:

```go
{MzTimestamp:1646868332570 MzDiff:1 row...}
Expand All @@ -194,8 +193,8 @@ An `MzDiff` value of `-1` indicates that Materialize is deleting one row with th
To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS amount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
14 changes: 7 additions & 7 deletions doc/user/content/integrations/client-libraries/java-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public class App {

public void source() {

String SQL = "CREATE SOURCE counter FROM LOAD GENERATOR COUNTER;";
String SQL = "CREATE SOURCE auction FROM LOAD GENERATOR AUCTION FOR ALL TABLES;";

try (Connection conn = connect()) {
Statement st = conn.createStatement();
Expand All @@ -301,9 +301,9 @@ For more information, see [`CREATE SOURCE`](/sql/create-source/).
```java
public void view() {

String SQL = "CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS "
+ "SELECT sum(counter)"
+ "FROM counter;";
String SQL = "CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS "
+ "SELECT sum(amount)"
+ "FROM bids;";

try (Connection conn = connect()) {
Statement st = conn.createStatement();
Expand Down Expand Up @@ -358,7 +358,7 @@ public class App {

Statement stmt = conn.createStatement();
stmt.execute("BEGIN");
stmt.execute("DECLARE c CURSOR FOR SUBSCRIBE counter_sum");
stmt.execute("DECLARE c CURSOR FOR SUBSCRIBE amount_sum");
while (true) {
ResultSet rs = stmt.executeQuery("FETCH ALL c");
if(rs.next()) {
Expand Down Expand Up @@ -394,8 +394,8 @@ A `mz_diff` value of `-1` indicates that Materialize is deleting one row with th
To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS amount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
14 changes: 7 additions & 7 deletions doc/user/content/integrations/client-libraries/node-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const client = new Client({
async function main() {
await client.connect();
const res = await client.query(
`CREATE SOURCE counter FROM LOAD GENERATOR COUNTER;`
`CREATE SOURCE auction FROM LOAD GENERATOR AUCTION FOR ALL TABLES;`
);
console.log(res);
}
Expand All @@ -176,9 +176,9 @@ const client = new Client({
async function main() {
await client.connect();
const res = await client.query(
`CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS
SELECT sum(counter)
FROM counter;`
`CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS
SELECT sum(amount)
FROM bids;`
);
console.log(res);
}
Expand Down Expand Up @@ -209,7 +209,7 @@ async function main() {
await client.connect();

await client.query('BEGIN');
await client.query('DECLARE c CURSOR FOR SUBSCRIBE counter_sum WITH (SNAPSHOT = FALSE)');
await client.query('DECLARE c CURSOR FOR SUBSCRIBE amount_sum WITH (SNAPSHOT = FALSE)');

while (true) {
const res = await client.query('FETCH ALL c');
Expand Down Expand Up @@ -265,8 +265,8 @@ client.connect((err, client) => {
To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS amount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
10 changes: 5 additions & 5 deletions doc/user/content/integrations/client-libraries/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Typically, you create sources, views, and indexes when deploying Materialize, al
// Include the Postgres connection details
require 'connect.php';

$sql = "CREATE SOURCE counter FROM LOAD GENERATOR COUNTER;";
$sql = "CREATE SOURCE auction FROM LOAD GENERATOR AUCTION FOR ALL TABLES;";

$statement = $connection->prepare($sql);
$statement->execute();
Expand All @@ -139,7 +139,7 @@ For more information, see [`CREATE SOURCE`](/sql/create-source/).
// Include the Postgres connection details
require 'connect.php';

$sql = "CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS SELECT SUM(value) FROM counter;";
$sql = "CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS SELECT SUM(amount) FROM bids;";

$statement = $connection->prepare($sql);
$statement->execute();
Expand All @@ -166,7 +166,7 @@ require 'connect.php';
// Begin a transaction
$connection->beginTransaction();
// Declare a cursor
$statement = $connection->prepare('DECLARE c CURSOR FOR SUBSCRIBE counter_sum WITH (FETCH = true);');
$statement = $connection->prepare('DECLARE c CURSOR FOR SUBSCRIBE amount_sum WITH (FETCH = true);');
// Execute the statement
$statement->execute();

Expand Down Expand Up @@ -214,8 +214,8 @@ An `mz_diff` value of `-1` indicates Materialize is deleting one row with the in
To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS ammount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
16 changes: 8 additions & 8 deletions doc/user/content/integrations/client-libraries/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ conn = psycopg2.connect(dsn)
conn.autocommit = True

with conn.cursor() as cur:
cur.execute("CREATE SOURCE counter FROM LOAD GENERATOR COUNTER;")
cur.execute("CREATE SOURCE auction FROM LOAD GENERATOR AUCTION FOR ALL TABLES;")

with conn.cursor() as cur:
cur.execute("SHOW SOURCES")
Expand All @@ -141,9 +141,9 @@ conn = psycopg2.connect(dsn)
conn.autocommit = True

with conn.cursor() as cur:
cur.execute("CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS " \
"SELECT sum(counter)" \
"FROM counter;")
cur.execute("CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS " \
"SELECT sum(amount)" \
"FROM bids;")

with conn.cursor() as cur:
cur.execute("SHOW VIEWS")
Expand All @@ -168,7 +168,7 @@ dsn = "user=MATERIALIZE_USERNAME password=MATERIALIZE_PASSWORD host=MATERIALIZE_
conn = psycopg2.connect(dsn)

with conn.cursor() as cur:
cur.execute("DECLARE c CURSOR FOR SUBSCRIBE counter_sum")
cur.execute("DECLARE c CURSOR FOR SUBSCRIBE amount_sum")
while True:
cur.execute("FETCH ALL c")
for row in cur:
Expand Down Expand Up @@ -204,7 +204,7 @@ dsn = "user=MATERIALIZE_USERNAME password=MATERIALIZE_PASSWORD host=MATERIALIZE_
conn = psycopg.connect(dsn)

with conn.cursor() as cur:
for row in cur.stream("SUBSCRIBE counter_sum"):
for row in cur.stream("SUBSCRIBE amount_sum"):
print(row)
```

Expand All @@ -213,8 +213,8 @@ with conn.cursor() as cur:
To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS amount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
14 changes: 7 additions & 7 deletions doc/user/content/integrations/client-libraries/ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ conn = PG.connect(host:"MATERIALIZE_HOST", port: 6875, user: "MATERIALIZE_USERNA

# Create a source
src = conn.exec(
"CREATE SOURCE IF NOT EXISTS counter FROM LOAD GENERATOR counter;"
"CREATE SOURCE IF NOT EXISTS auction FROM LOAD GENERATOR AUCTION FOR ALL TABLES;"
);

puts src.inspect
Expand All @@ -125,9 +125,9 @@ conn = PG.connect(host:"MATERIALIZE_HOST", port: 6875, user: "MATERIALIZE_USERNA

# Create a view
view = conn.exec(
"CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS
SELECT sum(counter)
FROM counter;"
"CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS
SELECT sum(amount)
FROM bids;"
);
puts view.inspect

Expand All @@ -153,7 +153,7 @@ require 'pg'
# Locally running instance:
conn = PG.connect(host:"MATERIALIZE_HOST", port: 6875, user: "MATERIALIZE_USERNAME", password: "MATERIALIZE_PASSWORD")
conn.exec('BEGIN')
conn.exec('DECLARE c CURSOR FOR SUBSCRIBE counter_sum')
conn.exec('DECLARE c CURSOR FOR SUBSCRIBE amount_sum')

while true
conn.exec('FETCH c') do |result|
Expand Down Expand Up @@ -182,8 +182,8 @@ An `mz_diff` value of `-1` indicates Materialize is deleting one row with the in
To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS amount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
19 changes: 9 additions & 10 deletions doc/user/content/integrations/client-libraries/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ pub(crate) fn create_source() -> Result<u64, Error> {

client.execute(
"
CREATE SOURCE IF NOT EXISTS counter
FROM LOAD GENERATOR COUNTER
(TICK INTERVAL '500ms');
CREATE SOURCE IF NOT EXISTS auction
FROM LOAD GENERATOR AUCTION FOR ALL TABLES;
",
&[],
)
Expand All @@ -134,9 +133,9 @@ pub(crate) fn create_materialized_view() -> Result<u64, Error> {

client.execute(
"
CREATE MATERIALIZED VIEW IF NOT EXISTS counter_sum AS
SELECT sum(counter)
FROM counter;
CREATE MATERIALIZED VIEW IF NOT EXISTS amount_sum AS
SELECT sum(amount)
FROM bids;
",
&[],
)
Expand All @@ -153,7 +152,7 @@ use crate::connection::create_client;
pub(crate) fn subscribe() {
let mut client = create_client().expect("Error creating client.");
let mut transaction = client.transaction().expect("Error creating transaction.");
transaction.execute("DECLARE c CURSOR FOR SUBSCRIBE (SELECT sum::text FROM counter_sum) WITH (SNAPSHOT = false);", &[]).expect("Error creating cursor.");
transaction.execute("DECLARE c CURSOR FOR SUBSCRIBE (SELECT sum::text FROM amount_sum) WITH (SNAPSHOT = false);", &[]).expect("Error creating cursor.");

loop {
let results = transaction.query("FETCH ALL c;", &[]).expect("Error running fetch.");
Expand All @@ -164,15 +163,15 @@ pub(crate) fn subscribe() {
}
```

The [SUBSCRIBE output format](/sql/subscribe/#output) of the `counter_sum` view contains all of the columns of the view, prepended with several additional columns that describe the nature of the update.
The [SUBSCRIBE output format](/sql/subscribe/#output) of the `amount_sum` view contains all of the columns of the view, prepended with several additional columns that describe the nature of the update.

## Clean up

To clean up the sources, views, and tables that we created, first connect to Materialize using a [PostgreSQL client](/integrations/sql-clients/) and then, run the following commands:

```mzsql
DROP MATERIALIZED VIEW IF EXISTS counter_sum;
DROP SOURCE IF EXISTS counter;
DROP MATERIALIZED VIEW IF EXISTS amount_sum;
DROP SOURCE IF EXISTS auction CASCADE;
DROP TABLE IF EXISTS countries;
```

Expand Down
2 changes: 1 addition & 1 deletion doc/user/content/releases/v0.94.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ patch: 2
* Set subsources into an errored state in the [PostgreSQL source](/sql/create-source/postgres/)
if the corresponding table is dropped from the publication upstream.

* Add a `KEY VALUE` [load generator source](/sql/create-source/load-generator/#key-value),
* Add a `KEY VALUE` load generator source,
which produces keyed data that can be passed through to [`ENVELOPE UPSERT`](/sql/create-source/#upsert-envelope).
This is useful for internal testing.
Loading