diff --git a/clients/bigquery/storagewrite_test.go b/clients/bigquery/storagewrite_test.go index 1c4158423..967a6020b 100644 --- a/clients/bigquery/storagewrite_test.go +++ b/clients/bigquery/storagewrite_test.go @@ -37,6 +37,7 @@ func TestRowToMessage(t *testing.T) { columns.NewColumn("c_float64", typing.Float), columns.NewColumn("c_numeric", typing.EDecimal), columns.NewColumn("c_string", typing.String), + columns.NewColumn("c_string_decimal", typing.String), columns.NewColumn("c_time", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType)), columns.NewColumn("c_date", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType)), columns.NewColumn("c_datetime", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)), @@ -45,19 +46,20 @@ func TestRowToMessage(t *testing.T) { } row := map[string]any{ - "c_bool": true, - "c_int": int(1234), - "c_int32": int32(1234), - "c_int64": int64(1234), - "c_float32": float32(1234.567), - "c_float64": float64(1234.567), - "c_numeric": decimal.NewDecimal(nil, 5, big.NewFloat(3.1415926)), - "c_string": "foo bar", - "c_time": ext.NewExtendedTime(time.Date(0, 0, 0, 4, 5, 6, 7, time.UTC), ext.TimeKindType, ""), - "c_date": ext.NewExtendedTime(time.Date(2001, 2, 3, 0, 0, 0, 0, time.UTC), ext.DateKindType, ""), - "c_datetime": ext.NewExtendedTime(time.Date(2001, 2, 3, 4, 5, 6, 7, time.UTC), ext.DateTimeKindType, ""), - "c_struct": map[string]any{"baz": []string{"foo", "bar"}}, - "c_array": []string{"foo", "bar"}, + "c_bool": true, + "c_int": int(1234), + "c_int32": int32(1234), + "c_int64": int64(1234), + "c_float32": float32(1234.567), + "c_float64": float64(1234.567), + "c_numeric": decimal.NewDecimal(nil, 5, big.NewFloat(3.1415926)), + "c_string": "foo bar", + "c_string_decimal": decimal.NewDecimal(nil, 5, big.NewFloat(1.618033)), + "c_time": ext.NewExtendedTime(time.Date(0, 0, 0, 4, 5, 6, 7, time.UTC), ext.TimeKindType, ""), + "c_date": ext.NewExtendedTime(time.Date(2001, 2, 3, 0, 0, 0, 0, time.UTC), ext.DateKindType, ""), + "c_datetime": ext.NewExtendedTime(time.Date(2001, 2, 3, 4, 5, 6, 7, time.UTC), ext.DateTimeKindType, ""), + "c_struct": map[string]any{"baz": []string{"foo", "bar"}}, + "c_array": []string{"foo", "bar"}, } desc, err := columnsToMessageDescriptor(columns) @@ -73,18 +75,19 @@ func TestRowToMessage(t *testing.T) { assert.NoError(t, json.Unmarshal(bytes, &result)) assert.Equal(t, map[string]any{ - "cBool": true, - "cFloat32": 1234.5670166015625, - "cFloat64": 1234.567, - "cInt": "1234", - "cInt32": "1234", - "cInt64": "1234", - "cNumeric": "3.14159", - "cString": "foo bar", - "cTime": "17521704960", - "cDate": float64(11356), - "cDatetime": "981173106000000", - "cStruct": `{"baz":["foo","bar"]}`, - "cArray": []any{"foo", "bar"}, + "cBool": true, + "cFloat32": 1234.5670166015625, + "cFloat64": 1234.567, + "cInt": "1234", + "cInt32": "1234", + "cInt64": "1234", + "cNumeric": "3.14159", + "cString": "foo bar", + "cStringDecimal": "1.61803", + "cTime": "17521704960", + "cDate": float64(11356), + "cDatetime": "981173106000000", + "cStruct": `{"baz":["foo","bar"]}`, + "cArray": []any{"foo", "bar"}, }, result) }