influxdb-client 2.8.0.pre.5729 → 2.8.0.pre.6014

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b30371fb8850853e21cfafeb46e0aa054060cfe740e32c0064e3a5d6af29b67
4
- data.tar.gz: 19c9bfeaeb7c61dfded00dd2eaa293e25a4384528b507c130b453c8d315d5241
3
+ metadata.gz: 630a979d3ca39c4a90ac470965c6700124ee996de1923e5176225b8370024a40
4
+ data.tar.gz: 4160657f219e8c69a1dc1dd0b72769039807543a6c324195d4d559aa058b2bc6
5
5
  SHA512:
6
- metadata.gz: f1a7a5374c3a722f8cffae085cf92438f198cb0c6747eca069d066a6c5e7f9d6bbe0c875a9bfe6de0e9855bf063728f1707d0ecbe1cc270682cf974272d68772
7
- data.tar.gz: '05971d819ada2ff62de2bf77f023048256d00d16bd157d2839ae893c2625be4e94f82859599347b02a2d164a971ed7858c9fb44c47410af63f81e68af014c877'
6
+ metadata.gz: 6eb28fb15cbd64fddd0380558517b0c593aa6a5824611554586c3973e728e83f4dc11fe68d2e5e69fd86dbba0d347b25c9ec60f7adef9fb03f92e03df547167d
7
+ data.tar.gz: 5568e0d31e6d3dcbcef095291382628df4f9dfd189a28184a21dac42f225442ce03844ee8705c32db9e495bcdf78635f66cf758c2fd8432d5a15da0d3f4541f4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## 2.8.0 [unreleased]
2
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
+
3
6
  ## 2.7.0 [2022-07-29]
4
7
 
5
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
@@ -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.8.0.pre.5729
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