From f2fb15603b2e0d11bd5d04dd675212a5e4a7b9d7 Mon Sep 17 00:00:00 2001 From: Diego Imbert <70353967+diegoimbert@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:35:36 +0200 Subject: [PATCH] fix: type snowflake columns in database manager insert and alter forms (#11578) * fix: type snowflake columns in database manager insert and alter forms Co-Authored-By: Claude Opus 5.5 (1M context) * fix: scope insert-form type lowercasing to snowflake Co-Authored-By: Claude Opus 5.5 (1M context) * fix: send snowflake insert-form dates as yyyy-MM-dd Co-Authored-By: Claude Opus 5.5 (1M context) * chore: update ee-repo-ref to acb254ac509aff244849c09e50a8d39aae185138 This commit updates the EE repository reference after PR #852 was merged in windmill-ee-private. Previous ee-repo-ref: 9cc330f1a8e80bc075a6ad9839966d3b344f8ddd New ee-repo-ref: acb254ac509aff244849c09e50a8d39aae185138 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 (1M context) Co-authored-by: windmill-internal-app[bot] Co-authored-by: Ruben Fiszel --- backend/ee-repo-ref.txt | 2 +- .../parsers/windmill-parser-sql/src/lib.rs | 12 ++-- .../windmill-worker/src/snowflake_executor.rs | 2 +- .../src/lib/components/DBTableEditor.svelte | 2 +- .../display/dbtable/InsertRow.svelte | 57 ++++++++++++++++++- frontend/src/lib/consts.ts | 21 ++++--- 6 files changed, 77 insertions(+), 19 deletions(-) diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 274389ff2d..5f22bddd84 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -afd5f322346baee24d9402ca18a95de29d5c2fde +acb254ac509aff244849c09e50a8d39aae185138 diff --git a/backend/parsers/windmill-parser-sql/src/lib.rs b/backend/parsers/windmill-parser-sql/src/lib.rs index 38f4b7a33e..10929e409a 100644 --- a/backend/parsers/windmill-parser-sql/src/lib.rs +++ b/backend/parsers/windmill-parser-sql/src/lib.rs @@ -1040,11 +1040,13 @@ pub fn parse_duckdb_typ(typ: &str) -> Typ { pub fn parse_snowflake_typ(typ: &str) -> Typ { match typ { - "varchar" => Typ::Str(None), - "binary" => Typ::Bytes, - "date" | "time" | "timestamp" => Typ::Datetime, - "int" => Typ::Int, - "float" => Typ::Float, + "varchar" | "text" | "string" | "char" | "character" => Typ::Str(None), + "binary" | "varbinary" => Typ::Bytes, + "date" | "time" | "datetime" | "timestamp" | "timestamp_ntz" | "timestamp_ltz" + | "timestamp_tz" => Typ::Datetime, + "int" | "integer" | "bigint" | "smallint" | "tinyint" | "byteint" => Typ::Int, + "float" | "float4" | "float8" | "double" | "double precision" | "real" | "number" + | "decimal" | "numeric" => Typ::Float, "boolean" => Typ::Bool, "s3object" => Typ::Resource("S3Object".to_string()), _ => Typ::Str(None), diff --git a/backend/windmill-worker/src/snowflake_executor.rs b/backend/windmill-worker/src/snowflake_executor.rs index b4bb448b99..24b07eacb9 100644 --- a/backend/windmill-worker/src/snowflake_executor.rs +++ b/backend/windmill-worker/src/snowflake_executor.rs @@ -855,7 +855,7 @@ fn convert_typ_val(arg_t: String, arg_v: Value) -> Value { } }) } - "binary" => { + "binary" | "varbinary" => { // convert base64 to hex as expected by snowflake let bytes = engine::general_purpose::STANDARD .decode(arg_v.as_str().unwrap_or("")) diff --git a/frontend/src/lib/components/DBTableEditor.svelte b/frontend/src/lib/components/DBTableEditor.svelte index 4eb07aea5f..21cca65f63 100644 --- a/frontend/src/lib/components/DBTableEditor.svelte +++ b/frontend/src/lib/components/DBTableEditor.svelte @@ -105,7 +105,7 @@ const defaultColumnType = ( { postgresql: 'BIGSERIAL', - snowflake: 'varchar', + snowflake: 'VARCHAR', ms_sql_server: 'varchar', bigquery: 'string', mysql: 'varchar', diff --git a/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte b/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte index 0483bbd272..767240a60f 100644 --- a/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte +++ b/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte @@ -30,6 +30,42 @@ nullable: 'YES' | 'NO' } + // Snowflake's information_schema reports canonical names (NUMBER, TEXT, + // TIMESTAMP_NTZ, ...), which the pinned parser wasm only knows by a few aliases. + function snowflakeParserAlias(typ: string): string { + switch (typ) { + case 'number': + case 'decimal': + case 'numeric': + case 'float4': + case 'float8': + case 'double': + case 'double precision': + case 'real': + return 'float' + case 'integer': + case 'bigint': + case 'smallint': + case 'tinyint': + case 'byteint': + return 'int' + case 'text': + case 'string': + case 'char': + case 'character': + return 'varchar' + case 'varbinary': + return 'binary' + case 'datetime': + case 'timestamp_ntz': + case 'timestamp_ltz': + case 'timestamp_tz': + return 'timestamp' + default: + return typ + } + } + function parseSQLArgs(field: string, dbType: DbType): string { let rawType = '' switch (dbType) { @@ -43,7 +79,7 @@ rawType = parse_bigquery(field) break case 'snowflake': - rawType = parse_snowflake(field) + rawType = parse_snowflake(snowflakeParserAlias(field.toLowerCase())) break case 'ms_sql_server': rawType = parse_mssql(field) @@ -97,12 +133,27 @@ schemaProperty.default = field.defaultValue } } - if (field.type === 'timestamp without time zone' || field.type === 'timestamp') { + const fieldType = dbType === 'snowflake' ? field.type.toLowerCase() : field.type + if ( + fieldType === 'timestamp without time zone' || + fieldType === 'timestamp' || + fieldType === 'timestamp_ntz' + ) { schemaProperty.format = 'naive-date-time' } - if (field.type === 'timestamp with time zone' || field.type === 'timestamptz') { + if ( + fieldType === 'timestamp with time zone' || + fieldType === 'timestamptz' || + fieldType === 'timestamp_tz' || + fieldType === 'timestamp_ltz' + ) { schemaProperty.format = 'date-time' } + if (dbType === 'snowflake' && fieldType === 'date') { + schemaProperty.format = 'date' + // DateInput defaults to dd-MM-yyyy, which Snowflake's AUTO input format rejects + schemaProperty.dateFormat = 'yyyy-MM-dd' + } properties[field.name] = schemaProperty diff --git a/frontend/src/lib/consts.ts b/frontend/src/lib/consts.ts index c6e18427f0..bfa1d845b2 100644 --- a/frontend/src/lib/consts.ts +++ b/frontend/src/lib/consts.ts @@ -179,14 +179,19 @@ export const BIGQUERY_TYPES = [ ] export const SNOWFLAKE_TYPES = [ - 'varchar', - 'binary', - 'date', - 'time', - 'timestamp', - 'int', - 'float', - 'boolean' + 'VARCHAR', + 'TEXT', + 'BINARY', + 'DATE', + 'TIME', + 'TIMESTAMP', + 'TIMESTAMP_NTZ', + 'TIMESTAMP_LTZ', + 'TIMESTAMP_TZ', + 'INT', + 'NUMBER', + 'FLOAT', + 'BOOLEAN' ] export const MSSQL_TYPES = [