diff --git a/docs/data-sources/query_specification.md b/docs/data-sources/query_specification.md index 2910c546..0cdda456 100644 --- a/docs/data-sources/query_specification.md +++ b/docs/data-sources/query_specification.md @@ -66,7 +66,7 @@ The following arguments are supported: * `time_range` - (Optional) The time range of the query in seconds, defaults to `7200` (two hours). * `start_time` - (Optional) The absolute start time of the query in Unix Time (= seconds since epoch). * `end_time` - (Optional) The absolute end time of the query in Unix Time (= seconds since epoch). -* `granularity` - (Optional) The time resolution of the query’s graph, in seconds. Valid values must be in between the query’s time range /10 at maximum, and /1000 at minimum. +* `granularity` - (Optional) The time resolution of the query’s graph, in seconds. Valid values must be in between the query’s time range at maximum, and /1000 at minimum. * `compare_time_offset` - (Optional) The time offset for comparison queries, in seconds. Used to compare current time range data with data from a previous time period. Valid values are the query time range, `1800`, `3600`, `7200`, `28800`, `86400`, `604800`, `2419200`, or `15724800`. ~> **NOTE** It is not allowed to specify all three of `time_range`, `start_time` and `end_time`. For more details about specifying time windows, check [Query specification: A caveat on time](https://docs.honeycomb.io/api/query-specification/#a-caveat-on-time). diff --git a/internal/provider/query_specification_data_source.go b/internal/provider/query_specification_data_source.go index 88c605f3..e725cdd5 100644 --- a/internal/provider/query_specification_data_source.go +++ b/internal/provider/query_specification_data_source.go @@ -84,7 +84,7 @@ func (d *querySpecDataSource) Schema(_ context.Context, _ datasource.SchemaReque }, "granularity": schema.Int64Attribute{ Description: "The time resolution of the query's graph, in seconds. " + - "Valid values must be in between the query's time range /10 at maximum, and /1000 at minimum.", + "Valid values must be in between the query's time range at maximum, and /1000 at minimum.", Optional: true, Validators: []validator.Int64{int64validator.AtLeast(0)}, }, @@ -490,11 +490,11 @@ func (d *querySpecDataSource) Read(ctx context.Context, req datasource.ReadReque ) } if querySpec.TimeRange != nil && querySpec.Granularity != nil { - if *querySpec.Granularity > (*querySpec.TimeRange / 10) { + if *querySpec.Granularity > *querySpec.TimeRange { resp.Diagnostics.AddAttributeError( path.Root("granularity"), "invalid granularity", - "granularity can not be greater than time_range/10", + "granularity can not be greater than time_range", ) } if *querySpec.Granularity != 0 && *querySpec.Granularity < (*querySpec.TimeRange/1000) { diff --git a/internal/provider/query_specification_data_source_test.go b/internal/provider/query_specification_data_source_test.go index f71c50d5..80bdb1b2 100644 --- a/internal/provider/query_specification_data_source_test.go +++ b/internal/provider/query_specification_data_source_test.go @@ -302,10 +302,10 @@ data "honeycombio_query_specification" "test" { Config: ` data "honeycombio_query_specification" "test" { time_range = 120 - granularity = 13 + granularity = 121 }`, PlanOnly: true, - ExpectError: regexp.MustCompile("granularity can not be greater than time_range/10"), + ExpectError: regexp.MustCompile("granularity can not be greater than time_range"), }, { Config: `