From ad5f1d4eaa0182c8c72c4f63f0d20a0c5c53823c Mon Sep 17 00:00:00 2001 From: Lory Cloutier <118481783+lorycloutier@users.noreply.github.com> Date: Mon, 27 Mar 2023 17:01:59 -0500 Subject: [PATCH] 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. --- sql3/test/defs/defs_bulkinsert.go | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sql3/test/defs/defs_bulkinsert.go b/sql3/test/defs/defs_bulkinsert.go index b07b300f8..57f0b4036 100644 --- a/sql3/test/defs/defs_bulkinsert.go +++ b/sql3/test/defs/defs_bulkinsert.go @@ -42,6 +42,41 @@ var bulkInsert = TableTest{ ExpRows: rows(), Compare: CompareExactOrdered, }, + { + name: "bulk-insert-assignment-compatibility", + SQLs: sqls( + `BULK INSERT INTO + bulktest (_id, id_col, string_col, int_col,decimal_col, bool_col, time_col, stringset_col, idset_col) + map (0 ID, 1 STRING, 2 STRING, 3 DECIMAL(2), 4 BOOL, 5 TIMESTAMP, 6 STRINGSET, 7 IDSET) + transform(@1, @0, @1, @2, @3, @4, @5, @6, @7) + FROM x'1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset1, 1 + 2,TEST2,321,31.2,1,2014-07-15T01:18:46Z,stringset1, 1 + 1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset2, 2' + with + BATCHSIZE 10000 + format 'CSV' + input 'STREAM';`, + ), + ExpErr: "an expression of type 'string' cannot be assigned to type 'int'", + Compare: CompareExactOrdered, + }, + { + name: "bulk-insert-assignment-compatibility-no-transform", + SQLs: sqls( + `BULK INSERT INTO + bulktest (_id, id_col, string_col, int_col,decimal_col, bool_col, time_col, stringset_col, idset_col) + map (0 ID, 1 ID, 2 STRING, 3 STRING, 4 DECIMAL(2), 5 BOOL, 6 TIMESTAMP, 7 STRINGSET, 8 IDSET) + FROM x'1, 1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset1, 1 + 2, 2,TEST2,321,31.2,1,2014-07-15T01:18:46Z,stringset1, 1 + 3, 1,TEST,-123,1.12,0,2013-07-15T01:18:46Z,stringset2, 2' + with + BATCHSIZE 10000 + format 'CSV' + input 'STREAM';`, + ), + ExpErr: "an expression of type 'id' cannot be assigned to type 'string'", + Compare: CompareExactOrdered, + }, { name: "leftjoin", SQLs: sqls(