mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-13 16:05:00 +00:00
snowflake resource picker to show both snowflake + snowflake_oauth (#5005)
This commit is contained in:
@@ -47,12 +47,19 @@
|
||||
async function loadResources(resourceType: string | undefined) {
|
||||
loading = true
|
||||
try {
|
||||
const nc = (
|
||||
await ResourceService.listResource({
|
||||
workspace: $workspaceStore!,
|
||||
resourceType
|
||||
})
|
||||
const resourceTypesToQuery =
|
||||
resourceType === 'snowflake' ? ['snowflake', 'snowflake_oauth'] : [resourceType]
|
||||
|
||||
const resources = await Promise.all(
|
||||
resourceTypesToQuery.map((rt) =>
|
||||
ResourceService.listResource({
|
||||
workspace: $workspaceStore!,
|
||||
resourceType: rt
|
||||
})
|
||||
)
|
||||
)
|
||||
const nc = resources
|
||||
.flat()
|
||||
.filter((x) => x.resource_type != 'state' && x.resource_type != 'cache')
|
||||
.map((x) => ({
|
||||
value: x.path,
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
lang: 'snowflake',
|
||||
argName: 'database'
|
||||
},
|
||||
snowflake_oauth: {
|
||||
code: `select 1`,
|
||||
lang: 'snowflake',
|
||||
argName: 'database'
|
||||
},
|
||||
ms_sql_server: {
|
||||
code: `SELECT 1`,
|
||||
lang: 'mssql',
|
||||
|
||||
@@ -137,7 +137,7 @@ ORDER BY
|
||||
ORDINAL_POSITION;
|
||||
|
||||
`
|
||||
} else if (resourceType === 'snowflake') {
|
||||
} else if (resourceType === 'snowflake' || resourceType === 'snowflake_oauth') {
|
||||
code = `
|
||||
select COLUMN_NAME as field,
|
||||
DATA_TYPE as DataType,
|
||||
@@ -380,6 +380,30 @@ return schema
|
||||
},
|
||||
argName: 'database'
|
||||
},
|
||||
snowflake_oauth: {
|
||||
code: `select TABLE_SCHEMA, TABLE_NAME, DATA_TYPE, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE from information_schema.columns where table_schema != 'INFORMATION_SCHEMA'`,
|
||||
lang: 'snowflake',
|
||||
processingFn: (rows) => {
|
||||
const schema = {}
|
||||
for (const row of rows) {
|
||||
if (!(row.TABLE_SCHEMA in schema)) {
|
||||
schema[row.TABLE_SCHEMA] = {}
|
||||
}
|
||||
if (!(row.TABLE_NAME in schema[row.TABLE_SCHEMA])) {
|
||||
schema[row.TABLE_SCHEMA][row.TABLE_NAME] = {}
|
||||
}
|
||||
schema[row.TABLE_SCHEMA][row.TABLE_NAME][row.COLUMN_NAME] = {
|
||||
type: row.DATA_TYPE,
|
||||
required: row.IS_NULLABLE === 'YES'
|
||||
}
|
||||
if (row.COLUMN_DEFAULT !== null) {
|
||||
schema[row.TABLE_SCHEMA][row.TABLE_NAME][row.COLUMN_NAME]['default'] = row.COLUMN_DEFAULT
|
||||
}
|
||||
}
|
||||
return schema
|
||||
},
|
||||
argName: 'database'
|
||||
},
|
||||
ms_sql_server: {
|
||||
argName: 'database',
|
||||
code: `select TABLE_SCHEMA, TABLE_NAME, DATA_TYPE, COLUMN_NAME, COLUMN_DEFAULT from information_schema.columns where table_schema != 'sys'`,
|
||||
@@ -560,6 +584,7 @@ export function getLanguageByResourceType(name: string): Preview['language'] {
|
||||
mysql: 'mysql',
|
||||
ms_sql_server: 'mssql',
|
||||
snowflake: 'snowflake',
|
||||
snowflake_oauth: 'snowflake',
|
||||
bigquery: 'bigquery'
|
||||
}
|
||||
return language[name]
|
||||
|
||||
@@ -3713,7 +3713,8 @@ See date-fns format for more information. By default, it is 'dd.MM.yyyy HH:mm'
|
||||
mysql: 'MySQL',
|
||||
ms_sql_server: 'MS SQL Server',
|
||||
snowflake: 'Snowflake',
|
||||
bigquery: 'BigQuery'
|
||||
bigquery: 'BigQuery',
|
||||
snowflake_oauth: 'Snowflake OAuth'
|
||||
},
|
||||
configuration: {
|
||||
postgresql: {
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@
|
||||
<IconSelectInput bind:value={componentInput.value} />
|
||||
{:else if fieldType === 'tab-select'}
|
||||
<TabSelectInput bind:componentInput />
|
||||
{:else if fieldType === 'resource' && subFieldType && ['mysql', 'postgres', 'ms_sql_server', 'snowflake', 'bigquery'].includes(subFieldType)}
|
||||
{:else if fieldType === 'resource' && subFieldType && ['mysql', 'postgres', 'ms_sql_server', 'snowflake', 'snowflake_oauth', 'bigquery'].includes(subFieldType)}
|
||||
<ResourcePicker
|
||||
initialValue={componentInput.value?.split('$res:')?.[1] || ''}
|
||||
on:change={(e) => {
|
||||
|
||||
@@ -38,6 +38,7 @@ export type InputType =
|
||||
| 'mysql'
|
||||
| 'ms_sql_server'
|
||||
| 'snowflake'
|
||||
| 'snowflake_oauth'
|
||||
| 'bigquery'
|
||||
| 'app-path'
|
||||
|
||||
@@ -224,6 +225,7 @@ export type AppInput =
|
||||
| AppInputSpec<'resource', string, 'mysql'>
|
||||
| AppInputSpec<'resource', string, 'ms_sql_server'>
|
||||
| AppInputSpec<'resource', string, 'snowflake'>
|
||||
| AppInputSpec<'resource', string, 'snowflake_oauth'>
|
||||
| AppInputSpec<'resource', string, 'bigquery'>
|
||||
| AppInputSpec<'array', object[], 'number-tuple'>
|
||||
| AppInputSpec<'app-path', string>
|
||||
|
||||
Reference in New Issue
Block a user