flyrain commented on code in PR #4538:
URL: https://github.com/apache/polaris/pull/4538#discussion_r3306982947


##########
site/content/guides/cockroachdb/index.md:
##########
@@ -0,0 +1,116 @@
+---
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on 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.
+#
+linkTitle: "Backend: JDBC, CockroachDB"
+title: "Getting Started with Apache Polaris, Relational JDBC, CockroachDB and 
Spark SQL"
+weight: 110
+tags:
+   - backend
+   - jdbc
+   - cockroachdb
+cascade:
+    type: guides
+menus:
+    main:
+        parent: Guides
+        weight: 110
+---
+
+This example requires `jq` to be installed on your machine.
+
+1. If such an image is not already present, build the Polaris image with 
support for JDBC persistence and
+   the Postgres JDBC driver:
+
+    ```shell
+    ./gradlew \
+       :polaris-server:assemble \
+       :polaris-server:quarkusAppPartsBuild --rerun \
+       :polaris-admin:assemble \
+       :polaris-admin:quarkusAppPartsBuild --rerun \
+       -Dquarkus.container-image.build=true
+    ```
+
+2. Start the docker compose group by running the following command from the 
root of the repository:
+
+    ```shell
+    export POLARIS_PERSISTENCE_RELATIONAL_JDBC_DATABASE_TYPE=cockroachdb
+    export 
QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://cockroachdb:26257/polaris?sslmode=disable
+    export QUARKUS_DATASOURCE_USERNAME=root
+    export QUARKUS_DATASOURCE_PASSWORD=""
+    export ASSETS_PATH=$(pwd)/site/content/guides/assets/
+    export CLIENT_ID=root
+    export CLIENT_SECRET=s3cr3t
+    docker compose -f site/content/guides/jdbc/docker-compose-bootstrap-db.yml 
-f site/content/guides/assets/cockroachdb/docker-compose-cockroachdb.yml -f 
site/content/guides/cockroachdb/docker-compose.yml up
+    ```
+
+<!-- Guide testing: do not exercise the expensive Docker compose setup.
+```shell
+exit 0
+```
+-->
+
+3. Using spark-sql: attach to the running spark-sql container:
+
+    ```shell
+    docker attach $(docker ps -q --filter name=spark-sql)
+    ```
+
+   You may not see Spark's prompt immediately, type ENTER to see it. A few 
commands that you can try:
+
+    ```sql
+    CREATE NAMESPACE polaris.ns1;
+    USE polaris.ns1;
+    CREATE TABLE table1 (id int, name string);
+    INSERT INTO table1 VALUES (1, 'a');
+    SELECT * FROM table1;
+    ```
+
+4. To access Polaris from the host machine, first request an access token:
+
+    ```shell
+    export POLARIS_TOKEN=$(curl -s 
http://localhost:8181/api/catalog/v1/oauth/tokens \
+       --user root:s3cr3t \
+       -d 'grant_type=client_credentials' \
+       -d 'scope=PRINCIPAL_ROLE:ALL' | jq -r .access_token)
+    ```
+
+5. Then, use the access token in the Authorization header when accessing 
Polaris:
+
+    ```shell
+    curl -v http://localhost:8181/api/management/v1/principal-roles -H 
"Authorization: Bearer $POLARIS_TOKEN"
+    curl -v 
http://localhost:8181/api/management/v1/catalogs/quickstart_catalog -H 
"Authorization: Bearer $POLARIS_TOKEN"
+    ```
+
+6. Using Trino CLI: To access the Trino CLI, run this command:
+```shell
+docker exec -it cockroachdb-trino-1 trino

Review Comment:
   This container name is almost certainly wrong. Compose derives the project 
name from the directory of the *first* `-f` file; in step 2 the first `-f` is 
`site/content/guides/jdbc/docker-compose-bootstrap-db.yml`, so the project name 
is `jdbc` and the trino container will be `jdbc-trino-1` (matching the existing 
jdbc guide), not `cockroachdb-trino-1`. Either fix the name or switch the 
example to something resilient like `docker exec -it $(docker ps -q --filter 
name=trino) trino`.



##########
site/content/guides/cockroachdb/docker-compose.yml:
##########
@@ -0,0 +1,111 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on 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.
+#
+

Review Comment:
   Not a blocker: This file is ~110 lines and a near-verbatim copy of 
`site/content/guides/jdbc/docker-compose.yml` — only 
`POLARIS_PERSISTENCE_RELATIONAL_JDBC_DATABASE_TYPE` materially differs. That's 
guaranteed drift over time. Could you reuse the jdbc compose as the base layer 
and keep only a small overlay here (the multi-`-f` chain already supports 
that)? If you'd rather keep the duplicate, a comment at the top pointing at the 
jdbc file would help future edits stay in sync.



##########
site/content/guides/cockroachdb/docker-compose.yml:
##########
@@ -0,0 +1,111 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on 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.
+#
+
+services:
+
+  polaris:
+    image: apache/polaris:latest
+    ports:
+      # API port
+      - "8181:8181"
+      # Management port (metrics and health checks)
+      - "8182:8182"
+      # Optional, allows attaching a debugger to the Polaris JVM
+      - "5005:5005"
+    environment:
+      JAVA_DEBUG: true
+      JAVA_DEBUG_PORT: "*:5005"

Review Comment:
   nit: it's OK to enable debugging, while it may not be necessarily there for 
by default as a getting-started guide.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to