| 1 | import type * as glue from "@distilled.cloud/aws/glue"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Table } from "./Table.ts"; |
| 5 | |
| 6 | export interface GetTableRequest extends Omit< |
| 7 | glue.GetTableRequest, |
| 8 | "DatabaseName" | "Name" | "CatalogId" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `glue:GetTable`. |
| 13 | * |
| 14 | * Reads the bound {@link Table}'s full catalog definition — columns, storage |
| 15 | * descriptor, partition keys, and parameters — so a function can introspect |
| 16 | * the schema it is writing against. The database/table names and catalog id |
| 17 | * are injected from the binding. Provide the implementation with |
| 18 | * `Effect.provide(AWS.Glue.GetTableHttp)`. |
| 19 | * ### Reading the Data Catalog |
| 20 | * **Example:** Introspect the Table Schema |
| 21 | * ```typescript |
| 22 | * // init |
| 23 | * const getTable = yield* AWS.Glue.GetTable(table); |
| 24 | * |
| 25 | * // runtime |
| 26 | * const { Table } = yield* getTable(); |
| 27 | * const columns = Table?.StorageDescriptor?.Columns ?? []; |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface GetTable extends Binding.Service< |
| 33 | GetTable, |
| 34 | "AWS.Glue.GetTable", |
| 35 | ( |
| 36 | table: Table, |
| 37 | ) => Effect.Effect< |
| 38 | ( |
| 39 | request?: GetTableRequest, |
| 40 | ) => Effect.Effect<glue.GetTableResponse, glue.GetTableError> |
| 41 | > |
| 42 | > {} |
| 43 | |
| 44 | export const GetTable = Binding.Service<GetTable>("AWS.Glue.GetTable"); |