-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(presto-client): add get catalog, schema, table & column utility methods #18
Changes from 5 commits
0433a79
d58d737
dfe5b16
8651de6
2ef5f6d
278ff85
b00a53d
09fc55a
51a6ae5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,68 @@ Additional notes | |
- The `query` method is asynchronous and will return a promise that resolves to a PrestoQuery object. | ||
- The `query` method will automatically retry the query if it fails due to a transient error. | ||
- The `query` method will cancel the query if the client is destroyed. | ||
|
||
## Query catalog, schema, table and column metadata | ||
|
||
### Get Catalogs | ||
|
||
The `getCatalogs` method retrieves all available database catalogs, returning them as an array of strings. | ||
|
||
#### Example usage | ||
|
||
```typescript | ||
const catalogs = await prestoClient.getCatalogs() | ||
console.log(catalogs) | ||
``` | ||
|
||
### Get Schemas | ||
|
||
The `getSchemas` method retrieves all schemas within a given catalog. It accepts a catalog parameter, which is a string representing the name of the catalog. | ||
|
||
Parameters | ||
|
||
- `catalog`: The name of the catalog for which to retrieve schemas. | ||
|
||
#### Example usage | ||
|
||
```typescript | ||
const schemas = await prestoClient.getSchemas('tpch') | ||
console.log(schemas) | ||
``` | ||
|
||
### Get Tables | ||
|
||
The `getTables` method retrieves a list of tables filtered by the given catalog and, optionally, the schema. It accepts an object containing `catalog` and optional `schema` parameters. | ||
|
||
Parameters | ||
|
||
- `catalog`: The catalog name. | ||
- `schema` (optional): The schema name. | ||
|
||
#### Example usage | ||
|
||
```typescript | ||
const tables = await prestoClient.getTables({ catalog: 'tpch', schema: 'sf100' }) | ||
console.log(tables) | ||
``` | ||
|
||
### Get Columns | ||
|
||
The `getColumns` method retrieves a list of columns filtered for the given catalog and optional schema and table filters. It accepts an object with `catalog`, and optional `schema` and `table` parameters. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good if you could mention the |
||
|
||
Parameters | ||
|
||
- `catalog`: The catalog name. | ||
- `schema` (optional): The schema name. | ||
- `table` (optional): The table name. | ||
|
||
#### Example usage | ||
|
||
```typescript | ||
const columns = await prestoClient.getColumns({ | ||
catalog: 'tpch', | ||
schema: 'sf100', | ||
table: 'orders', | ||
}) | ||
console.log(columns) | ||
``` |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved all private methods to the bottom, and left the public ones alphabetically sorted at the top |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export interface Table { | ||
alonsovb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tableCatalog: string | ||
tableSchema: string | ||
tableName: string | ||
tableType: string | ||
} | ||
|
||
export interface Column { | ||
tableCatalog: string | ||
tableSchema: string | ||
tableName: string | ||
columnName: string | ||
ordinalPosition: number | ||
columnDefault: unknown | ||
isNullable: boolean | ||
dataType: string | ||
comment: string | ||
extraInfo: unknown | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the
Table
data type here. Thanks!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done for both cases 👍