diff --git a/modules/sql/pages/get-started/deploy-sql-cluster.adoc b/modules/sql/pages/get-started/deploy-sql-cluster.adoc new file mode 100644 index 000000000..f49a5faae --- /dev/null +++ b/modules/sql/pages/get-started/deploy-sql-cluster.adoc @@ -0,0 +1,253 @@ += Enable Redpanda SQL on a BYOC Cluster +:description: Enable the Redpanda SQL engine on a BYOC cluster so you can query streaming data with standard PostgreSQL syntax. +:page-topic-type: how-to +:personas: platform_admin, data_engineer +:learning-objective-1: Enable Redpanda SQL on a new or existing BYOC cluster +:learning-objective-2: Scale or disable the SQL engine +:learning-objective-3: Verify that the SQL engine is running and ready to accept connections + +Enable Redpanda SQL on a Bring Your Own Cloud (BYOC) cluster so you can query streaming data in Redpanda topics using standard PostgreSQL syntax. For Iceberg-enabled topics, queries can span both the streaming topic and its Iceberg history. See xref:sql:query-data/query-iceberg-topics.adoc[Query Iceberg-enabled topics] for that workflow. + +Use this page to: + +* [ ] {learning-objective-1} +* [ ] {learning-objective-2} +* [ ] {learning-objective-3} + +NOTE: Redpanda SQL is currently available only on BYOC clusters running on AWS. + +== Prerequisites + +To enable Redpanda SQL, you need: + +* A Redpanda Cloud organization on xref:billing:billing.adoc[usage-based billing]. +* Admin permissions in your Redpanda Cloud organization. +* If using the link:/api/doc/cloud-controlplane/topic/topic-cloud-api-overview[Cloud API] to enable SQL, a valid bearer token for the API. See link:/api/doc/cloud-controlplane/authentication[Authenticate to the Cloud API]. + +== Enable Redpanda SQL + +You can enable Redpanda SQL on a new or existing BYOC cluster. + +=== On a new cluster + +[tabs] +===== +Cloud Console:: ++ +-- +. Log in to https://cloud.redpanda.com[Redpanda Cloud^]. +. Start creating a new BYOC cluster on AWS. For details and prerequisites, see xref:get-started:cluster-types/byoc/aws/create-byoc-cluster-aws.adoc[]. +. In the cluster creation form, select the option to enable SQL. +// TODO: Confirm guidance to provide on selecting capacity. The node-count +// selection is expected to be replaced with RPUs +. Choose the number of SQL nodes to deploy. ++ +The minimum is one node to enable SQL. You can scale up (maximum nine nodes) or down later as needed, but the cluster must have at least one SQL node to run the engine. +. Complete the remaining cluster configuration and deploy. +-- + +Cloud API:: ++ +-- +. Authenticate to the link:/api/doc/cloud-controlplane/topic/topic-cloud-api-overview[Cloud API]. For details, see link:/api/doc/cloud-controlplane/authentication[Authenticate to the Cloud API]. +// TODO: Is selecting capacity (currently node count, expected to change to RPUs) +// available with this endpoint? +. Make a link:/api/doc/cloud-controlplane/operation/operation-clusterservice_createcluster[`POST /v1/clusters`] request with `rpsql.enabled` set to `true` in the cluster spec: ++ +[,bash] +---- +curl -X POST "https://api.redpanda.com/v1/clusters" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "cluster": { + "name": "", + "cloud_provider": "CLOUD_PROVIDER_AWS", + "type": "TYPE_BYOC", + "region": "", + "zones": [ ], + "throughput_tier": "", + "resource_group_id": "", + "rpsql": { + "enabled": true + } + } + }' +---- ++ +For the full request body and field reference, see the link:/api/doc/cloud-controlplane/operation/operation-clusterservice_createcluster[Create Cluster API]. +. The request returns the ID of a long-running operation. Poll the link:/api/doc/cloud-controlplane/operation/operation-operationservice_getoperation[`GET /v1/operations/{operation.id}`] endpoint until the operation completes. +-- +===== + +=== On an existing cluster + +// TODO: The node-count selection in the Edit RP SQL dialog is expected to be +// replaced with one for RPUs + +[tabs] +===== +Cloud Console:: ++ +-- +. Log in to https://cloud.redpanda.com[Redpanda Cloud^] and open your cluster. +. From the left navigation, select *Dataplane settings*. +. On the *Cluster* tab, find the *RP SQL* row and click *Edit*. +. In the *Edit RP SQL* dialog, select *Enable*, set the *Number of RP SQL nodes* (1-9), and click *Save*. +-- + +Cloud API:: ++ +-- +. Authenticate to the link:/api/doc/cloud-controlplane/topic/topic-cloud-api-overview[Cloud API]. For details, see link:/api/doc/cloud-controlplane/authentication[Authenticate to the Cloud API]. +. Locate the cluster ID in the *Details* section of the cluster overview in the Cloud Console. +. Make a link:/api/doc/cloud-controlplane/operation/operation-clusterservice_updatecluster[`PATCH /v1/clusters/{cluster.id}`] request, replacing `{cluster.id}` with your cluster ID: ++ +[,bash] +---- +curl -X PATCH "https://api.redpanda.com/v1/clusters/{cluster.id}" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"rpsql":{"enabled":true}}' +---- ++ +The request returns the ID of a long-running operation. Poll the link:/api/doc/cloud-controlplane/operation/operation-operationservice_getoperation[`GET /v1/operations/{operation.id}`] endpoint until the operation completes: ++ +[,bash] +---- +curl -X GET "https://api.redpanda.com/v1/operations/{operation.id}" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" +---- ++ +When the operation is complete, the response shows `"state": "STATE_COMPLETED"`. +-- +===== + +== Scale Redpanda SQL + +Redpanda SQL supports horizontal scaling from one to nine nodes per cluster. You cannot scale to zero nodes. To remove Redpanda SQL from a cluster, disable the SQL engine instead. + +// TODO: Scaling unit is changing. The node-count input (1-9) shown in the +// current UI is expected to be replaced with RPUs + +[tabs] +===== +Cloud Console:: ++ +-- +. Log in to https://cloud.redpanda.com[Redpanda Cloud^] and open your cluster. +. From the left navigation, select *Dataplane settings*. +. On the *Cluster* tab, find the *RP SQL* row and click *Edit*. +. In the *Edit RP SQL* dialog, keep *Enable* selected, update *Number of RP SQL nodes* to a value between 1 and 9, and click *Save*. +-- + +Cloud API:: ++ +-- +Make a link:/api/doc/cloud-controlplane/operation/operation-clusterservice_updatecluster[`PATCH /v1/clusters/{cluster.id}`] request with the new replica count. Replace `{cluster.id}` with your cluster ID and `` with a value between 1 and 9: + +[,bash] +---- +curl -X PATCH "https://api.redpanda.com/v1/clusters/{cluster.id}" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"rpsql":{"replicas":}}' +---- + +The request returns the ID of a long-running operation. Poll link:/api/doc/cloud-controlplane/operation/operation-operationservice_getoperation[`GET /v1/operations/{operation.id}`] until the operation completes. +-- +===== + +== Verify the SQL engine is running + +After you enable Redpanda SQL, the cluster overview page in the Cloud Console shows the *SQL* tab and the *Details* pane displays the number of SQL nodes deployed with the cluster. + +// TODO: Confirm UI changes for SQL engine ready indicator +The *SQL* tab appears as soon as you enable SQL, but you can't connect until the engine is fully provisioned. Provisioning can take up to 30 minutes. + +Wait for the node-ready status indicator on the overview page to show the engine is ready. For the API flow, poll the long-running operation until it returns `STATE_COMPLETED`. + +To verify the SQL engine is running, use the connection details on the *SQL* tab to connect with a PostgreSQL client, such as `psql` (v16 or later required). + +To connect using a bearer token (xref:manage:rpk/rpk-install.adoc[`rpk` v26.1.6+] required): + +. Log in to Redpanda Cloud with `rpk cloud login`: ++ +[,bash] +---- +rpk cloud login +---- + +. Retrieve a temporary authentication token for the SQL engine: ++ +[,bash] +---- +rpsql_token=$(rpk cloud auth token) +---- + +. Connect with `psql` using the bearer token: ++ +[,bash] +---- +psql "host= port=5432 dbname=oxla user=ignored password=$rpsql_token options='-c auth_method=bearer' sslmode=require" +---- + +== Inspect your SQL cluster + +Redpanda SQL provides built-in commands to inspect the state of your SQL cluster: + +[,sql] +---- +SHOW NODES; -- List SQL compute nodes and their status +SHOW REDPANDA CATALOGS; -- List Redpanda catalogs +SHOW ICEBERG CATALOGS; -- List Iceberg catalogs +SHOW REDPANDA TABLES; -- List SQL tables mapped to Redpanda topics +SHOW QUERIES; -- List currently running queries +---- + +== Disable Redpanda SQL + +[WARNING] +==== +Disabling Redpanda SQL tears down the SQL compute engine and clears its catalog state (catalog metadata, table mappings, and role/grant data). In-flight queries fail when SQL is disabled. +==== + +Redpanda topic data, Schema Registry subjects, and any Iceberg-committed history for Iceberg-enabled topics are not affected. The Redpanda cluster itself continues to run normally; only the SQL engine and its associated state are removed. + +Re-enabling SQL on the same cluster provisions a fresh engine: no prior catalog state, table mappings, or grants are restored. You must re-create catalogs, tables, and grants after re-enabling. + +[tabs] +===== +Cloud Console:: ++ +-- +. Log in to https://cloud.redpanda.com[Redpanda Cloud^] and open your cluster. +. From the left navigation, select *Dataplane settings*. +. On the *Cluster* tab, find the *RP SQL* row and click *Edit*. +. In the *Edit RP SQL* dialog, select *Disable*, then click *Save*. +-- + +Cloud API:: ++ +-- +Make a link:/api/doc/cloud-controlplane/operation/operation-clusterservice_updatecluster[`PATCH /v1/clusters/{cluster.id}`] request with `rpsql.enabled` set to `false`. Replace `{cluster.id}` with your cluster ID: + +[,bash] +---- +curl -X PATCH "https://api.redpanda.com/v1/clusters/{cluster.id}" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"rpsql":{"enabled":false}}' +---- + +The request returns the ID of a long-running operation. Poll link:/api/doc/cloud-controlplane/operation/operation-operationservice_getoperation[`GET /v1/operations/{operation.id}`] until the operation completes. +-- +===== + +== Next steps + +* xref:sql:get-started/sql-quickstart.adoc[Quickstart]: Connect to Redpanda SQL with `psql` and run your first query. +// TODO: Uncomment once DOC-1999 merges (target page is on that branch). +// * xref:sql:connect-to-sql/authenticate.adoc[Authenticate to Redpanda SQL]: Connect with an OIDC bearer token, OIDC client credentials, or a SCRAM password for clients that don't support OIDC. +* xref:reference:sql/index.adoc[Redpanda SQL reference]: Explore the full SQL syntax, data types, functions, and clauses. diff --git a/modules/sql/pages/get-started/index.adoc b/modules/sql/pages/get-started/index.adoc new file mode 100644 index 000000000..1a7ab8979 --- /dev/null +++ b/modules/sql/pages/get-started/index.adoc @@ -0,0 +1,3 @@ += Get Started with Redpanda SQL +:description: Get started with Redpanda SQL, a column-oriented OLAP query engine built into Redpanda Cloud that lets you query streaming topics using standard SQL. +:page-layout: index diff --git a/modules/sql/pages/get-started/sql-quickstart.adoc b/modules/sql/pages/get-started/sql-quickstart.adoc new file mode 100644 index 000000000..37e898565 --- /dev/null +++ b/modules/sql/pages/get-started/sql-quickstart.adoc @@ -0,0 +1,199 @@ += Redpanda SQL Quickstart +:description: Connect to Redpanda SQL on a BYOC cluster and run your first query on streaming data. +:page-topic-type: tutorial +:personas: streaming_developer, data_engineer, platform_admin +:learning-objective-1: Connect to Redpanda SQL using psql and a bearer token +:learning-objective-2: Query a Redpanda topic with SQL + +Connect to Redpanda SQL on a Bring Your Own Cloud (BYOC) cluster and run your first query against streaming data, with no ETL pipelines required. For querying topics with Iceberg-translated history, see xref:sql:query-data/query-iceberg-topics.adoc[Query Iceberg topics]. + +After reading this page, you will be able to: + +* [ ] {learning-objective-1} +* [ ] {learning-objective-2} + +== Prerequisites + +* A Redpanda BYOC cluster on AWS with Redpanda SQL enabled. See xref:sql:get-started/deploy-sql-cluster.adoc[]. +* Admin access to your cluster in the Redpanda Cloud Console, or a role with the *SQL: Manage* permission. You need one of these to view SQL connection details and to create catalogs, tables, and grants in the SQL engine. For more information on authorization in Redpanda Cloud, see xref:security:authorization/rbac/index.adoc[]. +* A Redpanda topic with a schema registered in Schema Registry. If you don't have one, follow the optional <> section below to create a sample `orders` topic. +* xref:manage:rpk/rpk-install.adoc[`rpk` v26.1.6] or later installed on your local machine to generate an authentication token. +* https://www.postgresql.org/download/[`psql`^] v16 or later (PostgreSQL client) installed on your local machine. + +[#optional-produce-sample-data] +== Produce sample data + +[TIP] +==== +Skip this section if you already have a Redpanda topic with a schema registered in Schema Registry that you want to query. +==== + +If you don't have a topic with a corresponding schema in Schema Registry yet, follow these steps to create an `orders` topic with a small set of sample records. + +You also need permissions to create topics, register schemas, and produce records. + +. https://cloud.redpanda.com/[Log in to Redpanda Cloud^] and select your cluster. + +. On the *Topics* page, click *Create Topic*. Name the topic `orders` and create it with default settings. + +. On the *Schema Registry* page, click *Create new schema*. + +. Create a new schema with the following: ++ +* *Strategy*: Topic +* *Topic name*: orders +* *Schema applies to*: Value +* *Schema definition*: Select Protobuf and paste the following schema definition: ++ +[,proto] +---- +syntax = "proto3"; + +message Order { + int64 order_id = 1; + string customer = 2; + string product = 3; + int64 amount = 4; // amount in cents + string status = 5; // "pending", "shipped", "completed" +} +---- + +. Return to the *Topics* page and select the `orders` topic. Produce a few sample records: +// TODO: Verify exact steps to produce records in UI ++ +[,bash] +---- +{"order_id": 1, "customer": "alice", "product": "keyboard", "amount": 7500, "status": "completed"} +---- ++ +[,bash] +---- +{"order_id": 2, "customer": "bob", "product": "monitor", "amount": 32000, "status": "shipped"} +---- ++ +[,bash] +---- +{"order_id": 3, "customer": "carol", "product": "mouse", "amount": 4500, "status": "pending"} +---- ++ +[,bash] +---- +{"order_id": 4, "customer": "alice", "product": "monitor", "amount": 32000, "status": "completed"} +---- ++ +[,bash] +---- +{"order_id": 5, "customer": "dave", "product": "keyboard", "amount": 7500, "status": "pending"} +---- + +When you continue to the next section, use `orders` as the topic name when you define the SQL table. + +== Connect to Redpanda SQL + +SQL connection details are available on your cluster's *SQL* tab in the https://cloud.redpanda.com/[Cloud console]. To connect using `psql`: + +. Log in to Redpanda Cloud with `rpk`. This opens a browser window for SSO sign-in: ++ +[,bash] +---- +rpk cloud login +---- + +. Retrieve a temporary authentication token for the SQL engine: ++ +[,bash] +---- +rpsql_token=$(rpk cloud auth token) +---- + +. Copy and run the `psql` connection string from the *SQL* tab: ++ +[,bash] +---- +psql "host= port=5432 dbname=oxla user=ignored password=$rpsql_token options='-c auth_method=bearer' sslmode=require" +---- + +On a successful connection, you see output similar to: + +// TODO: Verify current psql banner text. +[.no-copy] +---- +psql (17.8 (Homebrew), server 16.0 (oxla version: 1.0.0, build: af2dffb-Release-x86_64-GNU, asio)) +SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, compression: off, ALPN: none) +Type "help" for help. + +=> +---- + +== Query topic data + +When you enable Redpanda SQL, a Redpanda catalog named `default_redpanda_catalog` is created automatically and points at your cluster. To query a Redpanda topic, define a SQL table against the topic, then run standard SQL queries against the table. + +. Define a SQL table from the topic with `CREATE TABLE`. The following example uses the `orders` topic from the optional sample data section. To use your own topic, replace `orders` with your topic name and `orders-value` with the Schema Registry subject that holds the topic's value schema. Your topic must have a schema registered in Schema Registry. ++ +[,sql] +---- +CREATE TABLE default_redpanda_catalog=>orders WITH ( + topic = 'orders', + schema_subject = 'orders-value', + confluent_wire_protocol = 'false' +); +---- ++ +Redpanda SQL reads the registered schema and maps each top-level field to a SQL column. ++ +Records produced through the Cloud Console don't carry the Schema Registry wire-format prefix, so the example sets `confluent_wire_protocol = 'false'`. If your producer client adds the wire format, set this option to `'true'` or omit it. For details on this and other CREATE TABLE options, see xref:reference:sql/sql-statements/create-table.adoc[CREATE TABLE]. + +. Run SQL queries against the table. These examples use the `orders` schema from the optional sample data section. ++ +View a sample of records: ++ +[,sql] +---- +SELECT * FROM default_redpanda_catalog=>orders LIMIT 10; +---- ++ +Count orders by status: ++ +[,sql] +---- +SELECT status, COUNT(*) AS total_orders +FROM default_redpanda_catalog=>orders +GROUP BY status; +---- ++ +Find the largest orders: ++ +[,sql] +---- +SELECT order_id, customer, product, amount +FROM default_redpanda_catalog=>orders +WHERE amount > 10000 +ORDER BY amount DESC +LIMIT 20; +---- + +== Grant access to a non-admin user + +To share SQL access with a teammate or service account: + +. In Redpanda Cloud, assign the user a role with the *SQL: Access* permission (see xref:security:authorization/rbac/rbac_dp.adoc[Configure RBAC in the Data Plane]). Redpanda Cloud provisions a corresponding user in the SQL engine. + +. As a *SQL: Manage* user, grant `SELECT` on the topics they need. The user identifier is the email on the user's Redpanda Cloud account: ++ +[,sql] +---- +GRANT SELECT ON EXTERNAL SOURCE default_redpanda_catalog => 'orders' TO "alice@example.com"; +---- + +For the full access model (privilege levels, wildcards, schema-level permissions, and grant inspection), see xref:sql:manage/manage-access.adoc[Manage access to Redpanda SQL]. + +The user can now connect to Redpanda SQL and run `SELECT` against the tables they've been granted. + +== Next steps + +// TODO: Uncomment once DOC-1990, DOC-1999, and DOC-2006 merge (target pages are on those branches). +// * xref:sql:query-data/query-streaming-topics.adoc[Query streaming topics]: Map a Redpanda topic to a SQL table and run analytical queries against live streaming data. +// * xref:sql:query-data/query-iceberg-topics.adoc[Query Iceberg topics]: Run a single SQL query that spans live records and the Iceberg-translated history of a topic. +// * xref:sql:connect-to-sql/authenticate.adoc[Authenticate to Redpanda SQL]: Connect with an OIDC bearer token, OIDC client credentials, or a SCRAM password for clients that don't support OIDC (for example, Power BI). +* xref:reference:sql/index.adoc[Redpanda SQL reference]: Explore the full SQL syntax, data types, functions, and clauses.