influxdb-client 1.9.0 → 1.10.0.pre.1451
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/CHANGELOG.md +11 -0
- data/README.md +2 -2
- data/bin/influxdb-restart.sh +1 -1
- data/lib/influxdb2/client/flux_csv_parser.rb +14 -6
- data/lib/influxdb2/client/version.rb +1 -1
- data/test/influxdb/flux_csv_parser_test.rb +68 -2
- data/test/influxdb/query_api_integration_test.rb +21 -0
- data/test/influxdb/query_api_test.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b48922639f94e9e7675f95f0bbd38fd4412fafa2ec628b3259d537593d081fb
|
4
|
+
data.tar.gz: 4fcaa586653829d4f0770614b2e25d096a14abe9e3a882e47c22b138a1bccbfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ce3a69f45a16ca75aebe7e028184360a3800501cf4ec46ba2a0cca423dfd5b2370d95df8cdd990bb22c9508136c0ab9590d9f30e6cc23959b583d6f5882bd25
|
7
|
+
data.tar.gz: e2dcb0883913a4bc05401badd02347125dfe795600c98e7d5e83b088009a185adfc153223681eb56bd0b74de06b6708f611821b9412f33ad6e08323d4e356d21
|
data/.circleci/config.yml
CHANGED
@@ -78,7 +78,7 @@ jobs:
|
|
78
78
|
default: &default-ruby-image "circleci/ruby:2.6-stretch"
|
79
79
|
influxdb-image:
|
80
80
|
type: string
|
81
|
-
default: &default-influxdb-image "influxdb:
|
81
|
+
default: &default-influxdb-image "influxdb:v2.0.2"
|
82
82
|
docker:
|
83
83
|
- image: << parameters.ruby-image >>
|
84
84
|
- image: &influx-image quay.io/influxdb/<< parameters.influxdb-image >>
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 1.10.0 [unreleased]
|
2
|
+
|
3
|
+
### Features
|
4
|
+
1. [#59](https://github.com/influxdata/influxdb-client-ruby/pull/59): CSV parser is able to parse export from UI
|
5
|
+
|
6
|
+
### CI
|
7
|
+
1. [#62](https://github.com/influxdata/influxdb-client-ruby/pull/62): Updated default docker image to v2.0.2
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
1. [#61](https://github.com/influxdata/influxdb-client-ruby/pull/61): Query results has precision with nanosecond, e.g. '1970-01-01T00:00:00.000123456+00:00'
|
11
|
+
|
1
12
|
## 1.9.0 [2020-10-30]
|
2
13
|
|
3
14
|
### Features
|
data/README.md
CHANGED
@@ -194,7 +194,7 @@ The data could be written as:
|
|
194
194
|
|
195
195
|
1. `String` that is formatted as a InfluxDB's line protocol
|
196
196
|
1. `Hash` with keys: name, tags, fields and time
|
197
|
-
1. [Data Point](https://github.com/influxdata/influxdb-client-ruby/blob/master/lib/
|
197
|
+
1. [Data Point](https://github.com/influxdata/influxdb-client-ruby/blob/master/lib/influxdb2/client/point.rb#L28) structure
|
198
198
|
1. `Array` of above items
|
199
199
|
|
200
200
|
```ruby
|
@@ -274,7 +274,7 @@ Server availability can be checked using the `client.health` method. That is equ
|
|
274
274
|
|
275
275
|
### InfluxDB 1.8 API compatibility
|
276
276
|
|
277
|
-
[InfluxDB 1.8.0 introduced forward compatibility APIs](https://docs.influxdata.com/influxdb/
|
277
|
+
[InfluxDB 1.8.0 introduced forward compatibility APIs](https://docs.influxdata.com/influxdb/v1.8/tools/api/#influxdb-2-0-api-compatibility-endpoints) for InfluxDB 2.0. This allow you to easily move from InfluxDB 1.x to InfluxDB 2.0 Cloud or open source.
|
278
278
|
|
279
279
|
The following forward compatible APIs are available:
|
280
280
|
|
data/bin/influxdb-restart.sh
CHANGED
@@ -27,7 +27,7 @@ DEFAULT_DOCKER_REGISTRY="quay.io/influxdb/"
|
|
27
27
|
DOCKER_REGISTRY="${DOCKER_REGISTRY:-$DEFAULT_DOCKER_REGISTRY}"
|
28
28
|
|
29
29
|
DEFAULT_INFLUXDB_V2_REPOSITORY="influxdb"
|
30
|
-
DEFAULT_INFLUXDB_V2_VERSION="
|
30
|
+
DEFAULT_INFLUXDB_V2_VERSION="v2.0.2"
|
31
31
|
INFLUXDB_V2_REPOSITORY="${INFLUXDB_V2_REPOSITORY:-$DEFAULT_INFLUXDB_V2_REPOSITORY}"
|
32
32
|
INFLUXDB_V2_VERSION="${INFLUXDB_V2_VERSION:-$DEFAULT_INFLUXDB_V2_VERSION}"
|
33
33
|
INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}${INFLUXDB_V2_REPOSITORY}:${INFLUXDB_V2_VERSION}
|
@@ -54,6 +54,7 @@ module InfluxDB2
|
|
54
54
|
@table_id = -1
|
55
55
|
@start_new_table = false
|
56
56
|
@table = nil
|
57
|
+
@groups = []
|
57
58
|
@parsing_state_error = false
|
58
59
|
|
59
60
|
@closed = false
|
@@ -102,14 +103,20 @@ module InfluxDB2
|
|
102
103
|
|
103
104
|
private
|
104
105
|
|
106
|
+
ANNOTATION_DATATYPE = '#datatype'.freeze
|
107
|
+
ANNOTATION_GROUP = '#group'.freeze
|
108
|
+
ANNOTATION_DEFAULT = '#default'.freeze
|
109
|
+
ANNOTATIONS = [ANNOTATION_DATATYPE, ANNOTATION_GROUP, ANNOTATION_DEFAULT].freeze
|
110
|
+
|
105
111
|
def _parse_line(csv)
|
106
112
|
token = csv[0]
|
107
113
|
|
108
114
|
# start new table
|
109
|
-
if token
|
115
|
+
if (ANNOTATIONS.include? token) && !@start_new_table
|
110
116
|
# Return already parsed DataFrame
|
111
117
|
@start_new_table = true
|
112
118
|
@table = InfluxDB2::FluxTable.new
|
119
|
+
@groups = []
|
113
120
|
|
114
121
|
@tables[@table_index] = @table unless @stream
|
115
122
|
|
@@ -120,13 +127,13 @@ module InfluxDB2
|
|
120
127
|
end
|
121
128
|
|
122
129
|
# # datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string
|
123
|
-
if token ==
|
130
|
+
if token == ANNOTATION_DATATYPE
|
124
131
|
_add_data_types(@table, csv)
|
125
132
|
|
126
|
-
elsif token ==
|
127
|
-
|
133
|
+
elsif token == ANNOTATION_GROUP
|
134
|
+
@groups = csv
|
128
135
|
|
129
|
-
elsif token ==
|
136
|
+
elsif token == ANNOTATION_DEFAULT
|
130
137
|
_add_default_empty_values(@table, csv)
|
131
138
|
else
|
132
139
|
_parse_values(csv)
|
@@ -170,6 +177,7 @@ module InfluxDB2
|
|
170
177
|
def _parse_values(csv)
|
171
178
|
# parse column names
|
172
179
|
if @start_new_table
|
180
|
+
_add_groups(@table, @groups)
|
173
181
|
_add_column_names_and_tags(@table, csv)
|
174
182
|
@start_new_table = false
|
175
183
|
return
|
@@ -236,7 +244,7 @@ module InfluxDB2
|
|
236
244
|
when 'base64Binary'
|
237
245
|
Base64.decode64(str_val)
|
238
246
|
when 'dateTime:RFC3339', 'dateTime:RFC3339Nano'
|
239
|
-
Time.parse(str_val).to_datetime.rfc3339
|
247
|
+
Time.parse(str_val).to_datetime.rfc3339(9)
|
240
248
|
else
|
241
249
|
str_val
|
242
250
|
end
|
@@ -155,10 +155,33 @@ class FluxCsvParserTest < MiniTest::Test
|
|
155
155
|
tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
|
156
156
|
records = tables[0].records
|
157
157
|
|
158
|
-
assert_equal
|
158
|
+
assert_equal _parse_time('1970-01-01T00:00:10Z'), records[0].values['value']
|
159
159
|
assert_nil records[1].values['value']
|
160
160
|
end
|
161
161
|
|
162
|
+
def test_mapping_rfc3339_nano
|
163
|
+
data = "#group,false,false,true,true,false,false,true,true,true,true,true,true\n" \
|
164
|
+
'#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,' \
|
165
|
+
"string,string,string,string,string,string\n" \
|
166
|
+
"#default,mean,,,,,,,,,,,\n" \
|
167
|
+
",result,table,_start,_stop,_time,_value,_field,_measurement,language,license,name,owner\n" \
|
168
|
+
',,0,2020-11-02T07:29:49.55050738Z,2020-12-02T07:29:49.55050738Z,2020-11-02T09:00:00Z,9,' \
|
169
|
+
"stars,github_repository,Ruby,MIT License,influxdb-client-ruby,influxdata\n"
|
170
|
+
|
171
|
+
tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
|
172
|
+
records = tables[0].records
|
173
|
+
|
174
|
+
assert_equal 9, records[0].values['_value']
|
175
|
+
start = Time.parse(records[0].values['_start'])
|
176
|
+
assert_equal 2020, start.year
|
177
|
+
assert_equal 11, start.month
|
178
|
+
assert_equal 2, start.day
|
179
|
+
assert_equal 7, start.hour
|
180
|
+
assert_equal 29, start.min
|
181
|
+
assert_equal 49, start.sec
|
182
|
+
assert_equal '55050738', start.strftime('%8N')
|
183
|
+
end
|
184
|
+
|
162
185
|
def test_mapping_duration
|
163
186
|
data = '#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339' \
|
164
187
|
",dateTime:RFC3339,long,string,string,string,duration\n" \
|
@@ -209,7 +232,7 @@ class FluxCsvParserTest < MiniTest::Test
|
|
209
232
|
private
|
210
233
|
|
211
234
|
def _parse_time(time)
|
212
|
-
Time.parse(time).to_datetime.rfc3339
|
235
|
+
Time.parse(time).to_datetime.rfc3339(9)
|
213
236
|
end
|
214
237
|
|
215
238
|
def _assert_record(flux_record, values: nil, size: 0, value: nil)
|
@@ -324,6 +347,32 @@ class FluxCsvParserErrorTest < MiniTest::Test
|
|
324
347
|
assert_equal 'Unable to parse CSV response. FluxTable definition was not found.', error.message
|
325
348
|
end
|
326
349
|
|
350
|
+
def test_response_with_error
|
351
|
+
data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
|
352
|
+
"#group,false,false,true,true,true,true,false,false,true\n" \
|
353
|
+
"#default,t1,,,,,,,,\n" \
|
354
|
+
",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
|
355
|
+
",,0,value,python,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
|
356
|
+
",,0,value,python,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
|
357
|
+
",,0,value,python,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
|
358
|
+
",,0,value,python,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
|
359
|
+
"\n" \
|
360
|
+
"#datatype,string,string\n" \
|
361
|
+
"#group,true,true\n" \
|
362
|
+
"#default,,\n" \
|
363
|
+
",error,reference\n" \
|
364
|
+
',"engine: unknown field type for value: xyz",'
|
365
|
+
|
366
|
+
parser = InfluxDB2::FluxCsvParser.new(data)
|
367
|
+
|
368
|
+
error = assert_raises InfluxDB2::FluxQueryError do
|
369
|
+
parser.parse
|
370
|
+
end
|
371
|
+
|
372
|
+
assert_equal 'engine: unknown field type for value: xyz', error.message
|
373
|
+
assert_equal 0, error.reference
|
374
|
+
end
|
375
|
+
|
327
376
|
def test_multiple_queries
|
328
377
|
data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
|
329
378
|
"#group,false,false,true,true,true,true,false,false,true\n" \
|
@@ -398,4 +447,21 @@ class FluxCsvParserErrorTest < MiniTest::Test
|
|
398
447
|
assert_equal 7, tables[0].records.size
|
399
448
|
assert_equal 7, tables[1].records.size
|
400
449
|
end
|
450
|
+
|
451
|
+
def test_parse_export_from_ui
|
452
|
+
data = "#group,false,false,true,true,true,true,true,true,false,false\n" \
|
453
|
+
"#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,double,dateTime:RFC3339\n" \
|
454
|
+
"#default,mean,,,,,,,,,\n" \
|
455
|
+
",result,table,_start,_stop,_field,_measurement,city,location,_value,_time\n" \
|
456
|
+
",,0,1754-06-26T11:30:27.613654848Z,2040-10-27T12:13:46.485Z,temp,weather,Lon,us,30,1975-09-01T16:59:54.5Z\n" \
|
457
|
+
",,1,1754-06-26T11:30:27.613654848Z,2040-10-27T12:13:46.485Z,temp,weather,Lon,us,86,1975-09-01T16:59:54.5Z\n"
|
458
|
+
|
459
|
+
tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
|
460
|
+
assert_equal 2, tables.size
|
461
|
+
assert_equal 1, tables[0].records.size
|
462
|
+
assert_equal false, tables[0].columns[0].group
|
463
|
+
assert_equal false, tables[0].columns[1].group
|
464
|
+
assert_equal true, tables[0].columns[2].group
|
465
|
+
assert_equal 1, tables[1].records.size
|
466
|
+
end
|
401
467
|
end
|
@@ -55,4 +55,25 @@ class QueryApiIntegrationTest < MiniTest::Test
|
|
55
55
|
assert_equal 2, record.value
|
56
56
|
assert_equal 'level', record.field
|
57
57
|
end
|
58
|
+
|
59
|
+
def test_parsed_time_precision
|
60
|
+
now = Time.now.utc
|
61
|
+
measurement = 'h2o_query_' + now.to_i.to_s + now.nsec.to_s
|
62
|
+
|
63
|
+
@client.create_write_api.write(data: InfluxDB2::Point.new(name: measurement)
|
64
|
+
.add_field('value', 10)
|
65
|
+
.time(123_456, InfluxDB2::WritePrecision::NANOSECOND))
|
66
|
+
|
67
|
+
result = @client.create_query_api.query(query: 'from(bucket: "my-bucket") |> range(start: 0, stop: now()) '\
|
68
|
+
"|> filter(fn: (r) => r._measurement == \"#{measurement}\")")
|
69
|
+
|
70
|
+
assert_equal 1, result.size
|
71
|
+
|
72
|
+
records = result[0].records
|
73
|
+
assert_equal 1, records.size
|
74
|
+
|
75
|
+
record = records[0]
|
76
|
+
assert_equal 10, record.value
|
77
|
+
assert_equal '1970-01-01T00:00:00.000123456+00:00', record.values['_time']
|
78
|
+
end
|
58
79
|
end
|
@@ -67,7 +67,7 @@ class QueryApiTest < MiniTest::Test
|
|
67
67
|
|
68
68
|
record1 = result[0].records[0]
|
69
69
|
|
70
|
-
assert_equal Time.parse('1970-01-01T00:00:10Z').to_datetime.rfc3339, record1.time
|
70
|
+
assert_equal Time.parse('1970-01-01T00:00:10Z').to_datetime.rfc3339(9), record1.time
|
71
71
|
assert_equal 'mem', record1.measurement
|
72
72
|
assert_equal 10, record1.value
|
73
73
|
assert_equal 'free', record1.field
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0.pre.1451
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,9 +198,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: 2.2.0
|
199
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
|
-
- - "
|
201
|
+
- - ">"
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version:
|
203
|
+
version: 1.3.1
|
204
204
|
requirements: []
|
205
205
|
rubygems_version: 3.0.3
|
206
206
|
signing_key:
|