Skip to content

Commit a540e28

Browse files
authored
Merge pull request #181 from phil-schreiber/fix-parse-numeric-map-key
Add support for numeric map type keys
2 parents a9ac4f8 + 2e3c7ea commit a540e28

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

Diff for: clickhouse_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ var ddls = []string{
3838
fs FixedString(8),
3939
lc LowCardinality(String),
4040
m Map(String, Array(Int64)),
41-
mi64 Map(String, Int64)
41+
mi64 Map(String, Int64),
42+
miint32int32 Map(Int32, Int32)
4243
) ENGINE = Memory`,
4344
`INSERT INTO data VALUES
44-
(-1, 1, 1.0, true, '1', '1', [1], [10], '2011-03-06', '2011-03-06 06:20:00', 'one', '10.1111', '100.1111', '1000.1111', '1.1111', '127.0.0.1', '2001:db8:3333:4444:5555:6666:7777:8888', '12345678', 'one', {'key1':[1]}, {'key1':1}),
45-
(-2, 2, 2.0, false, '2', '2', [2], [20], '2012-05-31', '2012-05-31 11:20:00', 'two', '30.1111', '300.1111', '2000.1111', '2.1111', '8.8.8.8', '2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF', '88888888', 'two', {'key2':[2]}, {'key2':2}),
46-
(-3, 3, 3.0, true, '3', '2', [3], [30], '2016-04-04', '2016-04-04 11:30:00', 'three', '40.1111', '400.1111', '3000.1111', '3.1111', '255.255.255.255', '::1234:5678', '87654321', 'three', {'key3':[3]}, {'key3':3})
45+
(-1, 1, 1.0, true, '1', '1', [1], [10], '2011-03-06', '2011-03-06 06:20:00', 'one', '10.1111', '100.1111', '1000.1111', '1.1111', '127.0.0.1', '2001:db8:3333:4444:5555:6666:7777:8888', '12345678', 'one', {'key1':[1]}, {'key1':1}, {1:1}),
46+
(-2, 2, 2.0, false, '2', '2', [2], [20], '2012-05-31', '2012-05-31 11:20:00', 'two', '30.1111', '300.1111', '2000.1111', '2.1111', '8.8.8.8', '2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF', '88888888', 'two', {'key2':[2]}, {'key2':2}, {2:2}),
47+
(-3, 3, 3.0, true, '3', '2', [3], [30], '2016-04-04', '2016-04-04 11:30:00', 'three', '40.1111', '400.1111', '3000.1111', '3.1111', '255.255.255.255', '::1234:5678', '87654321', 'three', {'key3':[3]}, {'key3':3}, {3:3})
4748
`,
4849
}
4950

Diff for: conn_go18_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (s *connSuite) TestColumnTypes() {
6060
"Int64", "UInt64", "Float64", "Bool", "String", "String", "Array(Int16)", "Array(UInt8)", "Date", "DateTime",
6161
"Enum8('one' = 1, 'two' = 2, 'three' = 3)",
6262
"Decimal(9, 4)", "Decimal(18, 4)", "Decimal(38, 4)", "Decimal(10, 4)", "IPv4", "IPv6", "FixedString(8)", "LowCardinality(String)",
63-
"Map(String, Array(Int64))", "Map(String, Int64)",
63+
"Map(String, Array(Int64))", "Map(String, Int64)", "Map(Int32, Int32)",
6464
}
6565
s.Require().Equal(len(expected), len(types))
6666
for i, e := range expected {

Diff for: conn_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (s *connSuite) TestQuery() {
5050
"2001:db8:3333:4444:5555:6666:7777:8888", "12345678", "one",
5151
map[string][]int64{"key1": {1}},
5252
map[string]int64{"key1": 1},
53+
map[int32]int32{1: 1},
5354
},
5455
},
5556
},
@@ -181,8 +182,8 @@ func (s *connSuite) TestServerError() {
181182
srvErr, ok := err.(*Error)
182183
s.Require().True(ok, err.Error())
183184
s.Equal(60, srvErr.Code)
184-
s.Contains(srvErr.Message, "Table default")
185-
s.Contains(srvErr.Error(), "Code: 60, Message: Table default")
185+
s.Contains(srvErr.Message, "Unknown table expression identifier '???' in scope SELECT 1 FROM `???`")
186+
s.Contains(srvErr.Error(), "Code: 60, Message: Unknown table expression identifier '???' in scope SELECT 1 FROM `???`")
186187
}
187188

188189
func (s *connSuite) TestServerKillQuery() {

Diff for: dataparser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ loop:
3838
switch r {
3939
case eof:
4040
break loop
41-
case ',', ']', ')', '}':
41+
case ',', ']', ')', '}', ':':
4242
_ = s.UnreadRune()
4343
break loop
4444
}

0 commit comments

Comments
 (0)