Skip to content

Commit

Permalink
feat(array): add support to pipe into array.from
Browse files Browse the repository at this point in the history
With this change you can now pipe the `rows` argument into the
array.from function.
  • Loading branch information
nathanielc committed Sep 2, 2022
1 parent f78ffe7 commit 2904eb8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libflux/go/libflux/buildinfo.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ var sourceHashes = map[string]string{
"libflux/flux/templates/package.html": "635e1d638ad1a430f3894ff0a458572ca3c4dc6b9cec2c57fe771443849e1402",
"libflux/flux/templates/value.html": "2af699af2535f83635acbc75c92d2ee941c2335350fc7e82ceb2dccf479360bf",
"libflux/include/influxdata/flux.h": "a50070b13297a6427fc47488d4cfbf18d3c804a2c3cb6f7a6f918b0ff29715a8",
"stdlib/array/array.flux": "232cffbcddea8959e2de8a815d3e1d2b667450085c0cc6c27677a05ea4323cc6",
"stdlib/array/array.flux": "ce86be4dbe34da8476b3fc011ae7f766cf477c4090dc3d953e99cfd9599af71e",
"stdlib/array/array_test.flux": "c4281ef1128ba6164c16f1dcb1b051d2231fe39617f23a070ae1942b5ddb70d5",
"stdlib/array/from_test.flux": "450810d4a5a8cc443462172fa7a0dee18f4a2c48bab1948a32a1c42935137f25",
"stdlib/array/from_test.flux": "688a3593d27aed7110d016c0b7634808dee533311d4349669a1104bc50a9f3e7",
"stdlib/bitwise/bitwise.flux": "580114d80074f27c12c28b5832e52269cd8f3a99890a53617c25aa778fd04acd",
"stdlib/bitwise/bitwise_test.flux": "150d847157570fe95f1ddeb65c75b7e30bb5fa8422df281d72b889b62e8db54c",
"stdlib/contrib/RohanSreerama5/naiveBayesClassifier/bayes_test.flux": "e02e637a7b50a0e1fb977491c349c547f9ab1d1daef4999735e73051c14291c1",
Expand Down
2 changes: 1 addition & 1 deletion stdlib/array/array.flux
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ package array
//
// ## Metadata
// tags: inputs
builtin from : (rows: [A]) => stream[A] where A: Record
builtin from : (<-rows: [A]) => stream[A] where A: Record

// concat appends two arrays and returns a new array.
//
Expand Down
66 changes: 66 additions & 0 deletions stdlib/array/from_test.flux
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,69 @@ testcase from_group {

testing.diff(want, got) |> yield()
}
testcase from_pipe {
want =
csv.from(
csv:
"
#datatype,string,long,string,string,string,dateTime:RFC3339,boolean
#group,false,false,false,false,false,false,false
#default,_result,,,,,,
,result,table,_measurement,_field,t0,_time,_value
,,0,m0,f0,tagvalue,2018-12-19T22:13:30Z,false
,,0,m0,f0,tagvalue,2018-12-19T22:13:40Z,true
,,0,m0,f0,tagvalue,2018-12-19T22:13:50Z,false
,,0,m0,f0,tagvalue,2018-12-19T22:14:00Z,false
,,0,m0,f0,tagvalue,2018-12-19T22:14:10Z,true
,,0,m0,f0,tagvalue,2018-12-19T22:14:20Z,true
",
)
got =
[
{
_measurement: "m0",
_field: "f0",
t0: "tagvalue",
_time: 2018-12-19T22:13:30Z,
_value: false,
},
{
_measurement: "m0",
_field: "f0",
t0: "tagvalue",
_time: 2018-12-19T22:13:40Z,
_value: true,
},
{
_measurement: "m0",
_field: "f0",
t0: "tagvalue",
_time: 2018-12-19T22:13:50Z,
_value: false,
},
{
_measurement: "m0",
_field: "f0",
t0: "tagvalue",
_time: 2018-12-19T22:14:00Z,
_value: false,
},
{
_measurement: "m0",
_field: "f0",
t0: "tagvalue",
_time: 2018-12-19T22:14:10Z,
_value: true,
},
{
_measurement: "m0",
_field: "f0",
t0: "tagvalue",
_time: 2018-12-19T22:14:20Z,
_value: true,
},
]
|> array.from()

testing.diff(want, got) |> yield()
}

0 comments on commit 2904eb8

Please sign in to comment.