influxdb-client 1.10.0.pre.1373 → 1.10.0.pre.1408

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: ee09c0b487146566919ffec3a0d716dd59fbe9b2e77c5239c69217bc224f74f7
4
- data.tar.gz: 9b6037a92f586e4a9570ae73c99f6c8fdaff7775cc39fe45e44698d41668adaa
3
+ metadata.gz: '013876e9eaa68bd87570e052b14006ac79fd316ddaf0cf71173b8db024ea271e'
4
+ data.tar.gz: 24c018d6b548cd9d2acd1b6f7b179976862cd01dcf7e8b136fb3f4ef19bcaa74
5
5
  SHA512:
6
- metadata.gz: 369c9541a691d5a61017199cefdf8cf02d897991bf96d1883bae59853146b2500c0b7dd4d3c778ffe2940e875338de56145f7eb993417298227e8b04339135db
7
- data.tar.gz: c58c29b507c07a93c0ab9011aa2c5c8fbd390bc179687ee655cfcc68e53985889d0bd4f0e7262639ee3e04a5a4fe415a10007aeb659eebac9e8c2ea94da4c229
6
+ metadata.gz: c2b4774d72b7b64c6c5cafef67159fd3abb4b1f3d10d3d3c3d51950a12e27776ab216cc62216c4cf190d1718f7a7dabf20fd80db35e4ea01a53306d6331bafe9
7
+ data.tar.gz: 8bcced7536d8495664de2e5ed33da09f980934ae08b3a5bc867383c7edf768334c4bc3192ad1b7d8ccf628b662d5fa6c1342d04ab7844fabb66a160f86e9cce8
@@ -1,5 +1,8 @@
1
1
  ## 1.10.0 [unreleased]
2
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
+
3
6
  ## 1.9.0 [2020-10-30]
4
7
 
5
8
  ### Features
@@ -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 == '#datatype'
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 == '#datatype'
130
+ if token == ANNOTATION_DATATYPE
124
131
  _add_data_types(@table, csv)
125
132
 
126
- elsif token == '#group'
127
- _add_groups(@table, csv)
133
+ elsif token == ANNOTATION_GROUP
134
+ @groups = csv
128
135
 
129
- elsif token == '#default'
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
@@ -424,4 +424,21 @@ class FluxCsvParserErrorTest < MiniTest::Test
424
424
  assert_equal 7, tables[0].records.size
425
425
  assert_equal 7, tables[1].records.size
426
426
  end
427
+
428
+ def test_parse_export_from_ui
429
+ data = "#group,false,false,true,true,true,true,true,true,false,false\n" \
430
+ "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,double,dateTime:RFC3339\n" \
431
+ "#default,mean,,,,,,,,,\n" \
432
+ ",result,table,_start,_stop,_field,_measurement,city,location,_value,_time\n" \
433
+ ",,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" \
434
+ ",,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"
435
+
436
+ tables = InfluxDB2::FluxCsvParser.new(data).parse.tables
437
+ assert_equal 2, tables.size
438
+ assert_equal 1, tables[0].records.size
439
+ assert_equal false, tables[0].columns[0].group
440
+ assert_equal false, tables[0].columns[1].group
441
+ assert_equal true, tables[0].columns[2].group
442
+ assert_equal 1, tables[1].records.size
443
+ end
427
444
  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.10.0.pre.1373
4
+ version: 1.10.0.pre.1408
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-09 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler