Skip to content

Commit

Permalink
[apache#3234] improve (doc): Update playground docs for using simple …
Browse files Browse the repository at this point in the history
…catalog (apache#3235)

### What changes were proposed in this pull request?

Update playground docs for using simple catalog

### Why are the changes needed?

Fix: apache#3234 

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

NO
  • Loading branch information
diqiu50 committed Jun 13, 2024
1 parent 343c360 commit 8b25b11
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions docs/how-to-use-the-playground.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ You can use simple queries to test in the Trino CLI.
```SQL
SHOW CATALOGS;
CREATE SCHEMA "metalake_demo.catalog_hive".company
CREATE SCHEMA catalog_hive.company
WITH (location = 'hdfs://hive:9000/user/hive/warehouse/company.db');
SHOW CREATE SCHEMA "metalake_demo.catalog_hive".company;
SHOW CREATE SCHEMA catalog_hive.company;
CREATE TABLE "metalake_demo.catalog_hive".company.employees
CREATE TABLE catalog_hive.company.employees
(
name varchar,
salary decimal(10,2)
Expand All @@ -73,15 +73,15 @@ WITH (
format = 'TEXTFILE'
);
INSERT INTO "metalake_demo.catalog_hive".company.employees (name, salary) VALUES ('Sam Evans', 55000);
INSERT INTO catalog_hive.company.employees (name, salary) VALUES ('Sam Evans', 55000);
SELECT * FROM "metalake_demo.catalog_hive".company.employees;
SELECT * FROM catalog_hive.company.employees;
SHOW SCHEMAS from "metalake_demo.catalog_hive";
SHOW SCHEMAS from catalog_hive;
DESCRIBE "metalake_demo.catalog_hive".company.employees;
DESCRIBE catalog_hive.company.employees;
SHOW TABLES from "metalake_demo.catalog_hive".company;
SHOW TABLES from catalog_hive.company;
```

### Cross-catalog queries
Expand All @@ -92,8 +92,8 @@ To know which employee has the largest sales amount, run this SQL:
```SQL
SELECT given_name, family_name, job_title, sum(total_amount) AS total_sales
FROM "metalake_demo.catalog_hive".sales.sales as s,
"metalake_demo.catalog_postgres".hr.employees AS e
FROM catalog_hive.sales.sales as s,
catalog_postgres.hr.employees AS e
where s.employee_id = e.employee_id
GROUP BY given_name, family_name, job_title
ORDER BY total_sales DESC
Expand All @@ -104,9 +104,9 @@ To know the top customers who bought the most by state, run this SQL:
```SQL
SELECT customer_name, location, SUM(total_amount) AS total_spent
FROM "metalake_demo.catalog_hive".sales.sales AS s,
"metalake_demo.catalog_hive".sales.stores AS l,
"metalake_demo.catalog_hive".sales.customers AS c
FROM catalog_hive.sales.sales AS s,
catalog_hive.sales.stores AS l,
catalog_hive.sales.customers AS c
WHERE s.store_id = l.store_id AND s.customer_id = c.customer_id
GROUP BY location, customer_name
ORDER BY location, SUM(total_amount) DESC;
Expand All @@ -116,9 +116,9 @@ To know the employee's average performance rating and total sales, run this SQL:

```SQL
SELECT e.employee_id, given_name, family_name, AVG(rating) AS average_rating, SUM(total_amount) AS total_sales
FROM "metalake_demo.catalog_postgres".hr.employees AS e,
"metalake_demo.catalog_postgres".hr.employee_performance AS p,
"metalake_demo.catalog_hive".sales.sales AS s
FROM catalog_postgres.hr.employees AS e,
catalog_postgres.hr.employee_performance AS p,
catalog_hive.sales.sales AS s
WHERE e.employee_id = p.employee_id AND p.employee_id = s.employee_id
GROUP BY e.employee_id, given_name, family_name;
```
Expand Down Expand Up @@ -171,7 +171,7 @@ trino@d2bbfccc7432:/$ trino
```
```SQL
select * from "metalake_demo.catalog_hive".sales.customers
select * from catalog_hive.sales.customers
union
select * from "metalake_demo.catalog_iceberg".sales.customers;
select * from catalog_iceberg.sales.customers;
```

0 comments on commit 8b25b11

Please sign in to comment.