1 | |
2 | * Load a preview of a parquet file |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | path: string, |
8 | offset: string | undefined, |
9 | limit: string | undefined, |
10 | sort_col: string | undefined, |
11 | sort_desc: string | undefined, |
12 | search_col: string | undefined, |
13 | search_term: string | undefined |
14 | ) { |
15 | const url = new URL( |
16 | `${BASE_URL}/api/w/${workspace}/job_helpers/load_parquet_preview/${path}` |
17 | ); |
18 | for (const [k, v] of [ |
19 | ["offset", offset], |
20 | ["limit", limit], |
21 | ["sort_col", sort_col], |
22 | ["sort_desc", sort_desc], |
23 | ["search_col", search_col], |
24 | ["search_term", search_term], |
25 | ]) { |
26 | if (v !== undefined && v !== "") { |
27 | url.searchParams.append(k, v); |
28 | } |
29 | } |
30 | const response = await fetch(url, { |
31 | method: "GET", |
32 | headers: { |
33 | Authorization: "Bearer " + WM_TOKEN, |
34 | }, |
35 | body: undefined, |
36 | }); |
37 | if (!response.ok) { |
38 | const text = await response.text(); |
39 | throw new Error(`${response.status} ${text}`); |
40 | } |
41 | return await response.json(); |
42 | } |
43 |
|