Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to map to tuple? #406

Closed
yuxiaooo opened this issue Aug 23, 2021 · 1 comment
Closed

how to map to tuple? #406

yuxiaooo opened this issue Aug 23, 2021 · 1 comment
Assignees

Comments

@yuxiaooo
Copy link

yuxiaooo commented Aug 23, 2021

CREATE TABLE sum_map(
    date Date,
    timeslot DateTime,
    statusMap Nested(
        status UInt16,
        requests UInt64
    ),
    statusMapTuple Tuple(Array(Int32), Array(Int32))
) ENGINE = Log;
INSERT INTO sum_map VALUES
    ('2000-01-01', '2000-01-01 00:00:00', [1, 2, 3], [10, 10, 10], ([1, 2, 3], [10, 10, 10])),
    ('2000-01-01', '2000-01-01 00:00:00', [3, 4, 5], [10, 10, 10], ([3, 4, 5], [10, 10, 10])),
    ('2000-01-01', '2000-01-01 00:01:00', [4, 5, 6], [10, 10, 10], ([4, 5, 6], [10, 10, 10])),
    ('2000-01-01', '2000-01-01 00:01:00', [6, 7, 8], [10, 10, 10], ([6, 7, 8], [10, 10, 10]));
type item struct{
   Timeslot time.Time `db:"timeslot"`
   SumMap  map[int32]int32 `db:"sumMap"`
}
err := conn.Select(&item,`SELECT timeslot,sumMap(statusMapTuple)
FROM sum_map
GROUP BY timeslot`)

when I run this SQL,error happended as following:
sql: Scan error on column index 1, name "sumMap": unsupported Scan, storing driver.Value type []interface {} into type *map[int32]int32

@kshvakov kshvakov self-assigned this Jan 13, 2022
@kshvakov kshvakov added the v2 label Jan 13, 2022
kshvakov added a commit that referenced this issue Jan 17, 2022
@kshvakov
Copy link
Collaborator

Full support for Tuple and Map types was added in V2

See example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants