diff --git a/.gitignore b/.gitignore index 922b355567..797590a619 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ node_modules/ *.pdf *.zshrc hs_err_pid*.log +*.interp +*.tokens +gen/ diff --git a/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/config/proxy.generated.as.yaml b/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/config/proxy.generated.as.yaml new file mode 100644 index 0000000000..0039c1f2d4 --- /dev/null +++ b/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/config/proxy.generated.as.yaml @@ -0,0 +1,36 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +--- +name: test +catalogs: + catalog0: + type: test + options: + url: http://localhost:8081 + id: 1 + schema: |- + { + "schema": "{\"fields\":[{\"name\":\"id\",\"type\":[\"null\",{\"type\":\"string\"}]},{\"name\":\"city\",\"type\":[\"null\",{\"type\":\"string\"}]},{\"name\":\"owner_id\",\"type\":[\"null\",{\"type\":\"string\"}],\"zillaType\":\"ZILLA_IDENTITY\"},{\"name\":\"created_at\",\"type\":[\"null\",{\"type\":\"long\",\"logicalType\":\"timestamp-millis\"}],\"zillaType\":\"ZILLA_TIMESTAMP\"}],\"name\":\"cities\",\"namespace\":\"public\",\"type\":\"record\"}", + "schemaType": "AVRO" + } +bindings: + app0: + type: pgsql-kafka + kind: proxy + catalog: + catalog0: + - strategy: topic + exit: app1 diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key.and.includes/client.rpt b/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/streams/pgsql/create.topic.with.generated.as/client.rpt similarity index 85% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key.and.includes/client.rpt rename to incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/streams/pgsql/create.topic.with.generated.as/client.rpt index 2bf28eebab..553b9d008a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key.and.includes/client.rpt +++ b/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/streams/pgsql/create.topic.with.generated.as/client.rpt @@ -17,6 +17,7 @@ connect "zilla://streams/app0" option zilla:window 8192 option zilla:transmission "duplex" + write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) .parameter("user", "app") @@ -32,18 +33,19 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "CREATE TABLE IF NOT EXISTS cities " - "(id VARCHAR, name VARCHAR, description VARCHAR," - " zilla_correlation_id VARCHAR, zilla_identity VARCHAR, zilla_timestamp TIMESTAMP," - " PRIMARY KEY (id));" +write "CREATE TOPIC IF NOT EXISTS cities (" + "id VARCHAR, " + "city VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id, city));" [0x00] - write flush read advised zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("CREATE_TABLE") + .tag("CREATE_TOPIC") .build() .build()} @@ -54,3 +56,5 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write close +read closed diff --git a/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/streams/pgsql/create.topic.with.generated.as/server.rpt b/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/streams/pgsql/create.topic.with.generated.as/server.rpt new file mode 100644 index 0000000000..738cfc58b8 --- /dev/null +++ b/incubator/binding-pgsql-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/kafka/streams/pgsql/create.topic.with.generated.as/server.rpt @@ -0,0 +1,61 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +accept "zilla://streams/app0" + option zilla:window 8192 + option zilla:transmission "duplex" + +accepted + +read zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "root") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "CREATE TOPIC IF NOT EXISTS cities (" + "id VARCHAR, " + "city VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id, city));" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("CREATE_TOPIC") + .build() + .build()} + +write notify CREATE_TOPIC_COMPLETED + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} +read closed +write close diff --git a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/AvroField.java b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/AvroField.java index c2d9d8c8f6..4c69b6f2b4 100644 --- a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/AvroField.java +++ b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/AvroField.java @@ -16,6 +16,7 @@ public record AvroField( String name, - Object type) + Object type, + Object zillaType) { } diff --git a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaAvroSchemaTemplate.java b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaAvroSchemaTemplate.java index e2e485c4b2..e326bfea6f 100644 --- a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaAvroSchemaTemplate.java +++ b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaAvroSchemaTemplate.java @@ -15,6 +15,7 @@ package io.aklivity.zilla.runtime.binding.pgsql.kafka.internal.schema; import java.util.List; +import java.util.Map; import jakarta.json.Json; import jakarta.json.JsonArray; @@ -25,6 +26,8 @@ import jakarta.json.bind.JsonbBuilder; import jakarta.json.bind.JsonbConfig; +import org.agrona.collections.Object2ObjectHashMap; + import io.aklivity.zilla.runtime.binding.pgsql.parser.model.AlterExpression; import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Operation; @@ -32,6 +35,16 @@ public abstract class PgsqlKafkaAvroSchemaTemplate { protected static final String DATABASE_PLACEHOLDER = "{database}"; + protected static final String ZILLA_IDENTITY = "GENERATED ALWAYS AS IDENTITY"; + protected static final String ZILLA_TIMESTAMP = "GENERATED ALWAYS AS NOW"; + + protected static final Map ZILLA_MAPPINGS = new Object2ObjectHashMap<>(); + static + { + ZILLA_MAPPINGS.put(ZILLA_IDENTITY, "ZILLA_IDENTITY"); + ZILLA_MAPPINGS.put(ZILLA_TIMESTAMP, "ZILLA_TIMESTAMP"); + } + protected Jsonb jsonbFormatted = JsonbBuilder.create(new JsonbConfig().withFormatting(true)); protected Jsonb jsonb = JsonbBuilder.create(); diff --git a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaKeyAvroSchemaTemplate.java b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaKeyAvroSchemaTemplate.java index 27e1eb01fe..a20eeebfb0 100644 --- a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaKeyAvroSchemaTemplate.java +++ b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaKeyAvroSchemaTemplate.java @@ -36,7 +36,7 @@ public String generate( final String newNamespace = namespace.replace(DATABASE_PLACEHOLDER, database); List fields = command.columns().stream() - .map(column -> new AvroField(column.name(), mapSqlTypeToAvroType(column.type()))) + .map(column -> new AvroField(column.name(), mapSqlTypeToAvroType(column.type()), null)) .collect(Collectors.toList()); AvroSchema schema = new AvroSchema("record", command.name(), newNamespace, fields); diff --git a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaValueAvroSchemaTemplate.java b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaValueAvroSchemaTemplate.java index c5290a55f0..4fed9421e9 100644 --- a/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaValueAvroSchemaTemplate.java +++ b/incubator/binding-pgsql-kafka/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/schema/PgsqlKafkaValueAvroSchemaTemplate.java @@ -49,12 +49,19 @@ public String generate( String columnName = column.name(); String sqlType = column.type(); Object avroType = mapSqlTypeToAvroType(sqlType); + List constraints = column.constraints(); - boolean isNullable = !column.constraints().contains("NOT NULL"); + boolean isNullable = !constraints.contains("NOT NULL"); + + String zillaType = ZILLA_MAPPINGS.entrySet().stream() + .filter(e -> constraints.contains(e.getKey())) + .map(Map.Entry::getValue) + .findFirst() + .orElse(null); return isNullable - ? new AvroField(columnName, new Object[]{"null", avroType}) - : new AvroField(columnName, avroType); + ? new AvroField(columnName, new Object[]{"null", avroType}, zillaType) + : new AvroField(columnName, avroType, zillaType); }) .collect(Collectors.toList()); diff --git a/incubator/binding-pgsql-kafka/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/stream/ProxyIT.java b/incubator/binding-pgsql-kafka/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/stream/ProxyIT.java index 012e16073b..b882c55408 100644 --- a/incubator/binding-pgsql-kafka/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/stream/ProxyIT.java +++ b/incubator/binding-pgsql-kafka/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/kafka/internal/stream/ProxyIT.java @@ -59,6 +59,17 @@ public void shouldCreateTopic() throws Exception k3po.finish(); } + @Test + @Configuration("proxy.generated.as.yaml") + @Specification({ + "${pgsql}/create.topic.with.generated.as/client", + "${kafka}/create.topic/server" + }) + public void shouldCreateTopicWithGeneratedAs() throws Exception + { + k3po.finish(); + } + @Test @Configuration("proxy.alter.yaml") @Specification({ diff --git a/incubator/binding-pgsql.spec/src/main/java/io/aklivity/zilla/specs/binding/pgsql/PgsqlFunctions.java b/incubator/binding-pgsql.spec/src/main/java/io/aklivity/zilla/specs/binding/pgsql/PgsqlFunctions.java index d0bea41b76..9652009034 100644 --- a/incubator/binding-pgsql.spec/src/main/java/io/aklivity/zilla/specs/binding/pgsql/PgsqlFunctions.java +++ b/incubator/binding-pgsql.spec/src/main/java/io/aklivity/zilla/specs/binding/pgsql/PgsqlFunctions.java @@ -28,6 +28,7 @@ import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlFlushExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlFormat; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlMessageType; +import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlNoticeFlushExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlQueryDataExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlReadyFlushExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlRowDataExFW; @@ -217,6 +218,13 @@ public PgsqlCompletedFlushExBuilder completion() return new PgsqlCompletedFlushExBuilder(); } + public PgsqlNoticeFlushExBuilder notice() + { + flushExRW.kind(PgsqlMessageType.NOTICE.value()); + + return new PgsqlNoticeFlushExBuilder(); + } + public PgsqlErrorFlushExBuilder error() { flushExRW.kind(PgsqlMessageType.ERROR.value()); @@ -405,6 +413,44 @@ public PgsqlFlushExBuilder build() } } + public final class PgsqlNoticeFlushExBuilder + { + private final PgsqlNoticeFlushExFW.Builder pgsqlNoticeFlushExRW = new PgsqlNoticeFlushExFW.Builder(); + + private PgsqlNoticeFlushExBuilder() + { + pgsqlNoticeFlushExRW.wrap(writeBuffer, PgsqlFlushExFW.FIELD_OFFSET_TYPE, writeBuffer.capacity()); + } + + public PgsqlNoticeFlushExBuilder severity( + String severity) + { + pgsqlNoticeFlushExRW.severity(String.format("S%s\u0000", severity)); + return this; + } + + public PgsqlNoticeFlushExBuilder code( + String code) + { + pgsqlNoticeFlushExRW.code(String.format("C%s\u0000", code)); + return this; + } + + public PgsqlNoticeFlushExBuilder message( + String message) + { + pgsqlNoticeFlushExRW.message(String.format("M%s\u0000", message)); + return this; + } + + public PgsqlFlushExBuilder build() + { + final PgsqlNoticeFlushExFW pgsqlNoticeFlushEx = pgsqlNoticeFlushExRW.build(); + flushExRO.wrap(writeBuffer, 0, pgsqlNoticeFlushEx.limit()); + return PgsqlFlushExBuilder.this; + } + } + public final class PgsqlCancelRequestFlushExBuilder { private final PgsqlCancelRequestFlushExFW.Builder pgsqlCancelREquestFlushExRW = diff --git a/incubator/binding-pgsql.spec/src/main/resources/META-INF/zilla/pgsql.idl b/incubator/binding-pgsql.spec/src/main/resources/META-INF/zilla/pgsql.idl index 0de2aaba27..843717e723 100644 --- a/incubator/binding-pgsql.spec/src/main/resources/META-INF/zilla/pgsql.idl +++ b/incubator/binding-pgsql.spec/src/main/resources/META-INF/zilla/pgsql.idl @@ -33,6 +33,7 @@ scope pgsql ROW (68), TYPE (84), COMPLETION (67), + NOTICE (78), ERROR (69), CANCEL_REQUEST (255), READY (90) @@ -60,6 +61,7 @@ scope pgsql case 84: pgsql::stream::PgsqlTypeFlushEx type; case 67: pgsql::stream::PgsqlCompletedFlushEx completion; case 69: pgsql::stream::PgsqlErrorFlushEx error; + case 78: pgsql::stream::PgsqlNoticeFlushEx notice; case 90: pgsql::stream::PgsqlReadyFlushEx ready; } @@ -103,6 +105,13 @@ scope pgsql string16 message; } + struct PgsqlNoticeFlushEx + { + string16 severity; + string16 code; + string16 message; + } + enum PgsqlStatus (uint8) { IDLE(73), diff --git a/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/application/create.view.with.notice/client.rpt b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/application/create.view.with.notice/client.rpt new file mode 100644 index 0000000000..56a6648cb5 --- /dev/null +++ b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/application/create.view.with.notice/client.rpt @@ -0,0 +1,63 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +connect "zilla://streams/app0" + option zilla:window 8192 + option zilla:transmission "duplex" + +write zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "root") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "CREATE VIEW IF NOT EXISTS cities_view AS SELECT name, created_at::timestamp FROM cities;" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .notice() + .severity("NOTICE") + .code("00000") + .message("Your session timezone is UTC.") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("CREATE_VIEW") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + +read closed +write close diff --git a/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/application/create.view.with.notice/server.rpt b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/application/create.view.with.notice/server.rpt new file mode 100644 index 0000000000..d7f06e4cd8 --- /dev/null +++ b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/application/create.view.with.notice/server.rpt @@ -0,0 +1,66 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +property serverAddress "zilla://streams/app0" + +accept ${serverAddress} + option zilla:window 8192 + option zilla:transmission "duplex" + +accepted + +read zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "root") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "CREATE VIEW IF NOT EXISTS cities_view AS SELECT name, created_at::timestamp FROM cities;" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .notice() + .severity("NOTICE") + .code("00000") + .message("Your session timezone is UTC.") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("CREATE_VIEW") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + +write close +read closed diff --git a/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/network/create.view.with.notice/client.rpt b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/network/create.view.with.notice/client.rpt new file mode 100644 index 0000000000..285a12ba44 --- /dev/null +++ b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/network/create.view.with.notice/client.rpt @@ -0,0 +1,98 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +property networkConnectWindow 8192 + +connect "zilla://streams/net0" + option zilla:window ${networkConnectWindow} + option zilla:transmission "duplex" + option zilla:byteorder "network" + +connected + +write 75 # length + 3s # major version + 0s # minor version + "user" [0x00] # name + "root" [0x00] # value + "database" [0x00] # name + "dev" [0x00] # value + "application_name" [0x00] # name + "psql" [0x00] # value + "client_encoding" [0x00] # name + "UTF8" [0x00] # value + [0x00] # end of parameters + +read [0x52] # type R + 8 # length + 0 # authentication type + +read [0x4b] # type K + 12 # length + 0 # pid + 0 # key + +read [0x53] # type S + 25 # length + "client_encoding" [0x00] # name + "UTF8" [0x00] # value + +read [0x53] # type S + 35 # length + "standard_conforming_strings" [0x00] # name + [0x6f 0x6e 0x00] # value + +read [0x53] # type S + 25 # length + "server_version" [0x00] # name + "9.1.0" [0x00] # value + +read [0x53] # type S + 27 # length + "application_name" [0x00] # name + "zilla" [0x00] # value + +read [0x5a] # type Z + 5 # length + [0x49] # status + +write [0x51] # type Q + 93 # length + "CREATE VIEW IF NOT EXISTS cities_view AS SELECT name, created_at::timestamp FROM cities;" + [0x00] # End of string + +read [0x4e] # type N + 50 # length + "SNOTICE" # severity + [0x00] # end of string + "C00000" # code + [0x00] # end of string + "MYour session timezone is UTC." # code + [0x00] # end of string + +read [0x43] # type C + 16 # length + "CREATE_VIEW" # tag + [0x00] # End of string + +read [0x5a] # type Z + 5 # length + [0x49] # status + +read [0x58] # type X + 4 # length + +read closed +write close diff --git a/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/network/create.view.with.notice/server.rpt b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/network/create.view.with.notice/server.rpt new file mode 100644 index 0000000000..da1ab2633d --- /dev/null +++ b/incubator/binding-pgsql.spec/src/main/scripts/io/aklivity/zilla/specs/binding/pgsql/streams/network/create.view.with.notice/server.rpt @@ -0,0 +1,100 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +property networkAcceptWindow 8192 + +accept "zilla://streams/net0" + option zilla:window ${networkAcceptWindow} + option zilla:transmission "duplex" + option zilla:byteorder "network" + +accepted + +connected + +read 75 # length + 3s # major version + 0s # minor version + "user" [0x00] # name + "root" [0x00] # value + "database" [0x00] # name + "dev" [0x00] # value + "application_name" [0x00] # name + "psql" [0x00] # value + "client_encoding" [0x00] # name + "UTF8" [0x00] # value + [0x00] # end of parameters + +write [0x52] # type R + 8 # length + 0 # authentication type + +write [0x4b] # type K + 12 # length + 0 # pid + 0 # key + +write [0x53] # type S + 25 # length + "client_encoding" [0x00] # name + "UTF8" [0x00] # value + +write [0x53] # type S + 35 # length + "standard_conforming_strings" [0x00] # name + [0x6f 0x6e 0x00] # value + +write [0x53] # type S + 25 # length + "server_version" [0x00] # name + "9.1.0" [0x00] # value + +write [0x53] # type S + 27 # length + "application_name" [0x00] # name + "zilla" [0x00] # value + +write [0x5a] # type Z + 5 # length + [0x49] # status + +read [0x51] # type Q + 93 # length + "CREATE VIEW IF NOT EXISTS cities_view AS SELECT name, created_at::timestamp FROM cities;" + [0x00] # End of string + +write [0x4e] # type N + 50 # length + "SNOTICE" # severity + [0x00] # end of string + "C00000" # code + [0x00] # end of string + "MYour session timezone is UTC." # code + [0x00] # end of string + +write [0x43] # type C + 16 # length + "CREATE_VIEW" # tag + [0x00] # End of string + +write [0x5a] # type Z + 5 # length + [0x49] # status + +write [0x58] # type X + 4 # length + +write close +read closed diff --git a/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/ApplicationIT.java b/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/ApplicationIT.java index 726c61118b..4874ddaf64 100644 --- a/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/ApplicationIT.java +++ b/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/ApplicationIT.java @@ -46,6 +46,16 @@ public void shouldCreateTableWithPrimaryKey() throws Exception k3po.finish(); } + @Test + @Specification({ + "${app}/create.view.with.notice/client", + "${app}/create.view.with.notice/server" + }) + public void shouldCreateViewWithNotice() throws Exception + { + k3po.finish(); + } + @Test @Specification({ "${app}/select.table/client", diff --git a/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/NetworkIT.java b/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/NetworkIT.java index 6441439911..e386a8a532 100644 --- a/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/NetworkIT.java +++ b/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/NetworkIT.java @@ -46,6 +46,16 @@ public void shouldCreateTableWithPrimaryKey() throws Exception k3po.finish(); } + @Test + @Specification({ + "${net}/create.view.with.notice/client", + "${net}/create.view.with.notice/server" + }) + public void shouldCreateViewWithNotice() throws Exception + { + k3po.finish(); + } + @Test @Specification({ "${net}/select.table/client", diff --git a/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/internal/PgsqlFunctionsTest.java b/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/internal/PgsqlFunctionsTest.java index 19fae7ba10..6deb990402 100644 --- a/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/internal/PgsqlFunctionsTest.java +++ b/incubator/binding-pgsql.spec/src/test/java/io/aklivity/zilla/specs/binding/pgsql/streams/internal/PgsqlFunctionsTest.java @@ -35,6 +35,7 @@ import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlBeginExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlDataExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlFlushExFW; +import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlNoticeFlushExFW; import io.aklivity.zilla.specs.binding.pgsql.internal.types.stream.PgsqlStatus; @@ -175,6 +176,28 @@ public void shouldEncodePgsqlFlushErrorExtension() assertEquals("Failed to run the query.\u0000", flushEx.error().message().asString()); } + @Test + public void shouldEncodePgsqlFlushNoticeExtension() + { + final byte[] build = flushEx() + .typeId(0x01) + .notice() + .severity("NOTICE") + .code("0000") + .message("Failed to run the query.") + .build() + .build(); + + DirectBuffer buffer = new UnsafeBuffer(build); + PgsqlFlushExFW flushEx = new PgsqlFlushExFW().wrap(buffer, 0, buffer.capacity()); + PgsqlNoticeFlushExFW notice = flushEx.notice(); + + assertEquals(0x01, flushEx.typeId()); + assertEquals("SNOTICE\u0000", notice.severity().asString()); + assertEquals("C0000\u0000", notice.code().asString()); + assertEquals("MFailed to run the query.\u0000", notice.message().asString()); + } + @Test public void shouldEncodePgsqlFlushCancelRequestExtension() { diff --git a/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlLexer.g4 b/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlLexer.g4 index b93a78c845..334384e3b3 100644 --- a/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlLexer.g4 +++ b/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlLexer.g4 @@ -283,6 +283,8 @@ SYMMETRIC: 'SYMMETRIC'; TABLE: 'TABLE'; +ZTABLE: 'ZTABLE'; + THEN: 'THEN'; TO: 'TO'; @@ -811,6 +813,8 @@ SYSTEM_P: 'SYSTEM'; TABLES: 'TABLES'; +ZTABLES: 'ZTABLES'; + TABLESPACE: 'TABLESPACE'; TEMP: 'TEMP'; diff --git a/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlParser.g4 b/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlParser.g4 index f394a0511a..1fe3739b0c 100644 --- a/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlParser.g4 +++ b/incubator/binding-pgsql/src/main/antlr4/io/aklivity/zilla/runtime/binding/pgsql/parser/PostgreSqlParser.g4 @@ -105,6 +105,7 @@ stmt | createschemastmt | createseqstmt | createstmt + | createztstmt | createstreamstmt | createsubscriptionstmt | createstatsstmt @@ -267,6 +268,7 @@ optschemaeltlist schema_stmt : createstmt | indexstmt + | createztstmt | createseqstmt | createtrigstmt | grantstmt @@ -402,6 +404,7 @@ discardstmt altertablestmt : ALTER TABLE (IF_P EXISTS)? relation_expr (alter_table_cmds | partition_cmd) | ALTER TABLE ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait + | ALTER ZTABLE (IF_P EXISTS)? relation_expr (alter_table_cmds | partition_cmd) | ALTER TOPIC (IF_P EXISTS)? relation_expr (alter_table_cmds | partition_cmd) | ALTER TOPIC ALL IN_P TABLESPACE name (OWNED BY role_list)? SET TABLESPACE name opt_nowait | ALTER INDEX (IF_P EXISTS)? qualified_name (alter_table_cmds | index_partition_cmd) @@ -711,6 +714,20 @@ opt_with_stream | ; +createztstmt + : CREATE optztable_type (IF_P NOT EXISTS)? qualified_name ( + OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit optpartitionspec table_access_method_clause optwith oncommitoption opttablespace + | OF any_name opttypedtableelementlist optpartitionspec table_access_method_clause optwith oncommitoption opttablespace + | PARTITION OF qualified_name opttypedtableelementlist partitionboundspec optpartitionspec table_access_method_clause optwith oncommitoption + opttablespace + ) + ; + +optztable_type + : ZTABLE + | TOPIC + ; + createstmt : CREATE opttemp opttable_type (IF_P NOT EXISTS)? qualified_name ( OPEN_PAREN opttableelementlist CLOSE_PAREN optinherit optpartitionspec table_access_method_clause optwith oncommitoption opttablespace @@ -722,7 +739,6 @@ createstmt opttable_type : TABLE - | TOPIC ; opttemp @@ -790,7 +806,7 @@ colconstraintelem | CHECK OPEN_PAREN a_expr CLOSE_PAREN opt_no_inherit | DEFAULT b_expr | GENERATED generated_when AS ( - IDENTITY_P optparenthesizedseqoptlist + (IDENTITY_P | NOW) optparenthesizedseqoptlist | OPEN_PAREN a_expr CLOSE_PAREN STORED ) | REFERENCES qualified_name opt_column_list key_match key_actions @@ -820,6 +836,7 @@ tablelikeoption | CONSTRAINTS | DEFAULTS | IDENTITY_P + | NOW | GENERATED | INDEXES | STATISTICS @@ -1628,6 +1645,8 @@ show_object_type_name | VIEWS | MATERIALIZED VIEWS | TOPICS + | HEAD + | ZTABLES | ZVIEWS ; @@ -1654,6 +1673,8 @@ object_type_any_name | TOPIC | STREAM | ZVIEW + | HEAD + | ZTABLE | INDEX | FOREIGN TABLE | COLLATION diff --git a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlClientFactory.java b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlClientFactory.java index 966a20dafc..58ed1de46a 100644 --- a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlClientFactory.java +++ b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlClientFactory.java @@ -54,6 +54,7 @@ import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlErrorFlushExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlFlushExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlFormat; +import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlNoticeFlushExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlQueryDataExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlStatus; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.ResetFW; @@ -64,7 +65,6 @@ import io.aklivity.zilla.runtime.engine.buffer.BufferPool; import io.aklivity.zilla.runtime.engine.config.BindingConfig; - public final class PgsqlClientFactory implements PgsqlStreamFactory { private static final Byte MESSAGE_TYPE_TYPE = 'T'; @@ -77,6 +77,7 @@ public final class PgsqlClientFactory implements PgsqlStreamFactory private static final Byte MESSAGE_TYPE_READY = 'Z'; private static final Byte MESSAGE_TYPE_TERMINATION = 'X'; private static final Byte MESSAGE_TYPE_ERROR = 'E'; + private static final Byte MESSAGE_TYPE_NOTICE = 'N'; private static final int AUTHENTICATION_SUCCESS_CODE = 0; private static final int END_OF_FIELD = 0x00; @@ -116,6 +117,7 @@ public final class PgsqlClientFactory implements PgsqlStreamFactory private final PgsqlDataExFW.Builder dataExRW = new PgsqlDataExFW.Builder(); private final PgsqlFlushExFW.Builder flushExRW = new PgsqlFlushExFW.Builder(); private final PgsqlErrorFlushExFW.Builder flushErrorExRW = new PgsqlErrorFlushExFW.Builder(); + private final PgsqlNoticeFlushExFW.Builder flushNoticeExRW = new PgsqlNoticeFlushExFW.Builder(); private final Array32FW.Builder columnsRW = new Array32FW.Builder<>(new PgsqlColumnInfoFW.Builder(), new PgsqlColumnInfoFW()); @@ -150,6 +152,7 @@ public final class PgsqlClientFactory implements PgsqlStreamFactory private final PgsqlClientDecoder decodePgsqlReady = this::decodePgsqlMessageReady; private final PgsqlClientDecoder decodePgsqlTermination = this::decodePgsqlMessageTerminator; private final PgsqlClientDecoder decodePgsqlPayload = this::decodePgsqlMessagePayload; + private final PgsqlClientDecoder decodePgsqlNotice = this::decodePgsqlMessageNotice; private final PgsqlClientDecoder decodePgsqlError = this::decodePgsqlMessageError; private final PgsqlClientDecoder decodePgsqlIgnoreOne = this::decodePgsqlIgnoreOne; private final PgsqlClientDecoder decodePgsqlIgnoreAll = this::decodePgsqlIgnoreAll; @@ -166,6 +169,7 @@ public final class PgsqlClientFactory implements PgsqlStreamFactory decodersByType.put(MESSAGE_TYPE_COMPLETION, decodePgsqlCompletion); decodersByType.put(MESSAGE_TYPE_READY, decodePgsqlReady); decodersByType.put(MESSAGE_TYPE_TERMINATION, decodePgsqlTermination); + decodersByType.put(MESSAGE_TYPE_NOTICE, decodePgsqlNotice); decodersByType.put(MESSAGE_TYPE_ERROR, decodePgsqlError); this.decodersByType = decodersByType; } @@ -742,6 +746,39 @@ private void onDecodeMessageError( stream.doApplicationFlush(traceId, authorization, decodeSlotReserved, completionEx); } + private void onDecodeMessageNotice( + long traceId, + long authorization, + DirectBuffer buffer, + int offset, + int length) + { + int progressOffset = offset; + + PgsqlNoticeFlushExFW.Builder notice = flushNoticeExRW.wrap(extBuffer, 0, extBuffer.capacity()); + + final int severityLength = getLengthOfString(buffer, progressOffset); + notice.severity(buffer, progressOffset, severityLength); + progressOffset += severityLength; + + final int codeLength = getLengthOfString(buffer, progressOffset); + notice.code(buffer, progressOffset, codeLength); + progressOffset += codeLength; + + final int messageLength = getLengthOfString(buffer, progressOffset); + notice.message(buffer, progressOffset, messageLength); + progressOffset += messageLength; + + assert offset + length == progressOffset; + + Consumer completionEx = e -> e.set((b, o, l) -> flushExRW.wrap(b, o, l) + .typeId(pgsqlTypeId) + .notice(c -> c.set(notice.build())) + .build().sizeof()); + + stream.doApplicationFlush(traceId, authorization, decodeSlotReserved, completionEx); + } + private void onDecodeMessageReady( long traceId, long authorization, @@ -1606,6 +1643,35 @@ private int decodePgsqlMessageError( return progressOffset; } + private int decodePgsqlMessageNotice( + PgsqlClient client, + long traceId, + long authorization, + long budgetId, + DirectBuffer buffer, + int offset, + int limit) + { + int progressOffset = offset; + + final PgsqlMessageFW pgsqlNotice = messageRO.tryWrap(buffer, offset, limit); + + if (pgsqlNotice != null && + limit - offset >= pgsqlNotice.length() + Integer.BYTES) + { + progressOffset = pgsqlNotice.limit(); + + int length = pgsqlNotice.length() - Integer.BYTES; + client.onDecodeMessageNotice(traceId, authorization, buffer, progressOffset, length); + + progressOffset += length; + + client.decoder = decodePgsqlMessage; + } + + return progressOffset; + } + private int decodePgsqlMessageReady( PgsqlClient client, long traceId, diff --git a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlServerFactory.java b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlServerFactory.java index d0e646b7c8..02f07dc7df 100644 --- a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlServerFactory.java +++ b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/PgsqlServerFactory.java @@ -53,6 +53,7 @@ import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlDataExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlErrorFlushExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlFlushExFW; +import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlNoticeFlushExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlParameterFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlReadyFlushExFW; import io.aklivity.zilla.runtime.binding.pgsql.internal.types.stream.PgsqlStatus; @@ -72,6 +73,7 @@ public final class PgsqlServerFactory implements PgsqlStreamFactory private static final Byte MESSAGE_TYPE_DATA_ROW = 'D'; private static final Byte MESSAGE_TYPE_COMPLETION = 'C'; private static final Byte MESSAGE_TYPE_ERROR = 'E'; + private static final Byte MESSAGE_TYPE_NOTICE = 'N'; private static final Byte MESSAGE_TYPE_READY = 'Z'; private static final Byte MESSAGE_TYPE_TERMINATE = 'X'; private static final Byte MESSAGE_TYPE_PARAMETER_STATUS = 'S'; @@ -911,6 +913,9 @@ private void onApplicationFlush( case PgsqlFlushExFW.KIND_ERROR: doEncodeError(traceId, authorization, pgsqlFlushEx.error()); break; + case PgsqlFlushExFW.KIND_NOTICE: + doEncodeNotice(traceId, authorization, pgsqlFlushEx.notice()); + break; case PgsqlFlushExFW.KIND_READY: doEncodeReady(traceId, authorization, pgsqlFlushEx.ready()); break; @@ -1213,6 +1218,32 @@ private void doEncodeError( server.doNetworkData(traceId, authorization, FLAGS_COMP, 0L, messageBuffer, 0, errorOffset); } + private void doEncodeNotice( + long traceId, + long authorization, + PgsqlNoticeFlushExFW notice) + { + int errorOffset = 0; + final int severityLength = notice.severity().value().capacity(); + final int codeLength = notice.code().value().capacity(); + final int messageLength = notice.message().value().capacity(); + + PgsqlMessageFW messageCompleted = messageRW.wrap(messageBuffer, 0, messageBuffer.capacity()) + .type(MESSAGE_TYPE_NOTICE) + .length(Integer.BYTES + severityLength + codeLength + messageLength) + .build(); + errorOffset += messageCompleted.limit(); + + messageBuffer.putBytes(errorOffset, notice.severity().value(), 0, severityLength); + errorOffset += severityLength; + messageBuffer.putBytes(errorOffset, notice.code().value(), 0, codeLength); + errorOffset += codeLength; + messageBuffer.putBytes(errorOffset, notice.message().value(), 0, messageLength); + errorOffset += messageLength; + + server.doNetworkData(traceId, authorization, FLAGS_COMP, 0L, messageBuffer, 0, errorOffset); + } + private void doEncodeReady( long traceId, long authorization, diff --git a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParser.java b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParser.java index 316ed6e5ea..4155dff887 100644 --- a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParser.java +++ b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParser.java @@ -23,11 +23,11 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlAlterStreamTopicListener; -import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlAlterTableTopicListener; +import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlAlterZtableTopicListener; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlCommandListener; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlCreateFunctionListener; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlCreateStreamListener; -import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlCreateTableTopicListener; +import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlCreateZtableTopicListener; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlCreateZviewListener; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlDropListener; import io.aklivity.zilla.runtime.binding.pgsql.parser.listener.SqlShowListener; @@ -47,8 +47,8 @@ public final class PgsqlParser private final PostgreSqlParser parser; private final SqlCommandListener commandListener; private final SqlCreateStreamListener createStreamListener; - private final SqlCreateTableTopicListener createTableListener; - private final SqlAlterTableTopicListener alterTableListener; + private final SqlCreateZtableTopicListener createTableListener; + private final SqlAlterZtableTopicListener alterTableListener; private final SqlAlterStreamTopicListener alterStreamListener; private final SqlCreateFunctionListener createFunctionListener; private final SqlCreateZviewListener createMaterializedViewListener; @@ -63,8 +63,8 @@ public PgsqlParser() this.tokens = new CommonTokenStream(lexer); this.parser = new PostgreSqlParser(tokens); this.commandListener = new SqlCommandListener(tokens); - this.createTableListener = new SqlCreateTableTopicListener(tokens); - this.alterTableListener = new SqlAlterTableTopicListener(tokens); + this.createTableListener = new SqlCreateZtableTopicListener(tokens); + this.alterTableListener = new SqlAlterZtableTopicListener(tokens); this.alterStreamListener = new SqlAlterStreamTopicListener(tokens); this.createStreamListener = new SqlCreateStreamListener(tokens); this.createFunctionListener = new SqlCreateFunctionListener(tokens); @@ -141,15 +141,21 @@ private void parser( String sql, PostgreSqlParserBaseListener listener) { - sql = sql.replace("\u0000", ""); - - CharStream input = CharStreams.fromString(sql); - lexer.reset(); - lexer.setInputStream(input); - - tokens.setTokenSource(lexer); - parser.setTokenStream(tokens); - - walker.walk(listener, parser.root()); + try + { + sql = sql.replace("\u0000", ""); + + CharStream input = CharStreams.fromString(sql); + lexer.reset(); + lexer.setInputStream(input); + + tokens.setTokenSource(lexer); + parser.setTokenStream(tokens); + + walker.walk(listener, parser.root()); + } + catch (Exception ignore) + { + } } } diff --git a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlAlterTableTopicListener.java b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlAlterZtableTopicListener.java similarity index 96% rename from incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlAlterTableTopicListener.java rename to incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlAlterZtableTopicListener.java index e38ed1fa3e..a51ad3b0b7 100644 --- a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlAlterTableTopicListener.java +++ b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlAlterZtableTopicListener.java @@ -25,7 +25,7 @@ import io.aklivity.zilla.runtime.binding.pgsql.parser.model.AlterExpression; import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Operation; -public class SqlAlterTableTopicListener extends PostgreSqlParserBaseListener +public class SqlAlterZtableTopicListener extends PostgreSqlParserBaseListener { private static final String PUBLIC_SCHEMA_NAME = "public"; private static final String SCHEMA_PATTERN = "\\."; @@ -36,7 +36,7 @@ public class SqlAlterTableTopicListener extends PostgreSqlParserBaseListener private String schema; private String name; - public SqlAlterTableTopicListener( + public SqlAlterZtableTopicListener( TokenStream tokens) { this.alterExpressions = new ArrayList<>(); diff --git a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCommandListener.java b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCommandListener.java index cbe323f002..737da741f4 100644 --- a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCommandListener.java +++ b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCommandListener.java @@ -44,19 +44,19 @@ public void enterRoot( } @Override - public void enterCreatestmt( - PostgreSqlParser.CreatestmtContext ctx) + public void enterCreateztstmt( + PostgreSqlParser.CreateztstmtContext ctx) { - command = "CREATE %s".formatted(ctx.opttable_type().getText()); + command = "CREATE %s".formatted(ctx.optztable_type().getText().toUpperCase()); } @Override public void enterAltertablestmt( PostgreSqlParser.AltertablestmtContext ctx) { - if (ctx.ALTER() != null && ctx.TABLE() != null) + if (ctx.ALTER() != null && ctx.ZTABLE() != null) { - command = "ALTER TABLE"; + command = "ALTER ZTABLE"; } else if (ctx.ALTER() != null && ctx.TOPIC() != null) { @@ -87,11 +87,7 @@ public void enterShowstmt( PostgreSqlParser.ShowstmtContext ctx) { String type = ctx.show_object_type_name().getText(); - - if ("ZVIEWS".equals(type)) - { - command = "SHOW ZVIEWS"; - } + command = "SHOW %s".formatted(type.toUpperCase()); } @Override diff --git a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCreateTableTopicListener.java b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCreateZtableTopicListener.java similarity index 94% rename from incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCreateTableTopicListener.java rename to incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCreateZtableTopicListener.java index 4ded45b717..7b81eef3df 100644 --- a/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCreateTableTopicListener.java +++ b/incubator/binding-pgsql/src/main/java/io/aklivity/zilla/runtime/binding/pgsql/parser/listener/SqlCreateZtableTopicListener.java @@ -26,7 +26,7 @@ import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; -public class SqlCreateTableTopicListener extends PostgreSqlParserBaseListener +public class SqlCreateZtableTopicListener extends PostgreSqlParserBaseListener { private static final String PUBLIC_SCHEMA_NAME = "public"; private static final String SCHEMA_PATTERN = "\\."; @@ -38,7 +38,7 @@ public class SqlCreateTableTopicListener extends PostgreSqlParserBaseListener private String schema; private String name; - public SqlCreateTableTopicListener( + public SqlCreateZtableTopicListener( TokenStream tokens) { this.primaryKeys = new ObjectHashSet<>(); @@ -72,8 +72,8 @@ public void enterQualified_name( } @Override - public void enterCreatestmt( - PostgreSqlParser.CreatestmtContext ctx) + public void enterCreateztstmt( + PostgreSqlParser.CreateztstmtContext ctx) { if (ctx.opttableelementlist().tableelementlist() != null) { @@ -109,7 +109,7 @@ private void addColumn( } else { - constraints.add(tokens.getText(constraint.colconstraintelem())); + constraints.add(tokens.getText(constraint.colconstraintelem()).toUpperCase()); } } columns.add(new TableColumn(columnName, dataType, constraints)); diff --git a/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ClientIT.java b/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ClientIT.java index 8621537a74..d1d6ea104e 100644 --- a/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ClientIT.java +++ b/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ClientIT.java @@ -58,6 +58,17 @@ public void shouldCreateTableWithPrimaryKey() throws Exception k3po.finish(); } + @Test + @Configuration("client.yaml") + @Specification({ + "${app}/create.view.with.notice/client", + "${net}/create.view.with.notice/server" + }) + public void shouldCreateViewWithNotice() throws Exception + { + k3po.finish(); + } + @Test @Configuration("client.yaml") @Specification({ diff --git a/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ServerIT.java b/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ServerIT.java index 9d301f9ca5..26ec542b52 100644 --- a/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ServerIT.java +++ b/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/internal/stream/ServerIT.java @@ -137,4 +137,15 @@ public void shouldSelectTableWithError() throws Exception { k3po.finish(); } + + @Test + @Configuration("server.yaml") + @Specification({ + "${net}/create.view.with.notice/client", + "${app}/create.view.with.notice/server" + }) + public void shouldCreateViewWithNotice() throws Exception + { + k3po.finish(); + } } diff --git a/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParserTest.java b/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParserTest.java index caa4d686b5..b1ecebca4e 100644 --- a/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParserTest.java +++ b/incubator/binding-pgsql/src/test/java/io/aklivity/zilla/runtime/binding/pgsql/parser/PgsqlParserTest.java @@ -16,11 +16,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.List; -import org.antlr.v4.runtime.misc.ParseCancellationException; import org.junit.Before; import org.junit.Test; @@ -43,9 +43,9 @@ public void setUp() } @Test - public void shouldCreateTableWithPrimaryKey() + public void shouldCreateZtableWithPrimaryKey() { - String sql = "CREATE TABLE test (id INT PRIMARY KEY, name VARCHAR(100));"; + String sql = "CREATE ZTABLE test (id INT PRIMARY KEY, name VARCHAR(100));"; CreateTable createTable = parser.parseCreateTable(sql); assertNotNull(createTable); @@ -53,10 +53,32 @@ public void shouldCreateTableWithPrimaryKey() } @Test - public void shouldCreateTableWithPrimaryKeyAsAggregate() + public void shouldCreateZtableParseWithGeneratedAsAlwaysSql() { String sql = """ - CREATE TABLE example_table ( + CREATE ZTABLE example_table ( + id INT, + name VARCHAR(100), + age INT, + owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, + created_at TIMESTAMP GENERATED ALWAYS AS NOW, + PRIMARY KEY (id, name) + );"""; + + CreateTable table = parser.parseCreateTable(sql); + + assertNotNull(table); + assertEquals(2, table.primaryKeys().size()); + assertEquals(5, table.columns().size()); + assertTrue(table.primaryKeys().contains("id")); + assertTrue(table.primaryKeys().contains("name")); + } + + @Test + public void shouldCreateZtableWithPrimaryKeyAsAggregate() + { + String sql = """ + CREATE ZTABLE example_table ( id INT PRIMARY KEY, name VARCHAR(100), age INT, @@ -74,36 +96,48 @@ PRIMARY KEY (id, name) @Test public void shouldCreateTableName() { - String sql = "CREATE TABLE test (id INT);"; + String sql = "CREATE ZTABLE test (id INT);"; CreateTable createTable = parser.parseCreateTable(sql); assertEquals("test", createTable.name()); } @Test - public void shouldCreateTableNameWithDoublePrecisionTypeField() + public void shouldCreateZtableNameWithDoublePrecisionTypeField() { - String sql = "CREATE TABLE test (id DOUBLE PRECISION);"; - CreateTable createTable = parser.parseCreateTable(sql); - assertEquals("test", createTable.name()); - assertEquals("DOUBLE PRECISION", createTable.columns().get(0).type()); + String sql = "CREATE ZTABLE test (id DOUBLE PRECISION);"; + CreateTable table = parser.parseCreateTable(sql); + assertEquals("test", table.name()); + assertEquals("DOUBLE PRECISION", table.columns().get(0).type()); } @Test public void shouldCreateTableColumns() { - String sql = "CREATE TABLE test (id INT, name VARCHAR(100));"; - CreateTable createTable = parser.parseCreateTable(sql); + String sql = "CREATE ZTABLE test (id INT, name VARCHAR(100));"; + CreateTable table = parser.parseCreateTable(sql); - assertEquals(2, createTable.columns().size()); - assertEquals("INT", createTable.columns().get(0).type()); - assertEquals("VARCHAR(100)", createTable.columns().get(1).type()); + assertEquals(2, table.columns().size()); + assertEquals("INT", table.columns().get(0).type()); + assertEquals("VARCHAR(100)", table.columns().get(1).type()); + } + + + @Test + public void shouldParseCreateZtableCompositePrimaryKey() + { + String sql = "CREATE ZTABLE test (id INT, name VARCHAR(100), PRIMARY KEY (id, name));"; + CreateTable table = parser.parseCreateTable(sql); + + assertEquals(2, table.primaryKeys().size()); + assertTrue(table.primaryKeys().contains("id")); + assertTrue(table.primaryKeys().contains("name")); } @Test - public void shouldHandleEmptyCreateTable() + public void shouldHandleEmptyCreateZtable() { - String sql = "CREATE TABLE test ();"; + String sql = "CREATE ZTABLE test ();"; CreateTable createTable = parser.parseCreateTable(sql); assertEquals(0, createTable.columns().size()); @@ -130,34 +164,39 @@ public void shouldCreateZview() assertEquals("SELECT * FROM test_table", createZview.select()); } - @Test(expected = ParseCancellationException.class) + @Test public void shouldHandleEmptyCreateZView() { String sql = "CREATE ZVIEW test_view AS ;"; CreateZview createZview = parser.parseCreateZView(sql); assertNotNull(createZview); - assertEquals("test_view", createZview.name()); + assertNull(createZview.name()); } - @Test(expected = ParseCancellationException.class) + @Test public void shouldHandleInvalidCreateZView() { String sql = "CREATE ZVIEW test_view"; - parser.parseCreateZView(sql); + CreateZview createZview = parser.parseCreateZView(sql); + + assertNull(createZview.name()); } - @Test(expected = ParseCancellationException.class) - public void shouldHandleInvalidCreateTable() + @Test + public void shouldHandleInvalidZCreateZtable() { - String sql = "CREATE TABLE test"; - parser.parseCreateTable(sql); + String sql = "CREATE ZTABLE test"; + CreateTable createTable = parser.parseCreateTable(sql); + + assertNull(createTable.name()); } @Test - public void shouldDropSingleTable() + public void shouldDropSingleZtable() { - String sql = "DROP TABLE test_table;"; + String sql = "DROP ZTABLE test_table;"; + List drops = parser.parseDrop(sql); assertEquals(1, drops.size()); @@ -166,9 +205,9 @@ public void shouldDropSingleTable() } @Test - public void shouldParseDropMultipleTables() + public void shouldDropMultipleZtables() { - String sql = "DROP TABLE table1, table2;"; + String sql = "DROP ZTABLE table1, table2;"; List drops = parser.parseDrop(sql); assertEquals(2, drops.size()); @@ -178,10 +217,10 @@ public void shouldParseDropMultipleTables() assertEquals("table2", drops.get(1).name()); } - @Test(expected = ParseCancellationException.class) - public void shouldDropTable() + @Test + public void shouldDropZtable() { - String sql = "DROP TABLE;"; + String sql = "DROP ZTABLE;"; List drops = parser.parseDrop(sql); assertEquals(0, drops.size()); @@ -232,11 +271,13 @@ public void shouldCreateStreamIfNotExists() assertEquals("VARCHAR(100)", createStream.columns().get("name")); } - @Test(expected = ParseCancellationException.class) + @Test public void shouldHandleInvalidCreateStream() { String sql = "CREATE STREAM test_stream"; - parser.parseCreateStream(sql); + CreateStream createStream = parser.parseCreateStream(sql); + + assertNull(createStream.name()); } @Test @@ -275,31 +316,21 @@ public void shouldCreateFunctionWithStructReturnType() assertEquals("python", function.language()); } - @Test(expected = ParseCancellationException.class) + @Test public void shouldHandleInvalidCreateFunction() { String sql = "CREATE FUNCTION test_function()"; - parser.parseCreateFunction(sql); - } - - @Test - public void shouldCreateTableWithUniqueConstraint() - { - String sql = "CREATE TABLE test (id INT UNIQUE, name VARCHAR(100));"; - CreateTable createTable = parser.parseCreateTable(sql); + Function function = parser.parseCreateFunction(sql); - assertNotNull(createTable); - assertEquals(2, createTable.columns().size()); - assertEquals("id", createTable.columns().get(0).name()); - assertEquals("name", createTable.columns().get(1).name()); + assertNull(function.name()); } @Test - public void shouldCreateTableWithForeignKey() + public void shouldCreateZtableWithUniqueConstraint() { - String sql = "CREATE TABLE test (id INT, name VARCHAR(100), CONSTRAINT fk_name FOREIGN KEY (name)" + - " REFERENCES other_table(name));"; + String sql = "CREATE ZTABLE test (id INT UNIQUE, name VARCHAR(100));"; CreateTable createTable = parser.parseCreateTable(sql); + assertNotNull(createTable); assertEquals(2, createTable.columns().size()); assertEquals("id", createTable.columns().get(0).name()); @@ -307,9 +338,9 @@ public void shouldCreateTableWithForeignKey() } @Test - public void shouldParseCreateTableWithCheckConstraint() + public void shouldParseCreateZtableWithCheckConstraint() { - String sql = "CREATE TABLE test (id INT, name VARCHAR(100), CHECK (id > 0));"; + String sql = "CREATE ZTABLE test (id INT, name VARCHAR(100), CHECK (id > 0));"; CreateTable createTable = parser.parseCreateTable(sql); assertNotNull(createTable); @@ -321,14 +352,14 @@ public void shouldParseCreateTableWithCheckConstraint() @Test public void shouldHandleInvalidCreateTableWithMissingColumns() { - String sql = "CREATE TABLE test ();"; + String sql = "CREATE ZTABLE test ();"; parser.parseCreateTable(sql); } @Test - public void shouldCreateTableWithDefaultValues() + public void shouldCreateZtableWithDefaultValues() { - String sql = "CREATE TABLE test (id INT DEFAULT 0, name VARCHAR(100) DEFAULT 'unknown');"; + String sql = "CREATE ZTABLE test (id INT DEFAULT 0, name VARCHAR(100) DEFAULT 'unknown');"; CreateTable createTable = parser.parseCreateTable(sql); assertNotNull(createTable); @@ -338,9 +369,9 @@ public void shouldCreateTableWithDefaultValues() } @Test - public void shouldCreateTableWithNotNullConstraint() + public void shouldCreateZtableWithNotNullConstraint() { - String sql = "CREATE TABLE test (id INT NOT NULL, name VARCHAR(100) NOT NULL);"; + String sql = "CREATE ZTABLE test (id INT NOT NULL, name VARCHAR(100) NOT NULL);"; CreateTable createTable = parser.parseCreateTable(sql); assertNotNull(createTable); @@ -350,9 +381,9 @@ public void shouldCreateTableWithNotNullConstraint() } @Test - public void shouldCreateTableWithMultipleConstraints() + public void shouldCreateZtableWithMultipleConstraints() { - String sql = "CREATE TABLE test (id INT PRIMARY KEY, name VARCHAR(100) UNIQUE, age INT CHECK (age > 0));"; + String sql = "CREATE ZTABLE test (id INT PRIMARY KEY, name VARCHAR(100) UNIQUE, age INT CHECK (age > 0));"; CreateTable createTable = parser.parseCreateTable(sql); assertNotNull(createTable); @@ -363,9 +394,9 @@ public void shouldCreateTableWithMultipleConstraints() } @Test - public void shouldAlterTableAddColumn() + public void shouldAlterZtableAddColumn() { - String sql = "ALTER TABLE test_table ADD COLUMN new_column INT;"; + String sql = "ALTER ZTABLE test_table ADD COLUMN new_column INT;"; Alter alter = parser.parseAlterTable(sql); assertEquals("test_table", alter.name()); @@ -389,9 +420,9 @@ public void shouldAlterTopicAddColumn() } @Test - public void shouldAlterTableDropColumn() + public void shouldAlterZtableDropColumn() { - String sql = "ALTER TABLE test_table DROP COLUMN old_column;"; + String sql = "ALTER ZTABLE test_table DROP COLUMN old_column;"; Alter alter = parser.parseAlterTable(sql); assertEquals("test_table", alter.name()); @@ -401,9 +432,9 @@ public void shouldAlterTableDropColumn() } @Test - public void shouldAlterTableModifyColumn() + public void shouldAlterZtableModifyColumn() { - String sql = "ALTER TABLE test_table ALTER COLUMN existing_column TYPE VARCHAR(100);"; + String sql = "ALTER ZTABLE test_table ALTER COLUMN existing_column TYPE VARCHAR(100);"; Alter alter = parser.parseAlterTable(sql); assertEquals("test_table", alter.name()); @@ -412,18 +443,20 @@ public void shouldAlterTableModifyColumn() assertEquals("existing_column", alter.expressions().get(0).columnName()); } - @Test(expected = ParseCancellationException.class) - public void shouldHandleInvalidAlterTable() + @Test + public void shouldHandleInvalidAlterZtable() { - String sql = "ALTER TABLE"; - parser.parseAlterTable(sql); + String sql = "ALTER ZTABLE"; + Alter alter = parser.parseAlterTable(sql); + + assertNull(alter.name()); } @Test public void shouldDetectAlterCommand() { - String sql = "ALTER TABLE test_table ALTER COLUMN existing_column TYPE VARCHAR(100);"; - String expectedCommand = "ALTER TABLE"; + String sql = "ALTER ZTABLE test_table ALTER COLUMN existing_column TYPE VARCHAR(100);"; + String expectedCommand = "ALTER ZTABLE"; String parsedCommand = parser.parseCommand(sql); @@ -466,11 +499,13 @@ public void shouldAlterStreamDropColumn() assertEquals("old_column", alter.expressions().get(0).columnName()); } - @Test(expected = ParseCancellationException.class) + @Test public void shouldHandleInvalidAlterStream() { String sql = "ALTER STREAM"; - parser.parseAlterStream(sql); + Alter alter = parser.parseAlterStream(sql); + + assertNull(alter.name()); } @Test @@ -494,4 +529,13 @@ public void shouldShowZviews() assertEquals("ZVIEWS", type); } + + @Test + public void shouldParseShowZtables() + { + String sql = "SHOW ZTABLES;"; + String type = parser.parseShow(sql); + + assertEquals("ZTABLES", type); + } } diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/client.rpt index 0455311153..1e251dd878 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -47,7 +47,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/server.rpt index d2d9208435..71ac5af89b 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.stream.add.column/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -50,7 +50,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.table.add.column/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.ztable.add.column/client.rpt similarity index 96% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.table.add.column/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.ztable.add.column/client.rpt index 9f3fc9cff0..2c0b6e5b8f 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.table.add.column/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.ztable.add.column/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -56,7 +56,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -70,7 +70,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.table.add.column/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.ztable.add.column/server.rpt similarity index 96% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.table.add.column/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.ztable.add.column/server.rpt index 5c17e363c5..09aa9d10a2 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.table.add.column/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/alter.ztable.add.column/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -57,7 +57,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -73,7 +73,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/client.rpt index f726fcbe04..aa3e32b15d 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -65,7 +65,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -79,7 +79,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/server.rpt index f3d6688638..76fa395b2a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/client.stream.established/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -49,7 +49,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/client.rpt index 15d845c9d9..0fd5bcdf9c 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/server.rpt index ec8efafccc..6011c85e8f 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded.python/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/client.rpt index 3811b7a5ab..39ba5c1b0e 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/server.rpt index 87c83e01fc..db7785a36e 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.embedded/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/client.rpt index a1aef923d1..7d5ed1d55c 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -56,36 +56,13 @@ read advised zilla:flush ${pgsql:flushEx() .build()} -write zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -write "GRANT ALL PRIVILEGES ON FUNCTION public.gcd TO app;" - [0x00] -write flush - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/server.rpt index 8a6e6d8b70..db40a088c5 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.python/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -55,33 +55,11 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} -read zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -read "GRANT ALL PRIVILEGES ON FUNCTION public.gcd TO app;" - [0x00] - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/client.rpt index 43bdf1b732..d978396b14 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -55,37 +55,13 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} - -write zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -write "GRANT ALL PRIVILEGES ON FUNCTION public.key_value TO app;" - [0x00] -write flush - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/server.rpt index c4a5d1520b..9e1a2232b1 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.struct/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -55,33 +55,11 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} -read zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -read "GRANT ALL PRIVILEGES ON FUNCTION public.key_value TO app;" - [0x00] - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/client.rpt index 577eab5609..f15e365b04 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -54,36 +54,13 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} -write zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -write "GRANT ALL PRIVILEGES ON FUNCTION public.series TO app;" - [0x00] -write flush - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/server.rpt index c5a0bfab9f..1f5ffe6051 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function.return.table/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -55,33 +55,11 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} -read zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -read "GRANT ALL PRIVILEGES ON FUNCTION public.series TO app;" - [0x00] - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/client.rpt index 543513a4ef..84bb2a91ff 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -55,36 +55,13 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} -write zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -write "GRANT ALL PRIVILEGES ON FUNCTION public.gcd TO app;" - [0x00] -write flush - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -read advised zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/server.rpt index 7e011294c1..93b4dee857 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.function/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -55,33 +55,11 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} -read zilla:data.ext ${pgsql:dataEx() - .typeId(zilla:id("pgsql")) - .query() - .build() - .build()} -read "GRANT ALL PRIVILEGES ON FUNCTION public.gcd TO app;" - [0x00] - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .completion() - .tag("GRANT_PRIVILEGES") - .build() - .build()} - -write advise zilla:flush ${pgsql:flushEx() - .typeId(zilla:id("pgsql")) - .ready() - .status("IDLE") - .build() - .build()} - accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/client.rpt index 3fa7f9a0b1..c86d68aafa 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -62,13 +62,36 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "GRANT ALL PRIVILEGES ON SOURCE public.weather TO zillabase;" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -82,7 +105,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/server.rpt index 7fed64f580..351844ae5c 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream.with.includes/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -65,11 +65,33 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "GRANT ALL PRIVILEGES ON SOURCE public.weather TO zillabase;" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -85,7 +107,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/client.rpt index f726fcbe04..286cd15792 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -59,13 +59,36 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "GRANT ALL PRIVILEGES ON SOURCE public.weather TO zillabase;" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -79,7 +102,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/server.rpt index 04e6d7901a..19ae4c7a09 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.stream/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -62,11 +62,33 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "GRANT ALL PRIVILEGES ON SOURCE public.weather TO zillabase;" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -82,7 +104,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/client.rpt index 9ad792d198..2838e04dd1 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -59,6 +59,29 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "GRANT ALL PRIVILEGES ON SOURCE public.weather_c TO zillabase;" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + write zilla:data.ext ${pgsql:dataEx() .typeId(zilla:id("pgsql")) .query() @@ -91,13 +114,36 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "GRANT ALL PRIVILEGES ON SOURCE public.weather_f TO zillabase;" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -111,7 +157,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/server.rpt index 4d95c24cf0..f6536341cd 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.streams/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -62,6 +62,28 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "GRANT ALL PRIVILEGES ON SOURCE public.weather_c TO zillabase;" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + read zilla:data.ext ${pgsql:dataEx() .typeId(zilla:id("pgsql")) .query() @@ -93,11 +115,33 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "GRANT ALL PRIVILEGES ON SOURCE public.weather_f TO zillabase;" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("GRANT_PRIVILEGES") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -113,7 +157,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key.and.includes/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.generated.as/client.rpt similarity index 82% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key.and.includes/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.generated.as/client.rpt index 910c953dab..52b32d6449 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key.and.includes/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.generated.as/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,9 +33,8 @@ write zilla:data.ext ${pgsql:dataEx() .build() .build()} write "CREATE SOURCE IF NOT EXISTS cities_source (*)\n" - "INCLUDE header 'zilla:correlation-id' AS zilla_correlation_id_header\n" - "INCLUDE header 'zilla:identity' AS zilla_identity_header\n" - "INCLUDE timestamp AS zilla_timestamp_timestamp\n" + "INCLUDE header 'zilla:identity' AS owner_id_header\n" + "INCLUDE timestamp AS created_at_timestamp\n" "WITH (\n" " connector='kafka',\n" " properties.bootstrap.server='localhost:9092',\n" @@ -69,9 +68,8 @@ write zilla:data.ext ${pgsql:dataEx() .build()} write "CREATE MATERIALIZED VIEW IF NOT EXISTS cities_view" " AS SELECT id, name, description," - " COALESCE(zilla_correlation_id, zilla_correlation_id_header::varchar) as zilla_correlation_id," - " COALESCE(zilla_identity, zilla_identity_header::varchar) as zilla_identity," - " COALESCE(zilla_timestamp, zilla_timestamp_timestamp::varchar) as zilla_timestamp" + " COALESCE(owner_id, owner_id_header::varchar) as owner_id," + " COALESCE(created_at, created_at_timestamp::timestamp) as created_at" " FROM cities_source;" [0x00] write flush @@ -97,7 +95,7 @@ write zilla:data.ext ${pgsql:dataEx() .build()} write "CREATE TABLE IF NOT EXISTS cities" " (id VARCHAR, name VARCHAR, description VARCHAR," - " zilla_correlation_id VARCHAR, zilla_identity VARCHAR, zilla_timestamp TIMESTAMP," + " owner_id VARCHAR, created_at TIMESTAMP," " PRIMARY KEY (id));" [0x00] write flush @@ -121,7 +119,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "GRANT ALL PRIVILEGES ON TABLE public.cities TO app;" +write "GRANT ALL PRIVILEGES ON TABLE public.cities TO zillabase;" [0x00] write flush @@ -194,13 +192,41 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "INSERT INTO zb_catalog.ztables (name, sql) VALUES " + "('cities', 'CREATE ZTABLE IF NOT EXISTS cities " + "(id VARCHAR, name VARCHAR, description VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id));');" + [0x00] + + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("INSERT 0 2") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -214,7 +240,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -227,11 +253,15 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "CREATE TOPIC IF NOT EXISTS cities " - "(id VARCHAR, name VARCHAR, description VARCHAR," - " zilla_correlation_id VARCHAR, zilla_identity VARCHAR, zilla_timestamp TIMESTAMP," - " PRIMARY KEY (id));" +write "CREATE TOPIC IF NOT EXISTS cities (" + "id VARCHAR, " + "name VARCHAR, " + "description VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id));" [0x00] + write flush read advised zilla:flush ${pgsql:flushEx() diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key.and.includes/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.generated.as/server.rpt similarity index 78% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key.and.includes/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.generated.as/server.rpt index b52f630964..bbcf29657a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key.and.includes/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.generated.as/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -36,20 +36,19 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "CREATE SOURCE IF NOT EXISTS cities_source (*)\n" - "INCLUDE header 'zilla:correlation-id' AS zilla_correlation_id_header\n" - "INCLUDE header 'zilla:identity' AS zilla_identity_header\n" - "INCLUDE timestamp AS zilla_timestamp_timestamp\n" - "WITH (\n" - " connector='kafka',\n" - " properties.bootstrap.server='localhost:9092',\n" - " topic='public.cities',\n" - " scan.startup.mode='latest',\n" - " scan.startup.timestamp.millis='140000000'\n" - ") FORMAT PLAIN ENCODE AVRO (\n" - " schema.registry = 'http://localhost:8081'\n" - ");" - [0x00] +read "CREATE SOURCE IF NOT EXISTS cities_source (*)\n" + "INCLUDE header 'zilla:identity' AS owner_id_header\n" + "INCLUDE timestamp AS created_at_timestamp\n" + "WITH (\n" + " connector='kafka',\n" + " properties.bootstrap.server='localhost:9092',\n" + " topic='public.cities',\n" + " scan.startup.mode='latest',\n" + " scan.startup.timestamp.millis='140000000'\n" + ") FORMAT PLAIN ENCODE AVRO (\n" + " schema.registry = 'http://localhost:8081'\n" + ");" + [0x00] write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) @@ -72,9 +71,8 @@ read zilla:data.ext ${pgsql:dataEx() .build()} read "CREATE MATERIALIZED VIEW IF NOT EXISTS cities_view" " AS SELECT id, name, description," - " COALESCE(zilla_correlation_id, zilla_correlation_id_header::varchar) as zilla_correlation_id," - " COALESCE(zilla_identity, zilla_identity_header::varchar) as zilla_identity," - " COALESCE(zilla_timestamp, zilla_timestamp_timestamp::varchar) as zilla_timestamp" + " COALESCE(owner_id, owner_id_header::varchar) as owner_id," + " COALESCE(created_at, created_at_timestamp::timestamp) as created_at" " FROM cities_source;" [0x00] @@ -99,7 +97,7 @@ read zilla:data.ext ${pgsql:dataEx() .build()} read "CREATE TABLE IF NOT EXISTS cities" " (id VARCHAR, name VARCHAR, description VARCHAR," - " zilla_correlation_id VARCHAR, zilla_identity VARCHAR, zilla_timestamp TIMESTAMP," + " owner_id VARCHAR, created_at TIMESTAMP," " PRIMARY KEY (id));" [0x00] @@ -122,7 +120,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "GRANT ALL PRIVILEGES ON TABLE public.cities TO app;" +read "GRANT ALL PRIVILEGES ON TABLE public.cities TO zillabase;" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -192,11 +190,38 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "INSERT INTO zb_catalog.ztables (name, sql) VALUES " + "('cities', 'CREATE ZTABLE IF NOT EXISTS cities " + "(id VARCHAR, name VARCHAR, description VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id));');" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("INSERT 0 2") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -212,7 +237,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -225,10 +250,13 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "CREATE TOPIC IF NOT EXISTS cities " - "(id VARCHAR, name VARCHAR, description VARCHAR," - " zilla_correlation_id VARCHAR, zilla_identity VARCHAR, zilla_timestamp TIMESTAMP," - " PRIMARY KEY (id));" +read "CREATE TOPIC IF NOT EXISTS cities (" + "id VARCHAR, " + "name VARCHAR, " + "description VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id));" [0x00] write advise zilla:flush ${pgsql:flushEx() diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.primary.key/client.rpt similarity index 88% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.primary.key/client.rpt index 793f2a2f74..4943ea8eb9 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.primary.key/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -111,7 +111,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "GRANT ALL PRIVILEGES ON TABLE public.cities TO app;" +write "GRANT ALL PRIVILEGES ON TABLE public.cities TO zillabase;" [0x00] write flush @@ -184,13 +184,37 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "INSERT INTO zb_catalog.ztables (name, sql) VALUES " + "('cities', 'CREATE ZTABLE IF NOT EXISTS cities (id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));');" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("INSERT 0 2") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -204,7 +228,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.primary.key/server.rpt similarity index 88% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.primary.key/server.rpt index b99cc414a5..cff56e6277 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.table.with.primary.key/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.ztable.with.primary.key/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -112,7 +112,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "GRANT ALL PRIVILEGES ON TABLE public.cities TO app;" +read "GRANT ALL PRIVILEGES ON TABLE public.cities TO zillabase;" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -182,11 +182,34 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "INSERT INTO zb_catalog.ztables (name, sql) VALUES " + "('cities', 'CREATE ZTABLE IF NOT EXISTS cities (id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));');" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("INSERT 0 2") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -202,7 +225,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/client.rpt index 79bd3ca5d2..1edd5d3faf 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -56,7 +56,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "GRANT ALL PRIVILEGES ON MATERIALIZED VIEW public.distinct_cities TO app;" +write "GRANT ALL PRIVILEGES ON MATERIALIZED VIEW public.distinct_cities TO zillabase;" [0x00] write flush @@ -79,7 +79,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "DESCRIBE distinct_cities;" +write "DESCRIBE public.distinct_cities;" [0x00] read advised zilla:flush ${pgsql:flushEx() @@ -204,7 +204,7 @@ write zilla:data.ext ${pgsql:dataEx() .build() .build()} write "INSERT INTO zb_catalog.zviews (name, sql) VALUES " - "('distinct_cities', 'CREATE MATERIALIZED VIEW IF NOT EXISTS distinct_cities AS SELECT id, city FROM weather GROUP BY city;');" + "('distinct_cities', 'CREATE ZVIEW IF NOT EXISTS distinct_cities AS SELECT id, city FROM weather GROUP BY city;');" [0x00] write flush @@ -228,7 +228,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -242,7 +242,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/server.rpt index 7028a490f8..b130e58c42 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/create.zview/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -57,7 +57,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "GRANT ALL PRIVILEGES ON MATERIALIZED VIEW public.distinct_cities TO app;" +read "GRANT ALL PRIVILEGES ON MATERIALIZED VIEW public.distinct_cities TO zillabase;" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -79,7 +79,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "DESCRIBE distinct_cities;" +read "DESCRIBE public.distinct_cities;" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -208,7 +208,7 @@ read zilla:data.ext ${pgsql:dataEx() .build() .build()} read "INSERT INTO zb_catalog.zviews (name, sql) VALUES " - "('distinct_cities', 'CREATE MATERIALIZED VIEW IF NOT EXISTS distinct_cities AS SELECT id, city FROM weather GROUP BY city;');" + "('distinct_cities', 'CREATE ZVIEW IF NOT EXISTS distinct_cities AS SELECT id, city FROM weather GROUP BY city;');" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -230,7 +230,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -246,7 +246,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/client.rpt index 61fc9fc126..9af567a8d8 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -32,7 +32,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "DROP SOURCE weather;" +write "DROP SOURCE zb_catalog.weather;" [0x00] write flush @@ -56,7 +56,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -70,7 +70,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/server.rpt index 0e821f3fc3..f374ef1099 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.stream/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -36,7 +36,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "DROP SOURCE weather;" +read "DROP SOURCE zb_catalog.weather;" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -57,7 +57,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -73,7 +73,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.table/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.ztable/client.rpt similarity index 87% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.table/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.ztable/client.rpt index eef388d7c7..081bbf5bc7 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.table/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.ztable/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -96,6 +96,29 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "DELETE FROM zb_catalog.ztables WHERE name = 'weather';" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("DELETE 0 1") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + write zilla:data.ext ${pgsql:dataEx() .typeId(zilla:id("pgsql")) .query() @@ -148,7 +171,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -162,7 +185,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.table/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.ztable/server.rpt similarity index 87% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.table/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.ztable/server.rpt index 239dfb1ead..e9a7bb2eff 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.table/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.ztable/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -97,6 +97,28 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "DELETE FROM zb_catalog.ztables WHERE name = 'weather';" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("DELETE 0 1") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + read zilla:data.ext ${pgsql:dataEx() .typeId(zilla:id("pgsql")) .query() @@ -145,7 +167,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -161,7 +183,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/client.rpt index bd6e1d2c2d..29925cbddc 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -103,7 +103,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -117,7 +117,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/server.rpt index ffa1d07358..6ea1be4803 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/drop.zview/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -100,7 +100,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -116,7 +116,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/client.rpt index 7beaa96ed5..d3fc8a8516 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -67,7 +67,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -104,7 +104,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/server.rpt index 0d49df82b6..a26fed89d4 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements.errored/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -68,7 +68,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -106,7 +106,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/client.rpt index 3b272f9e07..96a790603a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -111,7 +111,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "GRANT ALL PRIVILEGES ON TABLE public.cities TO app;" +write "GRANT ALL PRIVILEGES ON TABLE public.cities TO zillabase;" [0x00] write flush @@ -184,13 +184,36 @@ read advised zilla:flush ${pgsql:flushEx() .build() .build()} +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "INSERT INTO zb_catalog.ztables (name, sql) VALUES " + "('cities', 'CREATE ZTABLE IF NOT EXISTS cities (id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));');" + [0x00] + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("INSERT 0 2") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + connect "zilla://streams/app1" option zilla:window 8192 option zilla:transmission "duplex" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -227,7 +250,7 @@ connect "zilla://streams/app2" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/server.rpt index de21ba0f49..81923bfa3b 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/query.with.multiple.statements/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -112,7 +112,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "GRANT ALL PRIVILEGES ON TABLE public.cities TO app;" +read "GRANT ALL PRIVILEGES ON TABLE public.cities TO zillabase;" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -182,11 +182,34 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "INSERT INTO zb_catalog.ztables (name, sql) VALUES " + "('cities', 'CREATE ZTABLE IF NOT EXISTS cities (id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));');" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("INSERT 0 2") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -224,7 +247,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/client.rpt index c953e14921..05ed3e2ebf 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/server.rpt index 413947e6a0..bd11cbdb4a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/set.variable/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/client.rpt index 973ef5e4ab..687e504752 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/server.rpt index 3d55f1cf56..f5be0060df 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.tables.with.newline/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,7 +33,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -72,8 +72,6 @@ write advise zilla:flush ${pgsql:flushEx() .build() .build()} -write notify CREATE_TOPIC_COMPLETED - write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .ready() diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.ztables/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.ztables/client.rpt new file mode 100644 index 0000000000..183c87362f --- /dev/null +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.ztables/client.rpt @@ -0,0 +1,102 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +connect "zilla://streams/app1" + option zilla:window 8192 + option zilla:transmission "duplex" + +write zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "postgres") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "SELECT * FROM zb_catalog.ztables;" + [0x00] + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .type() + .column() + .name("name") + .tableOid(0) + .index(0) + .typeOid(701) + .length(8) + .modifier(-1) + .format("TEXT") + .build() + .column() + .name("sql") + .tableOid(0) + .index(0) + .typeOid(20) + .length(8) + .modifier(-1) + .format("TEXT") + .build() + .build() + .build()} + +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .row() + .build() + .build()} +read [0x00 0x02] # Field Count + [0x00 0x00 0x00 0x06] # Length + [0x63 0x69 0x74 0x69 0x65 0x73] # Data + [0x00 0x00 0x00 0x65] # Length + "CREATE ZTABLE IF NOT EXISTS cities " # Data + "(id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));" + [0x00] + + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("SELECT 1") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + +connect "zilla://streams/app1" + option zilla:window 8192 + option zilla:transmission "duplex" + +write zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "zillabase") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.ztables/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.ztables/server.rpt new file mode 100644 index 0000000000..c407fc66ee --- /dev/null +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.ztables/server.rpt @@ -0,0 +1,104 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +accept "zilla://streams/app1" + option zilla:window 8192 + option zilla:transmission "duplex" + +accepted + +read zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "postgres") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "SELECT * FROM zb_catalog.ztables;" +read [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .type() + .column() + .name("name") + .tableOid(0) + .index(0) + .typeOid(701) + .length(8) + .modifier(-1) + .format("TEXT") + .build() + .column() + .name("sql") + .tableOid(0) + .index(0) + .typeOid(20) + .length(8) + .modifier(-1) + .format("TEXT") + .build() + .build() + .build()} + +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .row() + .build() + .build()} +write [0x00 0x02] # Field Count + [0x00 0x00 0x00 0x06] # Length + [0x63 0x69 0x74 0x69 0x65 0x73] # Data + [0x00 0x00 0x00 0x65] # Length + "CREATE ZTABLE IF NOT EXISTS cities " # Data + "(id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));" + [0x00] +write flush + + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("SELECT 1") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + +accepted + +read zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "zillabase") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/client.rpt index 47139b40a5..a87203a830 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -70,6 +70,7 @@ read [0x00 0x02] # Field Count [0x00 0x00 0x00 0x65] # Length "CREATE MATERIALIZED VIEW IF NOT EXISTS distinct_cities AS" # Data " SELECT id, city FROM weather GROUP BY city;" + [0x00] read advised zilla:flush ${pgsql:flushEx() @@ -92,7 +93,7 @@ connect "zilla://streams/app1" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/server.rpt index 050011cf75..1d6af65ec3 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/effective/show.zviews/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "zillabase") + .parameter("user", "postgres") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -72,6 +72,8 @@ write [0x00 0x02] # Field Count [0x00 0x00 0x00 0x65] # Length "CREATE MATERIALIZED VIEW IF NOT EXISTS distinct_cities AS" # Data " SELECT id, city FROM weather GROUP BY city;" + [0x00] + write flush @@ -93,7 +95,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/client.rpt index c5718e47ff..874e48db35 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/client.rpt @@ -20,7 +20,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/server.rpt index 2135e6de29..8cf47f30b7 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.add.column/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/client.rpt index d3ac322ab9..c92417c41a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/server.rpt index c4e764908a..6545acb336 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.stream.modify.column.rejected/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.add.column/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.add.column/client.rpt similarity index 91% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.add.column/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.add.column/client.rpt index 426ab704cd..5d24fafc09 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.add.column/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.add.column/client.rpt @@ -20,7 +20,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -33,14 +33,14 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "ALTER TABLE cities ADD COLUMN zip INT;" +write "ALTER ZTABLE cities ADD COLUMN zip INT;" [0x00] write flush read advised zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("ALTER_TABLE") + .tag("ALTER_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.add.column/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.add.column/server.rpt similarity index 91% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.add.column/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.add.column/server.rpt index 9d92c3f447..7187c2ddbc 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.add.column/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.add.column/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -34,13 +34,13 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "ALTER TABLE cities ADD COLUMN zip INT;" +read "ALTER ZTABLE cities ADD COLUMN zip INT;" [0x00] write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("ALTER_TABLE") + .tag("ALTER_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.modify.column.rejected/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.modify.column.rejected/client.rpt similarity index 91% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.modify.column.rejected/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.modify.column.rejected/client.rpt index 3089f09f9c..1c43d6863b 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.modify.column.rejected/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.modify.column.rejected/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -32,7 +32,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "ALTER TABLE cities ALTER COLUMN name TYPE VARCHAR(100);" +write "ALTER ZTABLE cities ALTER COLUMN name TYPE VARCHAR(100);" [0x00] write flush @@ -41,7 +41,7 @@ read advised zilla:flush ${pgsql:flushEx() .error() .severity("ERROR") .code("XX000") - .message("Unable to execute command because ALTER TABLE only supports ADD") + .message("Unable to execute command because ALTER ZTABLE only supports ADD") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.modify.column.rejected/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.modify.column.rejected/server.rpt similarity index 91% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.modify.column.rejected/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.modify.column.rejected/server.rpt index 51af902532..adbe13da2e 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.table.modify.column.rejected/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/alter.ztable.modify.column.rejected/server.rpt @@ -21,7 +21,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -34,7 +34,7 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "ALTER TABLE cities ALTER COLUMN name TYPE VARCHAR(100);" +read "ALTER ZTABLE cities ALTER COLUMN name TYPE VARCHAR(100);" [0x00] write advise zilla:flush ${pgsql:flushEx() @@ -42,7 +42,7 @@ write advise zilla:flush ${pgsql:flushEx() .error() .severity("ERROR") .code("XX000") - .message("Unable to execute command because ALTER TABLE only supports ADD") + .message("Unable to execute command because ALTER ZTABLE only supports ADD") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/client.rpt index d5bd599d07..335e271f7a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/server.rpt index 443f0a0789..54f9582bba 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded.python/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/client.rpt index da966e7de3..347f459fd4 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/server.rpt index 61f02331cb..506c18cb76 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.embedded/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/client.rpt index 5743663f5b..4072ec2141 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/server.rpt index 17a18c0a37..33c2481860 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.python/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/client.rpt index ecb1a85122..195b4b32a2 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/server.rpt index e935a29277..d9f0266ddb 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.struct/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/client.rpt index 2994e3e31a..cb05af0956 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/server.rpt index 1a41a2beb6..8d202fda35 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function.return.table/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/client.rpt index 602e61dc72..5114f0b3f2 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/server.rpt index a7a67bb86e..426679a572 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.function/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/client.rpt index d6e72191a1..ae34f2e2d4 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/server.rpt index 2f6ace88dc..6df251e227 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream.with.includes/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/client.rpt index ddf2c5c990..d8b4ff2531 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/server.rpt index 81cbbcfd7f..c21726633a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.stream/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/client.rpt index da276503e5..dd9738c83a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/server.rpt index 952efb6b8a..c5efb2d291 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.streams/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.generated.as/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.generated.as/client.rpt new file mode 100644 index 0000000000..0c839c34a9 --- /dev/null +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.generated.as/client.rpt @@ -0,0 +1,58 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +connect "zilla://streams/app0" + option zilla:window 8192 + option zilla:transmission "duplex" + +write zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "zillabase") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "CREATE ZTABLE IF NOT EXISTS cities (" + "id VARCHAR, " + "name VARCHAR, " + "description VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id));" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("CREATE_ZTABLE") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key.and.includes/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.generated.as/server.rpt similarity index 82% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key.and.includes/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.generated.as/server.rpt index c4adad606f..a6b83f0482 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key.and.includes/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.generated.as/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -36,16 +36,19 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "CREATE TABLE IF NOT EXISTS cities " - "(id VARCHAR, name VARCHAR, description VARCHAR," - " zilla_correlation_id VARCHAR, zilla_identity VARCHAR, zilla_timestamp TIMESTAMP," - " PRIMARY KEY (id));" +read "CREATE ZTABLE IF NOT EXISTS cities (" + "id VARCHAR, " + "name VARCHAR, " + "description VARCHAR, " + "owner_id VARCHAR GENERATED ALWAYS AS IDENTITY, " + "created_at TIMESTAMP GENERATED ALWAYS AS NOW, " + "PRIMARY KEY (id));" [0x00] write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("CREATE_TABLE") + .tag("CREATE_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.primary.key/client.rpt similarity index 91% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.primary.key/client.rpt index 9a4f417a13..5c753fd7f5 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.primary.key/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -32,7 +32,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "CREATE TABLE IF NOT EXISTS cities " +write "CREATE ZTABLE IF NOT EXISTS cities " "(id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));" [0x00] @@ -41,7 +41,7 @@ write flush read advised zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("CREATE_TABLE") + .tag("CREATE_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.primary.key/server.rpt similarity index 92% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.primary.key/server.rpt index 6c172b0db7..3304e9deb3 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.table.with.primary.key/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.ztable.with.primary.key/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -36,14 +36,14 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "CREATE TABLE IF NOT EXISTS cities " +read "CREATE ZTABLE IF NOT EXISTS cities " "(id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));" [0x00] write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("CREATE_TABLE") + .tag("CREATE_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/client.rpt index a47f3d74b2..0fecebe6a5 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/server.rpt index a001a3e0a5..732f8c0713 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/create.zview/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/client.rpt index 4fa3fc1ef3..4f5f97fa98 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/server.rpt index 60c210249c..fa03d1578d 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.stream/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.table/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.ztable/client.rpt similarity index 92% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.table/client.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.ztable/client.rpt index 593846bdfb..ea92248810 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.table/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.ztable/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -32,7 +32,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "DROP TABLE weather;" +write "DROP ZTABLE weather;" [0x00] write flush @@ -40,7 +40,7 @@ write flush read advised zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("DROP_TABLE") + .tag("DROP_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.table/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.ztable/server.rpt similarity index 92% rename from incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.table/server.rpt rename to incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.ztable/server.rpt index fdc6bce367..1b94af8ae2 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.table/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.ztable/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -36,13 +36,13 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "DROP TABLE weather;" +read "DROP ZTABLE weather;" [0x00] write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("DROP_TABLE") + .tag("DROP_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/client.rpt index 51142ae4ae..a68a6f2a94 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/server.rpt index f61c2b2d6f..554b669f8f 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/drop.zview/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/client.rpt index aebeed5450..33ea204516 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/server.rpt index de6655efd6..dba2134d4a 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements.errored/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/client.rpt index 6838351c29..831810e2cb 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -32,7 +32,7 @@ write zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -write "CREATE TABLE IF NOT EXISTS cities " +write "CREATE ZTABLE IF NOT EXISTS cities " "(id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));" "UPDATE weather SET id = 'SF';" [0x00] @@ -42,7 +42,7 @@ write flush read advised zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("CREATE_TABLE") + .tag("CREATE_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/server.rpt index 742ea02bb7..a325b1923c 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/query.with.multiple.statements/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") @@ -36,14 +36,14 @@ read zilla:data.ext ${pgsql:dataEx() .query() .build() .build()} -read "CREATE TABLE IF NOT EXISTS cities " +read "CREATE ZTABLE IF NOT EXISTS cities " "(id VARCHAR, name VARCHAR, description VARCHAR, PRIMARY KEY (id));" "UPDATE weather SET id = 'SF';" [0x00] write advise zilla:flush ${pgsql:flushEx() .typeId(zilla:id("pgsql")) .completion() - .tag("CREATE_TABLE") + .tag("CREATE_ZTABLE") .build() .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/client.rpt index 47da738c0e..62231364d7 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/server.rpt index bc89f126ce..0adcb52382 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/set.variable/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/client.rpt index 0c739d5226..270b9b4247 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/server.rpt index f0d34142f6..66dfd41845 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.tables.with.newline/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.ztables/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.ztables/client.rpt new file mode 100644 index 0000000000..ee41dddaf1 --- /dev/null +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.ztables/client.rpt @@ -0,0 +1,76 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +connect "zilla://streams/app0" + option zilla:window 8192 + option zilla:transmission "duplex" + +write zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "zillabase") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +write "SHOW ZTABLES;" + [0x00] +write flush + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .type() + .column() + .name("Name") + .tableOid(0) + .index(0) + .typeOid(701) + .length(4) + .modifier(-1) + .format("TEXT") + .build() + .build() + .build()} + +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .row() + .build() + .build()} +read [0x00 0x01] # Field Count + [0x00 0x00 0x00 0x06] # Length + [0x63 0x69 0x74 0x69 0x65 0x73] # Data + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("SHOW_COMMAND") + .build() + .build()} + +read advised zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} + diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.ztables/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.ztables/server.rpt new file mode 100644 index 0000000000..9ac7e754f2 --- /dev/null +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.ztables/server.rpt @@ -0,0 +1,79 @@ +# +# Copyright 2021-2024 Aklivity Inc +# +# Licensed under the Aklivity Community License (the "License"); you may not use +# this file except in compliance with the License. You may obtain a copy of the +# License at +# +# https://www.aklivity.io/aklivity-community-license/ +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +property serverAddress "zilla://streams/app0" + +accept ${serverAddress} + option zilla:window 8192 + option zilla:transmission "duplex" + +accepted + +read zilla:begin.ext ${pgsql:beginEx() + .typeId(zilla:id("pgsql")) + .parameter("user", "zillabase") + .parameter("database", "dev") + .parameter("application_name", "psql") + .parameter("client_encoding", "UTF8") + .build()} + +connected + +read zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .query() + .build() + .build()} +read "SHOW ZTABLES;" + [0x00] + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .type() + .column() + .name("Name") + .tableOid(0) + .index(0) + .typeOid(701) + .length(4) + .modifier(-1) + .format("TEXT") + .build() + .build() + .build()} +write flush + +write zilla:data.ext ${pgsql:dataEx() + .typeId(zilla:id("pgsql")) + .row() + .build() + .build()} +write [0x00 0x01] # Field Count + [0x00 0x00 0x00 0x06] # Length + [0x63 0x69 0x74 0x69 0x65 0x73] # Data + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .completion() + .tag("SHOW_COMMAND") + .build() + .build()} + +write advise zilla:flush ${pgsql:flushEx() + .typeId(zilla:id("pgsql")) + .ready() + .status("IDLE") + .build() + .build()} diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/client.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/client.rpt index 6a7a998074..4f701af13b 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/client.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/client.rpt @@ -19,7 +19,7 @@ connect "zilla://streams/app0" write zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/server.rpt b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/server.rpt index cd25c522eb..5f42c02f56 100644 --- a/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/server.rpt +++ b/incubator/binding-risingwave.spec/src/main/scripts/io/aklivity/zilla/specs/binding/risingwave/streams/pgsql/show.zviews/server.rpt @@ -23,7 +23,7 @@ accepted read zilla:begin.ext ${pgsql:beginEx() .typeId(zilla:id("pgsql")) - .parameter("user", "app") + .parameter("user", "zillabase") .parameter("database", "dev") .parameter("application_name", "psql") .parameter("client_encoding", "UTF8") diff --git a/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/EffectiveIT.java b/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/EffectiveIT.java index 5dfa9a0fd5..90f971869a 100644 --- a/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/EffectiveIT.java +++ b/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/EffectiveIT.java @@ -38,10 +38,10 @@ public class EffectiveIT @Test @Specification({ - "${app}/create.table.with.primary.key/client", - "${app}/create.table.with.primary.key/server" + "${app}/create.ztable.with.primary.key/client", + "${app}/create.ztable.with.primary.key/server" }) - public void shouldCreateTableWithPrimaryKey() throws Exception + public void shouldCreateZtableWithPrimaryKey() throws Exception { k3po.finish(); } @@ -145,9 +145,9 @@ public void shouldCreateStreamWithIncludes() throws Exception @Test @Specification({ - "${app}/create.table.with.primary.key.and.includes/client", - "${app}/create.table.with.primary.key.and.includes/server" }) - public void shouldCreateTableWithPrimaryKeyAndIncludes() throws Exception + "${app}/create.ztable.with.generated.as/client", + "${app}/create.ztable.with.generated.as/server" }) + public void shouldCreateTableWithGeneratedAs() throws Exception { k3po.finish(); } @@ -193,9 +193,9 @@ public void shouldSetVariable() throws Exception @Test @Specification({ - "${app}/drop.table/client", - "${app}/drop.table/server" }) - public void shouldDropTable() throws Exception + "${app}/drop.ztable/client", + "${app}/drop.ztable/server" }) + public void shouldDropZtable() throws Exception { k3po.finish(); } @@ -220,9 +220,9 @@ public void shouldDropZview() throws Exception @Test @Specification({ - "${app}/alter.table.add.column/client", - "${app}/alter.table.add.column/server" }) - public void shouldAlterTableAddColumn() throws Exception + "${app}/alter.ztable.add.column/client", + "${app}/alter.ztable.add.column/server" }) + public void shouldAlterZtableAddColumn() throws Exception { k3po.finish(); } diff --git a/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/PgsqlIT.java b/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/PgsqlIT.java index 6c0303d11b..9f9eeccdb6 100644 --- a/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/PgsqlIT.java +++ b/incubator/binding-risingwave.spec/src/test/java/io/aklivity/zilla/specs/binding/risingwave/streams/PgsqlIT.java @@ -38,10 +38,10 @@ public class PgsqlIT @Test @Specification({ - "${app}/create.table.with.primary.key/client", - "${app}/create.table.with.primary.key/server" + "${app}/create.ztable.with.primary.key/client", + "${app}/create.ztable.with.primary.key/server" }) - public void shouldCreateTableWithPrimaryKey() throws Exception + public void shouldCreateZtableWithPrimaryKey() throws Exception { k3po.finish(); } @@ -145,9 +145,9 @@ public void shouldCreateStreamWithIncludes() throws Exception @Test @Specification({ - "${app}/create.table.with.primary.key.and.includes/client", - "${app}/create.table.with.primary.key.and.includes/server" }) - public void shouldCreateTableWithPrimaryKeyAndIncludes() throws Exception + "${app}/create.ztable.with.generated.as/client", + "${app}/create.ztable.with.generated.as/server" }) + public void shouldCreateTableWithGeneratedAs() throws Exception { k3po.finish(); } @@ -191,9 +191,9 @@ public void shouldSetVariable() throws Exception @Test @Specification({ - "${app}/drop.table/client", - "${app}/drop.table/server" }) - public void shouldDropTable() throws Exception + "${app}/drop.ztable/client", + "${app}/drop.ztable/server" }) + public void shouldDropZtable() throws Exception { k3po.finish(); } @@ -218,8 +218,8 @@ public void shouldDropZview() throws Exception @Test @Specification({ - "${app}/alter.table.add.column/client", - "${app}/alter.table.add.column/server" }) + "${app}/alter.ztable.add.column/client", + "${app}/alter.ztable.add.column/server" }) public void shouldAlterTableAddColumn() throws Exception { k3po.finish(); @@ -236,9 +236,9 @@ public void shouldAlterStreamAddColumn() throws Exception @Test @Specification({ - "${app}/alter.table.modify.column.rejected/client", - "${app}/alter.table.modify.column.rejected/server" }) - public void shouldNotAlterTableModifyColumn() throws Exception + "${app}/alter.ztable.modify.column.rejected/client", + "${app}/alter.ztable.modify.column.rejected/server" }) + public void shouldNotAlterZtableModifyColumn() throws Exception { k3po.finish(); } diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveBindingConfig.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveBindingConfig.java index 2043e0c73d..d1fd0d5cb1 100644 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveBindingConfig.java +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveBindingConfig.java @@ -24,24 +24,6 @@ import io.aklivity.zilla.runtime.binding.risingwave.config.RisingwaveOptionsConfig; import io.aklivity.zilla.runtime.binding.risingwave.config.RisingwaveUdfConfig; import io.aklivity.zilla.runtime.binding.risingwave.internal.RisingwaveConfiguration; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveAlterTableTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveAlterTopicTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveCreateFunctionTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveCreateMaterializedViewTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveCreateSinkTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveCreateSourceTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveCreateTableTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveCreateTopicTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDeleteFromCatalogTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDescribeTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDropMaterializedViewTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDropSinkTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDropSourceTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDropTableTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveDropTopicTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveGrantToSourceTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveInsertIntoCatalogTemplate; -import io.aklivity.zilla.runtime.binding.risingwave.internal.statement.RisingwaveShowTypeTemplate; import io.aklivity.zilla.runtime.engine.catalog.CatalogHandler; import io.aklivity.zilla.runtime.engine.config.BindingConfig; import io.aklivity.zilla.runtime.engine.config.CatalogedConfig; @@ -49,32 +31,16 @@ public final class RisingwaveBindingConfig { - private static final String INTERNAL_SCHEMA = "zb_catalog"; - private static final String PUBLIC_SCHEMA = "public"; + public static final String INTERNAL_SCHEMA = "zb_catalog"; + public static final String PUBLIC_SCHEMA = "public"; public final long id; public final String name; public final RisingwaveOptionsConfig options; public final KindConfig kind; public final List routes; - public final RisingwaveCreateTopicTemplate createTopic; - public final RisingwaveCreateMaterializedViewTemplate createView; - public final RisingwaveDescribeTemplate describeView; - public final RisingwaveCreateTableTemplate createTable; - public final RisingwaveCreateSourceTemplate createSource; - public final RisingwaveCreateSinkTemplate createSink; - public final RisingwaveCreateFunctionTemplate createFunction; - public final RisingwaveAlterTableTemplate alterTable; - public final RisingwaveAlterTopicTemplate alterTopic; - public final RisingwaveDropTableTemplate dropTable; - public final RisingwaveDropSourceTemplate dropSource; - public final RisingwaveDropTopicTemplate dropTopic; - public final RisingwaveDropMaterializedViewTemplate dropMaterializedView; - public final RisingwaveDropSinkTemplate dropSink; - public final RisingwaveInsertIntoCatalogTemplate catalogInsert; - public final RisingwaveDeleteFromCatalogTemplate catalogDelete; - public final RisingwaveGrantToSourceTemplate grantResource; - public final RisingwaveShowTypeTemplate showType; + public final String bootstrapServer; + public final String schemaRegistry; public RisingwaveBindingConfig( RisingwaveConfiguration config, @@ -88,7 +54,7 @@ public RisingwaveBindingConfig( this.routes = binding.routes.stream().map(RisingwaveRouteConfig::new).collect(toList()); String bootstrapServer = null; - String location = null; + String schemaRegistry = null; RisingwaveUdfConfig udf = null; if (options.kafka != null) @@ -98,28 +64,11 @@ public RisingwaveBindingConfig( final CatalogHandler catalogHandler = supplyCatalog.apply(cataloged.id); bootstrapServer = options.kafka.properties.bootstrapServer; - location = catalogHandler.location(); + schemaRegistry = catalogHandler.location(); } - this.createTable = new RisingwaveCreateTableTemplate(); - this.createSource = new RisingwaveCreateSourceTemplate(bootstrapServer, - location, config.kafkaScanStartupTimestampMillis()); - this.createSink = new RisingwaveCreateSinkTemplate(INTERNAL_SCHEMA, bootstrapServer, location); - this.createTopic = new RisingwaveCreateTopicTemplate(); - this.createView = new RisingwaveCreateMaterializedViewTemplate(); - this.alterTable = new RisingwaveAlterTableTemplate(); - this.alterTopic = new RisingwaveAlterTopicTemplate(); - this.describeView = new RisingwaveDescribeTemplate(); - this.dropTopic = new RisingwaveDropTopicTemplate(); - this.dropTable = new RisingwaveDropTableTemplate(); - this.dropSource = new RisingwaveDropSourceTemplate(); - this.dropMaterializedView = new RisingwaveDropMaterializedViewTemplate(); - this.dropSink = new RisingwaveDropSinkTemplate(INTERNAL_SCHEMA); - this.createFunction = new RisingwaveCreateFunctionTemplate(options.udfs); - this.catalogInsert = new RisingwaveInsertIntoCatalogTemplate(INTERNAL_SCHEMA); - this.catalogDelete = new RisingwaveDeleteFromCatalogTemplate(INTERNAL_SCHEMA); - this.grantResource = new RisingwaveGrantToSourceTemplate(); - this.showType = new RisingwaveShowTypeTemplate(); + this.bootstrapServer = bootstrapServer; + this.schemaRegistry = schemaRegistry; } public RisingwaveRouteConfig resolve( diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveCommandType.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveCommandType.java index 65297a968c..2f5209f51a 100644 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveCommandType.java +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/config/RisingwaveCommandType.java @@ -19,17 +19,18 @@ public enum RisingwaveCommandType { CREATE_TOPIC_COMMAND("CREATE TOPIC".getBytes()), - CREATE_TABLE_COMMAND("CREATE TABLE".getBytes()), + CREATE_ZTABLE_COMMAND("CREATE ZTABLE".getBytes()), CREATE_STREAM_COMMAND("CREATE STREAM".getBytes()), CREATE_ZVIEW_COMMAND("CREATE ZVIEW".getBytes()), CREATE_FUNCTION_COMMAND("CREATE FUNCTION".getBytes()), - ALTER_TABLE_COMMAND("ALTER TABLE".getBytes()), + ALTER_ZTABLE_COMMAND("ALTER ZTABLE".getBytes()), ALTER_STREAM_COMMAND("ALTER STREAM".getBytes()), ALTER_TOPIC_COMMAND("ALTER TOPIC".getBytes()), DROP_TOPIC_COMMAND("DROP TOPIC".getBytes()), - DROP_TABLE_COMMAND("DROP TABLE".getBytes()), + DROP_ZTABLE_COMMAND("DROP ZTABLE".getBytes()), DROP_STREAM_COMMAND("DROP STREAM".getBytes()), DROP_ZVIEW_COMMAND("DROP ZVIEW".getBytes()), + SHOW_ZTABLES_COMMAND("SHOW ZTABLES".getBytes()), SHOW_ZVIEWS_COMMAND("SHOW ZVIEWS".getBytes()), UNKNOWN_COMMAND("UNKNOWN".getBytes()); diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveAlterStreamMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveAlterStreamMacro.java new file mode 100644 index 0000000000..919bfd561c --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveAlterStreamMacro.java @@ -0,0 +1,97 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveAlterStreamMacro extends RisingwaveMacroBase +{ + private final StringBuilder fieldBuilder; + private final Alter command; + + public RisingwaveAlterStreamMacro( + String sql, + Alter command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.command = command; + this.fieldBuilder = new StringBuilder(); + } + + public RisingwaveMacroState start() + { + return new AlterTopicState(); + } + + private final class AlterTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + ALTER TOPIC %s %s;\u0000"""; + private final String fieldFormat = "%s COLUMN %s %s, "; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + fieldBuilder.setLength(0); + + command.expressions() + .forEach(c -> fieldBuilder.append( + String.format(fieldFormat, c.operation().name(), c.columnName(), c.columnType()))); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.ALTER_STREAM_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } + +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveAlterZtableMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveAlterZtableMacro.java new file mode 100644 index 0000000000..d5740d9699 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveAlterZtableMacro.java @@ -0,0 +1,144 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveAlterZtableMacro extends RisingwaveMacroBase +{ + private final StringBuilder fieldBuilder; + private final Alter command; + + public RisingwaveAlterZtableMacro( + String sql, + Alter command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.command = command; + this.fieldBuilder = new StringBuilder(); + } + + public RisingwaveMacroState start() + { + return new AlterTopicState(); + } + + private final class AlterTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + ALTER TOPIC %s %s;\u0000"""; + private final String fieldFormat = "%s COLUMN %s %s, "; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + fieldBuilder.setLength(0); + + command.expressions() + .forEach(c -> fieldBuilder.append( + String.format(fieldFormat, c.operation().name(), c.columnName(), c.columnType()))); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + AlterTableState state = new AlterTableState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + + return errorState(); + } + } + + private final class AlterTableState implements RisingwaveMacroState + { + private final String sqlFormat = """ + ALTER TABLE %s %s;\u0000"""; + private final String fieldFormat = "%s COLUMN %s %s, "; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + fieldBuilder.setLength(0); + + command.expressions() + .forEach(c -> fieldBuilder.append( + String.format(fieldFormat, c.operation().name(), c.columnName(), c.columnType()))); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.ALTER_ZTABLE_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateFunctionMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateFunctionMacro.java new file mode 100644 index 0000000000..3459e9ac07 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateFunctionMacro.java @@ -0,0 +1,165 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import java.util.List; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Function; +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.FunctionArgument; +import io.aklivity.zilla.runtime.binding.risingwave.config.RisingwaveUdfConfig; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveCreateFunctionMacro extends RisingwaveMacroBase +{ + private final String javaServer; + private final String pythonServer; + + private final String systemSchema; + private final String user; + private final String sql; + private final Function command; + private final StringBuilder fieldBuilder; + + public RisingwaveCreateFunctionMacro( + List udfs, + String systemSchema, + String user, + String sql, + Function command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + String javaServer = null; + String pythonServer = null; + + if (udfs != null && !udfs.isEmpty()) + { + for (RisingwaveUdfConfig udf : udfs) + { + if (udf.language.equalsIgnoreCase("java")) + { + javaServer = udf.server; + } + else if (udf.language.equalsIgnoreCase("python")) + { + pythonServer = udf.server; + } + } + } + + this.javaServer = javaServer; + this.pythonServer = pythonServer; + this.systemSchema = systemSchema; + this.user = user; + this.sql = sql; + this.command = command; + this.fieldBuilder = new StringBuilder(); + } + + + public RisingwaveMacroState start() + { + return new CreateFunctionState(); + } + + private final class CreateFunctionState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE FUNCTION %s(%s) + RETURNS %s + AS %s + LANGUAGE %s + USING LINK '%s';\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String functionName = command.name(); + String asFunction = command.asFunction(); + List arguments = command.arguments(); + List tables = command.tables(); + + fieldBuilder.setLength(0); + + arguments + .forEach(arg -> fieldBuilder.append( + arg.name() != null + ? "%s %s, ".formatted(arg.name(), arg.type()) + : "%s, ".formatted(arg.type()))); + + if (!arguments.isEmpty()) + { + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + } + String funcArguments = fieldBuilder.toString(); + + String language = command.language() != null ? command.language() : "java"; + String server = "python".equalsIgnoreCase(language) ? pythonServer : javaServer; + + String returnType = command.returnType(); + if (!tables.isEmpty()) + { + fieldBuilder.setLength(0); + fieldBuilder.append("TABLE ("); + tables.forEach(arg -> fieldBuilder.append( + arg.name() != null + ? "%s %s, ".formatted(arg.name(), arg.type()) + : "%s, ".formatted(arg.type()))); + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + fieldBuilder.append(")"); + + returnType = fieldBuilder.toString(); + } + + String sqlQuery = sqlFormat.formatted(functionName, funcArguments, returnType, asFunction, language, server); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.CREATE_FUNCTION_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateStreamMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateStreamMacro.java new file mode 100644 index 0000000000..ae9e05536b --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateStreamMacro.java @@ -0,0 +1,237 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.agrona.collections.Object2ObjectHashMap; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateStream; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveCreateStreamMacro extends RisingwaveMacroBase +{ + //TODO: Remove after implementing zstream + private static final String ZILLA_CORRELATION_ID_OLD = "zilla_correlation_id"; + private static final String ZILLA_IDENTITY_OLD = "zilla_identity"; + private static final String ZILLA_TIMESTAMP_OLD = "zilla_timestamp"; + + private static final Map ZILLA_MAPPINGS_OLD = new Object2ObjectHashMap<>(); + static + { + ZILLA_MAPPINGS_OLD.put(ZILLA_CORRELATION_ID_OLD, "INCLUDE header 'zilla:correlation-id' AS %s\n"); + ZILLA_MAPPINGS_OLD.put(ZILLA_IDENTITY_OLD, "INCLUDE header 'zilla:identity' AS %s\n"); + ZILLA_MAPPINGS_OLD.put(ZILLA_TIMESTAMP_OLD, "INCLUDE timestamp AS %s\n"); + } + + protected final StringBuilder fieldBuilder = new StringBuilder(); + protected final StringBuilder includeBuilder = new StringBuilder(); + + private final String bootstrapServer; + private final String schemaRegistry; + + private final long scanStartupMil; + private final String systemSchema; + private final String user; + private final CreateStream command; + + public RisingwaveCreateStreamMacro( + String bootstrapServer, + String schemaRegistry, + long scanStartupMil, + String systemSchema, + String user, + String sql, + CreateStream command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.scanStartupMil = scanStartupMil; + this.systemSchema = systemSchema; + this.user = user; + this.command = command; + + this.bootstrapServer = bootstrapServer; + this.schemaRegistry = schemaRegistry; + } + + public RisingwaveMacroState start() + { + return new CreateTopicState(); + } + + private final class CreateTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE TOPIC IF NOT EXISTS %s (%s%s);\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + + fieldBuilder.setLength(0); + + command.columns() + .entrySet() + .stream() + .filter(e -> !ZILLA_MAPPINGS_OLD.containsKey(e.getKey())) + .forEach(e -> fieldBuilder.append( + String.format("%s %s, ", e.getKey(), e.getValue()))); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder, ""); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateSourceState state = new CreateSourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + + return errorState(); + } + } + + private final class CreateSourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE SOURCE IF NOT EXISTS %s (*)%s + WITH ( + connector='kafka', + properties.bootstrap.server='%s', + topic='%s.%s', + scan.startup.mode='latest', + scan.startup.timestamp.millis='%d' + ) FORMAT PLAIN ENCODE AVRO ( + schema.registry = '%s' + );\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String schema = command.schema(); + String table = command.name(); + + includeBuilder.setLength(0); + Map includes = command.columns().entrySet().stream() + .filter(e -> ZILLA_MAPPINGS_OLD.containsKey(e.getKey())) + .collect(LinkedHashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), Map::putAll); + + if (!includes.isEmpty()) + { + includeBuilder.append("\n"); + includes.forEach((k, v) -> includeBuilder.append(String.format(ZILLA_MAPPINGS_OLD.get(k), k))); + includeBuilder.delete(includeBuilder.length() - 1, includeBuilder.length()); + } + + String sqlQuery = String.format(sqlFormat, table, includeBuilder, bootstrapServer, schema, + table, scanStartupMil, schemaRegistry); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + GrantResourceState state = new GrantResourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class GrantResourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + GRANT ALL PRIVILEGES ON SOURCE %s.%s TO %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.schema(), command.name(), user); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.CREATE_STREAM_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateZtableMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateZtableMacro.java new file mode 100644 index 0000000000..3b96f90fe9 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateZtableMacro.java @@ -0,0 +1,553 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.agrona.collections.Object2ObjectHashMap; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveCreateZtableMacro extends RisingwaveMacroBase +{ + private static final String ZTABLE_NAME = "ztables"; + private static final String TABLE_NAME = "tables"; + private static final String ZILLA_IDENTITY = "GENERATED ALWAYS AS IDENTITY"; + private static final String ZILLA_TIMESTAMP = "GENERATED ALWAYS AS NOW"; + + private static final Map ZILLA_MAPPINGS = new Object2ObjectHashMap<>(); + static + { + ZILLA_MAPPINGS.put(ZILLA_IDENTITY, "INCLUDE header 'zilla:identity' AS %s\n"); + ZILLA_MAPPINGS.put(ZILLA_TIMESTAMP, "INCLUDE timestamp AS %s\n"); + } + + private final String bootstrapServer; + private final String schemaRegistry; + private final long scanStartupMil; + + private final StringBuilder fieldBuilder; + private final StringBuilder includeBuilder; + private final String systemSchema; + private final String user; + private final CreateTable command; + + public RisingwaveCreateZtableMacro( + String bootstrapServer, + String schemaRegistry, + long scanStartupMil, + String systemSchema, + String user, + String sql, + CreateTable command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.systemSchema = systemSchema; + this.user = user; + this.command = command; + this.fieldBuilder = new StringBuilder(); + this.includeBuilder = new StringBuilder(); + + this.bootstrapServer = bootstrapServer; + this.schemaRegistry = schemaRegistry; + this.scanStartupMil = scanStartupMil; + } + + public RisingwaveMacroState start() + { + return new CreateTopicState(); + } + + private final class CreateTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE TOPIC IF NOT EXISTS %s (%s%s);\u0000"""; + private final String primaryKeyFormat = ", PRIMARY KEY (%s)"; + + private final StringBuilder fieldBuilder = new StringBuilder(); + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + String primaryKey = !command.primaryKeys().isEmpty() + ? String.format(primaryKeyFormat, command.primaryKeys().stream().findFirst().get()) + : ""; + + fieldBuilder.setLength(0); + + command.columns().forEach(c -> + { + fieldBuilder.append(c.name()); + fieldBuilder.append(" "); + fieldBuilder.append(c.type()); + if (!c.constraints().isEmpty()) + { + fieldBuilder.append(" "); + c.constraints().forEach(fieldBuilder::append); + } + fieldBuilder.append(", "); + }); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder, primaryKey); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateSourceState state = new CreateSourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateSourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE SOURCE IF NOT EXISTS %s (*)%s + WITH ( + connector='kafka', + properties.bootstrap.server='%s', + topic='%s.%s', + scan.startup.mode='latest', + scan.startup.timestamp.millis='%d' + ) FORMAT PLAIN ENCODE AVRO ( + schema.registry = '%s' + );\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String schema = command.schema(); + String table = command.name(); + String sourceName = "%s_source".formatted(table); + + includeBuilder.setLength(0); + List includes = command.columns().stream() + .filter(column -> column.constraints().stream() + .anyMatch(ZILLA_MAPPINGS::containsKey)) + .collect(Collectors.toCollection(ArrayList::new)); + + if (!includes.isEmpty()) + { + includeBuilder.append("\n"); + includes.forEach(i -> + { + String name = i.name(); + + i.constraints().stream() + .filter(ZILLA_MAPPINGS::containsKey) + .findFirst() + .ifPresent(c -> + { + if (ZILLA_TIMESTAMP.equals(c)) + { + includeBuilder.append(String.format(ZILLA_MAPPINGS.get(c), "%s_timestamp".formatted(name))); + } + else + { + includeBuilder.append(String.format(ZILLA_MAPPINGS.get(c), "%s_header".formatted(name))); + } + }); + + }); + includeBuilder.delete(includeBuilder.length() - 1, includeBuilder.length()); + } + + String sqlQuery = String.format(sqlFormat, sourceName, includeBuilder, bootstrapServer, + schema, table, scanStartupMil, schemaRegistry); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateMaterializedViewState state = new CreateMaterializedViewState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateMaterializedViewState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE MATERIALIZED VIEW IF NOT EXISTS %s AS %s;\u0000"""; + + private final String includeFormat = "COALESCE(%s, %s_header::%s) as %s, "; + private final String timestampFormat = "COALESCE(%s, %s_timestamp::%s) as %s, "; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String name = command.name(); + + String select = "*"; + List includes = command.columns().stream() + .filter(column -> column.constraints().stream() + .anyMatch(ZILLA_MAPPINGS::containsKey)) + .collect(Collectors.toCollection(ArrayList::new)); + + if (!includes.isEmpty()) + { + fieldBuilder.setLength(0); + + command.columns() + .forEach(i -> + { + String columnName = i.name(); + String columnType = i.type().toLowerCase(); + + Optional include = i.constraints().stream() + .filter(ZILLA_MAPPINGS::containsKey) + .findFirst(); + + if (include.isPresent()) + { + final String includeName = include.get(); + if (ZILLA_TIMESTAMP.equals(includeName)) + { + fieldBuilder.append( + String.format(timestampFormat, columnName, columnName, columnType, columnName)); + } + else + { + fieldBuilder.append( + String.format(includeFormat, columnName, columnName, columnType, columnName)); + } + } + else + { + fieldBuilder.append("%s, ".formatted(columnName)); + } + }); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + select = fieldBuilder.toString(); + } + + String sqlQuery = String.format(sqlFormat, "%s_view".formatted(name), + "SELECT %s FROM %s_source".formatted(select, name)); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateTableState state = new CreateTableState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateTableState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE TABLE IF NOT EXISTS %s (%s%s);\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + String primaryKeyFormat = ", PRIMARY KEY (%s)"; + String primaryKey = !command.primaryKeys().isEmpty() + ? String.format(primaryKeyFormat, command.primaryKeys().stream().findFirst().get()) + : ""; + + fieldBuilder.setLength(0); + + command.columns() + .forEach(c -> fieldBuilder.append( + String.format("%s %s, ", c.name(), c.type()))); + + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder, primaryKey); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + GrantResourceState state = new GrantResourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class GrantResourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + GRANT ALL PRIVILEGES ON %s %s.%s TO %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, "TABLE", command.schema(), command.name(), user); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateSinkIntoState state = new CreateSinkIntoState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateSinkIntoState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE SINK %s.%s_view_sink INTO %s FROM %s_view;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String name = command.name(); + String sqlQuery = String.format(sqlFormat, systemSchema, name, name, name); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateSinkState state = new CreateSinkState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateSinkState implements RisingwaveMacroState + { + private final String sqlKafkaFormat = """ + CREATE SINK %s.%s_sink + FROM %s + WITH ( + connector='kafka', + properties.bootstrap.server='%s', + topic='%s.%s'%s + ) FORMAT UPSERT ENCODE AVRO ( + schema.registry='%s' + ) KEY ENCODE TEXT;\u0000"""; + + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topicSchema = command.schema(); + String table = command.name(); + + String sqlQuery = String.format(sqlKafkaFormat, + systemSchema, + table, + table, + bootstrapServer, + topicSchema, + table, + ",\n primary_key='%s'".formatted(command.primaryKeys().stream().findFirst().get()), schemaRegistry); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + InsertIntoCatalogState state = new InsertIntoCatalogState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + + private final class InsertIntoCatalogState implements RisingwaveMacroState + { + private final String sqlFormat = """ + INSERT INTO %s.%s (name, sql) VALUES ('%s', '%s');\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String name = command.name(); + + String newSql = sql.replace(ZTABLE_NAME, TABLE_NAME) + .replace("\u0000", ""); + newSql = newSql.replaceAll("'", "''"); + String sqlQuery = String.format(sqlFormat, systemSchema, ZTABLE_NAME, name, newSql); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.CREATE_ZTABLE_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateZviewMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateZviewMacro.java new file mode 100644 index 0000000000..be1e5bd531 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveCreateZviewMacro.java @@ -0,0 +1,429 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.agrona.DirectBuffer; +import org.agrona.collections.Object2ObjectHashMap; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.OctetsFW; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.String32FW; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveCreateZviewMacro extends RisingwaveMacroBase +{ + protected static final int FLAGS_INIT = 0x02; + + private static final String MATERIALIZED_VIEW_NAME = "MATERIALIZED VIEW"; + private static final String ZVIEW_NAME = "zviews"; + + private final String32FW columnRO = new String32FW(ByteOrder.BIG_ENDIAN); + + private final List columnTypes; + private final List columnDescriptions; + private final Map columns; + private final String bootstrapServer; + private final String schemaRegistry; + private final String systemSchema; + private final String user; + private final CreateZview command; + + public RisingwaveCreateZviewMacro( + String bootstrapServer, + String schemaRegistry, + String systemSchema, + String user, + String sql, + CreateZview command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.bootstrapServer = bootstrapServer; + this.schemaRegistry = schemaRegistry; + this.systemSchema = systemSchema; + this.user = user; + this.command = command; + + this.columnTypes = new ArrayList<>(); + this.columnDescriptions = new ArrayList<>(); + this.columns = new Object2ObjectHashMap<>(); + } + + public RisingwaveMacroState start() + { + return new CreateMaterializedViewState(); + } + + private final class CreateMaterializedViewState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE MATERIALIZED VIEW IF NOT EXISTS %s AS %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String name = command.name(); + String select = command.select(); + + String sqlQuery = String.format(sqlFormat, name, select); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + GrantResourceState state = new GrantResourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class GrantResourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + GRANT ALL PRIVILEGES ON %s %s.%s TO %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, MATERIALIZED_VIEW_NAME, command.schema(), command.name(), user); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DescribeMaterializedViewState state = new DescribeMaterializedViewState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DescribeMaterializedViewState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DESCRIBE %s.%s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.schema(), command.name()); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onType( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + columnTypes.clear(); + flushEx.type().columns() + .forEach(c -> + { + String name = c.name().asString(); + name = name.substring(0, name.length() - 1); + columnTypes.add(name); + }); + + return this; + } + + @Override + public RisingwaveMacroState onRow( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int limit, + OctetsFW extension) + { + int progress = offset; + + if ((flags & FLAGS_INIT) != 0x00) + { + columnDescriptions.clear(); + progress += Short.BYTES; + } + + column: + while (progress < limit) + { + String32FW column = columnRO.tryWrap(buffer, progress, limit); + + if (column == null) + { + break column; + } + + columnDescriptions.add(column.asString()); + + progress = column.limit(); + } + + int nameIndex = columnTypes.indexOf("Name"); + int typeIndex = columnTypes.indexOf("Type"); + int isHiddenIndex = columnTypes.indexOf("Is Hidden"); + + if ("false".equals(columnDescriptions.get(isHiddenIndex))) + { + columns.put(columnDescriptions.get(nameIndex), columnDescriptions.get(typeIndex)); + } + + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateTopicState state = new CreateTopicState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + CREATE TOPIC IF NOT EXISTS %s (%s%s);\u0000"""; + private final String primaryKeyFormat = ", PRIMARY KEY (%s)"; + + private final StringBuilder fieldBuilder = new StringBuilder(); + private final StringBuilder primaryKeyBuilder = new StringBuilder(); + + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topic = command.name(); + + primaryKeyBuilder.setLength(0); + columns.keySet().forEach(k -> primaryKeyBuilder.append(k).append(", ")); + primaryKeyBuilder.delete(primaryKeyBuilder.length() - 2, primaryKeyBuilder.length()); + + String primaryKey = String.format(primaryKeyFormat, primaryKeyBuilder); + + fieldBuilder.setLength(0); + + columns.forEach((k, v) -> fieldBuilder.append(String.format("%s %s, ", k, + RisingwavePgsqlTypeMapping.typeName(v)))); + fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); + + String sqlQuery = String.format(sqlFormat, topic, fieldBuilder, primaryKey); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + CreateSinkState state = new CreateSinkState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class CreateSinkState implements RisingwaveMacroState + { + private final String sqlKafkaFormat = """ + CREATE SINK %s.%s_sink + FROM %s + WITH ( + connector='kafka', + properties.bootstrap.server='%s', + topic='%s.%s'%s + ) FORMAT UPSERT ENCODE AVRO ( + schema.registry='%s' + ) KEY ENCODE TEXT;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String topicSchema = command.schema(); + String viewName = command.name(); + + Optional> primaryKeyMatch = columns.entrySet().stream() + .filter(e -> "id".equalsIgnoreCase(e.getKey())) + .findFirst(); + + if (primaryKeyMatch.isEmpty()) + { + primaryKeyMatch = columns.entrySet().stream() + .filter(e -> e.getKey().toLowerCase().contains("id")) + .findFirst(); + } + + String textPrimaryKey = primaryKeyMatch.map(Map.Entry::getKey).orElse(null); + String primaryKey = textPrimaryKey != null ? ",\n primary_key='%s'".formatted(textPrimaryKey) : ""; + + String sqlQuery = String.format(sqlKafkaFormat, systemSchema, viewName, viewName, bootstrapServer, + topicSchema, viewName, primaryKey, schemaRegistry); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + InsertIntoCatalogState state = new InsertIntoCatalogState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class InsertIntoCatalogState implements RisingwaveMacroState + { + private final String sqlFormat = """ + INSERT INTO %s.%s (name, sql) VALUES ('%s', '%s');\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String name = command.name(); + + String newSql = sql.replace(ZVIEW_NAME, MATERIALIZED_VIEW_NAME) + .replace("\u0000", ""); + newSql = newSql.replaceAll("'", "''"); + String sqlQuery = String.format(sqlFormat, systemSchema, ZVIEW_NAME, name, newSql); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.CREATE_ZVIEW_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropStreamMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropStreamMacro.java new file mode 100644 index 0000000000..2f5dd4c094 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropStreamMacro.java @@ -0,0 +1,124 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveDropStreamMacro extends RisingwaveMacroBase +{ + private final String systemSchema; + private final Drop command; + + public RisingwaveDropStreamMacro( + String systemSchema, + String sql, + Drop command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.systemSchema = systemSchema; + this.command = command; + } + + public RisingwaveMacroState start() + { + return new DropTopicState(); + } + + private final class DropTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP TOPIC %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropSourceState state = new DropSourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropSourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP SOURCE %s.%s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, systemSchema, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.DROP_STREAM_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropZtableMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropZtableMacro.java new file mode 100644 index 0000000000..4a4e16523e --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropZtableMacro.java @@ -0,0 +1,309 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveDropZtableMacro extends RisingwaveMacroBase +{ + private final String systemSchema; + private final Drop command; + + public RisingwaveDropZtableMacro( + String systemSchema, + String sql, + Drop command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.systemSchema = systemSchema; + this.command = command; + } + + public RisingwaveMacroState start() + { + return new DropTopicState(); + } + + private final class DropTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP TOPIC %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropSinkState state = new DropSinkState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropSinkState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP SINK %s.%s_sink;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, systemSchema, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropTableSinkState state = new DropTableSinkState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropTableSinkState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP SINK %s.%s_view_sink;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, systemSchema, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropTableState state = new DropTableState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropTableState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP TABLE %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DeleteFromCatalogState state = new DeleteFromCatalogState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DeleteFromCatalogState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DELETE FROM %s.ztables WHERE name = '%s';\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, systemSchema, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropMaterializedViewState state = new DropMaterializedViewState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropMaterializedViewState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP MATERIALIZED VIEW %s_view;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropSourceState state = new DropSourceState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropSourceState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP SOURCE %s_source;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.DROP_ZTABLE_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropZviewMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropZviewMacro.java new file mode 100644 index 0000000000..2a15d76a08 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveDropZviewMacro.java @@ -0,0 +1,198 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveDropZviewMacro extends RisingwaveMacroBase +{ + private final String systemSchema; + private final Drop command; + + public RisingwaveDropZviewMacro( + String systemSchema, + String sql, + Drop command, + RisingwaveMacroHandler handler) + { + super(sql, handler); + + this.systemSchema = systemSchema; + this.command = command; + } + + public RisingwaveMacroState start() + { + return new DropTopicState(); + } + + private final class DropTopicState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP TOPIC %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropSinkState state = new DropSinkState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropSinkState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP SINK %s.%s_sink;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, systemSchema, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DeleteFromCatalogState state = new DeleteFromCatalogState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DeleteFromCatalogState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DELETE FROM %s.zviews WHERE name = '%s';\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, systemSchema, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + DropMaterializedViewState state = new DropMaterializedViewState(); + state.onStarted(traceId, authorization); + + return state; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return errorState(); + } + } + + private final class DropMaterializedViewState implements RisingwaveMacroState + { + private final String sqlFormat = """ + DROP MATERIALIZED VIEW %s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.name()); + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.DROP_ZVIEW_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroBase.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroBase.java new file mode 100644 index 0000000000..e32af81d28 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroBase.java @@ -0,0 +1,49 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public abstract class RisingwaveMacroBase +{ + protected final RisingwaveMacroHandler handler; + protected final String sql; + + public RisingwaveMacroBase( + String sql, + RisingwaveMacroHandler handler) + { + this.sql = sql; + this.handler = handler; + } + + protected RisingwaveMacroState errorState() + { + return new ErrorState(); + } + + protected final class ErrorState implements RisingwaveMacroState + { + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroHandler.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroHandler.java new file mode 100644 index 0000000000..6eba7deb94 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroHandler.java @@ -0,0 +1,73 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import org.agrona.DirectBuffer; + +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.OctetsFW; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public interface RisingwaveMacroHandler +{ + void doExecuteUserClient( + long traceId, + long authorization, + String query); + + void doExecuteSystemClient( + long traceId, + long authorization, + String query); + + void doDescription( + long traceId, + long authorization, + String name); + + void doRow( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int limit); + + void doCompletion( + long traceId, + long authorization, + RisingwaveCompletionCommand command); + + void doReady( + long traceId, + long authorization, + int progress); + + void doFlushProxy( + long traceId, + long authorization, + PgsqlFlushExFW flushEx); + + void doDataProxy( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int length, + OctetsFW extension); +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroState.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroState.java new file mode 100644 index 0000000000..fcc843f462 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveMacroState.java @@ -0,0 +1,71 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import org.agrona.DirectBuffer; + +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.OctetsFW; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public interface RisingwaveMacroState +{ + default void onStarted( + long traceId, + long authorization) + { + } + + default RisingwaveMacroState onRow( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int limit, + OctetsFW extension) + { + return this; + } + + default RisingwaveMacroState onType( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + return this; + } + + default RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + return this; + } + + RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx); + + default RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + return this; + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwavePgsqlTypeMapping.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwavePgsqlTypeMapping.java similarity index 95% rename from incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwavePgsqlTypeMapping.java rename to incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwavePgsqlTypeMapping.java index 866d2eb842..142960fa90 100644 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwavePgsqlTypeMapping.java +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwavePgsqlTypeMapping.java @@ -12,7 +12,7 @@ * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; import java.util.Map; diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveShowCommandMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveShowCommandMacro.java new file mode 100644 index 0000000000..2c05f24b75 --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveShowCommandMacro.java @@ -0,0 +1,115 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import org.agrona.DirectBuffer; + +import io.aklivity.zilla.runtime.binding.risingwave.internal.stream.RisingwaveCompletionCommand; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.OctetsFW; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveShowCommandMacro +{ + private final String sql; + private final String command; + private final RisingwaveMacroHandler handler; + + public RisingwaveShowCommandMacro( + String sql, + String command, + RisingwaveMacroHandler handler) + { + this.sql = sql; + this.command = command; + this.handler = handler; + } + + + public RisingwaveMacroState start() + { + return new ShowCommandState(); + } + + private final class ShowCommandState implements RisingwaveMacroState + { + private final String sqlFormat = """ + SELECT * FROM zb_catalog.%s;\u0000"""; + + @Override + public void onStarted( + long traceId, + long authorization) + { + String sqlQuery = String.format(sqlFormat, command.toLowerCase()); + + handler.doExecuteSystemClient(traceId, authorization, sqlQuery); + } + + @Override + public RisingwaveMacroState onRow( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int limit, + OctetsFW extension) + { + handler.doRow(client, traceId, authorization, flags, buffer, offset, limit); + return this; + } + + @Override + public RisingwaveMacroState onType( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doDescription(traceId, authorization, "Name"); + return this; + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doCompletion(traceId, authorization, RisingwaveCompletionCommand.SHOW_COMMAND); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveUnknownMacro.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveUnknownMacro.java new file mode 100644 index 0000000000..5abf948c8b --- /dev/null +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/macro/RisingwaveUnknownMacro.java @@ -0,0 +1,106 @@ +/* + * Copyright 2021-2024 Aklivity Inc + * + * Licensed under the Aklivity Community License (the "License"); you may not use + * this file except in compliance with the License. You may obtain a copy of the + * License at + * + * https://www.aklivity.io/aklivity-community-license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.aklivity.zilla.runtime.binding.risingwave.internal.macro; + +import org.agrona.DirectBuffer; + +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.OctetsFW; +import io.aklivity.zilla.runtime.binding.risingwave.internal.types.stream.PgsqlFlushExFW; + +public class RisingwaveUnknownMacro +{ + private final String sql; + private final RisingwaveMacroHandler handler; + + public RisingwaveUnknownMacro( + String sql, + RisingwaveMacroHandler handler) + { + this.sql = sql; + this.handler = handler; + } + + + public RisingwaveMacroState start() + { + return new UnknownState(); + } + + private final class UnknownState implements RisingwaveMacroState + { + @Override + public void onStarted( + long traceId, + long authorization) + { + handler.doExecuteUserClient(traceId, authorization, sql); + } + + @Override + public RisingwaveMacroState onRow( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int length, + OctetsFW extension) + { + handler.doDataProxy(client, traceId, authorization, flags, buffer, offset, length, extension); + return this; + } + + @Override + public RisingwaveMacroState onType( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + + @Override + public RisingwaveMacroState onCompletion( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + + @Override + public RisingwaveMacroState onReady( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doReady(traceId, authorization, sql.length()); + return null; + } + + @Override + public RisingwaveMacroState onError( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + handler.doFlushProxy(traceId, authorization, flushEx); + return this; + } + } +} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveAlterTableTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveAlterTableTemplate.java deleted file mode 100644 index 6ae793ae4c..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveAlterTableTemplate.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter; - -public class RisingwaveAlterTableTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - ALTER TABLE %s %s;\u0000"""; - private final String fieldFormat = "%s COLUMN %s %s, "; - - public String generate( - Alter alter) - { - String topic = alter.name(); - fieldBuilder.setLength(0); - - alter.expressions() - .forEach(c -> fieldBuilder.append( - String.format(fieldFormat, c.operation().name(), c.columnName(), c.columnType()))); - - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - - return String.format(sqlFormat, topic, fieldBuilder); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveAlterTopicTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveAlterTopicTemplate.java deleted file mode 100644 index 01772ff4c9..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveAlterTopicTemplate.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Alter; - -public class RisingwaveAlterTopicTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - ALTER TOPIC %s %s;\u0000"""; - private final String fieldFormat = "%s COLUMN %s %s, "; - - public String generate( - Alter alter) - { - String topic = alter.name(); - fieldBuilder.setLength(0); - - alter.expressions() - .forEach(c -> fieldBuilder.append( - String.format(fieldFormat, c.operation().name(), c.columnName(), c.columnType()))); - - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - - return String.format(sqlFormat, topic, fieldBuilder); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCommandTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCommandTemplate.java deleted file mode 100644 index c66c075b80..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCommandTemplate.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import java.util.Map; - -import org.agrona.collections.Object2ObjectHashMap; - - -public abstract class RisingwaveCommandTemplate -{ - protected static final String ZILLA_CORRELATION_ID = "zilla_correlation_id"; - protected static final String ZILLA_IDENTITY = "zilla_identity"; - protected static final String ZILLA_TIMESTAMP = "zilla_timestamp"; - - protected final StringBuilder fieldBuilder = new StringBuilder(); - protected final StringBuilder includeBuilder = new StringBuilder(); - - protected static final Map ZILLA_MAPPINGS = new Object2ObjectHashMap<>(); - static - { - ZILLA_MAPPINGS.put(ZILLA_CORRELATION_ID, "INCLUDE header 'zilla:correlation-id' AS %s\n"); - ZILLA_MAPPINGS.put(ZILLA_IDENTITY, "INCLUDE header 'zilla:identity' AS %s\n"); - ZILLA_MAPPINGS.put(ZILLA_TIMESTAMP, "INCLUDE timestamp AS %s\n"); - } - - protected static final Map ZILLA_INCLUDE_TYPE_MAPPINGS = new Object2ObjectHashMap<>(); - static - { - ZILLA_INCLUDE_TYPE_MAPPINGS.put(ZILLA_CORRELATION_ID, "VARCHAR"); - ZILLA_INCLUDE_TYPE_MAPPINGS.put(ZILLA_IDENTITY, "VARCHAR"); - ZILLA_INCLUDE_TYPE_MAPPINGS.put(ZILLA_TIMESTAMP, "TIMESTAMP"); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateFunctionTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateFunctionTemplate.java deleted file mode 100644 index 2706048100..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateFunctionTemplate.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import java.util.List; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Function; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.FunctionArgument; -import io.aklivity.zilla.runtime.binding.risingwave.config.RisingwaveUdfConfig; - -public class RisingwaveCreateFunctionTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - CREATE FUNCTION %s(%s) - RETURNS %s - AS %s - LANGUAGE %s - USING LINK '%s';\u0000"""; - - private final String javaServer; - private final String pythonServer; - - public RisingwaveCreateFunctionTemplate( - List udfs) - { - String javaServer = null; - String pythonServer = null; - - if (udfs != null && !udfs.isEmpty()) - { - for (RisingwaveUdfConfig udf : udfs) - { - if (udf.language.equalsIgnoreCase("java")) - { - javaServer = udf.server; - } - else if (udf.language.equalsIgnoreCase("python")) - { - pythonServer = udf.server; - } - } - } - - this.javaServer = javaServer; - this.pythonServer = pythonServer; - } - - public String generate( - Function function) - { - String functionName = function.name(); - String asFunction = function.asFunction(); - List arguments = function.arguments(); - List tables = function.tables(); - - fieldBuilder.setLength(0); - - arguments - .forEach(arg -> fieldBuilder.append( - arg.name() != null - ? "%s %s, ".formatted(arg.name(), arg.type()) - : "%s, ".formatted(arg.type()))); - - if (!arguments.isEmpty()) - { - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - } - String funcArguments = fieldBuilder.toString(); - - String language = function.language() != null ? function.language() : "java"; - String server = "python".equalsIgnoreCase(language) ? pythonServer : javaServer; - - String returnType = function.returnType(); - if (!tables.isEmpty()) - { - fieldBuilder.setLength(0); - fieldBuilder.append("TABLE ("); - tables.forEach(arg -> fieldBuilder.append( - arg.name() != null - ? "%s %s, ".formatted(arg.name(), arg.type()) - : "%s, ".formatted(arg.type()))); - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - fieldBuilder.append(")"); - - returnType = fieldBuilder.toString(); - } - - return sqlFormat.formatted(functionName, funcArguments, returnType, asFunction, language, server); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateMaterializedViewTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateMaterializedViewTemplate.java deleted file mode 100644 index 8ce43f5273..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateMaterializedViewTemplate.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; - -public class RisingwaveCreateMaterializedViewTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - CREATE MATERIALIZED VIEW IF NOT EXISTS %s AS %s;\u0000"""; - private final String fieldFormat = "%s, "; - private final String includeFormat = "COALESCE(%s, %s_header::varchar) as %s, "; - private final String timestampFormat = "COALESCE(%s, %s_timestamp::varchar) as %s, "; - - public String generate( - CreateZview createZview) - { - String name = createZview.name(); - String select = createZview.select(); - - return String.format(sqlFormat, name, select); - } - - public String generate( - CreateTable createTable) - { - String name = createTable.name(); - - String select = "*"; - - List includes = createTable.columns().stream() - .filter(c -> ZILLA_MAPPINGS.containsKey(c.name())) - .collect(Collectors.toCollection(ArrayList::new)); - - if (!includes.isEmpty()) - { - fieldBuilder.setLength(0); - - createTable.columns() - .stream() - .filter(c -> !ZILLA_MAPPINGS.containsKey(c.name())) - .forEach(c -> fieldBuilder.append(String.format(fieldFormat, c.name()))); - - includes.forEach(c -> - { - String columnName = c.name(); - if (ZILLA_TIMESTAMP.equals(columnName)) - { - fieldBuilder.append(String.format(timestampFormat, columnName, columnName, columnName)); - } - else - { - fieldBuilder.append(String.format(includeFormat, columnName, columnName, columnName)); - } - }); - - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - select = fieldBuilder.toString(); - } - - return String.format(sqlFormat, "%s_view".formatted(name), "SELECT %s FROM %s_source".formatted(select, name)); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSinkTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSinkTemplate.java deleted file mode 100644 index b1e3ef4058..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSinkTemplate.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import java.util.Map; -import java.util.Optional; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview; - -public class RisingwaveCreateSinkTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - CREATE SINK %s.%s_view_sink INTO %s FROM %s_view;\u0000"""; - private final String sqlKafkaFormat = """ - CREATE SINK %s.%s_sink - FROM %s - WITH ( - connector='kafka', - properties.bootstrap.server='%s', - topic='%s.%s'%s - ) FORMAT UPSERT ENCODE AVRO ( - schema.registry='%s' - ) KEY ENCODE TEXT;\u0000"""; - - private final String primaryKeyFormat = ",\n primary_key='%s'"; - - private final String schema; - private final String bootstrapServer; - private final String schemaRegistry; - - public RisingwaveCreateSinkTemplate( - String schema, - String bootstrapServer, - String schemaRegistry) - { - this.schema = schema; - this.bootstrapServer = bootstrapServer; - this.schemaRegistry = schemaRegistry; - } - - public String generateOutgress( - Map columns, - CreateZview createZview) - { - String topicSchema = createZview.schema(); - String viewName = createZview.name(); - - Optional> primaryKeyMatch = columns.entrySet().stream() - .filter(e -> "id".equalsIgnoreCase(e.getKey())) - .findFirst(); - - if (primaryKeyMatch.isEmpty()) - { - primaryKeyMatch = columns.entrySet().stream() - .filter(e -> e.getKey().toLowerCase().contains("id")) - .findFirst(); - } - - String textPrimaryKey = primaryKeyMatch.map(Map.Entry::getKey).orElse(null); - String primaryKey = textPrimaryKey != null ? primaryKeyFormat.formatted(textPrimaryKey) : ""; - - return String.format(sqlKafkaFormat, schema, viewName, viewName, bootstrapServer, - topicSchema, viewName, primaryKey, schemaRegistry); - } - - public String generateOutgress( - CreateTable createTableInfo) - { - String topicSchema = createTableInfo.schema(); - String table = createTableInfo.name(); - - return String.format(sqlKafkaFormat, schema, table, table, bootstrapServer, topicSchema, table, - primaryKeyFormat.formatted(createTableInfo.primaryKeys().stream().findFirst().get()), schemaRegistry); - } - - public String generateInto( - CreateTable createTableInfo) - { - String table = createTableInfo.name(); - - return String.format(sqlFormat, schema, table, table, table); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSourceTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSourceTemplate.java deleted file mode 100644 index ba97fea731..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSourceTemplate.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateStream; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; - -public class RisingwaveCreateSourceTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - CREATE SOURCE IF NOT EXISTS %s (*)%s - WITH ( - connector='kafka', - properties.bootstrap.server='%s', - topic='%s.%s', - scan.startup.mode='latest', - scan.startup.timestamp.millis='%d' - ) FORMAT PLAIN ENCODE AVRO ( - schema.registry = '%s' - );\u0000"""; - - private final String bootstrapServer; - private final String schemaRegistry; - private final long scanStartupMil; - - public RisingwaveCreateSourceTemplate( - String bootstrapServer, - String schemaRegistry, - long scanStartupMil) - { - this.bootstrapServer = bootstrapServer; - this.schemaRegistry = schemaRegistry; - this.scanStartupMil = scanStartupMil; - } - - public String generateStreamSource( - CreateStream createStream) - { - String schema = createStream.schema(); - String table = createStream.name(); - - includeBuilder.setLength(0); - Map includes = createStream.columns().entrySet().stream() - .filter(e -> ZILLA_MAPPINGS.containsKey(e.getKey())) - .collect(LinkedHashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), Map::putAll); - - if (!includes.isEmpty()) - { - includeBuilder.append("\n"); - includes.forEach((k, v) -> includeBuilder.append(String.format(ZILLA_MAPPINGS.get(k), k))); - includeBuilder.delete(includeBuilder.length() - 1, includeBuilder.length()); - } - - return String.format(sqlFormat, table, includeBuilder, bootstrapServer, schema, table, scanStartupMil, schemaRegistry); - } - - public String generateTableSource( - CreateTable createTableInfo) - { - String schema = createTableInfo.schema(); - String table = createTableInfo.name(); - String sourceName = "%s_source".formatted(table); - - includeBuilder.setLength(0); - List includes = createTableInfo.columns().stream() - .filter(c -> ZILLA_MAPPINGS.containsKey(c.name())) - .collect(Collectors.toCollection(ArrayList::new)); - - if (!includes.isEmpty()) - { - includeBuilder.append("\n"); - includes.forEach(c -> - { - String name = c.name(); - if (ZILLA_TIMESTAMP.equals(name)) - { - includeBuilder.append(String.format(ZILLA_MAPPINGS.get(name), "%s_timestamp".formatted(name))); - } - else - { - includeBuilder.append(String.format(ZILLA_MAPPINGS.get(name), "%s_header".formatted(name))); - } - }); - includeBuilder.delete(includeBuilder.length() - 1, includeBuilder.length()); - } - - return String.format(sqlFormat, sourceName, includeBuilder, bootstrapServer, - schema, table, scanStartupMil, schemaRegistry); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateTableTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateTableTemplate.java deleted file mode 100644 index ea27495595..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateTableTemplate.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; - -public class RisingwaveCreateTableTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - CREATE TABLE IF NOT EXISTS %s (%s%s);\u0000"""; - private final String fieldFormat = "%s %s, "; - - public String generate( - CreateTable createTable) - { - String topic = createTable.name(); - String primaryKeyFormat = ", PRIMARY KEY (%s)"; - String primaryKey = !createTable.primaryKeys().isEmpty() - ? String.format(primaryKeyFormat, createTable.primaryKeys().stream().findFirst().get()) - : ""; - - fieldBuilder.setLength(0); - - createTable.columns() - .forEach(c -> fieldBuilder.append( - String.format(fieldFormat, c.name(), c.type()))); - - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - - return String.format(sqlFormat, topic, fieldBuilder, primaryKey); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateTopicTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateTopicTemplate.java deleted file mode 100644 index 8290439698..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateTopicTemplate.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import java.util.Map; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateStream; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview; - -public class RisingwaveCreateTopicTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - CREATE TOPIC IF NOT EXISTS %s (%s%s);\u0000"""; - private final String primaryKeyFormat = ", PRIMARY KEY (%s)"; - private final String fieldFormat = "%s %s, "; - - private final StringBuilder fieldBuilder = new StringBuilder(); - private final StringBuilder primaryKeyBuilder = new StringBuilder(); - - public String generate( - CreateTable createTable) - { - String topic = createTable.name(); - String primaryKey = !createTable.primaryKeys().isEmpty() - ? String.format(primaryKeyFormat, createTable.primaryKeys().stream().findFirst().get()) - : ""; - - fieldBuilder.setLength(0); - - createTable.columns() - .forEach(c -> fieldBuilder.append( - String.format(fieldFormat, c.name(), c.type()))); - - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - - return String.format(sqlFormat, topic, fieldBuilder, primaryKey); - } - - public String generate( - CreateStream createStream) - { - String topic = createStream.name(); - - fieldBuilder.setLength(0); - - createStream.columns() - .entrySet() - .stream() - .filter(e -> !ZILLA_MAPPINGS.containsKey(e.getKey())) - .forEach(e -> fieldBuilder.append( - String.format(fieldFormat, e.getKey(), e.getValue()))); - - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - - return String.format(sqlFormat, topic, fieldBuilder, ""); - } - - public String generate( - CreateZview createZview, - Map columns) - { - String topic = createZview.name(); - - primaryKeyBuilder.setLength(0); - columns.keySet().forEach(k -> primaryKeyBuilder.append(k).append(", ")); - primaryKeyBuilder.delete(primaryKeyBuilder.length() - 2, primaryKeyBuilder.length()); - - String primaryKey = String.format(primaryKeyFormat, primaryKeyBuilder); - - fieldBuilder.setLength(0); - - columns.forEach((k, v) -> fieldBuilder.append(String.format(fieldFormat, k, - RisingwavePgsqlTypeMapping.typeName(v)))); - fieldBuilder.delete(fieldBuilder.length() - 2, fieldBuilder.length()); - - return String.format(sqlFormat, topic, fieldBuilder, primaryKey); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDeleteFromCatalogTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDeleteFromCatalogTemplate.java deleted file mode 100644 index 6a9a7b07ac..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDeleteFromCatalogTemplate.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; - -public class RisingwaveDeleteFromCatalogTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DELETE FROM %s.%s WHERE name = '%s';\u0000"""; - private final String schema; - - public RisingwaveDeleteFromCatalogTemplate( - String schema) - { - this.schema = schema; - } - - public String generate( - String catalog, - Drop drop) - { - return String.format(sqlFormat, schema, catalog, drop.name()); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDescribeTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDescribeTemplate.java deleted file mode 100644 index f29f200c6a..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDescribeTemplate.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview; - -public class RisingwaveDescribeTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DESCRIBE %s;\u0000"""; - - public String generate( - CreateZview createZview) - { - String name = createZview.name(); - - return String.format(sqlFormat, name); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropMaterializedViewTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropMaterializedViewTemplate.java deleted file mode 100644 index 174aa94fb6..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropMaterializedViewTemplate.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; - -public class RisingwaveDropMaterializedViewTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DROP MATERIALIZED VIEW %s;\u0000"""; - - public String generate( - Drop drop) - { - return generate(drop, ""); - } - - public String generate( - Drop drop, - String suffix) - { - String source = "%s%s".formatted(drop.name(), suffix); - - return String.format(sqlFormat, source); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropSinkTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropSinkTemplate.java deleted file mode 100644 index caf291b932..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropSinkTemplate.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; - -public class RisingwaveDropSinkTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DROP SINK %s.%s%s;\u0000"""; - private final String schema; - - public RisingwaveDropSinkTemplate( - String schema) - { - this.schema = schema; - } - - public String generate( - Drop drop) - { - return generate(drop, "_sink"); - } - - public String generate( - Drop drop, - String suffix) - { - return String.format(sqlFormat, schema, drop.name(), suffix); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropSourceTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropSourceTemplate.java deleted file mode 100644 index 0e880f291d..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropSourceTemplate.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; - -public class RisingwaveDropSourceTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DROP SOURCE %s;\u0000"""; - - public String generate( - Drop drop) - { - return generate(drop, ""); - } - - public String generate( - Drop drop, - String suffix) - { - String source = "%s%s".formatted(drop.name(), suffix); - - return String.format(sqlFormat, source); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropTableTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropTableTemplate.java deleted file mode 100644 index 05e506dc3d..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropTableTemplate.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; - -public class RisingwaveDropTableTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DROP TABLE %s;\u0000"""; - - public String generate( - Drop drop) - { - return String.format(sqlFormat, drop.name()); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropTopicTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropTopicTemplate.java deleted file mode 100644 index 0f6c9f9531..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveDropTopicTemplate.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Drop; - -public class RisingwaveDropTopicTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - DROP TOPIC %s;\u0000"""; - - public String generate( - Drop drop) - { - return String.format(sqlFormat, drop.name()); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveGrantToSourceTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveGrantToSourceTemplate.java deleted file mode 100644 index 963281df2c..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveGrantToSourceTemplate.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -public class RisingwaveGrantToSourceTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - GRANT ALL PRIVILEGES ON %s %s.%s TO %s;\u0000"""; - - public String generate( - String source, - String schema, - String name, - String user) - { - return String.format(sqlFormat, source, schema, name, user); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveInsertIntoCatalogTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveInsertIntoCatalogTemplate.java deleted file mode 100644 index 772b921f3d..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveInsertIntoCatalogTemplate.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -public class RisingwaveInsertIntoCatalogTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - INSERT INTO %s.%s (name, sql) VALUES ('%s', '%s');\u0000"""; - private final String schema; - - public RisingwaveInsertIntoCatalogTemplate( - String schema) - { - this.schema = schema; - } - - public String generate( - String catalog, - String name, - String statement) - { - statement = statement.replace("ZVIEW", "MATERIALIZED VIEW"); - statement = statement.replace("\u0000", ""); - return String.format(sqlFormat, schema, catalog, name, statement); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveShowTypeTemplate.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveShowTypeTemplate.java deleted file mode 100644 index e911054200..0000000000 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveShowTypeTemplate.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -public class RisingwaveShowTypeTemplate extends RisingwaveCommandTemplate -{ - private final String sqlFormat = """ - SELECT * FROM zb_catalog.%s;\u0000"""; - - public String generate( - String type) - { - return String.format(sqlFormat, type.toLowerCase()); - } -} diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveCompletionCommand.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveCompletionCommand.java index d13e4fc9ec..fbe8572c4b 100644 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveCompletionCommand.java +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveCompletionCommand.java @@ -17,13 +17,13 @@ public enum RisingwaveCompletionCommand { UNKNOWN_COMMAND("UNKNOWN".getBytes()), - CREATE_TABLE_COMMAND("CREATE_TABLE".getBytes()), + CREATE_ZTABLE_COMMAND("CREATE_ZTABLE".getBytes()), CREATE_ZVIEW_COMMAND("CREATE_ZVIEW".getBytes()), CREATE_STREAM_COMMAND("CREATE_STREAM".getBytes()), CREATE_FUNCTION_COMMAND("CREATE_FUNCTION".getBytes()), - ALTER_TABLE_COMMAND("ALTER_TABLE".getBytes()), + ALTER_ZTABLE_COMMAND("ALTER_ZTABLE".getBytes()), ALTER_STREAM_COMMAND("ALTER_STREAM".getBytes()), - DROP_TABLE_COMMAND("DROP_TABLE".getBytes()), + DROP_ZTABLE_COMMAND("DROP_ZTABLE".getBytes()), DROP_STREAM_COMMAND("DROP_STREAM".getBytes()), DROP_ZVIEW_COMMAND("DROP_ZVIEW".getBytes()), SHOW_COMMAND("SHOW_COMMAND".getBytes()); diff --git a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveProxyFactory.java b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveProxyFactory.java index d6136e063c..d5396991fd 100644 --- a/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveProxyFactory.java +++ b/incubator/binding-risingwave/src/main/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/RisingwaveProxyFactory.java @@ -47,6 +47,19 @@ import io.aklivity.zilla.runtime.binding.risingwave.internal.config.RisingwaveBindingConfig; import io.aklivity.zilla.runtime.binding.risingwave.internal.config.RisingwaveCommandType; import io.aklivity.zilla.runtime.binding.risingwave.internal.config.RisingwaveRouteConfig; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveAlterStreamMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveAlterZtableMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveCreateFunctionMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveCreateStreamMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveCreateZtableMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveCreateZviewMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveDropStreamMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveDropZtableMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveDropZviewMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveMacroHandler; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveMacroState; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveShowCommandMacro; +import io.aklivity.zilla.runtime.binding.risingwave.internal.macro.RisingwaveUnknownMacro; import io.aklivity.zilla.runtime.binding.risingwave.internal.types.Flyweight; import io.aklivity.zilla.runtime.binding.risingwave.internal.types.OctetsFW; import io.aklivity.zilla.runtime.binding.risingwave.internal.types.String32FW; @@ -84,12 +97,8 @@ public final class RisingwaveProxyFactory implements RisingwaveStreamFactory private static final String SEVERITY_WARNING = "WARNING\u0000"; private static final String CODE_XX000 = "XX000\u0000"; - private static final String ZILLABASE_USER = "zillabase\u0000"; + private static final String POSTGRES_USER = "postgres\u0000"; private static final String DEFAULT_USER = "default\u0000"; - private static final String ZVIEW_TABLE_NAME = "zviews"; - - private static final int COMMAND_PROCESSED_ERRORED = -1; - private static final int COMMAND_PROCESSED_NONE = 0; private static final DirectBuffer EMPTY_BUFFER = new UnsafeBuffer(new byte[0]); private static final OctetsFW EMPTY_OCTETS = new OctetsFW().wrap(EMPTY_BUFFER, 0, 0); @@ -110,8 +119,6 @@ public final class RisingwaveProxyFactory implements RisingwaveStreamFactory private final AbortFW.Builder abortRW = new AbortFW.Builder(); private final FlushFW.Builder flushRW = new FlushFW.Builder(); - private final String32FW columnRO = new String32FW(ByteOrder.BIG_ENDIAN); - private final ResetFW resetRO = new ResetFW(); private final WindowFW windowRO = new WindowFW(); @@ -119,6 +126,7 @@ public final class RisingwaveProxyFactory implements RisingwaveStreamFactory private final PgsqlBeginExFW pgsqlBeginExRO = new PgsqlBeginExFW(); private final PgsqlDataExFW pgsqlDataExRO = new PgsqlDataExFW(); private final PgsqlFlushExFW pgsqlFlushExRO = new PgsqlFlushExFW(); + private final String32FW columnRO = new String32FW(ByteOrder.BIG_ENDIAN); private final PgsqlBeginExFW.Builder beginExRW = new PgsqlBeginExFW.Builder(); private final PgsqlDataExFW.Builder dataExRW = new PgsqlDataExFW.Builder(); @@ -142,28 +150,20 @@ public final class RisingwaveProxyFactory implements RisingwaveStreamFactory private final Long2ObjectHashMap bindings; private final int pgsqlTypeId; - private final PgsqlFlushCommand showColumnFlushCommand = this::showColumnFlushCommand; - private final PgsqlFlushCommand typeFlushCommand = this::typeFlushCommand; - private final PgsqlFlushCommand proxyFlushCommand = this::proxyFlushCommand; - private final PgsqlFlushCommand ignoreFlushCommand = this::ignoreFlushCommand; - - private final PgsqlDataCommand proxyDataCommand = this::proxyDataCommand; - private final PgsqlDataCommand rowDataCommand = this::rowDataCommand; - private final PgsqlDataCommand showColumnDataCommand = this::showColumnDataCommand; - private final Object2ObjectHashMap clientTransforms; { Object2ObjectHashMap clientTransforms = new Object2ObjectHashMap<>(); - clientTransforms.put(RisingwaveCommandType.CREATE_TABLE_COMMAND, this::decodeCreateTableCommand); + clientTransforms.put(RisingwaveCommandType.CREATE_ZTABLE_COMMAND, this::decodeCreateZtableCommand); clientTransforms.put(RisingwaveCommandType.CREATE_STREAM_COMMAND, this::decodeCreateStreamCommand); clientTransforms.put(RisingwaveCommandType.CREATE_ZVIEW_COMMAND, this::decodeCreateZviewCommand); clientTransforms.put(RisingwaveCommandType.CREATE_FUNCTION_COMMAND, this::decodeCreateFunctionCommand); - clientTransforms.put(RisingwaveCommandType.ALTER_TABLE_COMMAND, this::decodeAlterTableCommand); + clientTransforms.put(RisingwaveCommandType.ALTER_ZTABLE_COMMAND, this::decodeAlterZtableCommand); clientTransforms.put(RisingwaveCommandType.ALTER_STREAM_COMMAND, this::decodeAlterStreamCommand); clientTransforms.put(RisingwaveCommandType.DROP_STREAM_COMMAND, this::decodeDropStreamCommand); - clientTransforms.put(RisingwaveCommandType.DROP_TABLE_COMMAND, this::decodeDropTableCommand); + clientTransforms.put(RisingwaveCommandType.DROP_ZTABLE_COMMAND, this::decodeDropZtableCommand); clientTransforms.put(RisingwaveCommandType.DROP_ZVIEW_COMMAND, this::decodeDropZviewCommand); + clientTransforms.put(RisingwaveCommandType.SHOW_ZTABLES_COMMAND, this::decodeShowCommand); clientTransforms.put(RisingwaveCommandType.SHOW_ZVIEWS_COMMAND, this::decodeShowCommand); clientTransforms.put(RisingwaveCommandType.UNKNOWN_COMMAND, this::decodeUnknownCommand); this.clientTransforms = clientTransforms; @@ -255,10 +255,8 @@ private final class PgsqlServer private final Map parameters; private final Deque responses; private final IntArrayQueue queries; - private final List columnTypes; - private final List columnDescriptions; - private final Map columns; private final String user; + private final RisingwaveMacroDefaultHandler macroHandler; private final long initialId; private final long replyId; @@ -283,7 +281,7 @@ private final class PgsqlServer private int state; - private int commandsProcessed = COMMAND_PROCESSED_NONE; + private RisingwaveMacroState macroState; private int queryProgressOffset; private PgsqlServer( @@ -303,16 +301,14 @@ private PgsqlServer( this.binding = bindings.get(routedId); this.parameters = parameters; - this.columns = new Object2ObjectHashMap<>(); - this.columnTypes = new ArrayList<>(); - this.columnDescriptions = new ArrayList<>(); this.systemClientsByRouteId = new Long2ObjectHashMap<>(); this.responses = new ArrayDeque<>(); this.queries = new IntArrayQueue(); + this.macroHandler = new RisingwaveMacroDefaultHandler(); binding.routes.forEach(r -> systemClientsByRouteId.put(r.id, - new PgsqlClient(this, routedId, r.id, ZILLABASE_USER))); + new PgsqlClient(this, routedId, r.id, POSTGRES_USER))); userClient = new PgsqlClient(this, routedId, systemId, DEFAULT_USER); @@ -414,7 +410,7 @@ private void onAppData( final ExtensionFW dataEx = extension.get(extensionRO::tryWrap); final PgsqlDataExFW pgsqlDataEx = dataEx != null && dataEx.typeId() == pgsqlTypeId ? - extension.get(pgsqlDataExRO::tryWrap) : null; + extension.get(pgsqlDataExRO::tryWrap) : null; if (pgsqlDataEx != null && pgsqlDataEx.kind() == PgsqlDataExFW.KIND_QUERY) @@ -497,7 +493,7 @@ private void onAppWindow( assert acknowledge >= replyAck; assert maximum + acknowledge >= replyMax + replyAck; - int credit = (int)(acknowledge - replyAck) + (maximum - replyMax); + int credit = (int) (acknowledge - replyAck) + (maximum - replyMax); replyBudgetId = budgetId; replyAck = acknowledge; @@ -523,7 +519,7 @@ private void onAppWindow( client.doAppWindow(authorization, traceId); - credit = Math.max(credit - (int)(client.replyAck - streamAckSnapshot), 0); + credit = Math.max(credit - (int) (client.replyAck - streamAckSnapshot), 0); if (client.replyAck != client.replySeq) { @@ -535,22 +531,14 @@ private void onAppWindow( } } - private void onCommandCompleted( + private void onCommandReady( long traceId, long authorization, - int progress, - RisingwaveCompletionCommand command) + int progress) { final MutableDirectBuffer parserBuffer = bufferPool.buffer(parserSlot); - if (commandsProcessed != COMMAND_PROCESSED_ERRORED) - { - doCommandCompletion(traceId, authorization, command); - } - parserSlotOffset -= progress; - commandsProcessed = COMMAND_PROCESSED_NONE; - parserBuffer.putBytes(0, parserBuffer, progress, parserSlotOffset); final int queryLength = queries.peekInt(); @@ -562,6 +550,8 @@ private void onCommandCompleted( doQueryReady(traceId, authorization); } + macroState = null; + if (parserSlotOffset == 0) { cleanupParserSlotIfNecessary(); @@ -574,25 +564,6 @@ private void onCommandCompleted( doAppWindow(traceId, authorization); } - private void onQueryReady( - long traceId, - long authorization, - PgsqlFlushExFW pgsqlFlushEx) - { - PgsqlStatus pgsqlStatus = pgsqlFlushEx.ready().status().get(); - if (pgsqlStatus == PgsqlStatus.IDLE) - { - commandsProcessed = commandsProcessed != COMMAND_PROCESSED_ERRORED - ? commandsProcessed + 1 - : COMMAND_PROCESSED_ERRORED; - doParseQuery(traceId, authorization); - } - else - { - cleanup(traceId, authorization); - } - } - private void doAppBegin( long traceId, long authorization) @@ -603,9 +574,8 @@ private void doAppBegin( state = RisingwaveState.openingReply(state); } - private void doAppData( - PgsqlClient client, - long routeId, + private void doAppData( + T client, long traceId, long authorization, int flags, @@ -614,7 +584,7 @@ private void doAppData( int limit, Flyweight extension) { - responses.add(client); + responses.add((PgsqlClient) client); final int length = limit - offset; final int reserved = length + initialPad; @@ -719,7 +689,7 @@ private void doAppFlush( int reserved = (int) replySeq; doFlush(app, originId, routedId, replyId, replySeq, replyAck, replyMax, traceId, - authorization, replyBudgetId, reserved, extension); + authorization, replyBudgetId, reserved, extension); replySeq += reserved; } @@ -732,7 +702,7 @@ private void doAppFlush( int reserved = (int) replySeq; doFlush(app, originId, routedId, replyId, replySeq, replyAck, replyMax, traceId, - authorization, replyBudgetId, reserved, extension); + authorization, replyBudgetId, reserved, extension); replySeq += reserved; } @@ -749,7 +719,7 @@ private void doCommandCompletion( Consumer completionEx = e -> e.set((b, o, l) -> flushExRW.wrap(b, o, l) .typeId(pgsqlTypeId) - .completion(c -> c.tag(extBuffer, 0, command.value().length + 1)) + .completion(c -> c.tag(extBuffer, 0, command.value().length + 1)) .build().sizeof()); doAppFlush(traceId, authorization, completionEx); @@ -761,9 +731,9 @@ private void doQueryReady( long authorization) { Consumer readyEx = e -> e.set((b, o, l) -> flushExRW.wrap(b, o, l) - .typeId(pgsqlTypeId) - .ready(r -> r.status(s -> s.set(PgsqlStatus.IDLE))) - .build().sizeof()); + .typeId(pgsqlTypeId) + .ready(r -> r.status(s -> s.set(PgsqlStatus.IDLE))) + .build().sizeof()); doAppFlush(traceId, authorization, readyEx); } @@ -783,7 +753,9 @@ private void doParseQuery( .ifPresent(statement -> { String command = parser.parseCommand(statement); - final PgsqlTransform transform = clientTransforms.get(RisingwaveCommandType.valueOf(command.getBytes())); + final PgsqlTransform transform = command == null + ? clientTransforms.get(RisingwaveCommandType.UNKNOWN_COMMAND) + : clientTransforms.get(RisingwaveCommandType.valueOf(command.getBytes())); transform.transform(this, traceId, authorizationId, statement); }); } @@ -809,6 +781,143 @@ private void cleanupParserSlotIfNecessary() parserSlotOffset = 0; } } + + private final class RisingwaveMacroDefaultHandler implements RisingwaveMacroHandler + { + @Override + public void doExecuteUserClient( + long traceId, + long authorization, + String query) + { + int progress = 0; + statementBuffer.putBytes(progress, query.getBytes()); + progress += query.length(); + + userClient.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); + } + + @Override + public void doExecuteSystemClient( + long traceId, + long authorization, + String query) + { + int progress = 0; + statementBuffer.putBytes(progress, query.getBytes()); + progress += query.length(); + + final RisingwaveRouteConfig route = + binding.resolve(authorization, statementBuffer, 0, progress); + + final PgsqlClient client = systemClientsByRouteId.get(route.id); + client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); + } + + @Override + public void doDescription( + long traceId, + long authorization, + String name) + { + PgsqlFlushExFW descriptionEx = flushExRW.wrap(extBuffer, 0, extBuffer.capacity()) + .typeId(pgsqlTypeId) + .type(t -> t + .columns(c -> c + .item(s -> s + .name("%s\u0000".formatted(name)) + .tableOid(0) + .index((short) 0) + .typeOid(701) + .length((short) name.length()) + .modifier(-1) + .format(f -> f.set(PgsqlFormat.TEXT)) + ))) + .build(); + + doAppFlush(traceId, authorization, descriptionEx); + } + + @Override + public void doRow( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int limit) + { + int progress = offset; + + if ((flags & FLAGS_INIT) != 0x00) + { + progress += Short.BYTES; + } + + String32FW column = columnRO.tryWrap(buffer, progress, limit); + + if (column != null) + { + PgsqlDataExFW dataEx = dataExRW.wrap(extBuffer, 0, extBuffer.capacity()) + .typeId(pgsqlTypeId) + .row(q -> q.deferred(0)) + .build(); + + final int length = column.sizeof(); + + int statementProgress = 0; + statementBuffer.putShort(statementProgress, (short) 1, ByteOrder.BIG_ENDIAN); + statementProgress += Short.BYTES; + statementBuffer.putBytes(statementProgress, column.buffer(), column.offset(), length); + statementProgress += length; + + doAppData(client, traceId, authorization, flags, + statementBuffer, 0, statementProgress, dataEx); + } + } + + @Override + public void doCompletion( + long traceId, + long authorization, + RisingwaveCompletionCommand command) + { + doCommandCompletion(traceId, authorization, command); + } + + @Override + public void doReady( + long traceId, + long authorization, + int progress) + { + onCommandReady(traceId, authorization, progress); + } + + @Override + public void doFlushProxy( + long traceId, + long authorization, + PgsqlFlushExFW flushEx) + { + doAppFlush(traceId, authorization, flushEx); + } + + @Override + public void doDataProxy( + T client, + long traceId, + long authorization, + int flags, + DirectBuffer buffer, + int offset, + int length, + OctetsFW extension) + { + doAppData(client, traceId, authorization, flags, buffer, offset, length, extension); + } + } } private final class PgsqlClient @@ -837,9 +946,6 @@ private final class PgsqlClient private int state; private int messageOffset; - private PgsqlFlushCommand typeCommand; - private PgsqlDataCommand dataCommand; - private PgsqlFlushCommand completionCommand; private PgsqlClient( PgsqlServer server, @@ -852,9 +958,6 @@ private PgsqlClient( this.routedId = routedId; this.user = user; - this.dataCommand = proxyDataCommand; - this.typeCommand = proxyFlushCommand; - this.completionCommand = ignoreFlushCommand; } private void onAppMessage( @@ -939,7 +1042,7 @@ private void onAppData( final OctetsFW extension = data.extension(); final OctetsFW payload = data.payload(); - dataCommand.handle(server, this, routedId, traceId, authorization, flags, + server.macroState.onRow(this, traceId, authorization, flags, payload.buffer(), payload.offset(), payload.limit(), extension); } } @@ -989,7 +1092,6 @@ private void onAppFlush( onAppReadyFlush(traceId, authorization, pgsqlFlushEx); break; default: - assert false; break; } } @@ -1059,7 +1161,7 @@ private void onAppTypeFlush( long authorization, PgsqlFlushExFW pgsqlFlushEx) { - typeCommand.handle(server, traceId, authorization, pgsqlFlushEx); + server.macroState.onType(traceId, authorization, pgsqlFlushEx); } private void onAppCompletionFlush( @@ -1068,7 +1170,7 @@ private void onAppCompletionFlush( PgsqlFlushExFW pgsqlFlushEx) { messageOffset = 0; - completionCommand.handle(server, traceId, authorization, pgsqlFlushEx); + server.macroState.onCompletion(traceId, authorization, pgsqlFlushEx); } private void onAppErrorFlush( @@ -1077,8 +1179,7 @@ private void onAppErrorFlush( PgsqlFlushExFW flushEx) { messageOffset = 0; - server.doAppFlush(traceId, authorization, flushEx); - server.commandsProcessed = COMMAND_PROCESSED_ERRORED; + server.macroState = server.macroState.onError(traceId, authorization, flushEx); } private void onAppReadyFlush( @@ -1086,8 +1187,7 @@ private void onAppReadyFlush( long authorization, PgsqlFlushExFW pgsqlFlushEx) { - dataCommand = proxyDataCommand; - server.onQueryReady(traceId, authorization, pgsqlFlushEx); + server.macroState = server.macroState.onReady(traceId, authorization, pgsqlFlushEx); } private void doAppBegin( @@ -1109,7 +1209,7 @@ private void doAppBegin( .typeId(pgsqlTypeId) .parameters(p -> server.parameters.forEach((k, v) -> { - if (k.contains("user") && user.equals(ZILLABASE_USER)) + if (k.contains("user") && user.equals(POSTGRES_USER)) { p.item(i -> i.name(k).value(user)); } @@ -1544,65 +1644,30 @@ private void doWindow( sender.accept(window.typeId(), window.buffer(), window.offset(), window.sizeof()); } - private void decodeCreateTableCommand( + private void decodeCreateZtableCommand( PgsqlServer server, long traceId, long authorization, String statement) { - if (server.commandsProcessed == 7 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.CREATE_TABLE_COMMAND); - } - else + if (server.macroState == null) { - final RisingwaveBindingConfig binding = server.binding; - final CreateTable createTable = parser.parseCreateTable(statement); - - String newStatement = ""; - int progress = 0; - - if (server.commandsProcessed == 0) - { - newStatement = binding.createTopic.generate(createTable); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.createSource.generateTableSource(createTable); - } - else if (server.commandsProcessed == 2) - { - newStatement = binding.createView.generate(createTable); - } - else if (server.commandsProcessed == 3) - { - newStatement = binding.createTable.generate(createTable); - } - else if (server.commandsProcessed == 4) - { - newStatement = binding.grantResource.generate("TABLE", createTable.schema(), createTable.name(), server.user); - } - else if (server.commandsProcessed == 5) - { - newStatement = binding.createSink.generateInto(createTable); - } - else if (server.commandsProcessed == 6) - { - newStatement = binding.createSink.generateOutgress(createTable); - } - - statementBuffer.putBytes(progress, newStatement.getBytes()); - progress += newStatement.length(); + final CreateTable command = parser.parseCreateTable(statement); - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + RisingwaveBindingConfig binding = server.binding; + RisingwaveCreateZtableMacro machine = new RisingwaveCreateZtableMacro( + binding.bootstrapServer, + binding.schemaRegistry, + config.kafkaScanStartupTimestampMillis(), + RisingwaveBindingConfig.INTERNAL_SCHEMA, + server.user, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeCreateStreamCommand( @@ -1611,39 +1676,25 @@ private void decodeCreateStreamCommand( long authorization, String statement) { - if (server.commandsProcessed == 2 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) + if (server.macroState == null) { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.CREATE_STREAM_COMMAND); - } - else - { - final RisingwaveBindingConfig binding = server.binding; - final CreateStream createStream = parser.parseCreateStream(statement); - - String newStatement = ""; - int progress = 0; + final CreateStream command = parser.parseCreateStream(statement); - if (server.commandsProcessed == 0) - { - newStatement = binding.createTopic.generate(createStream); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.createSource.generateStreamSource(createStream); - } - - statementBuffer.putBytes(progress, newStatement.getBytes()); - progress += newStatement.length(); + RisingwaveBindingConfig binding = server.binding; - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + RisingwaveCreateStreamMacro machine = new RisingwaveCreateStreamMacro( + binding.bootstrapServer, + binding.schemaRegistry, + config.kafkaScanStartupTimestampMillis(), + RisingwaveBindingConfig.INTERNAL_SCHEMA, + server.user, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeCreateZviewCommand( @@ -1652,64 +1703,24 @@ private void decodeCreateZviewCommand( long authorization, String statement) { - if (server.commandsProcessed == 6 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, - RisingwaveCompletionCommand.CREATE_ZVIEW_COMMAND); - } - else + if (server.macroState == null) { - final RisingwaveBindingConfig binding = server.binding; - final CreateZview createZview = parser.parseCreateZView(statement); - PgsqlFlushCommand typeCommand = ignoreFlushCommand; - PgsqlDataCommand dataCommand = proxyDataCommand; - - String newStatement = ""; - int progress = 0; - - if (server.commandsProcessed == 0) - { - newStatement = binding.createView.generate(createZview); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.grantResource.generate( - "MATERIALIZED VIEW", createZview.schema(), createZview.name(), server.user); - } - else if (server.commandsProcessed == 2) - { - newStatement = binding.describeView.generate(createZview); - typeCommand = typeFlushCommand; - dataCommand = rowDataCommand; - server.columns.clear(); - } - else if (server.commandsProcessed == 3) - { - newStatement = binding.createTopic.generate(createZview, server.columns); - } - else if (server.commandsProcessed == 4) - { - newStatement = binding.createSink.generateOutgress(server.columns, createZview); - } - else if (server.commandsProcessed == 5) - { - newStatement = binding.catalogInsert.generate(ZVIEW_TABLE_NAME, createZview.name(), statement); - } + final CreateZview command = parser.parseCreateZView(statement); - statementBuffer.putBytes(progress, newStatement.getBytes()); - progress += newStatement.length(); + RisingwaveBindingConfig binding = server.binding; - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = typeCommand; - client.dataCommand = dataCommand; - client.completionCommand = ignoreFlushCommand; + RisingwaveCreateZviewMacro machine = new RisingwaveCreateZviewMacro( + binding.bootstrapServer, + binding.schemaRegistry, + RisingwaveBindingConfig.INTERNAL_SCHEMA, + server.user, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeCreateFunctionCommand( @@ -1718,87 +1729,53 @@ private void decodeCreateFunctionCommand( long authorization, String statement) { - if (server.commandsProcessed == 2 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.CREATE_FUNCTION_COMMAND); - } - else + if (server.macroState == null) { - final RisingwaveBindingConfig binding = server.binding; - final Function function = parser.parseCreateFunction(statement); + final Function command = parser.parseCreateFunction(statement); - String newStatement = ""; - int progress = 0; + RisingwaveBindingConfig binding = server.binding; - if (server.commandsProcessed == 0) - { - newStatement = binding.createFunction.generate(function); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.grantResource.generate("FUNCTION", function.schema(), function.name(), server.user); - } - - statementBuffer.putBytes(progress, newStatement.getBytes()); - progress += newStatement.length(); - - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + RisingwaveCreateFunctionMacro machine = new RisingwaveCreateFunctionMacro( + binding.options.udfs, + RisingwaveBindingConfig.INTERNAL_SCHEMA, + server.user, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } - private void decodeAlterTableCommand( + private void decodeAlterZtableCommand( PgsqlServer server, long traceId, long authorization, String statement) { - final RisingwaveBindingConfig binding = server.binding; - final Alter alter = parser.parseAlterTable(statement); + final Alter command = parser.parseAlterTable(statement); - boolean supportedOperation = alter.expressions().stream() + boolean supportedOperation = command.expressions().stream() .noneMatch(c -> c.operation() != Operation.ADD); if (!supportedOperation) { - decodeUnsupportedCommand(server, traceId, authorization, RisingwaveCompletionCommand.ALTER_TABLE_COMMAND, - statement, "ALTER TABLE only supports ADD"); - } - else if (server.commandsProcessed == 2 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.ALTER_TABLE_COMMAND); + decodeUnsupportedCommand(server, traceId, authorization, RisingwaveCompletionCommand.ALTER_ZTABLE_COMMAND, + statement, "ALTER ZTABLE only supports ADD"); } else { - String newStatement = ""; - int progress = 0; - - if (server.commandsProcessed == 0) + if (server.macroState == null) { - newStatement = binding.alterTopic.generate(alter); + RisingwaveAlterZtableMacro machine = new RisingwaveAlterZtableMacro( + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } - else if (server.commandsProcessed == 1) - { - newStatement = binding.alterTable.generate(alter); - } - - statementBuffer.putBytes(progress, newStatement.getBytes()); - progress += newStatement.length(); - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + server.macroState.onStarted(traceId, authorization); } } @@ -1808,10 +1785,9 @@ private void decodeAlterStreamCommand( long authorization, String statement) { - final RisingwaveBindingConfig binding = server.binding; - final Alter alter = parser.parseAlterStream(statement); + final Alter command = parser.parseAlterStream(statement); - boolean supportedOperation = alter.expressions().stream() + boolean supportedOperation = command.expressions().stream() .noneMatch(c -> c.operation() != Operation.ADD); if (!supportedOperation) @@ -1819,26 +1795,18 @@ private void decodeAlterStreamCommand( decodeUnsupportedCommand(server, traceId, authorization, RisingwaveCompletionCommand.ALTER_STREAM_COMMAND, statement, "ALTER STREAM only supports ADD"); } - else if (server.commandsProcessed == 1 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.ALTER_STREAM_COMMAND); - } - else if (server.commandsProcessed == 0) + else { - int progress = 0; - String newStatement = binding.alterTopic.generate(alter); - - statementBuffer.putBytes(progress, newStatement.getBytes()); - progress += newStatement.length(); - - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); + if (server.macroState == null) + { + RisingwaveAlterStreamMacro machine = new RisingwaveAlterStreamMacro( + statement, + command, + server.macroHandler); + server.macroState = machine.start(); + } - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + server.macroState.onStarted(traceId, authorization); } } @@ -1852,66 +1820,31 @@ private void decodeUnsupportedCommand( { server.doCommandError(traceId, authorization, SEVERITY_ERROR, CODE_XX000, "Unable to execute command because %s\u0000".formatted(reason)); - server.commandsProcessed = COMMAND_PROCESSED_ERRORED; final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, command); + server.onCommandReady(traceId, authorization, length); } - private void decodeDropTableCommand( + private void decodeDropZtableCommand( PgsqlServer server, long traceId, long authorization, String statement) { - if (server.commandsProcessed == 6) + if (server.macroState == null) { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.DROP_TABLE_COMMAND); - } - else - { - final RisingwaveBindingConfig binding = server.binding; - final Drop table = parser.parseDrop(statement).get(0); - - String newStatement = ""; - int progress = 0; + // TODO: Enhance multiple streams + final Drop command = parser.parseDrop(statement).get(0); - if (server.commandsProcessed == 0) - { - newStatement = binding.dropTopic.generate(table); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.dropSink.generate(table); - } - else if (server.commandsProcessed == 2) - { - newStatement = binding.dropSink.generate(table, "_view_sink"); - } - else if (server.commandsProcessed == 3) - { - newStatement = binding.dropTable.generate(table); - } - else if (server.commandsProcessed == 4) - { - newStatement = binding.dropMaterializedView.generate(table, "_view"); - } - else if (server.commandsProcessed == 5) - { - newStatement = binding.dropSource.generate(table, "_source"); - } - - statementBuffer.putStringWithoutLengthUtf8(progress, newStatement); - progress += newStatement.length(); - - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + RisingwaveDropZtableMacro machine = new RisingwaveDropZtableMacro( + RisingwaveBindingConfig.INTERNAL_SCHEMA, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeDropStreamCommand( @@ -1920,38 +1853,20 @@ private void decodeDropStreamCommand( long authorization, String statement) { - if (server.commandsProcessed == 2) + if (server.macroState == null) { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.DROP_STREAM_COMMAND); - } - else - { - final RisingwaveBindingConfig binding = server.binding; - final Drop stream = parser.parseDrop(statement).get(0); - - String newStatement = ""; - int progress = 0; - - if (server.commandsProcessed == 0) - { - newStatement = binding.dropTopic.generate(stream); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.dropSource.generate(stream); - } - - statementBuffer.putStringWithoutLengthUtf8(progress, newStatement); - progress += newStatement.length(); + // TODO: Enhance multiple streams + final Drop command = parser.parseDrop(statement).get(0); - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); - - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = ignoreFlushCommand; + RisingwaveDropStreamMacro machine = new RisingwaveDropStreamMacro( + RisingwaveBindingConfig.INTERNAL_SCHEMA, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeDropZviewCommand( @@ -1960,47 +1875,20 @@ private void decodeDropZviewCommand( long authorization, String statement) { - if (server.commandsProcessed == 4) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, - RisingwaveCompletionCommand.DROP_ZVIEW_COMMAND); - } - else + if (server.macroState == null) { - final RisingwaveBindingConfig binding = server.binding; - final Drop view = parser.parseDrop(statement).get(0); - - String newStatement = ""; - int progress = 0; - - if (server.commandsProcessed == 0) - { - newStatement = binding.dropTopic.generate(view); - } - else if (server.commandsProcessed == 1) - { - newStatement = binding.dropSink.generate(view); - } - else if (server.commandsProcessed == 2) - { - newStatement = binding.catalogDelete.generate(ZVIEW_TABLE_NAME, view); - } - else if (server.commandsProcessed == 3) - { - newStatement = binding.dropMaterializedView.generate(view); - } - - statementBuffer.putStringWithoutLengthUtf8(progress, newStatement); - progress += newStatement.length(); - - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); + // TODO: Enhance multiple streams + final Drop command = parser.parseDrop(statement).get(0); - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.completionCommand = ignoreFlushCommand; + RisingwaveDropZviewMacro machine = new RisingwaveDropZviewMacro( + RisingwaveBindingConfig.INTERNAL_SCHEMA, + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeShowCommand( @@ -2009,30 +1897,18 @@ private void decodeShowCommand( long authorization, String statement) { - if (server.commandsProcessed == 1) - { - final int length = statement.length(); - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.SHOW_COMMAND); - } - else + if (server.macroState == null) { - final RisingwaveBindingConfig binding = server.binding; - final String type = parser.parseShow(statement); - - int progress = 0; - String newStatement = binding.showType.generate(type); - - statementBuffer.putStringWithoutLengthUtf8(progress, newStatement); - progress += newStatement.length(); - - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, progress); + final String command = parser.parseShow(statement); - final PgsqlClient client = server.systemClientsByRouteId.get(route.id); - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, progress); - client.typeCommand = showColumnFlushCommand; - client.dataCommand = showColumnDataCommand; + RisingwaveShowCommandMacro machine = new RisingwaveShowCommandMacro( + statement, + command, + server.macroHandler); + server.macroState = machine.start(); } + + server.macroState.onStarted(traceId, authorization); } private void decodeUnknownCommand( @@ -2041,185 +1917,15 @@ private void decodeUnknownCommand( long authorization, String statement) { - final int length = statement.length(); - - if (server.commandsProcessed == 1 || - server.commandsProcessed == COMMAND_PROCESSED_ERRORED) + if (server.macroState == null) { - server.onCommandCompleted(traceId, authorization, length, RisingwaveCompletionCommand.UNKNOWN_COMMAND); + RisingwaveUnknownMacro machine = new RisingwaveUnknownMacro( + statement, + server.macroHandler); + server.macroState = machine.start(); } - else - { - statementBuffer.putBytes(0, statement.getBytes()); - - final RisingwaveRouteConfig route = - server.binding.resolve(authorization, statementBuffer, 0, length); - - final PgsqlClient client = server.userClient; - client.doPgsqlQuery(traceId, authorization, statementBuffer, 0, length); - client.completionCommand = proxyFlushCommand; - } - } - private void ignoreFlushCommand( - PgsqlServer server, - long traceId, - long authorization, - PgsqlFlushExFW flushEx) - { - //NOOP - } - - private void proxyFlushCommand( - PgsqlServer server, - long traceId, - long authorization, - PgsqlFlushExFW flushEx) - { - server.doAppFlush(traceId, authorization, flushEx); - } - - private void typeFlushCommand( - PgsqlServer server, - long traceId, - long authorization, - PgsqlFlushExFW flushEx) - { - server.columnTypes.clear(); - flushEx.type().columns() - .forEach(c -> - { - String name = c.name().asString(); - name = name.substring(0, name.length() - 1); - server.columnTypes.add(name); - }); - } - - private void showColumnFlushCommand( - PgsqlServer server, - long traceId, - long authorization, - PgsqlFlushExFW flushEx) - { - PgsqlFlushExFW descriptionEx = flushExRW.wrap(extBuffer, 0, extBuffer.capacity()) - .typeId(pgsqlTypeId) - .type(t -> t - .columns(c -> c - .item(s -> s - .name("Name\u0000") - .tableOid(0) - .index((short) 0) - .typeOid(701) - .length((short) 4) - .modifier(-1) - .format(f -> f.set(PgsqlFormat.TEXT)) - ))) - .build(); - - server.doAppFlush(traceId, authorization, descriptionEx); - } - - private void rowDataCommand( - PgsqlServer server, - PgsqlClient client, - long traceId, - long authorization, - long routedId, - int flags, - DirectBuffer buffer, - int offset, - int limit, - OctetsFW extension) - { - int progress = offset; - - final List columnDescriptions = server.columnDescriptions; - - if ((flags & FLAGS_INIT) != 0x00) - { - columnDescriptions.clear(); - progress += Short.BYTES; - } - - column: - while (progress < limit) - { - String32FW column = columnRO.tryWrap(buffer, progress, limit); - - if (column == null) - { - break column; - } - - columnDescriptions.add(column.asString()); - - progress = column.limit(); - } - - int nameIndex = server.columnTypes.indexOf("Name"); - int typeIndex = server.columnTypes.indexOf("Type"); - int isHiddenIndex = server.columnTypes.indexOf("Is Hidden"); - - if ("false".equals(columnDescriptions.get(isHiddenIndex))) - { - server.columns.put(columnDescriptions.get(nameIndex), columnDescriptions.get(typeIndex)); - } - } - - private void showColumnDataCommand( - PgsqlServer server, - PgsqlClient client, - long traceId, - long authorization, - long routedId, - int flags, - DirectBuffer buffer, - int offset, - int limit, - OctetsFW extension) - { - int progress = offset; - - if ((flags & FLAGS_INIT) != 0x00) - { - progress += Short.BYTES; - } - - String32FW column = columnRO.tryWrap(buffer, progress, limit); - - if (column != null) - { - PgsqlDataExFW dataEx = dataExRW.wrap(extBuffer, 0, extBuffer.capacity()) - .typeId(pgsqlTypeId) - .row(q -> q.deferred(0)) - .build(); - - final int length = column.sizeof(); - - int statementProgress = 0; - statementBuffer.putShort(statementProgress, (short) 1, ByteOrder.BIG_ENDIAN); - statementProgress += Short.BYTES; - statementBuffer.putBytes(statementProgress, column.buffer(), column.offset(), length); - statementProgress += length; - - server.doAppData(client, routedId, traceId, authorization, flags, - statementBuffer, 0, statementProgress, dataEx); - } - } - - private void proxyDataCommand( - PgsqlServer server, - PgsqlClient client, - long traceId, - long authorization, - long routedId, - int flags, - DirectBuffer buffer, - int offset, - int limit, - OctetsFW extension) - { - server.doAppData(client, routedId, traceId, authorization, flags, buffer, offset, limit, extension); + server.macroState.onStarted(traceId, authorization); } public List splitStatements( @@ -2276,30 +1982,4 @@ void transform( long authorization, String statement); } - - @FunctionalInterface - private interface PgsqlFlushCommand - { - void handle( - PgsqlServer server, - long traceId, - long authorization, - PgsqlFlushExFW flushEx); - } - - @FunctionalInterface - private interface PgsqlDataCommand - { - void handle( - PgsqlServer server, - PgsqlClient client, - long traceId, - long authorization, - long routedId, - int flags, - DirectBuffer buffer, - int offset, - int limit, - OctetsFW extension); - } } diff --git a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateCreateTableTemplateTest.java b/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateCreateTableTemplateTest.java deleted file mode 100644 index 4a4e579fad..0000000000 --- a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateCreateTableTemplateTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; - -public class RisingwaveCreateCreateTableTemplateTest -{ - private static RisingwaveCreateTableTemplate template; - - @BeforeClass - public static void setUp() - { - template = new RisingwaveCreateTableTemplate(); - } - - @Test - public void shouldGenerateTableWithValidTableInfo() - { - List columns = new ArrayList<>(); - columns.add(new TableColumn("id", "INT", List.of())); - columns.add(new TableColumn("name", "STRING", List.of())); - - CreateTable createTable = new CreateTable( - "public", - "test_table", - columns, - Set.of("id")); - String expectedSQL = """ - CREATE TABLE IF NOT EXISTS test_table (id INT, name STRING, PRIMARY KEY (id));\u0000"""; - - String actualSQL = template.generate(createTable); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateTableWithoutPrimaryKey() - { - List columns = new ArrayList<>(); - columns.add(new TableColumn("id", "INT", List.of())); - columns.add(new TableColumn("name", "STRING", List.of())); - - CreateTable createTable = new CreateTable( - "public", - "test_table", - columns, - Set.of()); - String expectedSQL = """ - CREATE TABLE IF NOT EXISTS test_table (id INT, name STRING);\u0000"""; - - String actualSQL = template.generate(createTable); - - assertEquals(expectedSQL, actualSQL); - } - - @Ignore("TODO") - @Test - public void shouldGenerateTableWithMultiplePrimaryKeys() - { - List columns = new ArrayList<>(); - columns.add(new TableColumn("id", "INT", List.of())); - columns.add(new TableColumn("name", "STRING", List.of())); - - CreateTable createTable = new CreateTable( - "public", - "test_table", - columns, - Set.of("id", "name")); - String expectedSQL = """ - CREATE TABLE IF NOT EXISTS test_table (id INT, name STRING, PRIMARY KEY (id));\u0000"""; - - String actualSQL = template.generate(createTable); - - assertEquals(expectedSQL, actualSQL); - } -} diff --git a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateFunctionTemplateTest.java b/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateFunctionTemplateTest.java deleted file mode 100644 index 9ee286699f..0000000000 --- a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateFunctionTemplateTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Test; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.Function; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.FunctionArgument; -import io.aklivity.zilla.runtime.binding.risingwave.config.RisingwaveUdfConfig; - -public class RisingwaveCreateFunctionTemplateTest -{ - private static RisingwaveCreateFunctionTemplate template; - - @BeforeClass - public static void setUp() - { - template = new RisingwaveCreateFunctionTemplate(List.of( - RisingwaveUdfConfig.builder().server("http://localhost:8815").language("java").build(), - RisingwaveUdfConfig.builder().server("http://localhost:8816").language("python").build())); - } - - @Test - public void shouldGenerateFunctionWithValidFunctionInfo() - { - Function function = new Function( - "public", - "test_function", - List.of(new FunctionArgument("arg1", "INT")), - "INT", - List.of(), - "test_function", - "java"); - String expectedSQL = """ - CREATE FUNCTION test_function(arg1 INT) - RETURNS INT - AS test_function - LANGUAGE java - USING LINK 'http://localhost:8815';\u0000"""; - - String actualSQL = template.generate(function); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateFunctionWithTableReturnType() - { - Function functionInfo = new Function( - "public", - "test_function", - List.of(new FunctionArgument("arg1", "INT")), - "INT", - List.of(new FunctionArgument("tab1", "INT")), - "test_function", - "java"); - - String expectedSQL = """ - CREATE FUNCTION test_function(arg1 INT) - RETURNS TABLE (tab1 INT) - AS test_function - LANGUAGE java - USING LINK 'http://localhost:8815';\u0000"""; - - String actualSQL = template.generate(functionInfo); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateFunctionWithTableAsReturnType() - { - Function functionInfo = new Function( - "public", - "test_function", - List.of(new FunctionArgument("arg1", "INT")), - "INT", - List.of(), - "test_function", - "java"); - - String expectedSQL = """ - CREATE FUNCTION test_function(arg1 INT) - RETURNS INT - AS test_function - LANGUAGE java - USING LINK 'http://localhost:8815';\u0000"""; - - String actualSQL = template.generate(functionInfo); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateFunctionWithMultipleArguments() - { - Function function = new Function( - "public", - "test_function", - List.of(new FunctionArgument("arg1", "INT"), new FunctionArgument("arg2", "STRING")), - "STRING", - List.of(), - "test_function", - "python"); - - String expectedSQL = """ - CREATE FUNCTION test_function(arg1 INT, arg2 STRING) - RETURNS STRING - AS test_function - LANGUAGE python - USING LINK 'http://localhost:8816';\u0000"""; - - String actualSQL = template.generate(function); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateFunctionWithUnnamedArguments() - { - Function function = new Function( - "public", - "test_function", - List.of(new FunctionArgument(null, "INT"), new FunctionArgument(null, "STRING")), - "STRING", - List.of(), - "test_function", - "java"); - - String expectedSQL = """ - CREATE FUNCTION test_function(INT, STRING) - RETURNS STRING - AS test_function - LANGUAGE java - USING LINK 'http://localhost:8815';\u0000"""; - - String actualSQL = template.generate(function); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateFunctionWithEmptyArguments() - { - Function function = new Function( - "public", - "test_function", - List.of(), - "VOID", - List.of(), - "test_function", - "python"); - - String expectedSQL = """ - CREATE FUNCTION test_function() - RETURNS VOID - AS test_function - LANGUAGE python - USING LINK 'http://localhost:8816';\u0000"""; - - String actualSQL = template.generate(function); - - assertEquals(expectedSQL, actualSQL); - } - -} diff --git a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateMaterializedCreateZviewTemplateTest.java b/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateMaterializedCreateZviewTemplateTest.java deleted file mode 100644 index aabdcbc8e3..0000000000 --- a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateMaterializedCreateZviewTemplateTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.junit.Ignore; -import org.junit.Test; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateZview; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; - -public class RisingwaveCreateMaterializedCreateZviewTemplateTest -{ - private final RisingwaveCreateMaterializedViewTemplate template = new RisingwaveCreateMaterializedViewTemplate(); - - @Test - public void shouldGenerateMaterializedViewWithValidViewInfo() - { - CreateZview createZview = new CreateZview("public", "test_view", "SELECT * FROM test_table"); - String expectedSQL = """ - CREATE MATERIALIZED VIEW IF NOT EXISTS test_view AS SELECT * FROM test_table;\u0000"""; - - String actualSQL = template.generate(createZview); - - assertEquals(expectedSQL, actualSQL); - } - - @Ignore("TODO") - @Test - public void shouldGenerateMaterializedViewWithValidTableInfo() - { - CreateTable createTable = new CreateTable( - "public", - "test_table", - List.of(new TableColumn("id", "INT", List.of()), - new TableColumn("name", "STRING", List.of())), - Set.of("id")); - String expectedSQL = """ - CREATE MATERIALIZED VIEW IF NOT EXISTS test_table_view AS SELECT id, name FROM test_table_source;\u0000"""; - - String actualSQL = template.generate(createTable); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateMaterializedViewWithEmptyColumns() - { - CreateTable createTable = new CreateTable("public", "empty_table", List.of(), Set.of()); - String expectedSQL = """ - CREATE MATERIALIZED VIEW IF NOT EXISTS empty_table_view AS SELECT * FROM empty_table_source;\u0000"""; - - String actualSQL = template.generate(createTable); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateMaterializedViewWithIncludes() - { - List columns = new ArrayList<>(); - columns.add(new TableColumn("id", "INT", List.of())); - columns.add(new TableColumn("zilla_correlation_id", "VARCHAR", List.of())); - columns.add(new TableColumn("zilla_identity", "VARCHAR", List.of())); - columns.add(new TableColumn("zilla_timestamp", "TIMESTAMP", List.of())); - - CreateTable createTable = new CreateTable("public", "test_table", columns, Set.of("id")); - String expectedSQL = "CREATE MATERIALIZED VIEW IF NOT EXISTS test_table_view AS SELECT id," + - " COALESCE(zilla_correlation_id, zilla_correlation_id_header::varchar) as zilla_correlation_id," + - " COALESCE(zilla_identity, zilla_identity_header::varchar) as zilla_identity," + - " COALESCE(zilla_timestamp, zilla_timestamp_timestamp::varchar) as zilla_timestamp" + - " FROM test_table_source;\u0000"; - - String actualSQL = template.generate(createTable); - - assertEquals(expectedSQL, actualSQL); - } -} diff --git a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSourceTemplateTest.java b/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSourceTemplateTest.java deleted file mode 100644 index 0781dd93ad..0000000000 --- a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/statement/RisingwaveCreateSourceTemplateTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2021-2024 Aklivity Inc - * - * Licensed under the Aklivity Community License (the "License"); you may not use - * this file except in compliance with the License. You may obtain a copy of the - * License at - * - * https://www.aklivity.io/aklivity-community-license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.aklivity.zilla.runtime.binding.risingwave.internal.statement; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.BeforeClass; -import org.junit.Test; - -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateStream; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.CreateTable; -import io.aklivity.zilla.runtime.binding.pgsql.parser.model.TableColumn; - -public class RisingwaveCreateSourceTemplateTest -{ - private static RisingwaveCreateSourceTemplate template; - - @BeforeClass - public static void setUp() - { - template = new RisingwaveCreateSourceTemplate("localhost:9092", "http://localhost:8081", 1627846260000L); - } - - @Test - public void shouldGenerateStreamSourceWithValidStreamInfo() - { - CreateStream createStream = new CreateStream("public", "test_stream", Map.of("id", "INT", "name", "STRING")); - String expectedSQL = """ - CREATE SOURCE IF NOT EXISTS test_stream (*) - WITH ( - connector='kafka', - properties.bootstrap.server='localhost:9092', - topic='public.test_stream', - scan.startup.mode='latest', - scan.startup.timestamp.millis='1627846260000' - ) FORMAT PLAIN ENCODE AVRO ( - schema.registry = 'http://localhost:8081' - );\u0000"""; - - String actualSQL = template.generateStreamSource(createStream); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateTableSourceWithValidTableInfoAndIncludes() - { - List columns = new ArrayList<>(); - columns.add(new TableColumn("id", "INT", List.of())); - columns.add(new TableColumn("zilla_correlation_id", "VARCHAR", List.of())); - columns.add(new TableColumn("zilla_identity", "VARCHAR", List.of())); - columns.add(new TableColumn("zilla_timestamp", "TIMESTAMP", List.of())); - - CreateTable createTable = new CreateTable( - "public", "test_table", columns, Set.of("id")); - String expectedSQL = """ - CREATE SOURCE IF NOT EXISTS test_table_source (*) - INCLUDE header 'zilla:correlation-id' AS zilla_correlation_id_header - INCLUDE header 'zilla:identity' AS zilla_identity_header - INCLUDE timestamp AS zilla_timestamp_timestamp - WITH ( - connector='kafka', - properties.bootstrap.server='localhost:9092', - topic='public.test_table', - scan.startup.mode='latest', - scan.startup.timestamp.millis='1627846260000' - ) FORMAT PLAIN ENCODE AVRO ( - schema.registry = 'http://localhost:8081' - );\u0000"""; - - String actualSQL = template.generateTableSource(createTable); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateStreamSourceWithEmptyColumnsReturnsSQLWithoutIncludes() - { - CreateStream createStream = new CreateStream("public", "empty_stream", Map.of()); - String expectedSQL = """ - CREATE SOURCE IF NOT EXISTS empty_stream (*) - WITH ( - connector='kafka', - properties.bootstrap.server='localhost:9092', - topic='public.empty_stream', - scan.startup.mode='latest', - scan.startup.timestamp.millis='1627846260000' - ) FORMAT PLAIN ENCODE AVRO ( - schema.registry = 'http://localhost:8081' - );\u0000"""; - - String actualSQL = template.generateStreamSource(createStream); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateStreamSourceWithEmptyColumnsReturnsSQLWithIncludes() - { - Map columns = new LinkedHashMap<>(); - columns.put("id", "INT"); - columns.put("zilla_correlation_id", "VARCHAR"); - columns.put("zilla_identity", "VARCHAR"); - columns.put("zilla_timestamp", "TIMESTAMP"); - - String expectedSQL = """ - CREATE SOURCE IF NOT EXISTS include_stream (*) - INCLUDE header 'zilla:correlation-id' AS zilla_correlation_id - INCLUDE header 'zilla:identity' AS zilla_identity - INCLUDE timestamp AS zilla_timestamp - WITH ( - connector='kafka', - properties.bootstrap.server='localhost:9092', - topic='public.include_stream', - scan.startup.mode='latest', - scan.startup.timestamp.millis='1627846260000' - ) FORMAT PLAIN ENCODE AVRO ( - schema.registry = 'http://localhost:8081' - );\u0000"""; - CreateStream createStream = new CreateStream("public", "include_stream", columns); - - String actualSQL = template.generateStreamSource(createStream); - - assertEquals(expectedSQL, actualSQL); - } - - @Test - public void shouldGenerateTableSourceWithEmptyColumnsAndWithoutIncludes() - { - CreateTable createTable = new CreateTable("public", "empty_table", List.of(), Set.of()); - String expectedSQL = """ - CREATE SOURCE IF NOT EXISTS empty_table_source (*) - WITH ( - connector='kafka', - properties.bootstrap.server='localhost:9092', - topic='public.empty_table', - scan.startup.mode='latest', - scan.startup.timestamp.millis='1627846260000' - ) FORMAT PLAIN ENCODE AVRO ( - schema.registry = 'http://localhost:8081' - );\u0000"""; - - String actualSQL = template.generateTableSource(createTable); - - assertEquals(expectedSQL, actualSQL); - } -} diff --git a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/ProxyIT.java b/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/ProxyIT.java index 2cbd735aba..7fe9f27e6b 100644 --- a/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/ProxyIT.java +++ b/incubator/binding-risingwave/src/test/java/io/aklivity/zilla/runtime/binding/risingwave/internal/stream/ProxyIT.java @@ -52,9 +52,9 @@ public class ProxyIT @Test @Configuration("proxy.yaml") @Specification({ - "${pgsql}/create.table.with.primary.key/client", - "${effective}/create.table.with.primary.key/server" }) - public void shouldCreateTableWithPrimaryKey() throws Exception + "${pgsql}/create.ztable.with.primary.key/client", + "${effective}/create.ztable.with.primary.key/server" }) + public void shouldCreateZtableWithPrimaryKey() throws Exception { k3po.finish(); } @@ -195,9 +195,9 @@ public void shouldCreateStreamWithIncludes() throws Exception @Test @Configuration("proxy.yaml") @Specification({ - "${pgsql}/create.table.with.primary.key.and.includes/client", - "${effective}/create.table.with.primary.key.and.includes/server" }) - public void shouldCreateTableWithPrimaryKeyAndIncludes() throws Exception + "${pgsql}/create.ztable.with.generated.as/client", + "${effective}/create.ztable.with.generated.as/server" }) + public void shouldCreateTableWithGeneratedAs() throws Exception { k3po.finish(); } @@ -225,9 +225,9 @@ public void shouldDropStream() throws Exception @Test @Configuration("proxy.yaml") @Specification({ - "${pgsql}/drop.table/client", - "${effective}/drop.table/server" }) - public void shouldDropTable() throws Exception + "${pgsql}/drop.ztable/client", + "${effective}/drop.ztable/server" }) + public void shouldDropZtable() throws Exception { k3po.finish(); } @@ -245,9 +245,9 @@ public void shouldDropZview() throws Exception @Test @Configuration("proxy.yaml") @Specification({ - "${pgsql}/alter.table.add.column/client", - "${effective}/alter.table.add.column/server" }) - public void shouldAlterTableAddColumn() throws Exception + "${pgsql}/alter.ztable.add.column/client", + "${effective}/alter.ztable.add.column/server" }) + public void shouldAlterZtableAddColumn() throws Exception { k3po.finish(); } @@ -265,9 +265,9 @@ public void shouldAlterStreamAddColumn() throws Exception @Test @Configuration("proxy.yaml") @Specification({ - "${pgsql}/alter.table.modify.column.rejected/client", + "${pgsql}/alter.ztable.modify.column.rejected/client", "${effective}/client.stream.established/server" }) - public void shouldNotAlterTableModifyColumn() throws Exception + public void shouldNotAlterZtableModifyColumn() throws Exception { k3po.finish(); } @@ -291,4 +291,14 @@ public void shouldShowZviews() throws Exception { k3po.finish(); } + + @Test + @Configuration("proxy.risingwave.yaml") + @Specification({ + "${pgsql}/show.ztables/client", + "${effective}/show.ztables/server" }) + public void shouldShowZtables() throws Exception + { + k3po.finish(); + } } diff --git a/runtime/model-avro/src/main/java/org/apache/avro/io/CanonicalJsonDecoder.java b/runtime/model-avro/src/main/java/org/apache/avro/io/CanonicalJsonDecoder.java index fd08d9836d..3656e1d44d 100644 --- a/runtime/model-avro/src/main/java/org/apache/avro/io/CanonicalJsonDecoder.java +++ b/runtime/model-avro/src/main/java/org/apache/avro/io/CanonicalJsonDecoder.java @@ -26,14 +26,6 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -import org.apache.avro.AvroTypeException; -import org.apache.avro.Schema; -import org.apache.avro.io.parsing.Symbol; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -43,6 +35,13 @@ import java.nio.charset.Charset; import java.util.List; +import org.apache.avro.AvroTypeException; +import org.apache.avro.Schema; +import org.apache.avro.io.parsing.Symbol; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; + public final class CanonicalJsonDecoder extends JsonDecoder { private static final Method ADVANCE; @@ -112,8 +111,8 @@ else if (CanonicalJsonEncoder.isNullableSingle(a)) { label = CanonicalJsonEncoder.getNullableSingle(a); } - else if (currentToken == JsonToken.START_OBJECT - && lin.nextToken() == JsonToken.FIELD_NAME) + else if (currentToken == JsonToken.START_OBJECT && + lin.nextToken() == JsonToken.FIELD_NAME) { label = lin.getText(); lin.nextToken(); diff --git a/runtime/model-avro/src/main/java/org/apache/avro/io/JsonDecoder.java b/runtime/model-avro/src/main/java/org/apache/avro/io/JsonDecoder.java index 37f15568b4..9de5203574 100644 --- a/runtime/model-avro/src/main/java/org/apache/avro/io/JsonDecoder.java +++ b/runtime/model-avro/src/main/java/org/apache/avro/io/JsonDecoder.java @@ -26,6 +26,13 @@ import java.util.Map; import java.util.Stack; +import org.apache.avro.AvroTypeException; +import org.apache.avro.Schema; +import org.apache.avro.io.parsing.JsonGrammarGenerator; +import org.apache.avro.io.parsing.Parser; +import org.apache.avro.io.parsing.Symbol; +import org.apache.avro.util.Utf8; + import com.fasterxml.jackson.core.Base64Variant; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonLocation; @@ -35,13 +42,6 @@ import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.Version; -import org.apache.avro.AvroTypeException; -import org.apache.avro.Schema; -import org.apache.avro.io.parsing.JsonGrammarGenerator; -import org.apache.avro.io.parsing.Parser; -import org.apache.avro.io.parsing.Symbol; -import org.apache.avro.util.Utf8; - /** A {@link Decoder} for Avro's JSON data encoding. *

* Construct using {@link DecoderFactory}.