Skip to content

Instantly share code, notes, and snippets.

@eckardt
Created February 16, 2014 21:00
Show Gist options
  • Save eckardt/9040576 to your computer and use it in GitHub Desktop.
Save eckardt/9040576 to your computer and use it in GitHub Desktop.
$ influxdb -v
InfluxDB v0.4.4 (git: 8dcf3f537f374c5bf0b10526952a58abb2d19d8a)
# The following data is in a:
test> select * from a
┌──────────────────┬─────────────────┬─────┐
│ time │ sequence_number │ foo │
├──────────────────┼─────────────────┼─────┤
│ 16/2/14 21:34:31 │ 2448960001 │ 2 │
│ 16/2/14 21:34:29 │ 2448940001 │ 1 │
│ 16/2/14 21:33:16 │ 2447990001 │ 2 │
│ 16/2/14 21:33:14 │ 2447960001 │ 1 │
│ 16/2/14 21:33:07 │ 2447880001 │ 2 │
│ 16/2/14 21:33:03 │ 2447840001 │ 1 │
└──────────────────┴─────────────────┴─────┘
# Counting, grouped by foo and time on a directly works as expected:
test> select count(foo) from a group by foo, time(1m)
┌──────────────────┬───────┬─────┐
│ time │ count │ foo │
├──────────────────┼───────┼─────┤
│ 16/2/14 21:34:00 │ 1 │ 2 │
│ 16/2/14 21:34:00 │ 1 │ 1 │
│ 16/2/14 21:33:00 │ 2 │ 2 │
│ 16/2/14 21:33:00 │ 2 │ 1 │
└──────────────────┴───────┴─────┘
# Now creating a continuous query:
test> select count(foo) from a group by foo, time(1m) into a.1m
test> list continuous queries
┌─────────────────┬─────────────────┬────┬───────────────────────────────────────────────────────────┐
│ time │ sequence_number │ id │ query │
├─────────────────┼─────────────────┼────┼───────────────────────────────────────────────────────────┤
│ 1/1/70 01:23:12 │ 1 │ 1 │ select count(foo) from a group by foo, time(1m) into a.1m │
└─────────────────┴─────────────────┴────┴───────────────────────────────────────────────────────────┘
# Querying the continuous query yields unexpected results:
test> select * from a.1m group by foo
┌──────────────────┬─────────────────┬───────┬─────┐
│ time │ sequence_number │ count │ foo │
├──────────────────┼─────────────────┼───────┼─────┤
│ 16/2/14 21:34:00 │ 1 │ 1 │ 1 │
│ 16/2/14 21:33:00 │ 1 │ 2 │ 1 │
└──────────────────┴─────────────────┴───────┴─────┘
# Expected result is this:
┌──────────────────┬───────┬─────┐
│ time │ count │ foo │
├──────────────────┼───────┼─────┤
│ 16/2/14 21:34:00 │ 1 │ 2 │
│ 16/2/14 21:34:00 │ 1 │ 1 │
│ 16/2/14 21:33:00 │ 2 │ 2 │
│ 16/2/14 21:33:00 │ 2 │ 1 │
└──────────────────┴───────┴─────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment