Querying data using Trino
Learn how to query data in Apache Kudu using Trino with or without schema emulation.
Apache Kudu does not support namespaces or schemas for tables. The Cloudera Trino Kudu connector manages schemas in Apache Kudu clusters by providing optional schema emulation through table naming conventions.
Default behavior without schema emulation
Schema emulation is disabled by default. In this mode, all Apache Kudu tables reside in the default schema:
- Query an Apache Kudu table named orders in Trino by running SELECT * FROM example.default.orders or SELECT * FROM orders when catalog and schema are set to kudu and default.
- Enclose table names in double quotes when they contain special characters, for example, SELECT * FROM example.default."special.table!".
The following example shows how to create a table, inspect the table structure, insert data, and query the results in the default schema:
Create the users table:
CREATE TABLE example.default.users (
user_id int WITH (primary_key = true),
first_name VARCHAR,
last_name VARCHAR
) WITH (
partition_by_hash_columns = ARRAY['user_id'],
partition_by_hash_buckets = 2
);
Describe the table structure:
DESCRIBE example.default.users;
The command returns the following column metadata:
| Column | Type | Extra |
|---|---|---|
| user_id | integer | primary_key, encoding=auto, compression=default |
| first_name | varchar | nullable, encoding=auto, compression=default |
| last_name | varchar | nullable, encoding=auto, compression=default |
Insert data into the table:
INSERT INTO example.default.users VALUES (1, 'Donald', 'Duck'), (2, 'Mickey', 'Mouse');
Query the inserted data:
SELECT * FROM example.default.users;
Behavior with schema emulation
When schema emulation is enabled in the catalog configuration file (for example, etc/catalog/example.properties), the connector maps Apache Kudu table names to Trino schemas.
When kudu.schema-emulation.enabled=true and kudu.schema-emulation.prefix=, the connector uses the following mappings and creates a special table named $schemas to manage schemas:
| Kudu table name | Trino qualified name |
|---|---|
| orders | kudu.default.orders |
| part1.part2 | kudu.part1.part2 |
| x.y.z | kudu.x."y.z" |
When kudu.schema-emulation.enabled=true and kudu.schema-emulation.prefix=presto::, the connector uses the following mappings and creates a special table named presto::$schemas to manage schemas:
| Kudu table name | Trino qualified name |
|---|---|
| orders | kudu.default.orders |
| part1.part2 | kudu.default."part1.part2" |
| x.y.z | kudu.default."x.y.z" |
| presto::part1.part2 | kudu.part1.part2 |
| presto:x.y.z | kudu.x."y.z" |
