Commit Graph

48 Commits (cb95b2f62952fdde37a86f7ac03c10c74f4e4920)

Author SHA1 Message Date
Ben Johnson 7d4bea7153
add node id to execution options
This commit changes the `ExecutionOptions` and `SelectOptions` to
allow a `NodeID` for specifying an exact node to query against.
2016-06-10 09:20:44 -06:00
Jonathan A. Sternberg 1e84b22407 Update SHOW TAG VALUES to use a fast dedupe iterator
Include a benchmark test for the fast dedupe iterator.
2016-06-02 22:03:59 -05:00
Nathaniel Cook 6ed0d94343 Add Holt-Winters forecasting method. 2016-05-19 09:24:56 -06:00
Jonathan A. Sternberg 23f6a706bb Support cast syntax for selecting a specific type
Casting syntax is done with the PostgreSQL syntax `field1::float` to
specify which type should be used when selecting a field. You can also
do `field1::field` or `tag1::tag` to specify that a field or tag should
be selected.

This makes it possible to select a tag when a field key and a tag key
conflict with each other in a measurement. It also means it's possible
to choose a field with a specific type if multiple shards disagree. If
no types are given, the same ordering for how a type is chosen is used
to determine which type to return.

The FieldDimensions method has been updated to return the data type for
the fields that get returned. The SeriesKeys function has also been
removed since it is no longer needed. SeriesKeys was originally used for
the fill iterator, but then expanded to be used by auxiliary iterators
for determining the channel iterator types. The fill iterator doesn't
need it anymore and the auxiliary types are better served by
FieldDimensions implementing that functionality, so SeriesKeys is no
longer needed.

Fixes #6519.
2016-05-16 12:08:29 -04:00
Ben Johnson 417df18396 Merge pull request #6533 from benbjohnson/optimize-show-series
Optimize SHOW SERIES
2016-05-03 09:15:21 -06:00
Ben Johnson 49eb3b8d04
optimize show series iterator
This commit changes the `SeriesIterator` to process one measurement
at a time and uses a `floatFastDedupeIterator` to avoid point
encoding during deduplication.
2016-05-03 08:52:44 -06:00
Jonathan A. Sternberg d6d0addcec Fix aggregate returns when data is missing from some shards
If a shard is empty for a specific field and the field type is something
other than a float, a nil iterator would get returned from one of the
empty shards and cause the combined iterators to be cast to the float
type and all other iterator types to be discarded (or for integers, to
be cast).

This is rare since most aggregates don't accept strings or booleans, but
for queries like:

    SELECT distinct(string) FROM mydata

It would result in nothing getting returned if one of the shards didn't
have a value for `string`.

This change modifies the query engine to return nil for the shards
instead of a fake iterator and then to only use the fake iterator if the
final aggregate iterator is nil (meaning that no iterators could be
constructed for the field from any shard).

Fixes #6495.
2016-05-03 10:41:22 -04:00
Jonathan A. Sternberg 043bd6031e Return the time with a selector when there is no group by interval
The time of the point will be returned with a selector when there is no
group by interval and when there is only one selector. Any other
conditions will return the start time of the interval.

Fixes #5890.
2016-04-29 11:27:26 -04:00
thbourlove 0e3964d8c2 fix panic in transform iterator on division
if left point is nil in division expr, the influxd server would panic. Now check left point before use it.
2016-04-21 00:07:20 +08:00
Nathaniel Cook 465f5a375f add elapsed function 2016-04-19 12:54:54 -06:00
Jonathan A. Sternberg 86046bb2d0 Implement derivatives across intervals for aggregate queries
For aggregate queries, derivatives will now alter the start time to one
interval behind and will use that interval to find the derivative of the
first point instead of giving no value for that interval. Null values
will still be discarded so if the interval before the one you are
querying is null, then it will be discarded like if it were in the
middle of the query. You can use `fill(0)` to fill in these values.

This does not apply to raw queries yet.

Also modified the derivative and difference aggregates to use the stream
iterator instead of the reduce slice iterator for space efficiency.

Fixes #3247. Contributes to #5943.
2016-04-15 18:16:08 -04:00
Jonathan A. Sternberg d176c8babb Throw an error when an invalid expression is used with aux iterators
The following query was fixed previously:

    SELECT 'value' FROM cpu

This ended up hitting the `buildExprIterator()` code path and was
handled properly. But this query:

    SELECT 'value', value FROM cpu

