diff --git a/flux-client-rxjava/src/main/java/org/influxdata/flux/FluxClientReactive.java b/flux-client-rxjava/src/main/java/org/influxdata/flux/FluxClientReactive.java index 6c62254e613..387a5fa8f86 100644 --- a/flux-client-rxjava/src/main/java/org/influxdata/flux/FluxClientReactive.java +++ b/flux-client-rxjava/src/main/java/org/influxdata/flux/FluxClientReactive.java @@ -82,7 +82,7 @@ public interface FluxClientReactive { * Returns {@link Flowable} emitting raw response from InfluxDB server line by line. * * @param dialect Dialect is an object defining the options to use when encoding the response. - * See dialect SPEC.. + * See dialect SPEC.. * @param query the Flux query to execute * @return {@link Maybe} of a raw {@code Response} */ @@ -93,7 +93,7 @@ public interface FluxClientReactive { * Returns {@link Flowable} emitting raw response from InfluxDB server line by line. * * @param dialect Dialect is an object defining the options to use when encoding the response. - * See dialect SPEC.. + * See dialect SPEC.. * @param queryStream the Flux query publisher * @return {@link Maybe} of a raw {@code Response} */ diff --git a/flux-client/src/main/java/org/influxdata/flux/FluxClient.java b/flux-client/src/main/java/org/influxdata/flux/FluxClient.java index 443e440b0c8..874be595c32 100644 --- a/flux-client/src/main/java/org/influxdata/flux/FluxClient.java +++ b/flux-client/src/main/java/org/influxdata/flux/FluxClient.java @@ -102,7 +102,7 @@ void query(@Nonnull final String query, * * @param query the flux query to execute * @param dialect Dialect is an object defining the options to use when encoding the response. - * See dialect SPEC.. + * See dialect SPEC.. * @return the raw response that matched the query */ @Nonnull @@ -125,7 +125,7 @@ void raw(@Nonnull final String query, * * @param query the flux query to execute * @param dialect Dialect is an object defining the options to use when encoding the response. - * See dialect SPEC.. + * See dialect SPEC.. * @param onResponse callback to consume the raw response which are matched the query. * The callback call contains the one line of the response. */ @@ -152,7 +152,7 @@ void raw(@Nonnull final String query, * * @param query the flux query to execute * @param dialect Dialect is an object defining the options to use when encoding the response. - * See dialect SPEC.. + * See dialect SPEC.. * @param onResponse callback to consume the raw response which are matched the query. * The callback call contains the one line of the response. * @param onError callback to consume any error notification @@ -184,7 +184,7 @@ void raw(@Nonnull final String query, * * @param query the flux query to execute * @param dialect Dialect is an object defining the options to use when encoding the response. - * See dialect SPEC.. + * See dialect SPEC.. * @param onResponse callback to consume the raw response which are matched the query. * The callback call contains the one line of the response. * @param onError callback to consume any error notification diff --git a/flux-client/src/main/java/org/influxdata/flux/domain/FluxRecord.java b/flux-client/src/main/java/org/influxdata/flux/domain/FluxRecord.java index 1824e701ce9..fdde18fbc30 100644 --- a/flux-client/src/main/java/org/influxdata/flux/domain/FluxRecord.java +++ b/flux-client/src/main/java/org/influxdata/flux/domain/FluxRecord.java @@ -34,7 +34,7 @@ /** * A record is a tuple of values. Each record in the table represents a single point in the series. * - * Specification. + * Specification. */ public final class FluxRecord { diff --git a/flux-client/src/main/java/org/influxdata/flux/domain/FluxTable.java b/flux-client/src/main/java/org/influxdata/flux/domain/FluxTable.java index 924661304f0..6dc6b4fbf78 100644 --- a/flux-client/src/main/java/org/influxdata/flux/domain/FluxTable.java +++ b/flux-client/src/main/java/org/influxdata/flux/domain/FluxTable.java @@ -30,7 +30,7 @@ /** * This class represents table structure of Flux CSV Response. * - * Specification. + * Specification. */ public final class FluxTable { diff --git a/flux-client/src/main/java/org/influxdata/flux/option/FluxConnectionOptions.java b/flux-client/src/main/java/org/influxdata/flux/option/FluxConnectionOptions.java index 95af671afcb..c3c1aa58aa7 100644 --- a/flux-client/src/main/java/org/influxdata/flux/option/FluxConnectionOptions.java +++ b/flux-client/src/main/java/org/influxdata/flux/option/FluxConnectionOptions.java @@ -52,7 +52,6 @@ private FluxConnectionOptions(@Nonnull final Builder builder) { * Creates a builder instance. * * @return a builder - * @since 1.0.0 */ @Nonnull public static FluxConnectionOptions.Builder builder() { @@ -62,7 +61,6 @@ public static FluxConnectionOptions.Builder builder() { /** * @return the url to connect to Flux * @see FluxConnectionOptions.Builder#url(String) - * @since 1.0.0 */ @Nonnull public String getUrl() { @@ -72,7 +70,6 @@ public String getUrl() { /** * @return HTTP client to use for communication with Flux * @see FluxConnectionOptions.Builder#okHttpClient(OkHttpClient.Builder) - * @since 1.0.0 */ @Nonnull public OkHttpClient.Builder getOkHttpClient() { @@ -81,8 +78,6 @@ public OkHttpClient.Builder getOkHttpClient() { /** * A builder for {@code FluxConnectionOptions}. - * - * @since 1.0.0 */ @NotThreadSafe public static class Builder { @@ -95,7 +90,6 @@ public static class Builder { * * @param url the url to connect to Flux. It must be defined. * @return {@code this} - * @since 1.0.0 */ @Nonnull public Builder url(@Nonnull final String url) { @@ -109,7 +103,6 @@ public Builder url(@Nonnull final String url) { * * @param okHttpClient the HTTP client to use. * @return {@code this} - * @since 1.0.0 */ @Nonnull public Builder okHttpClient(@Nonnull final OkHttpClient.Builder okHttpClient) { diff --git a/flux-dsl/README.md b/flux-dsl/README.md index 884eab3f921..6cde1bfc3f8 100644 --- a/flux-dsl/README.md +++ b/flux-dsl/README.md @@ -45,7 +45,7 @@ Flux flux = Flux ### from -Starting point for all queries. Get data from the specified database [[doc](https://github.com/influxdata/platform/tree/master/query#from)]. +Starting point for all queries. Get data from the specified database [[doc](http://bit.ly/flux-spec#from)]. - `bucket` - The name of the bucket to query. [string] - `hosts` - [array of strings] @@ -66,7 +66,7 @@ Flux flux = Flux.from("telegraf") ``` ### count -Counts the number of results [[doc](https://github.com/influxdata/platform/tree/master/query#count)]. +Counts the number of results [[doc](http://bit.ly/flux-spec#count)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java Flux flux = Flux @@ -163,13 +163,18 @@ Flux flux = Flux ``` ### duplicate -Duplicate will duplicate a specified column in a table [[doc](https://github.com/influxdata/flux/blob/master/docs/SPEC.md#duplicate)]. +Duplicate will duplicate a specified column in a table [[doc](http://bit.ly/flux-spec#duplicate)]. - `column` - The column to duplicate. [string] - `as` The name that should be assigned to the duplicate column. [string] +```java +Flux flux = Flux + .from("telegraf") + .duplicate("host", "server"); +``` ### filter -Filters the results using an expression [[doc](https://github.com/influxdata/platform/tree/master/query#filter)]. +Filters the results using an expression [[doc](http://bit.ly/flux-spec#filter)]. - `fn` - Function to when filtering the records. The function must accept a single parameter which will be the records and return a boolean value. Records which evaluate to true, will be included in the results. [function(record) bool] @@ -220,7 +225,7 @@ Flux flux = Flux ``` ### first -Returns the first result of the query [[doc](https://github.com/influxdata/platform/tree/master/query#first)]. +Returns the first result of the query [[doc](http://bit.ly/flux-spec#first)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -230,7 +235,7 @@ Flux flux = Flux ``` ### group -Groups results by a user-specified set of tags [[doc](https://github.com/influxdata/platform/tree/master/query#group)]. +Groups results by a user-specified set of tags [[doc](http://bit.ly/flux-spec#group)]. - `by` - Group by these specific tag names. Cannot be used with `except` option. [array of strings] - `keep` - Keep specific tag keys that were not in `by` in the results. [array of strings] - `except` - Group by all but these tag keys. Cannot be used with `by` option. [array of strings] @@ -264,7 +269,7 @@ Flux flux = Flux ``` ### join -Join two time series together on time and the list of `on` keys [[doc](https://github.com/influxdata/platform/tree/master/query#join)]. +Join two time series together on time and the list of `on` keys [[doc](http://bit.ly/flux-spec#join)]. - `tables` - Map of tables to join. Currently only two tables are allowed. [map of tables] - `on` - List of tag keys that when equal produces a result set. [array of strings] - `method` - An optional parameter that specifies the type of join to be performed. When not specified, an inner join is performed. [string] @@ -313,7 +318,7 @@ Flux flux = Flux ``` ### last -Returns the last result of the query [[doc](https://github.com/influxdata/platform/tree/master/query#last)]. +Returns the last result of the query [[doc](http://bit.ly/flux-spec#last)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -323,7 +328,7 @@ Flux flux = Flux ``` ### limit -Restricts the number of rows returned in the results [[doc](https://github.com/influxdata/platform/tree/master/query#limit)]. +Restricts the number of rows returned in the results [[doc](http://bit.ly/flux-spec#limit)]. - `n` - The maximum number of records to output. [int] ```java Flux flux = Flux @@ -331,7 +336,7 @@ Flux flux = Flux .limit(5); ``` ### map -Applies a function to each row of the table [[doc](https://github.com/influxdata/platform/tree/master/query#map)]. +Applies a function to each row of the table [[doc](http://bit.ly/flux-spec#map)]. - `fn` - The function to apply to each row. The return value of the function may be a single value or an object. ```java @@ -367,7 +372,7 @@ Flux flux = Flux ``` ### max -Returns the max value within the results [[doc](https://github.com/influxdata/platform/tree/master/query#max)]. +Returns the max value within the results [[doc](http://bit.ly/flux-spec#max)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -379,7 +384,7 @@ Flux flux = Flux ``` ### mean -Returns the mean of the values within the results [[doc](https://github.com/influxdata/platform/tree/master/query#mean)]. +Returns the mean of the values within the results [[doc](http://bit.ly/flux-spec#mean)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -391,7 +396,7 @@ Flux flux = Flux ``` ### min -Returns the min value within the results [[doc](https://github.com/influxdata/platform/tree/master/query#min)]. +Returns the min value within the results [[doc](http://bit.ly/flux-spec#min)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -402,8 +407,23 @@ Flux flux = Flux .min(); ``` +### pivot +Pivot collects values stored vertically (column-wise) in a table +and aligns them horizontally (row-wise) into logical sets [[doc](https://github.com/influxdata/flux/blob/master/docs/SPEC.md#pivot)]. +- `rowKey` - List of columns used to uniquely identify a row for the output. [array of strings] +- `colKey` - List of columns used to pivot values onto each row identified by the rowKey. [array of strings] +- `valueCol` - Identifies the single column that contains the value to be moved around the pivot [string] + +```java +Flux flux = Flux.from("telegraf") + .pivot() + .withRowKey(new String[]{"_time"}) + .withColKey(new String[]{"_field"}) + .withValueCol("_value"); +``` + ### range -Filters the results by time boundaries [[doc](https://github.com/influxdata/platform/tree/master/query#range)]. +Filters the results by time boundaries [[doc](http://bit.ly/flux-spec#range)]. - `start` - Specifies the oldest time to be included in the results. [duration or timestamp] - `stop` - Specifies the exclusive newest time to be included in the results. Defaults to `"now"`. [duration or timestamp] @@ -444,7 +464,7 @@ Flux flux = Flux ``` ### sample -Sample values from a table [[doc](https://github.com/influxdata/platform/tree/master/query#sample)]. +Sample values from a table [[doc](http://bit.ly/flux-spec#sample)]. - `n` - Sample every Nth element. [int] - `pos` - Position offset from start of results to begin sampling. `pos` must be less than `n`. If `pos` less than 0, a random offset is used. Default is -1 (random offset). [int] ```java @@ -461,7 +481,7 @@ Flux flux = Flux.from("telegraf") ``` ### set -Assigns a static value to each record [[doc](https://github.com/influxdata/platform/tree/master/query#set)]. +Assigns a static value to each record [[doc](http://bit.ly/flux-spec#set)]. - `key` - Label for the column to set. [string] - `value` - Value for the column to set. [string] @@ -487,7 +507,7 @@ Flux flux = Flux ``` ### skew -Skew of the results [[doc](https://github.com/influxdata/platform/tree/master/query#skew)]. +Skew of the results [[doc](http://bit.ly/flux-spec#skew)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -498,7 +518,7 @@ Flux flux = Flux ``` ### sort -Sorts the results by the specified columns. Default sort is ascending [[doc](https://github.com/influxdata/platform/tree/master/query#skew)]. +Sorts the results by the specified columns. Default sort is ascending [[doc](http://bit.ly/flux-spec#skew)]. - `cols` - List of columns used to sort. Precedence from left to right. Default is `"value"`. [array of strings] - `desc` - Sort results descending. Default false. [boolean] @@ -514,7 +534,7 @@ Flux flux = Flux ``` ### spread -Difference between min and max values [[doc](https://github.com/influxdata/platform/tree/master/query#spread)]. +Difference between min and max values [[doc](http://bit.ly/flux-spec#spread)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -524,7 +544,7 @@ Flux flux = Flux ``` ### stddev -Standard Deviation of the results [[doc](https://github.com/influxdata/platform/tree/master/query#stddev)]. +Standard Deviation of the results [[doc](http://bit.ly/flux-spec#stddev)]. - `useStartTime` - Use the start time as the timestamp of the resulting aggregate. [boolean] ```java @@ -534,7 +554,7 @@ Flux flux = Flux ``` ### sum -Sum of the results [[doc](https://github.com/influxdata/platform/tree/master/query#sum)]. +Sum of the results [[doc](http://bit.ly/flux-spec#sum)]. ```java Flux flux = Flux .from("telegraf") @@ -542,7 +562,7 @@ Flux flux = Flux ``` ### toBool -Convert a value to a bool [[doc](https://github.com/influxdata/platform/tree/master/query#tobool)]. +Convert a value to a bool [[doc](http://bit.ly/flux-spec#tobool)]. ```java Flux flux = Flux .from("telegraf") @@ -551,7 +571,7 @@ Flux flux = Flux ``` ### toInt -Convert a value to a int [[doc](https://github.com/influxdata/platform/tree/master/query#toint)]. +Convert a value to a int [[doc](http://bit.ly/flux-spec#toint)]. ```java Flux flux = Flux .from("telegraf") @@ -560,7 +580,7 @@ Flux flux = Flux ``` ### toFloat -Convert a value to a float [[doc](https://github.com/influxdata/platform/tree/master/query#tofloat)]. +Convert a value to a float [[doc](http://bit.ly/flux-spec#tofloat)]. ```java Flux flux = Flux .from("telegraf") @@ -569,7 +589,7 @@ Flux flux = Flux ``` ### toDuration -Convert a value to a duration [[doc](https://github.com/influxdata/platform/tree/master/query#toduration)]. +Convert a value to a duration [[doc](http://bit.ly/flux-spec#toduration)]. ```java Flux flux = Flux .from("telegraf") @@ -578,7 +598,7 @@ Flux flux = Flux ``` ### toString -Convert a value to a string [[doc](https://github.com/influxdata/platform/tree/master/query#tostring)]. +Convert a value to a string [[doc](http://bit.ly/flux-spec#tostring)]. ```java Flux flux = Flux .from("telegraf") @@ -587,7 +607,7 @@ Flux flux = Flux ``` ### toTime -Convert a value to a time [[doc](https://github.com/influxdata/platform/tree/master/query#totime)]. +Convert a value to a time [[doc](http://bit.ly/flux-spec#totime)]. ```java Flux flux = Flux .from("telegraf") @@ -596,7 +616,7 @@ Flux flux = Flux ``` ### toUInt -Convert a value to a uint [[doc](https://github.com/influxdata/platform/tree/master/query#touint)]. +Convert a value to a uint [[doc](http://bit.ly/flux-spec#touint)]. ```java Flux flux = Flux .from("telegraf") @@ -605,7 +625,7 @@ Flux flux = Flux ``` ### window -Groups the results by a given time range [[doc](https://github.com/influxdata/platform/tree/master/query#window)]. +Groups the results by a given time range [[doc](http://bit.ly/flux-spec#window)]. - `every` - Duration of time between windows. Defaults to `period's` value. [duration] - `period` - Duration of the windowed partition. Defaults to `period's` value. [duration] - `offset` - The offset duration relative to the location offset. It can be negative, indicating that the offset goes backwards in time. The default aligns the window boundaries to line up with the `now` option time. [time] diff --git a/flux-dsl/src/main/java/org/influxdata/flux/Flux.java b/flux-dsl/src/main/java/org/influxdata/flux/Flux.java index 99269a3e854..691c5390720 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/Flux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/Flux.java @@ -51,6 +51,7 @@ import org.influxdata.flux.functions.MaxFlux; import org.influxdata.flux.functions.MeanFlux; import org.influxdata.flux.functions.MinFlux; +import org.influxdata.flux.functions.PivotFlux; import org.influxdata.flux.functions.RangeFlux; import org.influxdata.flux.functions.RenameFlux; import org.influxdata.flux.functions.SampleFlux; @@ -75,9 +76,9 @@ import org.influxdata.platform.Arguments; /** - * Flux - Data Scripting Language. + * Flux - Data Scripting Language. *
- * Flux Specification + * Flux Specification * *

The operators:

* * * @author Jakub Bednar (bednar@github) (22/06/2018 10:16) - * @since 1.0.0 */ @SuppressWarnings({"FileLength"}) public abstract class Flux { @@ -1049,6 +1049,63 @@ public final MinFlux min(final boolean useStartTime) { return new MinFlux(this).withUseStartTime(useStartTime); } + /** + * Pivot collects values stored vertically (column-wise) in a table + * and aligns them horizontally (row-wise) into logical sets. + * + *

The parameters had to be defined by:

+ * + * + * @return {@link PivotFlux} + */ + @Nonnull + public final PivotFlux pivot() { + return new PivotFlux(this); + } + + /** + * Pivot collects values stored vertically (column-wise) in a table + * and aligns them horizontally (row-wise) into logical sets. + * + * @param rowKey the columns used to uniquely identify a row for the output + * @param colKey the columns used to pivot values onto each row identified by the rowKey. + * @param valueCol the single column that contains the value to be moved around the pivot + * @return {@link PivotFlux} + */ + @Nonnull + public final PivotFlux pivot(@Nonnull final String[] rowKey, + @Nonnull final String[] colKey, + @Nonnull final String valueCol) { + + return new PivotFlux(this).withRowKey(rowKey).withColKey(colKey).withValueCol(valueCol); + } + + /** + * Pivot collects values stored vertically (column-wise) in a table + * and aligns them horizontally (row-wise) into logical sets. + * + * @param rowKey the columns used to uniquely identify a row for the output + * @param colKey the columns used to pivot values onto each row identified by the rowKey. + * @param valueCol the single column that contains the value to be moved around the pivot + * @return {@link PivotFlux} + */ + @Nonnull + public final PivotFlux pivot(@Nonnull final Collection rowKey, + @Nonnull final Collection colKey, + @Nonnull final String valueCol) { + + return new PivotFlux(this).withRowKey(rowKey).withColKey(colKey).withValueCol(valueCol); + } + /** * Filters the results by time boundaries. * diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/CountFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/CountFlux.java index b579977bca6..8c17c205621 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/CountFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/CountFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * count - Counts the number of results. + * count - Counts the number of results. * *

Options

*
    @@ -41,7 +41,6 @@ * * * @author Jakub Bednar (bednar@github) (22/06/2018 11:06) - * @since 1.0.0 */ public final class CountFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/CovarianceFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/CovarianceFlux.java index a1ef57baa63..698cfa82b7c 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/CovarianceFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/CovarianceFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * covariance - + * covariance - * Covariance is an aggregate operation. Covariance computes the covariance between two columns. * *

    Options

    @@ -52,7 +52,6 @@ * * * @author Jakub Bednar (bednar@github) (17/07/2018 13:13) - * @since 1.0.0 */ public final class CovarianceFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/DerivativeFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/DerivativeFlux.java index e58447a646d..5d041dec0d2 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/DerivativeFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/DerivativeFlux.java @@ -29,7 +29,7 @@ import org.influxdata.platform.Arguments; /** - * derivative - + * derivative - * Computes the time based difference between subsequent non null records. * *

    Options

    @@ -56,7 +56,6 @@ * * * @author Jakub Bednar (bednar@github) (03/07/2018 14:28) - * @since 1.0.0 */ public final class DerivativeFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/DifferenceFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/DifferenceFlux.java index 43165978a56..51b18fdd8c0 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/DifferenceFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/DifferenceFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * difference - + * difference - * Difference computes the difference between subsequent non null records. * *

    Options

    @@ -58,7 +58,6 @@ * * * @author Jakub Bednar (bednar@github) (17/07/2018 12:28) - * @since 1.0.0 */ public final class DifferenceFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/DistinctFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/DistinctFlux.java index b1c0c6d899b..c52e2d08ffb 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/DistinctFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/DistinctFlux.java @@ -27,7 +27,7 @@ import org.influxdata.platform.Arguments; /** - * distinct - Distinct + * distinct - Distinct * produces the unique values for a given column. * *

    Options

    @@ -46,7 +46,6 @@ * * * @author Jakub Bednar (bednar@github) (17/07/2018 12:08) - * @since 1.0.0 */ public final class DistinctFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/DropFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/DropFlux.java index a79fc8306fd..aab58e842dd 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/DropFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/DropFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * duplicate - Duplicate will + * duplicate - Duplicate will * duplicate a specified column in a table. * *

    Options

    @@ -56,7 +56,6 @@ * * * @author Jakub Bednar (bednar@github) (02/08/2018 09:47) - * @since 1.0.0 */ public final class DropFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/DuplicateFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/DuplicateFlux.java index 0593c405574..ee4ee8eed79 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/DuplicateFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/DuplicateFlux.java @@ -27,7 +27,7 @@ import org.influxdata.platform.Arguments; /** - * duplicate -Duplicate will + * duplicate -Duplicate will * duplicate a specified column in a table. * *

    Options

    @@ -42,6 +42,9 @@ * *

    Example

    *
    + * Flux flux = Flux
    + *     .from("telegraf")
    + *     .duplicate("host", "server");
      * 
    * * @author Jakub Bednar (bednar@github) (09/10/2018 13:13) diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ExpressionFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ExpressionFlux.java index 06c6fd81201..1d2a561ba0c 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ExpressionFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ExpressionFlux.java @@ -38,7 +38,6 @@ * * * @author Jakub Bednar (bednar@github) (27/06/2018 11:21) - * @since 1.0.0 */ public final class ExpressionFlux extends AbstractFluxWithUpstream { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/FilterFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/FilterFlux.java index 1cf91722014..943059b253e 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/FilterFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/FilterFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * filter - + * filter - * Filters the results using an expression. * *

    Options

    @@ -56,7 +56,6 @@ * * * @author Jakub Bednar (bednar@github) (28/06/2018 14:12) - * @since 1.0.0 */ public final class FilterFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/FirstFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/FirstFlux.java index d5556d9433c..0d79b45b5bc 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/FirstFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/FirstFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * first - Returns the first result of + * first - Returns the first result of * the query. * *

    Options

    @@ -42,7 +42,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 09:28) - * @since 1.0.0 */ public final class FirstFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/FromFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/FromFlux.java index 8f4cf264254..c1798276ecc 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/FromFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/FromFlux.java @@ -24,7 +24,7 @@ import javax.annotation.Nonnull; /** - * from - starting point + * from - starting point * for all queries. Get data from the specified bucket. * *

    Options

    @@ -43,7 +43,6 @@ * * * @author Jakub Bednar (bednar@github) (22/06/2018 10:20) - * @since 1.0.0 */ public final class FromFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/GroupFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/GroupFlux.java index e0d07c613e9..592f706986c 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/GroupFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/GroupFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * group - Groups results by + * group - Groups results by * a user-specified set of tags. * *

    Options

    @@ -54,7 +54,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 14:56) - * @since 1.0.0 */ public final class GroupFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/IntegralFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/IntegralFlux.java index a5cd06d423b..4b417b75cd0 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/IntegralFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/IntegralFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * integral - + * integral - * For each aggregate column, it outputs the area under the curve of non null records. * The curve is defined as function where the domain is the record times and the range is the record values. * @@ -45,7 +45,6 @@ * * * @author Jakub Bednar (bednar@github) (03/07/2018 12:33) - * @since 1.0.0 */ public final class IntegralFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/JoinFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/JoinFlux.java index 89c60a358d6..99da836f649 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/JoinFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/JoinFlux.java @@ -32,7 +32,7 @@ import org.influxdata.platform.Arguments; /** - * join - + * join - * Join two time series together on time and the list of on keys. * *

    Options

    @@ -61,7 +61,6 @@ * * * @author Jakub Bednar (bednar@github) (17/07/2018 14:47) - * @since 1.0.0 */ public final class JoinFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/KeepFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/KeepFlux.java index fa831c316f5..a4410144e3c 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/KeepFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/KeepFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * keep - + * keep - * Keep is the inverse of drop. It will return a table containing only columns that are specified, ignoring all others. * Only columns in the group key that are also specified in keep will be kept in the resulting group key. * @@ -57,7 +57,6 @@ * * * @author Jakub Bednar (bednar@github) (02/08/2018 11:22) - * @since 1.0.0 */ public final class KeepFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/LastFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/LastFlux.java index c8b26b0de06..f28111db2f7 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/LastFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/LastFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * last - Returns the last result of + * last - Returns the last result of * the query. * *

    Options

    @@ -42,7 +42,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 09:43) - * @since 1.0.0 */ public final class LastFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/LimitFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/LimitFlux.java index dc666a4fee0..2caf005a809 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/LimitFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/LimitFlux.java @@ -27,7 +27,7 @@ import org.influxdata.platform.Arguments; /** - * limit - Restricts the number of rows + * limit - Restricts the number of rows * returned in the results. * *

    Options

    @@ -43,7 +43,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 11:22) - * @since 1.0.0 */ public final class LimitFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/MapFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/MapFlux.java index 154850a8733..3043ece0555 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/MapFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/MapFlux.java @@ -27,7 +27,7 @@ import org.influxdata.platform.Arguments; /** - * map - Applies a function to + * map - Applies a function to * each row of the table. * *

    Options

    @@ -62,7 +62,6 @@ * * * @author Jakub Bednar (bednar@github) (17/07/2018 07:48) - * @since 1.0.0 */ public final class MapFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/MaxFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/MaxFlux.java index 306851e6760..d3a45916d63 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/MaxFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/MaxFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * max - Returns the max value + * max - Returns the max value * within the results. * *

    Options

    @@ -44,7 +44,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 09:49) - * @since 1.0.0 */ public final class MaxFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/MeanFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/MeanFlux.java index a1b1dba7268..0504b778d49 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/MeanFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/MeanFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * mean - Returns the mean of the + * mean - Returns the mean of the * within the results. * *

    Options

    @@ -44,7 +44,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 09:55) - * @since 1.0.0 */ public final class MeanFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/MinFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/MinFlux.java index 3e1c38b3497..db761f20a83 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/MinFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/MinFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * min - Returns the min value within + * min - Returns the min value within * the results. * *

    Options

    @@ -44,7 +44,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 10:00) - * @since 1.0.0 */ public final class MinFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/PivotFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/PivotFlux.java new file mode 100644 index 00000000000..daa0e27dd40 --- /dev/null +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/PivotFlux.java @@ -0,0 +1,134 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.influxdata.flux.functions; + +import java.util.Collection; +import javax.annotation.Nonnull; + +import org.influxdata.flux.Flux; +import org.influxdata.platform.Arguments; + +/** + * pivot - Pivot collects values stored vertically (column-wise) in a table + * and aligns them horizontally (row-wise) into logical sets. + * + *

    Options

    + *
      + *
    • rowKey - List of columns used to uniquely identify a row for the output. [array of strings]
    • + *
    • colKey - + * List of columns used to pivot values onto each row identified by the rowKey. [array of strings]
    • + *
    • valueCol - Identifies the single column that contains the value to be moved around the pivot [string]
    • + *
    + * + *

    Example

    + *
    + * Flux flux = Flux.from("telegraf")
    + *     .pivot()
    + *         .withRowKey(new String[]{"_time"})
    + *         .withColKey(new String[]{"_field"})
    + *         .withValueCol("_value");
    + * 
    + * + * @author Jakub Bednar (10/10/2018 06:16) + */ +public final class PivotFlux extends AbstractParametrizedFlux { + + public PivotFlux(@Nonnull final Flux source) { + super(source); + } + + @Nonnull + @Override + protected String operatorName() { + return "pivot"; + } + + /** + * @param rowKey the columns used to uniquely identify a row for the output. + * @return this + */ + @Nonnull + public PivotFlux withRowKey(@Nonnull final String[] rowKey) { + + Arguments.checkNotNull(rowKey, "rowKey"); + + this.withPropertyValue("rowKey", rowKey); + + return this; + } + + /** + * @param rowKey the columns used to uniquely identify a row for the output. + * @return this + */ + @Nonnull + public PivotFlux withRowKey(@Nonnull final Collection rowKey) { + + Arguments.checkNotNull(rowKey, "rowKey"); + + this.withPropertyValue("rowKey", rowKey); + + return this; + } + + /** + * @param colKey the columns used to pivot values onto each row identified by the rowKey. + * @return this + */ + @Nonnull + public PivotFlux withColKey(@Nonnull final String[] colKey) { + + Arguments.checkNotNull(colKey, "colKey"); + + this.withPropertyValue("colKey", colKey); + + return this; + } + + /** + * @param colKey the columns used to pivot values onto each row identified by the rowKey. + * @return this + */ + @Nonnull + public PivotFlux withColKey(@Nonnull final Collection colKey) { + + Arguments.checkNotNull(colKey, "colKey"); + + this.withPropertyValue("colKey", colKey); + + return this; + } + + /** + * @param valueCol the single column that contains the value to be moved around the pivot + * @return this + */ + @Nonnull + public PivotFlux withValueCol(@Nonnull final String valueCol) { + + Arguments.checkNonEmpty(valueCol, "valueCol"); + + this.withPropertyValueEscaped("valueCol", valueCol); + + return this; + } +} diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/RangeFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/RangeFlux.java index 290e2917fab..01f26c10dc3 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/RangeFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/RangeFlux.java @@ -29,7 +29,7 @@ import org.influxdata.platform.Arguments; /** - * range - Filters the results by + * range - Filters the results by * time boundaries. * *

    Options

    @@ -49,7 +49,6 @@ * * * @author Jakub Bednar (bednar@github) (26/06/2018 07:04) - * @since 1.0.0 */ public final class RangeFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/RenameFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/RenameFlux.java index db7cddd4100..4105cc4b273 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/RenameFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/RenameFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * rename - + * rename - * Rename will rename specified columns in a table. If a column is renamed and is part of the group key, * the column name in the group key will be updated * diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/SampleFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/SampleFlux.java index 5c682ab3f2b..46da71476ba 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/SampleFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/SampleFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * sample - Sample values from a table. + * sample - Sample values from a table. * *

    Options

    *
      @@ -51,7 +51,6 @@ * * * @author Jakub Bednar (bednar@github) (29/06/2018 07:25) - * @since 1.0.0 */ public final class SampleFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/SetFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/SetFlux.java index 31a30072d67..ffddaba066a 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/SetFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/SetFlux.java @@ -27,7 +27,7 @@ import org.influxdata.platform.Arguments; /** - * yield - Assigns a static + * yield - Assigns a static * value to each record. * *

      Options

      @@ -44,7 +44,6 @@ * * * @author Jakub Bednar (bednar@github) (29/06/2018 09:19) - * @since 1.0.0 */ public final class SetFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ShiftFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ShiftFlux.java index 1932ad24fe8..12db3849a23 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ShiftFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ShiftFlux.java @@ -29,7 +29,7 @@ import org.influxdata.platform.Arguments; /** - * shift - + * shift - * Shift add a fixed duration to time columns. * *

      Options

      @@ -51,7 +51,6 @@ * * * @author Jakub Bednar (bednar@github) (29/06/2018 10:27) - * @since 1.0.0 */ public final class ShiftFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/SkewFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/SkewFlux.java index e9f123e77da..ee371f9152f 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/SkewFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/SkewFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * skew - Skew of the results. + * skew - Skew of the results. * *

      Options

      *
        @@ -42,7 +42,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 10:06) - * @since 1.0.0 */ public final class SkewFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/SortFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/SortFlux.java index dd09dc74a9e..335d131bda7 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/SortFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/SortFlux.java @@ -28,7 +28,7 @@ import org.influxdata.platform.Arguments; /** - * sort - Sorts the results by the + * sort - Sorts the results by the * specified columns Default sort is ascending. * *

        Options

        @@ -53,7 +53,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 13:20) - * @since 1.0.0 */ public final class SortFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/SpreadFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/SpreadFlux.java index fbb4d7c3d72..4bcae3b8364 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/SpreadFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/SpreadFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * spread - Difference between min + * spread - Difference between min * and max values. * *

        Options

        @@ -42,7 +42,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 10:10) - * @since 1.0.0 */ public final class SpreadFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/StddevFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/StddevFlux.java index 584d226604e..403f3b339ff 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/StddevFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/StddevFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * stddev - Standard Deviation of + * stddev - Standard Deviation of * the results. * *

        Options

        @@ -42,7 +42,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 10:15) - * @since 1.0.0 */ public final class StddevFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/SumFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/SumFlux.java index 3be0eb6fbc4..84b20a2e309 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/SumFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/SumFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * sum - Sum of the results. + * sum - Sum of the results. * *

        Options

        *
          @@ -41,7 +41,6 @@ * * * @author Jakub Bednar (bednar@github) (25/06/2018 10:19) - * @since 1.0.0 */ public final class SumFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToBoolFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToBoolFlux.java index 2ceb3f6376d..285e55e933b 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToBoolFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToBoolFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * toBool - Convert a value to a bool. + * toBool - Convert a value to a bool. * *

          Example

          *
          @@ -37,7 +37,6 @@
            * 
          * * @author Jakub Bednar (bednar@github) (25/06/2018 15:57) - * @since 1.0.0 */ public final class ToBoolFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToDurationFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToDurationFlux.java index 6a0c5c1c707..eee34e9357d 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToDurationFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToDurationFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * toDuration - + * toDuration - * Convert a value to a duration. * *

          Example

          diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToFloatFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToFloatFlux.java index 1dddaea770d..43025296c4b 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToFloatFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToFloatFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * toFloat - Convert a value to a float. + * toFloat - Convert a value to a float. * *

          Example

          *
          diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToIntFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToIntFlux.java
          index aa10b355609..a704b16c038 100644
          --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToIntFlux.java
          +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToIntFlux.java
          @@ -26,7 +26,7 @@
           import org.influxdata.flux.Flux;
           
           /**
          - * toInt - Convert a value to a int.
          + * toInt - Convert a value to a int.
            *
            * 

          Example

          *
          diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToStringFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToStringFlux.java
          index 8b4798f1a84..9dbca99bc67 100644
          --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToStringFlux.java
          +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToStringFlux.java
          @@ -26,7 +26,7 @@
           import org.influxdata.flux.Flux;
           
           /**
          - * toString - Convert a value
          + * toString - Convert a value
            * to a string.
            *
            * 

          Example

          @@ -38,7 +38,6 @@ *
          * * @author Jakub Bednar (bednar@github) (26/06/2018 06:32) - * @since 1.0.0 */ public final class ToStringFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToTimeFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToTimeFlux.java index 3eceff1d306..6385cfa814a 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToTimeFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToTimeFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * toTime - Convert a value to a time. + * toTime - Convert a value to a time. * *

          Example

          *
          @@ -37,7 +37,6 @@
            * 
          * * @author Jakub Bednar (bednar@github) (26/06/2018 06:37) - * @since 1.0.0 */ public final class ToTimeFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToUIntFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToUIntFlux.java index c248eec4534..9ec2b4b8186 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/ToUIntFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/ToUIntFlux.java @@ -26,7 +26,7 @@ import org.influxdata.flux.Flux; /** - * toDuration - + * toDuration - * Convert a value to a duration. * *

          Example

          @@ -38,7 +38,6 @@ *
          * * @author Jakub Bednar (bednar@github) (26/06/2018 06:40) - * @since 1.0.0 */ public final class ToUIntFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/WindowFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/WindowFlux.java index 891457aab32..0f877f22fcd 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/WindowFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/WindowFlux.java @@ -29,7 +29,7 @@ import org.influxdata.platform.Arguments; /** - * window - Groups the results by + * window - Groups the results by * a given time range. * *

          Options

          @@ -60,7 +60,6 @@ * * * @author Jakub Bednar (bednar@github) (27/06/2018 12:01) - * @since 1.0.0 */ public final class WindowFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/YieldFlux.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/YieldFlux.java index a40d944774e..7f22db4a9e4 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/YieldFlux.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/YieldFlux.java @@ -27,7 +27,7 @@ import org.influxdata.platform.Arguments; /** - * set - Yield a query results + * set - Yield a query results * to yielded results. * *

          Options

          @@ -43,7 +43,6 @@ * * * @author Jakub Bednar (bednar@github) (29/06/2018 09:55) - * @since 1.0.0 */ public final class YieldFlux extends AbstractParametrizedFlux { diff --git a/flux-dsl/src/main/java/org/influxdata/flux/functions/properties/TimeInterval.java b/flux-dsl/src/main/java/org/influxdata/flux/functions/properties/TimeInterval.java index b08e9e52a7f..a081ca748f2 100644 --- a/flux-dsl/src/main/java/org/influxdata/flux/functions/properties/TimeInterval.java +++ b/flux-dsl/src/main/java/org/influxdata/flux/functions/properties/TimeInterval.java @@ -29,7 +29,7 @@ /** * Flux duration literal - - * spec. + * spec. *

          * A duration literal is a representation of a length of time. It has an integer part and a duration unit part. * diff --git a/flux-dsl/src/test/java/org/influxdata/flux/functions/PivotFluxTest.java b/flux-dsl/src/test/java/org/influxdata/flux/functions/PivotFluxTest.java new file mode 100644 index 00000000000..fcc997c0ff8 --- /dev/null +++ b/flux-dsl/src/test/java/org/influxdata/flux/functions/PivotFluxTest.java @@ -0,0 +1,80 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.influxdata.flux.functions; + +import java.util.ArrayList; +import java.util.List; + +import org.influxdata.flux.Flux; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.platform.runner.JUnitPlatform; +import org.junit.runner.RunWith; + +/** + * @author Jakub Bednar (10/10/2018 06:59) + */ +@RunWith(JUnitPlatform.class) +class PivotFluxTest { + + @Test + void pivot() { + + Flux flux = Flux.from("telegraf") + .pivot() + .withRowKey(new String[]{"_time"}) + .withColKey(new String[]{"_field"}) + .withValueCol("_value"); + + String expected = "from(bucket:\"telegraf\") |> pivot(rowKey: [\"_time\"], colKey: [\"_field\"], valueCol: \"_value\")"; + + Assertions.assertThat(flux.toString()).isEqualToIgnoringWhitespace(expected); + } + + @Test + void pivotArray() { + + Flux flux = Flux.from("telegraf") + .pivot(new String[]{"_time"}, new String[]{"_measurement", "_field"}, "_value"); + + String expected = "from(bucket:\"telegraf\") |> pivot(rowKey: [\"_time\"], colKey: [\"_measurement\", \"_field\"], valueCol: \"_value\")"; + + Assertions.assertThat(flux.toString()).isEqualToIgnoringWhitespace(expected); + } + + @Test + void pivotCollection() { + + List rowKey = new ArrayList<>(); + rowKey.add("_stop"); + List colKey = new ArrayList<>(); + colKey.add("host"); + + Flux flux = Flux.from("telegraf") + .pivot(rowKey, colKey, "_value"); + + String expected = "from(bucket:\"telegraf\") |> pivot(rowKey: [\"_stop\"], colKey: [\"host\"], valueCol: \"_value\")"; + + Assertions.assertThat(flux.toString()).isEqualToIgnoringWhitespace(expected); + } +}