import { BigQuery } from "@google-cloud/bigquery"
export type DynSelect_dataset_id = string
// Dropdown of the datasets in the service account's project.
export async function dataset_id(auth: RT.Bigquery) {
const [datasets] = await client(auth).getDatasets()
return datasets.map((d) => ({ value: d.id!, label: d.id! }))
}
function client(auth: RT.Bigquery) {
return new BigQuery({ credentials: auth, projectId: auth.project_id })
}
/**
* List Tables
* List the tables and views in a BigQuery dataset, with their type and creation time.
*/
export async function main(
auth: RT.Bigquery,
dataset_id: DynSelect_dataset_id
) {
const [tables] = await client(auth).dataset(dataset_id).getTables()
return tables.map((t) => t.metadata)
}
Submitted by hugo989 4 hours ago