This took a different code path that would trigger a panic because it
triggered a panic instead of an error condition. This code path has now
been modified to trigger an error instead of a panic.

Fixes #6248.
2016-04-07 11:01:45 -04:00
Jonathan A. Sternberg 6453dbc249 Implement simple moving average
The simple moving average will gradually emit points instead of waiting
until the end. This should apply to derivative and difference in the
future too.

Fixes #6112.
2016-03-29 14:36:43 -04:00
Jonathan A. Sternberg a9720f926e Implement the difference function
The difference function is implemented very similar to how derivative is
implemented. It is an aggregate function that acts over the entire
aggregate. This function will also have the same problems that
derivative has with getting values from the previous interval or point.
This will be fixed separately as part of #5943.

Fixes #1825.
2016-03-29 09:27:12 -04:00
Jonathan A. Sternberg 79fe4490c2 Support a timeout for running queries in the query manager
Include an interrupt iterator at the top level to interrupt the fill
iterator if it is producing too many points.

Fixes #6075.
2016-03-22 13:30:40 -04:00
Jonathan A. Sternberg 6655ca7769 Create a new interrupt iterator that will stop emitting points after an interrupt
Use of the iterator is spread out into both `IteratorCreators` and
inside of the iterators themselves. Part of the interrupt must be
handled inside of the engine so it stops trying to emit points when an
interrupt is found and another part of the interrupt has to happen when
combining the iterators so it doesn't just start reading the next shard.
2016-03-21 12:07:07 -04:00
Jonathan A. Sternberg 43a5e84aaf Merge pull request #6047 from influxdata/js-6040-boolean-distinct
Support the distinct() call for booleans
2016-03-17 17:17:21 -04:00
Jonathan A. Sternberg e47426ff6e Support integer literals in the query language
Numbers in the query without any decimal will now be emitted as integers
instead and be parsed as an IntegerLiteral. This ensures we keep the
original context that a query was issued with and allows us to act more
similar to how programming languages are typically structured when it
comes to floats and ints.

This adds functionality for dealing with integers promoting to floats in
the various different places where math are used.

Fixes #5744 and #5629.
2016-03-17 10:37:34 -04:00
Jonathan A. Sternberg 2e7816ebd9 Support the distinct() call for booleans
Normalize the time for the distinct() call to either be at the beginning
of the group by interval or the start time similar to every other call.
The timestamp previously just showed the first time found and didn't
make a lot of sense in the context of what the function was supposed to
do.

Fixes #6040.
2016-03-17 09:32:54 -04:00
Jonathan A. Sternberg 94916082c9 Make binary expressions with either point being nil return a nil point
This also fixes integer to float and float/integer to boolean binary
expressions to correctly work with nil points at all.

Related to #5973.
2016-03-14 13:27:59 -04:00
Jonathan A. Sternberg 3f68bd12ee Merge pull request #5979 from influxdata/js-5974-aux-iterator-close-panic
Fix aux iterators to respect early closing
2016-03-14 12:03:50 -04:00
Jonathan A. Sternberg 0042866002 Teach the AuxIterator how to background
Now the AuxIterator will know when it is backgrounded so that it can
stop reading from the primary iterator when all of the child iterators
have been closed.
2016-03-14 11:12:02 -04:00
Jonathan A. Sternberg 74d51e3842 Support nil values in binary math expressions with two iterators
Related to #5959 and #5973.
2016-03-11 15:57:35 -05:00
Jonathan A. Sternberg 546de3f7cb Return error message when improper types are used in SELECT
Fixes #5949.
2016-03-09 11:36:18 -05:00
Jonathan A. Sternberg 9113839e4c Fix sorting of `first()` and `last()` calls across shards
Previously the call iterator would normalize the time to the interval
for all calls. This meant that when `first()` or `last()` was called
with no group by interval the value would be found for each shard, the
time was normalized, then it tried to find the value between the shards
(but no longer with any time data as that had already been eliminated).

This removes part of the time logic from the call iterators and makes a
new iterator `IntervalIterator` to normalize the times as they come out
of the underlying iterator.

Fixes #5890.
2016-03-03 21:15:43 -05:00
Jonathan A. Sternberg fabc41dcfb Have division always return a float in the new query engine
Fixes #5892.
2016-03-03 08:15:54 -05:00
Jonathan A. Sternberg 7a03df2af1 Remove the non-unreachable panics in the new query engine
The only panics left are ones that should be unreachable unless there is
a bug.

