github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/internal/params/struct_test.go (about)

     1  package params
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/google/uuid"
     8  	"github.com/stretchr/testify/require"
     9  	"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
    10  
    11  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
    12  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
    13  )
    14  
    15  func TestStruct(t *testing.T) {
    16  	for _, tt := range []struct {
    17  		name    string
    18  		builder Builder
    19  		params  map[string]*Ydb.TypedValue
    20  	}{
    21  		{
    22  			name:    xtest.CurrentFileLine(),
    23  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Uint64(123).EndStruct(),
    24  			params: map[string]*Ydb.TypedValue{
    25  				"$x": {
    26  					Type: &Ydb.Type{
    27  						Type: &Ydb.Type_StructType{
    28  							StructType: &Ydb.StructType{
    29  								Members: []*Ydb.StructMember{
    30  									{
    31  										Name: "col1",
    32  										Type: &Ydb.Type{
    33  											Type: &Ydb.Type_TypeId{
    34  												TypeId: Ydb.Type_UINT64,
    35  											},
    36  										},
    37  									},
    38  								},
    39  							},
    40  						},
    41  					},
    42  					Value: &Ydb.Value{
    43  						Items: []*Ydb.Value{
    44  							{
    45  								Value: &Ydb.Value_Uint64Value{
    46  									Uint64Value: 123,
    47  								},
    48  							},
    49  						},
    50  					},
    51  				},
    52  			},
    53  		},
    54  		{
    55  			name:    xtest.CurrentFileLine(),
    56  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Int64(123).EndStruct(),
    57  			params: map[string]*Ydb.TypedValue{
    58  				"$x": {
    59  					Type: &Ydb.Type{
    60  						Type: &Ydb.Type_StructType{
    61  							StructType: &Ydb.StructType{
    62  								Members: []*Ydb.StructMember{
    63  									{
    64  										Name: "col1",
    65  										Type: &Ydb.Type{
    66  											Type: &Ydb.Type_TypeId{
    67  												TypeId: Ydb.Type_INT64,
    68  											},
    69  										},
    70  									},
    71  								},
    72  							},
    73  						},
    74  					},
    75  					Value: &Ydb.Value{
    76  						Items: []*Ydb.Value{
    77  							{
    78  								Value: &Ydb.Value_Int64Value{
    79  									Int64Value: 123,
    80  								},
    81  							},
    82  						},
    83  					},
    84  				},
    85  			},
    86  		},
    87  		{
    88  			name:    xtest.CurrentFileLine(),
    89  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Uint32(123).EndStruct(),
    90  			params: map[string]*Ydb.TypedValue{
    91  				"$x": {
    92  					Type: &Ydb.Type{
    93  						Type: &Ydb.Type_StructType{
    94  							StructType: &Ydb.StructType{
    95  								Members: []*Ydb.StructMember{
    96  									{
    97  										Name: "col1",
    98  										Type: &Ydb.Type{
    99  											Type: &Ydb.Type_TypeId{
   100  												TypeId: Ydb.Type_UINT32,
   101  											},
   102  										},
   103  									},
   104  								},
   105  							},
   106  						},
   107  					},
   108  					Value: &Ydb.Value{
   109  						Items: []*Ydb.Value{
   110  							{
   111  								Value: &Ydb.Value_Uint32Value{
   112  									Uint32Value: 123,
   113  								},
   114  							},
   115  						},
   116  					},
   117  				},
   118  			},
   119  		},
   120  		{
   121  			name:    xtest.CurrentFileLine(),
   122  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Int32(123).EndStruct(),
   123  			params: map[string]*Ydb.TypedValue{
   124  				"$x": {
   125  					Type: &Ydb.Type{
   126  						Type: &Ydb.Type_StructType{
   127  							StructType: &Ydb.StructType{
   128  								Members: []*Ydb.StructMember{
   129  									{
   130  										Name: "col1",
   131  										Type: &Ydb.Type{
   132  											Type: &Ydb.Type_TypeId{
   133  												TypeId: Ydb.Type_INT32,
   134  											},
   135  										},
   136  									},
   137  								},
   138  							},
   139  						},
   140  					},
   141  					Value: &Ydb.Value{
   142  						Items: []*Ydb.Value{
   143  							{
   144  								Value: &Ydb.Value_Int32Value{
   145  									Int32Value: 123,
   146  								},
   147  							},
   148  						},
   149  					},
   150  				},
   151  			},
   152  		},
   153  		{
   154  			name:    xtest.CurrentFileLine(),
   155  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Uint16(123).EndStruct(),
   156  			params: map[string]*Ydb.TypedValue{
   157  				"$x": {
   158  					Type: &Ydb.Type{
   159  						Type: &Ydb.Type_StructType{
   160  							StructType: &Ydb.StructType{
   161  								Members: []*Ydb.StructMember{
   162  									{
   163  										Name: "col1",
   164  										Type: &Ydb.Type{
   165  											Type: &Ydb.Type_TypeId{
   166  												TypeId: Ydb.Type_UINT16,
   167  											},
   168  										},
   169  									},
   170  								},
   171  							},
   172  						},
   173  					},
   174  					Value: &Ydb.Value{
   175  						Items: []*Ydb.Value{
   176  							{
   177  								Value: &Ydb.Value_Uint32Value{
   178  									Uint32Value: 123,
   179  								},
   180  							},
   181  						},
   182  					},
   183  				},
   184  			},
   185  		},
   186  		{
   187  			name:    xtest.CurrentFileLine(),
   188  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Int16(123).EndStruct(),
   189  			params: map[string]*Ydb.TypedValue{
   190  				"$x": {
   191  					Type: &Ydb.Type{
   192  						Type: &Ydb.Type_StructType{
   193  							StructType: &Ydb.StructType{
   194  								Members: []*Ydb.StructMember{
   195  									{
   196  										Name: "col1",
   197  										Type: &Ydb.Type{
   198  											Type: &Ydb.Type_TypeId{
   199  												TypeId: Ydb.Type_INT16,
   200  											},
   201  										},
   202  									},
   203  								},
   204  							},
   205  						},
   206  					},
   207  					Value: &Ydb.Value{
   208  						Items: []*Ydb.Value{
   209  							{
   210  								Value: &Ydb.Value_Int32Value{
   211  									Int32Value: 123,
   212  								},
   213  							},
   214  						},
   215  					},
   216  				},
   217  			},
   218  		},
   219  		{
   220  			name:    xtest.CurrentFileLine(),
   221  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Uint8(123).EndStruct(),
   222  			params: map[string]*Ydb.TypedValue{
   223  				"$x": {
   224  					Type: &Ydb.Type{
   225  						Type: &Ydb.Type_StructType{
   226  							StructType: &Ydb.StructType{
   227  								Members: []*Ydb.StructMember{
   228  									{
   229  										Name: "col1",
   230  										Type: &Ydb.Type{
   231  											Type: &Ydb.Type_TypeId{
   232  												TypeId: Ydb.Type_UINT8,
   233  											},
   234  										},
   235  									},
   236  								},
   237  							},
   238  						},
   239  					},
   240  					Value: &Ydb.Value{
   241  						Items: []*Ydb.Value{
   242  							{
   243  								Value: &Ydb.Value_Uint32Value{
   244  									Uint32Value: 123,
   245  								},
   246  							},
   247  						},
   248  					},
   249  				},
   250  			},
   251  		},
   252  		{
   253  			name:    xtest.CurrentFileLine(),
   254  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Int8(123).EndStruct(),
   255  			params: map[string]*Ydb.TypedValue{
   256  				"$x": {
   257  					Type: &Ydb.Type{
   258  						Type: &Ydb.Type_StructType{
   259  							StructType: &Ydb.StructType{
   260  								Members: []*Ydb.StructMember{
   261  									{
   262  										Name: "col1",
   263  										Type: &Ydb.Type{
   264  											Type: &Ydb.Type_TypeId{
   265  												TypeId: Ydb.Type_INT8,
   266  											},
   267  										},
   268  									},
   269  								},
   270  							},
   271  						},
   272  					},
   273  					Value: &Ydb.Value{
   274  						Items: []*Ydb.Value{
   275  							{
   276  								Value: &Ydb.Value_Int32Value{
   277  									Int32Value: 123,
   278  								},
   279  							},
   280  						},
   281  					},
   282  				},
   283  			},
   284  		},
   285  		{
   286  			name:    xtest.CurrentFileLine(),
   287  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Bool(true).EndStruct(),
   288  			params: map[string]*Ydb.TypedValue{
   289  				"$x": {
   290  					Type: &Ydb.Type{
   291  						Type: &Ydb.Type_StructType{
   292  							StructType: &Ydb.StructType{
   293  								Members: []*Ydb.StructMember{
   294  									{
   295  										Name: "col1",
   296  										Type: &Ydb.Type{
   297  											Type: &Ydb.Type_TypeId{
   298  												TypeId: Ydb.Type_BOOL,
   299  											},
   300  										},
   301  									},
   302  								},
   303  							},
   304  						},
   305  					},
   306  					Value: &Ydb.Value{
   307  						Items: []*Ydb.Value{
   308  							{
   309  								Value: &Ydb.Value_BoolValue{
   310  									BoolValue: true,
   311  								},
   312  							},
   313  						},
   314  					},
   315  				},
   316  			},
   317  		},
   318  		{
   319  			name:    xtest.CurrentFileLine(),
   320  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Text("test").EndStruct(),
   321  			params: map[string]*Ydb.TypedValue{
   322  				"$x": {
   323  					Type: &Ydb.Type{
   324  						Type: &Ydb.Type_StructType{
   325  							StructType: &Ydb.StructType{
   326  								Members: []*Ydb.StructMember{
   327  									{
   328  										Name: "col1",
   329  										Type: &Ydb.Type{
   330  											Type: &Ydb.Type_TypeId{
   331  												TypeId: Ydb.Type_UTF8,
   332  											},
   333  										},
   334  									},
   335  								},
   336  							},
   337  						},
   338  					},
   339  					Value: &Ydb.Value{
   340  						Items: []*Ydb.Value{
   341  							{
   342  								Value: &Ydb.Value_TextValue{
   343  									TextValue: "test",
   344  								},
   345  							},
   346  						},
   347  					},
   348  				},
   349  			},
   350  		},
   351  		{
   352  			name:    xtest.CurrentFileLine(),
   353  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Bytes([]byte("test")).EndStruct(),
   354  			params: map[string]*Ydb.TypedValue{
   355  				"$x": {
   356  					Type: &Ydb.Type{
   357  						Type: &Ydb.Type_StructType{
   358  							StructType: &Ydb.StructType{
   359  								Members: []*Ydb.StructMember{
   360  									{
   361  										Name: "col1",
   362  										Type: &Ydb.Type{
   363  											Type: &Ydb.Type_TypeId{
   364  												TypeId: Ydb.Type_STRING,
   365  											},
   366  										},
   367  									},
   368  								},
   369  							},
   370  						},
   371  					},
   372  					Value: &Ydb.Value{
   373  						Items: []*Ydb.Value{
   374  							{
   375  								Value: &Ydb.Value_BytesValue{
   376  									BytesValue: []byte("test"),
   377  								},
   378  							},
   379  						},
   380  					},
   381  				},
   382  			},
   383  		},
   384  		{
   385  			name:    xtest.CurrentFileLine(),
   386  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Float(123).EndStruct(),
   387  			params: map[string]*Ydb.TypedValue{
   388  				"$x": {
   389  					Type: &Ydb.Type{
   390  						Type: &Ydb.Type_StructType{
   391  							StructType: &Ydb.StructType{
   392  								Members: []*Ydb.StructMember{
   393  									{
   394  										Name: "col1",
   395  										Type: &Ydb.Type{
   396  											Type: &Ydb.Type_TypeId{
   397  												TypeId: Ydb.Type_FLOAT,
   398  											},
   399  										},
   400  									},
   401  								},
   402  							},
   403  						},
   404  					},
   405  					Value: &Ydb.Value{
   406  						Items: []*Ydb.Value{
   407  							{
   408  								Value: &Ydb.Value_FloatValue{
   409  									FloatValue: 123,
   410  								},
   411  							},
   412  						},
   413  					},
   414  				},
   415  			},
   416  		},
   417  		{
   418  			name:    xtest.CurrentFileLine(),
   419  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Double(123).EndStruct(),
   420  			params: map[string]*Ydb.TypedValue{
   421  				"$x": {
   422  					Type: &Ydb.Type{
   423  						Type: &Ydb.Type_StructType{
   424  							StructType: &Ydb.StructType{
   425  								Members: []*Ydb.StructMember{
   426  									{
   427  										Name: "col1",
   428  										Type: &Ydb.Type{
   429  											Type: &Ydb.Type_TypeId{
   430  												TypeId: Ydb.Type_DOUBLE,
   431  											},
   432  										},
   433  									},
   434  								},
   435  							},
   436  						},
   437  					},
   438  					Value: &Ydb.Value{
   439  						Items: []*Ydb.Value{
   440  							{
   441  								Value: &Ydb.Value_DoubleValue{
   442  									DoubleValue: 123,
   443  								},
   444  							},
   445  						},
   446  					},
   447  				},
   448  			},
   449  		},
   450  		{
   451  			name:    xtest.CurrentFileLine(),
   452  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Interval(time.Second).EndStruct(),
   453  			params: map[string]*Ydb.TypedValue{
   454  				"$x": {
   455  					Type: &Ydb.Type{
   456  						Type: &Ydb.Type_StructType{
   457  							StructType: &Ydb.StructType{
   458  								Members: []*Ydb.StructMember{
   459  									{
   460  										Name: "col1",
   461  										Type: &Ydb.Type{
   462  											Type: &Ydb.Type_TypeId{
   463  												TypeId: Ydb.Type_INTERVAL,
   464  											},
   465  										},
   466  									},
   467  								},
   468  							},
   469  						},
   470  					},
   471  					Value: &Ydb.Value{
   472  						Items: []*Ydb.Value{
   473  							{
   474  								Value: &Ydb.Value_Int64Value{
   475  									Int64Value: 1000000,
   476  								},
   477  							},
   478  						},
   479  					},
   480  				},
   481  			},
   482  		},
   483  		{
   484  			name:    xtest.CurrentFileLine(),
   485  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Datetime(time.Unix(123456789, 456)).EndStruct(),
   486  			params: map[string]*Ydb.TypedValue{
   487  				"$x": {
   488  					Type: &Ydb.Type{
   489  						Type: &Ydb.Type_StructType{
   490  							StructType: &Ydb.StructType{
   491  								Members: []*Ydb.StructMember{
   492  									{
   493  										Name: "col1",
   494  										Type: &Ydb.Type{
   495  											Type: &Ydb.Type_TypeId{
   496  												TypeId: Ydb.Type_DATETIME,
   497  											},
   498  										},
   499  									},
   500  								},
   501  							},
   502  						},
   503  					},
   504  					Value: &Ydb.Value{
   505  						Items: []*Ydb.Value{
   506  							{
   507  								Value: &Ydb.Value_Uint32Value{
   508  									Uint32Value: 123456789,
   509  								},
   510  							},
   511  						},
   512  					},
   513  				},
   514  			},
   515  		},
   516  		{
   517  			name:    xtest.CurrentFileLine(),
   518  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Date(time.Unix(123456789, 456)).EndStruct(),
   519  			params: map[string]*Ydb.TypedValue{
   520  				"$x": {
   521  					Type: &Ydb.Type{
   522  						Type: &Ydb.Type_StructType{
   523  							StructType: &Ydb.StructType{
   524  								Members: []*Ydb.StructMember{
   525  									{
   526  										Name: "col1",
   527  										Type: &Ydb.Type{
   528  											Type: &Ydb.Type_TypeId{
   529  												TypeId: Ydb.Type_DATE,
   530  											},
   531  										},
   532  									},
   533  								},
   534  							},
   535  						},
   536  					},
   537  					Value: &Ydb.Value{
   538  						Items: []*Ydb.Value{
   539  							{
   540  								Value: &Ydb.Value_Uint32Value{
   541  									Uint32Value: 1428,
   542  								},
   543  							},
   544  						},
   545  					},
   546  				},
   547  			},
   548  		},
   549  		{
   550  			name:    xtest.CurrentFileLine(),
   551  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Timestamp(time.Unix(123456789, 456)).EndStruct(),
   552  			params: map[string]*Ydb.TypedValue{
   553  				"$x": {
   554  					Type: &Ydb.Type{
   555  						Type: &Ydb.Type_StructType{
   556  							StructType: &Ydb.StructType{
   557  								Members: []*Ydb.StructMember{
   558  									{
   559  										Name: "col1",
   560  										Type: &Ydb.Type{
   561  											Type: &Ydb.Type_TypeId{
   562  												TypeId: Ydb.Type_TIMESTAMP,
   563  											},
   564  										},
   565  									},
   566  								},
   567  							},
   568  						},
   569  					},
   570  					Value: &Ydb.Value{
   571  						Items: []*Ydb.Value{
   572  							{
   573  								Value: &Ydb.Value_Uint64Value{
   574  									Uint64Value: 123456789000000,
   575  								},
   576  							},
   577  						},
   578  					},
   579  				},
   580  			},
   581  		},
   582  		{
   583  			name:    xtest.CurrentFileLine(),
   584  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").Decimal([...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6}, 22, 9).EndStruct(), //nolint:lll
   585  			params: map[string]*Ydb.TypedValue{
   586  				"$x": {
   587  					Type: &Ydb.Type{
   588  						Type: &Ydb.Type_StructType{
   589  							StructType: &Ydb.StructType{
   590  								Members: []*Ydb.StructMember{
   591  									{
   592  										Name: "col1",
   593  										Type: &Ydb.Type{
   594  											Type: &Ydb.Type_DecimalType{
   595  												DecimalType: &Ydb.DecimalType{
   596  													Precision: 22,
   597  													Scale:     9,
   598  												},
   599  											},
   600  										},
   601  									},
   602  								},
   603  							},
   604  						},
   605  					},
   606  					Value: &Ydb.Value{
   607  						Items: []*Ydb.Value{
   608  							{
   609  								High_128: 72623859790382856,
   610  								Value: &Ydb.Value_Low_128{
   611  									Low_128: 648519454493508870,
   612  								},
   613  							},
   614  						},
   615  					},
   616  				},
   617  			},
   618  		},
   619  		{
   620  			name:    xtest.CurrentFileLine(),
   621  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").JSON(`{"a": 1,"b": "B"}`).EndStruct(),
   622  			params: map[string]*Ydb.TypedValue{
   623  				"$x": {
   624  					Type: &Ydb.Type{
   625  						Type: &Ydb.Type_StructType{
   626  							StructType: &Ydb.StructType{
   627  								Members: []*Ydb.StructMember{
   628  									{
   629  										Name: "col1",
   630  										Type: &Ydb.Type{
   631  											Type: &Ydb.Type_TypeId{
   632  												TypeId: Ydb.Type_JSON,
   633  											},
   634  										},
   635  									},
   636  								},
   637  							},
   638  						},
   639  					},
   640  					Value: &Ydb.Value{
   641  						Items: []*Ydb.Value{
   642  							{
   643  								Value: &Ydb.Value_TextValue{
   644  									TextValue: `{"a": 1,"b": "B"}`,
   645  								},
   646  							},
   647  						},
   648  					},
   649  				},
   650  			},
   651  		},
   652  		{
   653  			name:    xtest.CurrentFileLine(),
   654  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").JSONDocument(`{"a": 1,"b": "B"}`).EndStruct(),
   655  			params: map[string]*Ydb.TypedValue{
   656  				"$x": {
   657  					Type: &Ydb.Type{
   658  						Type: &Ydb.Type_StructType{
   659  							StructType: &Ydb.StructType{
   660  								Members: []*Ydb.StructMember{
   661  									{
   662  										Name: "col1",
   663  										Type: &Ydb.Type{
   664  											Type: &Ydb.Type_TypeId{
   665  												TypeId: Ydb.Type_JSON_DOCUMENT,
   666  											},
   667  										},
   668  									},
   669  								},
   670  							},
   671  						},
   672  					},
   673  					Value: &Ydb.Value{
   674  						Items: []*Ydb.Value{
   675  							{
   676  								Value: &Ydb.Value_TextValue{
   677  									TextValue: `{"a": 1,"b": "B"}`,
   678  								},
   679  							},
   680  						},
   681  					},
   682  				},
   683  			},
   684  		},
   685  		{
   686  			name:    xtest.CurrentFileLine(),
   687  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").YSON([]byte(`[ 1; 2; 3; 4; 5 ]`)).EndStruct(),
   688  			params: map[string]*Ydb.TypedValue{
   689  				"$x": {
   690  					Type: &Ydb.Type{
   691  						Type: &Ydb.Type_StructType{
   692  							StructType: &Ydb.StructType{
   693  								Members: []*Ydb.StructMember{
   694  									{
   695  										Name: "col1",
   696  										Type: &Ydb.Type{
   697  											Type: &Ydb.Type_TypeId{
   698  												TypeId: Ydb.Type_YSON,
   699  											},
   700  										},
   701  									},
   702  								},
   703  							},
   704  						},
   705  					},
   706  					Value: &Ydb.Value{
   707  						Items: []*Ydb.Value{
   708  							{
   709  								Value: &Ydb.Value_BytesValue{
   710  									BytesValue: []byte(`[ 1; 2; 3; 4; 5 ]`),
   711  								},
   712  							},
   713  						},
   714  					},
   715  				},
   716  			},
   717  		},
   718  		{
   719  			name: xtest.CurrentFileLine(),
   720  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").
   721  				UUIDWithIssue1501Value([...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}).EndStruct(),
   722  			params: map[string]*Ydb.TypedValue{
   723  				"$x": {
   724  					Type: &Ydb.Type{
   725  						Type: &Ydb.Type_StructType{
   726  							StructType: &Ydb.StructType{
   727  								Members: []*Ydb.StructMember{
   728  									{
   729  										Name: "col1",
   730  										Type: &Ydb.Type{
   731  											Type: &Ydb.Type_TypeId{
   732  												TypeId: Ydb.Type_UUID,
   733  											},
   734  										},
   735  									},
   736  								},
   737  							},
   738  						},
   739  					},
   740  					Value: &Ydb.Value{
   741  						Items: []*Ydb.Value{
   742  							{
   743  								Value: &Ydb.Value_Low_128{
   744  									Low_128: 651345242494996240,
   745  								},
   746  								High_128: 72623859790382856,
   747  							},
   748  						},
   749  					},
   750  				},
   751  			},
   752  		},
   753  		{
   754  			name: xtest.CurrentFileLine(),
   755  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").
   756  				Uuid(uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}).EndStruct(),
   757  			params: map[string]*Ydb.TypedValue{
   758  				"$x": {
   759  					Type: &Ydb.Type{
   760  						Type: &Ydb.Type_StructType{
   761  							StructType: &Ydb.StructType{
   762  								Members: []*Ydb.StructMember{
   763  									{
   764  										Name: "col1",
   765  										Type: &Ydb.Type{
   766  											Type: &Ydb.Type_TypeId{
   767  												TypeId: Ydb.Type_UUID,
   768  											},
   769  										},
   770  									},
   771  								},
   772  							},
   773  						},
   774  					},
   775  					Value: &Ydb.Value{
   776  						Items: []*Ydb.Value{
   777  							{
   778  								Value: &Ydb.Value_Low_128{
   779  									Low_128: 506660481424032516,
   780  								},
   781  								High_128: 1157159078456920585,
   782  							},
   783  						},
   784  					},
   785  				},
   786  			},
   787  		},
   788  		{
   789  			name: xtest.CurrentFileLine(),
   790  			builder: Builder{}.Param("$x").BeginStruct().
   791  				Field("col1").Text("text").
   792  				Field("col2").Uint32(123).
   793  				Field("col3").Int64(456).
   794  				EndStruct(),
   795  			params: map[string]*Ydb.TypedValue{
   796  				"$x": {
   797  					Type: &Ydb.Type{
   798  						Type: &Ydb.Type_StructType{
   799  							StructType: &Ydb.StructType{
   800  								Members: []*Ydb.StructMember{
   801  									{
   802  										Name: "col1",
   803  										Type: &Ydb.Type{
   804  											Type: &Ydb.Type_TypeId{
   805  												TypeId: Ydb.Type_UTF8,
   806  											},
   807  										},
   808  									},
   809  									{
   810  										Name: "col2",
   811  										Type: &Ydb.Type{
   812  											Type: &Ydb.Type_TypeId{
   813  												TypeId: Ydb.Type_UINT32,
   814  											},
   815  										},
   816  									},
   817  									{
   818  										Name: "col3",
   819  										Type: &Ydb.Type{
   820  											Type: &Ydb.Type_TypeId{
   821  												TypeId: Ydb.Type_INT64,
   822  											},
   823  										},
   824  									},
   825  								},
   826  							},
   827  						},
   828  					},
   829  					Value: &Ydb.Value{
   830  						Items: []*Ydb.Value{
   831  							{
   832  								Value: &Ydb.Value_TextValue{
   833  									TextValue: "text",
   834  								},
   835  							},
   836  							{
   837  								Value: &Ydb.Value_Uint32Value{
   838  									Uint32Value: 123,
   839  								},
   840  							},
   841  							{
   842  								Value: &Ydb.Value_Int64Value{
   843  									Int64Value: 456,
   844  								},
   845  							},
   846  						},
   847  					},
   848  				},
   849  			},
   850  		},
   851  		{
   852  			name:    xtest.CurrentFileLine(),
   853  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").TzDatetime(time.Unix(123456789, 456).UTC()).EndStruct(),
   854  			params: map[string]*Ydb.TypedValue{
   855  				"$x": {
   856  					Type: &Ydb.Type{
   857  						Type: &Ydb.Type_StructType{
   858  							StructType: &Ydb.StructType{
   859  								Members: []*Ydb.StructMember{
   860  									{
   861  										Name: "col1",
   862  										Type: &Ydb.Type{
   863  											Type: &Ydb.Type_TypeId{
   864  												TypeId: Ydb.Type_TZ_DATETIME,
   865  											},
   866  										},
   867  									},
   868  								},
   869  							},
   870  						},
   871  					},
   872  					Value: &Ydb.Value{
   873  						Items: []*Ydb.Value{
   874  							{
   875  								Value: &Ydb.Value_TextValue{
   876  									TextValue: "1973-11-29T21:33:09Z",
   877  								},
   878  							},
   879  						},
   880  					},
   881  				},
   882  			},
   883  		},
   884  		{
   885  			name:    xtest.CurrentFileLine(),
   886  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").TzDate(time.Unix(123456789, 456).UTC()).EndStruct(),
   887  			params: map[string]*Ydb.TypedValue{
   888  				"$x": {
   889  					Type: &Ydb.Type{
   890  						Type: &Ydb.Type_StructType{
   891  							StructType: &Ydb.StructType{
   892  								Members: []*Ydb.StructMember{
   893  									{
   894  										Name: "col1",
   895  										Type: &Ydb.Type{
   896  											Type: &Ydb.Type_TypeId{
   897  												TypeId: Ydb.Type_TZ_DATE,
   898  											},
   899  										},
   900  									},
   901  								},
   902  							},
   903  						},
   904  					},
   905  					Value: &Ydb.Value{
   906  						Items: []*Ydb.Value{
   907  							{
   908  								Value: &Ydb.Value_TextValue{
   909  									TextValue: "1973-11-29",
   910  								},
   911  							},
   912  						},
   913  					},
   914  				},
   915  			},
   916  		},
   917  		{
   918  			name:    xtest.CurrentFileLine(),
   919  			builder: Builder{}.Param("$x").BeginStruct().Field("col1").TzTimestamp(time.Unix(123456789, 456).UTC()).EndStruct(),
   920  			params: map[string]*Ydb.TypedValue{
   921  				"$x": {
   922  					Type: &Ydb.Type{
   923  						Type: &Ydb.Type_StructType{
   924  							StructType: &Ydb.StructType{
   925  								Members: []*Ydb.StructMember{
   926  									{
   927  										Name: "col1",
   928  										Type: &Ydb.Type{
   929  											Type: &Ydb.Type_TypeId{
   930  												TypeId: Ydb.Type_TZ_TIMESTAMP,
   931  											},
   932  										},
   933  									},
   934  								},
   935  							},
   936  						},
   937  					},
   938  					Value: &Ydb.Value{
   939  						Items: []*Ydb.Value{
   940  							{
   941  								Value: &Ydb.Value_TextValue{
   942  									TextValue: "1973-11-29T21:33:09.000000Z",
   943  								},
   944  							},
   945  						},
   946  					},
   947  				},
   948  			},
   949  		},
   950  	} {
   951  		t.Run(tt.name, func(t *testing.T) {
   952  			a := allocator.New()
   953  			defer a.Free()
   954  			params := tt.builder.Build().ToYDB(a)
   955  			require.Equal(t, xtest.ToJSON(tt.params), xtest.ToJSON(params))
   956  		})
   957  	}
   958  }