Skip to content

Commit d5655f3

Browse files
authored
SNOW-1501890 Implement structured maps (#1171)
1 parent 20f611f commit d5655f3

8 files changed

+1216
-142
lines changed

bind_uploader.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ func getBindValues(bindings []driver.NamedValue, params map[string]*string) (map
256256
}
257257
if t == nullType || t == unSupportedType {
258258
t = textType // if null or not supported, pass to GS as text
259-
} else if t == nilObjectType {
259+
} else if t == nilObjectType || t == mapType || t == nilMapType {
260260
t = objectType
261-
} else if t == emptyArrayType || t == nilArrayType {
261+
} else if t == nilArrayType {
262262
t = arrayType
263263
}
264264
bindValues[bindingName(binding, idx)] = execBindParameter{
@@ -355,3 +355,8 @@ func supportedStructuredArrayBind(nv *driver.NamedValue) bool {
355355
typ := reflect.TypeOf(nv.Value)
356356
return typ != nil && (typ.Kind() == reflect.Array || typ.Kind() == reflect.Slice)
357357
}
358+
359+
func supportedStructuredMapBind(nv *driver.NamedValue) bool {
360+
typ := reflect.TypeOf(nv.Value)
361+
return typ != nil && (typ.Kind() == reflect.Map || typ == reflect.TypeOf(NilMapTypes{}))
362+
}

connection.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func (sc *snowflakeConn) Ping(ctx context.Context) error {
470470
// CheckNamedValue determines which types are handled by this driver aside from
471471
// the instances captured by driver.Value
472472
func (sc *snowflakeConn) CheckNamedValue(nv *driver.NamedValue) error {
473-
if supportedNullBind(nv) || supportedArrayBind(nv) || supportedStructuredObjectWriterBind(nv) || supportedStructuredArrayBind(nv) {
473+
if supportedNullBind(nv) || supportedArrayBind(nv) || supportedStructuredObjectWriterBind(nv) || supportedStructuredArrayBind(nv) || supportedStructuredMapBind(nv) {
474474
return nil
475475
}
476476
return driver.ErrSkip

0 commit comments

Comments
 (0)