Fixes #5777.
2016-02-22 12:52:43 -05:00
Jonathan A. Sternberg 6982d5310e Replace a panic with returning an error when an unsupported call is used
Fixes #5773.
2016-02-21 19:39:14 -05:00
Jonathan A. Sternberg f84556fe22 Update binary expressions to handle mixed math between integers and floats
This also changes it so all NumericLiterals are treated as a float
rather than sometimes being cast to an integer.

Fixes #5740.
2016-02-19 14:32:22 -05:00
Jonathan A. Sternberg 18c7c554ba Optimize the mean() call by moving the calculation into the shard iterator
A new attribute has been added to points to track how many points were
used to calculate that point. This is particularly useful for finding
the mean as we can then split mean calculation into two phases: one at
the shard level and a second at the shards level.

This optimization is now used so we don't have to hold so many points in
memory while calculating the mean.
2016-02-16 10:32:34 -05:00
Jonathan A. Sternberg 559a11d0ab Pass the implicit end time from the query executor to the select call
The select call and the query executor would both calculate the time
range, but in separate ways. The query executor needed some way to pass
in the implicit end time that is placed there by the query executor.

Fixes #5636.
2016-02-12 16:03:24 -05:00
Jonathan A. Sternberg b70d83af6a Merge pull request #5633 from seiflotfy/fix5630
Make sure parenthesized SELECT arguments are evaluated properly without panic
2016-02-11 18:57:34 -05:00
Seif Lotfy 18f22a22fb Make sure parenthesized SELECT arguemnts are evaluated properly without panic
Fixes #5630
2016-02-11 17:41:33 -06:00
Jonathan A. Sternberg f5d8a4a6c0 Clear the start and end times for derivative calls
Derivatives rely on the underlying iterator to handle start and end
times. They do not perform them or organize points into groups. In
certain circumstances, the start time or end time that got implicitly
passed could be on an uneven interval with the first point returned by
the aggregate, which caused the entire iterator not to be read.

This fixes #5571.
2016-02-11 16:17:15 -05:00
Jonathan A. Sternberg ed151598ff Modify the AuxIterator to include a Start method
The AuxIterator streams points to the underlying iterators. When it
started automatically, race conditions occurred between the stream
closing the iterators and creating iterators from the AuxIterator.
2016-02-10 09:40:30 -07:00
Jonathan A. Sternberg 5c9cdd05c2 Modify the fill iterator to not produce empty name/tags for a time range
If a name/tag combination does not have any points in the time range at
all, fill will not generate points for it.
2016-02-10 09:40:30 -07:00
Jonathan A. Sternberg d1f7c445e7 Modify iterators to work across shards
Aux iterators now ask the iterator creator what series will be returned
and determine which aux fields to create based on the results.

The `tsdb.Shards` struct also creates a call iterator around the
iterators returned from each shard.
2016-02-10 09:40:29 -07:00
Jonathan A. Sternberg c2d1206177 Implement the fill iterator
Fill requires an additional function for IteratorCreator to retrieve the
series that will be returned from the iterator. When fill is required
for an aggregate, the IteratorCreator will be asked what series will be
returned by the created iterator.
2016-02-10 09:40:29 -07:00
Ben Johnson 627cd9d486 add dedupe iterator 2016-02-10 09:40:29 -07:00
Ben Johnson 607750ab1b add SHOW MEASUREMENTS iterator 2016-02-10 09:40:28 -07:00
Ben Johnson 6204350d65 fix math operations 2016-02-10 09:40:27 -07:00
Ben Johnson b8918a780c integer support 2016-02-10 09:40:25 -07:00
Jonathan A. Sternberg 97752df03d Repair regressions in derivatives with group by tests
Also fixes the `first()` and `last()` calls to do the same thing as
`min()` and `max()` by returning the time corresponding to the start of
the interval rather than the point's real time.
2016-02-10 09:40:25 -07:00
Jonathan A. Sternberg e0ac29dd2d Implement most of top() and bottom()
This does not implement the time selector, but everything else is
implemented. Unfortunately, there are no tests for bottom() in the old
query engine, so only top() is properly tested.
2016-02-10 09:40:25 -07:00
Ben Johnson 00806de9b8 refactor query engine 2016-02-10 09:40:25 -07:00
Ben Johnson 0ad9c31169 simple derivative 2016-02-10 09:40:24 -07:00
Ben Johnson 60b051ee88 LIMIT/OFFSET 2016-02-10 09:40:24 -07:00
Ben Johnson cde973f409 refactor query engine 2016-02-10 09:40:24 -07:00