Skip to content

Commit

Permalink
fix(stdlib): make nullable timestamp and tags fields in `parse_influx…
Browse files Browse the repository at this point in the history
…db` function (#1011)

* fix: make nullable timestamp and tags fields

* Add changelog entry

Signed-off-by: Jesse Szwedko <[email protected]>

---------

Signed-off-by: Jesse Szwedko <[email protected]>
Co-authored-by: Jesse Szwedko <[email protected]>
  • Loading branch information
jorgehermo9 and jszwedko authored Sep 4, 2024
1 parent b63e099 commit 5f635f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.d/1011.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
For the `parse_influxdb` function the `timestamp` and `tags` fields of returned objects are now
correctly marked as nullable.

authors: jorgehermo9
8 changes: 4 additions & 4 deletions src/stdlib/parse_influxdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl FunctionExpression for ParseInfluxDBFn {
}

fn tags_kind() -> Kind {
Kind::object(Collection::from_unknown(Kind::bytes()))
Kind::object(Collection::from_unknown(Kind::bytes())) | Kind::null()
}

fn gauge_kind() -> Kind {
Expand All @@ -253,7 +253,7 @@ fn metric_kind() -> BTreeMap<Field, Kind> {
btreemap! {
"name" => Kind::bytes(),
"tags" => tags_kind(),
"timestamp" => Kind::timestamp(),
"timestamp" => Kind::timestamp() | Kind::null(),
"kind" => Kind::bytes(),
"gauge" => gauge_kind(),
}
Expand All @@ -276,7 +276,7 @@ mod test {
parse_influxdb => ParseInfluxDB;

influxdb_valid {
args: func_args![ value: format!("cpu,host=A,region=us-west usage_system=64i,usage_user=10u,temperature=50.5,on=true,sleep=false 1590488773254420000") ],
args: func_args![ value: "cpu,host=A,region=us-west usage_system=64i,usage_user=10u,temperature=50.5,on=true,sleep=false 1590488773254420000" ],
want: Ok(Value::from(vec![
Value::from(btreemap! {
"name" => "cpu_usage_system",
Expand Down Expand Up @@ -373,7 +373,7 @@ mod test {
}

influxdb_valid_no_tags {
args: func_args![ value: format!("cpu usage_system=64i,usage_user=10i 1590488773254420000") ],
args: func_args![ value: "cpu usage_system=64i,usage_user=10i 1590488773254420000" ],
want: Ok(Value::from(vec![
Value::from(btreemap! {
"name" => "cpu_usage_system",
Expand Down

0 comments on commit 5f635f9

Please sign in to comment.