( params: ClusterSearchParameters | ObjectSearchParameters, )
| 21 | |
| 22 | // This function is used to get the id of an object or cluster by its name. |
| 23 | export async function getIdByName( |
| 24 | params: ClusterSearchParameters | ObjectSearchParameters, |
| 25 | ) { |
| 26 | const client = await getMaterializeClient(); |
| 27 | |
| 28 | if ("schemaName" in params) { |
| 29 | const { |
| 30 | rows: [object], |
| 31 | } = await client.query( |
| 32 | ` |
| 33 | select id |
| 34 | from mz_internal.mz_object_fully_qualified_names |
| 35 | where name = '${params.name}' AND |
| 36 | schema_name = '${params.schemaName}' AND |
| 37 | database_name = '${params.databaseName}'`, |
| 38 | ); |
| 39 | |
| 40 | return object.id as string; |
| 41 | } |
| 42 | const { |
| 43 | rows: [cluster], |
| 44 | } = await client.query( |
| 45 | `select id from mz_clusters where name = '${params.name}'`, |
| 46 | ); |
| 47 | return cluster.id as string; |
| 48 | } |
no test coverage detected