@@ -120,6 +120,48 @@ type ScriptTestAssertion struct {
120120// Unlike other engine tests, ScriptTests must be self-contained. No other tables are created outside the definition of
121121// the tests.
122122var ScriptTests = []ScriptTest {
123+ {
124+ // https://github.com/dolthub/dolt/issues/9733
125+ Name : "String to number casting should handle partial numeric strings with warnings" ,
126+ SetUpScript : []string {
127+ "CREATE TABLE test01(pk VARCHAR(20) PRIMARY KEY)" ,
128+ "INSERT INTO test01 VALUES ('11d'), ('11wha?'), ('11'), ('12')" ,
129+ "CREATE TABLE test_cast(pk VARCHAR(50) PRIMARY KEY)" ,
130+ "INSERT INTO test_cast VALUES (' 3 12 4'), ('3. 12 4'), ('3.2 12 4'), ('-3.1234'), ('-3.1a'), ('-5+8'), ('+3.1234'), ('11-5'), ('1a1'), ('2,345'), ('4,12'), ('5.932887e+07'), ('5.932887e+07abc'), ('5.932887e7'), ('5.932887e7abc'), ('a1a1')" ,
131+ },
132+ Assertions : []ScriptTestAssertion {
133+ {
134+ Query : "SELECT cast(pk as signed) FROM test01" ,
135+ Expected : []sql.Row {{11 }, {11 }, {11 }, {12 }},
136+ ExpectedWarningsCount : 2 ,
137+ ExpectedWarning : 1292 ,
138+ },
139+ {
140+ Query : "SELECT cast(pk as unsigned) FROM test01" ,
141+ Expected : []sql.Row {{uint64 (11 )}, {uint64 (11 )}, {uint64 (11 )}, {uint64 (12 )}},
142+ ExpectedWarningsCount : 2 ,
143+ ExpectedWarning : 1292 ,
144+ },
145+ {
146+ Query : "SELECT cast(pk as signed) FROM test_cast ORDER BY pk" ,
147+ Expected : []sql.Row {{3 }, {- 3 }, {- 3 }, {- 5 }, {3 }, {11 }, {1 }, {2 }, {3 }, {3 }, {4 }, {5 }, {5 }, {5 }, {5 }, {0 }},
148+ ExpectedWarningsCount : 16 ,
149+ ExpectedWarning : 1292 ,
150+ },
151+ {
152+ Query : "SELECT cast(pk as unsigned) FROM test_cast ORDER BY pk" ,
153+ Expected : []sql.Row {{uint64 (3 )}, {uint64 (18446744073709551613 )}, {uint64 (18446744073709551613 )}, {uint64 (18446744073709551611 )}, {uint64 (3 )}, {uint64 (11 )}, {uint64 (1 )}, {uint64 (2 )}, {uint64 (3 )}, {uint64 (3 )}, {uint64 (4 )}, {uint64 (5 )}, {uint64 (5 )}, {uint64 (5 )}, {uint64 (5 )}, {uint64 (0 )}},
154+ ExpectedWarningsCount : 22 ,
155+ ExpectedWarning : 1292 ,
156+ },
157+ {
158+ Query : "SELECT cast(pk as double) FROM test_cast ORDER BY pk" ,
159+ Expected : []sql.Row {{3.0 }, {- 3.1234 }, {- 3.1 }, {- 5.0 }, {3.1234 }, {11.0 }, {1.0 }, {2.0 }, {3.0 }, {3.2 }, {4.0 }, {59328870.0 }, {59328870.0 }, {59328870.0 }, {59328870.0 }, {0.0 }},
160+ ExpectedWarningsCount : 9 ,
161+ ExpectedWarning : 1292 ,
162+ },
163+ },
164+ },
123165 {
124166 // https://github.com/dolthub/dolt/issues/9812
125167 Name : "String-to-number comparison operators should behave consistently" ,
0 commit comments