influxdb-client 2.7.0 → 2.8.0.pre.6014

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: 24a33716dacd82c821bfc2561b36ed84dd433aae91be982280943ccbc49722c5
4
- data.tar.gz: c6a0a05942ab88f8040afa733e3282e4ca8cce42353c225c75de0c6745a53dd0
3
+ metadata.gz: 630a979d3ca39c4a90ac470965c6700124ee996de1923e5176225b8370024a40
4
+ data.tar.gz: 4160657f219e8c69a1dc1dd0b72769039807543a6c324195d4d559aa058b2bc6
5
5
  SHA512:
6
- metadata.gz: 8207c34e987a48044c9ce6a7380d2b3964ebf517f44af5a2a9de22a0183b7d408732cf6037ef49ceff1b70201643c75090b6f32fdf91bf51085db212f9d66295
7
- data.tar.gz: 8d065bfdb63e7b215a5bde3ef8ad88d430d677327a2d20ed28658c617f297704dadf4278c617eedcd1c8f79ee9cba2c1030912b98df07cf77b49ffdf80120528
6
+ metadata.gz: 6eb28fb15cbd64fddd0380558517b0c593aa6a5824611554586c3973e728e83f4dc11fe68d2e5e69fd86dbba0d347b25c9ec60f7adef9fb03f92e03df547167d
7
+ data.tar.gz: 5568e0d31e6d3dcbcef095291382628df4f9dfd189a28184a21dac42f225442ce03844ee8705c32db9e495bcdf78635f66cf758c2fd8432d5a15da0d3f4541f4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2.8.0 [unreleased]
2
+
3
+ ### Features
4
+ 1. [#118](https://github.com/influxdata/influxdb-client-ruby/pull/118): Added `FluxRecord.row` which stores response data in a array
5
+
1
6
  ## 2.7.0 [2022-07-29]
2
7
 
3
8
  ### Features
@@ -125,8 +125,8 @@ module InfluxDB2
125
125
  token = csv[0]
126
126
 
127
127
  # start new table
128
- if ((ANNOTATIONS.include? token) && !@start_new_table) ||
129
- (@response_mode == InfluxDB2::FluxResponseMode::ONLY_NAMES && @table.nil?)
128
+ if ((ANNOTATIONS.include? token) && !@start_new_table) || (@response_mode ==
129
+ InfluxDB2::FluxResponseMode::ONLY_NAMES && @table.nil?)
130
130
 
131
131
  # Return already parsed DataFrame
132
132
  @start_new_table = true
@@ -187,6 +187,12 @@ module InfluxDB2
187
187
  column.label = csv[i]
188
188
  i += 1
189
189
  end
190
+
191
+ duplicates = table.columns.group_by { :label }.select { |_k, v| v.size > 1 }
192
+
193
+ warning = "The response contains columns with duplicated names: #{duplicates.keys.join(', ')}
194
+ You should use the 'FluxRecord.row to access your data instead of 'FluxRecord.values' hash."
195
+ puts warning unless duplicates.empty?
190
196
  end
191
197
 
192
198
  def _parse_values(csv)
@@ -234,7 +240,9 @@ module InfluxDB2
234
240
  table.columns.each do |flux_column|
235
241
  column_name = flux_column.label
236
242
  str_val = csv[flux_column.index + 1]
237
- record.values[column_name] = _to_value(str_val, flux_column)
243
+ value = _to_value(str_val, flux_column)
244
+ record.values[column_name] = value
245
+ record.row.push(value)
238
246
  end
239
247
 
240
248
  record
@@ -26,6 +26,7 @@ module InfluxDB2
26
26
  @columns = []
27
27
  @records = []
28
28
  end
29
+
29
30
  attr_reader :columns, :records
30
31
 
31
32
  # A table's group key is subset of the entire columns dataset that assigned to the table.
@@ -46,11 +47,14 @@ module InfluxDB2
46
47
  class FluxRecord
47
48
  # @param [Integer] table the index of table which contains the record
48
49
  # @param [Hash] values tuple of values
49
- def initialize(table, values: nil)
50
+ # @param [Array] row record columns
51
+ def initialize(table, values: nil, row: nil)
50
52
  @table = table
51
53
  @values = values || {}
54
+ @row = row || []
52
55
  end
53
- attr_reader :table, :values
56
+
57
+ attr_reader :table, :values, :row
54
58
  attr_writer :table
55
59
 
56
60
  # @return [Time] the inclusive lower time bound of all records
@@ -93,6 +97,7 @@ module InfluxDB2
93
97
  @group = group
94
98
  @default_value = default_value
95
99
  end
100
+
96
101
  attr_reader :index, :label, :data_type, :group, :default_value
97
102
  attr_writer :index, :label, :data_type, :group, :default_value
98
103
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module InfluxDB2
22
- VERSION = '2.7.0'.freeze
22
+ VERSION = '2.8.0'.freeze
23
23
  end
@@ -506,4 +506,24 @@ class FluxCsvParserErrorTest < MiniTest::Test
506
506
  assert_equal '11', tables[0].records[0].values['value1']
507
507
  assert_equal 'west', tables[0].records[0].values['region']
508
508
  end
509
+
510
+ def test_parse_duplicate_column_names
511
+ data = '#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double
512
+ #group,false,false,true,true,false,true,true,false
513
+ #default,_result,,,,,,,
514
+ ,result,table,_start,_stop,_time,_measurement,location,result
515
+ ,,0,2022-09-13T06:14:40.469404272Z,2022-09-13T06:24:40.469404272Z,2022-09-13T06:24:33.746Z,my_measurement,Prague,25.3
516
+ ,,0,2022-09-13T06:14:40.469404272Z,2022-09-13T06:24:40.469404272Z,2022-09-13T06:24:39.299Z,my_measurement,Prague,25.3
517
+ ,,0,2022-09-13T06:14:40.469404272Z,2022-09-13T06:24:40.469404272Z,2022-09-13T06:24:40.454Z,my_measurement,Prague,25.3'
518
+
519
+ tables = InfluxDB2::FluxCsvParser.new(data, stream: false, response_mode: InfluxDB2::FluxResponseMode::ONLY_NAMES)
520
+ .parse
521
+ .tables
522
+ assert_equal 1, tables.size
523
+ assert_equal 8, tables[0].columns.size
524
+ assert_equal 3, tables[0].records.size
525
+ assert_equal 7, tables[0].records[0].values.size
526
+ assert_equal 8, tables[0].records[0].row.size
527
+ assert_equal 25.3, tables[0].records[0].row[7]
528
+ end
509
529
  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: 2.7.0
4
+ version: 2.8.0.pre.6014
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Bednar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-29 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -180,11 +180,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: 2.2.0
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - ">="
183
+ - - ">"
184
184
  - !ruby/object:Gem::Version
185
- version: '0'
185
+ version: 1.3.1
186
186
  requirements: []
187
- rubygems_version: 3.0.3.1
187
+ rubygems_version: 3.3.11
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Ruby library for InfluxDB 2.