LakeQL
Overview
  • Introduction
Configuration
  • Client Setup
Queries
  • Executing Queries
  • Streaming
Metadata
  • Inspecting Catalogs
  • API Reference
GitHub
LakeQL
  1. Trino Client
  2. Metadata
  3. Inspecting Catalogs

On this page

  1. Overview
  2. schemas
  3. tables
  4. views
  5. columns
    1. Typed objects with asObject
  6. Full Discovery Example

Inspecting Catalogs

List schemas, tables, views, and columns from any Trino catalog.

Overview #

The Trino client provides convenience methods for inspecting catalog metadata. Each method executes a SQL query internally and returns a simplified result — typically an array of strings or tuples.

See the API Reference for full method signatures and return types.

schemas #

Lists all schemas in a catalog.

1
2
3
4
5
6
7
8
9
10
11
12
import { TrinoClient } from "@lakeql/trino-client"

const client = new TrinoClient({
  host: "https://trino.example.com",
  port: 8443,
  auth: { type: "basic", username: "analyst", password: "secret" },
  catalog: "hive",
})

const schemas = await client.schemas({ catalog: "hive" })
// ["default", "sales", "analytics", "information_schema"]

tables #

Lists all base tables in a catalog and schema.

1
2
3
4
5
6
7
8
9
10
11
12
import { TrinoClient } from "@lakeql/trino-client"

const client = new TrinoClient({
  host: "https://trino.example.com",
  port: 8443,
  auth: { type: "basic", username: "analyst", password: "secret" },
  catalog: "hive",
})

const tables = await client.tables({ catalog: "hive", schema: "sales" })
// ["orders", "customers", "products", "invoices"]

views #

Lists all views in a catalog and schema.

1
2
3
4
5
6
7
8
9
10
11
12
import { TrinoClient } from "@lakeql/trino-client"

const client = new TrinoClient({
  host: "https://trino.example.com",
  port: 8443,
  auth: { type: "basic", username: "analyst", password: "secret" },
  catalog: "hive",
})

const views = await client.views({ catalog: "hive", schema: "sales" })
// ["monthly_revenue", "top_customers"]

columns #

Lists all columns for a specific table, including their types and metadata.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20import { TrinoClient } from "@lakeql/trino-client"

const client = new TrinoClient({
  host: "https://trino.example.com",
  port: 8443,
  auth: { type: "basic", username: "analyst", password: "secret" },
  catalog: "hive",
})

const columns = await client.columns({
  catalog: "hive",
  schema: "sales",
  table: "orders",
})
// [
//   ["id", "varchar", "", "Order identifier"],
//   ["amount", "double", "", "Total order amount"],
//   ["created_at", "timestamp(3)", "", "When the order was placed"],
// ]

Typed objects with asObject #

Pass asObject: true to get ColumnInfo[] objects instead of raw tuples:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24import { TrinoClient } from "@lakeql/trino-client"

const client = new TrinoClient({
  host: "https://trino.example.com",
  port: 8443,
  auth: { type: "basic", username: "analyst", password: "secret" },
  catalog: "hive",
})

const columns = await client.columns({
  catalog: "hive",
  schema: "sales",
  table: "orders",
  asObject: true,
})
// [
//   { name: "id", type: "varchar", extra: "", description: "Order identifier" },
//   { name: "amount", type: "double", extra: "", description: "Total order amount" },
// ]

for (const col of columns) {
  console.log(`${col.name}: ${col.type}`)
}

Full Discovery Example #

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28import { TrinoClient } from "@lakeql/trino-client"

const client = new TrinoClient({
  host: "https://trino.example.com",
  port: 8443,
  auth: { type: "bearer", token: "eyJhbGciOiJSUzI1NiIs..." },
  catalog: "iceberg",
})

// Discover all tables across all schemas
const schemas = await client.schemas({ catalog: "iceberg" })

for (const schema of schemas) {
  if (schema === "information_schema") {
    continue
  }

  const tables = await client.tables({ catalog: "iceberg", schema })
  console.log(`${schema}: ${tables.join(", ")}`)

  for (const table of tables) {
    const columns = await client.columns({ catalog: "iceberg", schema, table })
    console.log(
      `  ${table}: ${columns.map(([name, type]) => `${name} (${type})`).join(", ")}`
    )
  }
}

Previous page

Metadata

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28