mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-30 00:16:53 +00:00
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) <noreply@anthropic.com> * fix: scope insert-form type lowercasing to snowflake Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix: send snowflake insert-form dates as yyyy-MM-dd Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * 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) <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
co-authored by
Claude Opus 5.5
windmill-internal-app[bot]
Ruben Fiszel
parent
03e484e597
commit
f2fb15603b
@@ -1 +1 @@
|
||||
afd5f322346baee24d9402ca18a95de29d5c2fde
|
||||
acb254ac509aff244849c09e50a8d39aae185138
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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(""))
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
const defaultColumnType = (
|
||||
{
|
||||
postgresql: 'BIGSERIAL',
|
||||
snowflake: 'varchar',
|
||||
snowflake: 'VARCHAR',
|
||||
ms_sql_server: 'varchar',
|
||||
bigquery: 'string',
|
||||
mysql: 'varchar',
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user