Skip to content

Commit

Permalink
Merge pull request #181 from phil-schreiber/fix-parse-numeric-map-key
Browse files Browse the repository at this point in the history
Add support for numeric map type keys
  • Loading branch information
DoubleDi authored May 28, 2024
2 parents a9ac4f8 + 2e3c7ea commit a540e28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ var ddls = []string{
fs FixedString(8),
lc LowCardinality(String),
m Map(String, Array(Int64)),
mi64 Map(String, Int64)
mi64 Map(String, Int64),
miint32int32 Map(Int32, Int32)
) ENGINE = Memory`,
`INSERT INTO data VALUES
(-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}),
(-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}),
(-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})
(-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}),
(-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}),
(-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})
`,
}

Expand Down
2 changes: 1 addition & 1 deletion conn_go18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *connSuite) TestColumnTypes() {
"Int64", "UInt64", "Float64", "Bool", "String", "String", "Array(Int16)", "Array(UInt8)", "Date", "DateTime",
"Enum8('one' = 1, 'two' = 2, 'three' = 3)",
"Decimal(9, 4)", "Decimal(18, 4)", "Decimal(38, 4)", "Decimal(10, 4)", "IPv4", "IPv6", "FixedString(8)", "LowCardinality(String)",
"Map(String, Array(Int64))", "Map(String, Int64)",
"Map(String, Array(Int64))", "Map(String, Int64)", "Map(Int32, Int32)",
}
s.Require().Equal(len(expected), len(types))
for i, e := range expected {
Expand Down
5 changes: 3 additions & 2 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *connSuite) TestQuery() {
"2001:db8:3333:4444:5555:6666:7777:8888", "12345678", "one",
map[string][]int64{"key1": {1}},
map[string]int64{"key1": 1},
map[int32]int32{1: 1},
},
},
},
Expand Down Expand Up @@ -181,8 +182,8 @@ func (s *connSuite) TestServerError() {
srvErr, ok := err.(*Error)
s.Require().True(ok, err.Error())
s.Equal(60, srvErr.Code)
s.Contains(srvErr.Message, "Table default")
s.Contains(srvErr.Error(), "Code: 60, Message: Table default")
s.Contains(srvErr.Message, "Unknown table expression identifier '???' in scope SELECT 1 FROM `???`")
s.Contains(srvErr.Error(), "Code: 60, Message: Unknown table expression identifier '???' in scope SELECT 1 FROM `???`")
}

func (s *connSuite) TestServerKillQuery() {
Expand Down
2 changes: 1 addition & 1 deletion dataparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ loop:
switch r {
case eof:
break loop
case ',', ']', ')', '}':
case ',', ']', ')', '}', ':':
_ = s.UnreadRune()
break loop
}
Expand Down

0 comments on commit a540e28

Please sign in to comment.