influxdb-client 1.2.0.pre.591 → 1.2.0.pre.604

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab9dc109c0da3edd23cb1d54412a102e47f21a2c149c359637051be8aa9b894f
4
- data.tar.gz: c2985b21be98321a305fe68dc4ffa40fcb89b5456605ca014c24767de4563085
3
+ metadata.gz: ccc248b0ce9d417db8099be667f01f83d6e2a8f79f507cc5969d61272242b29e
4
+ data.tar.gz: 5a5dbe9e660cfe1206d98008d4965b0de1fc1c4ec5812e217ca49a58737ac0a2
5
5
  SHA512:
6
- metadata.gz: d83d15691520858955c0f800d9cc753c2a5a1f83e2321fbab81068a576e9cd20b8146c39309d9ba3d5b1ee97030396d43da27a8f34e342286da13b27b4f555be
7
- data.tar.gz: 4c5ad67e4d11d4665881ea29f42e09b2d3d7800a62b2e664cce202d4c61144d55028f21de1e0f9581e64a3b80d96ed701e2739e0c39a9ba5b8fe2828a19f0076
6
+ metadata.gz: 5b468226ff6d5b50ec6bb9e2605f0f8b7ea59ded39a9ddc8267a863084d30a568711cfb2bda845b6b011891aed8d2440681b257cd7c5e364b67e278386ee511d
7
+ data.tar.gz: 0b1864cb3f0a621dd40bdba72111ef03bd1cde8882e399fb757bab37e8762518e61d99505c94b81f01e49b431fd112966d9cacab3e604e47a185e2dc69979307
data/.rubocop.yml CHANGED
@@ -27,7 +27,7 @@ AllCops:
27
27
  Metrics/LineLength:
28
28
  Max: 120
29
29
  Metrics/MethodLength:
30
- Max: 30
30
+ Max: 50
31
31
  Metrics/ClassLength:
32
32
  Max: 200
33
33
  Metrics/AbcSize:
data/CHANGELOG.md CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  ### Bugs
9
9
  1. [#22](https://github.com/influxdata/influxdb-client-ruby/pull/22): Fixed batch write
10
+ 1. [#28](https://github.com/influxdata/influxdb-client-ruby/pull/28): Correctly parse CSV where multiple results include multiple tables
10
11
 
11
12
  ## 1.1.0 [2020-02-14]
12
13
 
@@ -51,6 +51,7 @@ module InfluxDB2
51
51
  @tables = {}
52
52
 
53
53
  @table_index = 0
54
+ @table_id = -1
54
55
  @start_new_table = false
55
56
  @table = nil
56
57
  @parsing_state_error = false
@@ -113,6 +114,7 @@ module InfluxDB2
113
114
  @tables[@table_index] = @table unless @stream
114
115
 
115
116
  @table_index += 1
117
+ @table_id = -1
116
118
  elsif @table.nil?
117
119
  raise FluxCsvParserError, 'Unable to parse CSV response. FluxTable definition was not found.'
118
120
  end
@@ -173,9 +175,10 @@ module InfluxDB2
173
175
  return
174
176
  end
175
177
 
176
- @current_index = csv[2].to_i
178
+ current_id = csv[2].to_i
179
+ @table_id = current_id if @table_id == -1
177
180
 
178
- if @current_index > (@table_index - 1)
181
+ if @table_id != current_id
179
182
  # create new table with previous column headers settings
180
183
  @flux_columns = @table.columns
181
184
  @table = InfluxDB2::FluxTable.new
@@ -186,6 +189,7 @@ module InfluxDB2
186
189
 
187
190
  @tables[@table_index] = @table unless @stream
188
191
  @table_index += 1
192
+ @table_id = current_id
189
193
  end
190
194
 
191
195
  flux_record = _parse_record(@table_index - 1, @table, csv)
@@ -323,4 +323,79 @@ class FluxCsvParserErrorTest < MiniTest::Test
323
323
 
324
324
  assert_equal 'Unable to parse CSV response. FluxTable definition was not found.', error.message
325
325
  end
326
+
327
+ def test_multiple_queries
328
+ data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
329
+ "#group,false,false,true,true,true,true,false,false,true\n" \
330
+ "#default,t1,,,,,,,,\n" \
331
+ ",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
332
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
333
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
334
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
335
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
336
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test1\n" \
337
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test1\n" \
338
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test1\n" \
339
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test2\n" \
340
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test2\n" \
341
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test2\n" \
342
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test2\n" \
343
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test2\n" \
344
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test2\n" \
345
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test2\n" \
346
+ "\n" \
347
+ "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
348
+ "#group,false,false,true,true,true,true,false,false,true\n" \
349
+ "#default,t2,,,,,,,,\n" \
350
+ ",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
351
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
352
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
353
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
354
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
355
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test1\n" \
356
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test1\n" \
357
+ ",,0,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test1\n" \
358
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test2\n" \
359
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test2\n" \
360
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test2\n" \
361
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test2\n" \
362
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test2\n" \
363
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test2\n" \
364
+ ',,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test2'
365
+
366
+ tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
367
+
368
+ assert_equal 4, tables.size
369
+ assert_equal 7, tables[0].records.size
370
+ assert_equal 7, tables[1].records.size
371
+ assert_equal 7, tables[2].records.size
372
+ assert_equal 7, tables[3].records.size
373
+ end
374
+
375
+ def test_table_not_start_at_zero
376
+ data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \
377
+ "#group,false,false,true,true,true,true,false,false,true\n" \
378
+ "#default,t1,,,,,,,,\n" \
379
+ ",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \
380
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \
381
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \
382
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \
383
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \
384
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test1\n" \
385
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test1\n" \
386
+ ",,1,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test1\n" \
387
+ ",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test2\n" \
388
+ ",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test2\n" \
389
+ ",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test2\n" \
390
+ ",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test2\n" \
391
+ ",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:26:40Z,2,test2\n" \
392
+ ",,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:28:20Z,2,test2\n" \
393
+ ',,2,value,pct,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:30:00Z,2,test2\n'
394
+
395
+ tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
396
+
397
+ assert_equal 2, tables.size
398
+ assert_equal 7, tables[0].records.size
399
+ assert_equal 7, tables[1].records.size
400
+ end
326
401
  end
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.2.0.pre.591
4
+ version: 1.2.0.pre.604
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-02-27 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler