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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/influxdb2/client/flux_csv_parser.rb +11 -3
- data/lib/influxdb2/client/flux_table.rb +7 -2
- data/test/influxdb/flux_csv_parser_test.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630a979d3ca39c4a90ac470965c6700124ee996de1923e5176225b8370024a40
|
4
|
+
data.tar.gz: 4160657f219e8c69a1dc1dd0b72769039807543a6c324195d4d559aa058b2bc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eb28fb15cbd64fddd0380558517b0c593aa6a5824611554586c3973e728e83f4dc11fe68d2e5e69fd86dbba0d347b25c9ec60f7adef9fb03f92e03df547167d
|
7
|
+
data.tar.gz: 5568e0d31e6d3dcbcef095291382628df4f9dfd189a28184a21dac42f225442ce03844ee8705c32db9e495bcdf78635f66cf758c2fd8432d5a15da0d3f4541f4
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
11
|
+
date: 2022-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|