Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit ad5f1d4

Browse files
authored
Add test coverage in compilebulkinsert.go (#2353)
Assignment compatibility checking in analyzeBulkInsertStatement is now tested. This isn't checking the values themselves, it's there to make sure the structure is correct for mapping values to columns.
1 parent f490589 commit ad5f1d4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

sql3/test/defs/defs_bulkinsert.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,41 @@ var bulkInsert = TableTest{
4242
ExpRows: rows(),
4343
Compare: CompareExactOrdered,
4444
},
45+
{
46+
name: "bulk-insert-assignment-compatibility",
47+
SQLs: sqls(
48+
`BULK INSERT INTO
49+
bulktest (_id, id_col, string_col, int_col,decimal_col, bool_col, time_col, stringset_col, idset_col)
50+
map (0 ID, 1 STRING, 2 STRING, 3 DECIMAL(2), 4 BOOL, 5 TIMESTAMP, 6 STRINGSET, 7 IDSET)
51+
transform(@1, @0, @1, @2, @3, @4, @5, @6, @7)
52+
FROM x'1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset1, 1
53+
2,TEST2,321,31.2,1,2014-07-15T01:18:46Z,stringset1, 1
54+
1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset2, 2'
55+
with
56+
BATCHSIZE 10000
57+
format 'CSV'
58+
input 'STREAM';`,
59+
),
60+
ExpErr: "an expression of type 'string' cannot be assigned to type 'int'",
61+
Compare: CompareExactOrdered,
62+
},
63+
{
64+
name: "bulk-insert-assignment-compatibility-no-transform",
65+
SQLs: sqls(
66+
`BULK INSERT INTO
67+
bulktest (_id, id_col, string_col, int_col,decimal_col, bool_col, time_col, stringset_col, idset_col)
68+
map (0 ID, 1 ID, 2 STRING, 3 STRING, 4 DECIMAL(2), 5 BOOL, 6 TIMESTAMP, 7 STRINGSET, 8 IDSET)
69+
FROM x'1, 1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset1, 1
70+
2, 2,TEST2,321,31.2,1,2014-07-15T01:18:46Z,stringset1, 1
71+
3, 1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset2, 2'
72+
with
73+
BATCHSIZE 10000
74+
format 'CSV'
75+
input 'STREAM';`,
76+
),
77+
ExpErr: "an expression of type 'id' cannot be assigned to type 'string'",
78+
Compare: CompareExactOrdered,
79+
},
4580
{
4681
name: "leftjoin",
4782
SQLs: sqls(

0 commit comments

Comments
 (0)