diff --git a/a.flux b/a.flux new file mode 100644 index 0000000000..8368c41d00 --- /dev/null +++ b/a.flux @@ -0,0 +1,5 @@ +import "array" +import "internal/debug" + +array.from(rows: [{}]) + |> debug.sink() diff --git a/libflux/go/libflux/buildinfo.gen.go b/libflux/go/libflux/buildinfo.gen.go index 562e959ab1..3365103937 100644 --- a/libflux/go/libflux/buildinfo.gen.go +++ b/libflux/go/libflux/buildinfo.gen.go @@ -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", diff --git a/stdlib/array/array.flux b/stdlib/array/array.flux index 82c4f3b31f..88a9cee8fa 100644 --- a/stdlib/array/array.flux +++ b/stdlib/array/array.flux @@ -12,7 +12,7 @@ package array // records must have the same keys and data types. // // ## Parameters -// - rows: Array of records to construct a table with. +// - rows: Array of records to construct a table with. Default is the piped-forward array (`<-`). // // ## Examples // @@ -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. // diff --git a/stdlib/array/from_test.flux b/stdlib/array/from_test.flux index 282cc962a6..39f68ebcd0 100644 --- a/stdlib/array/from_test.flux +++ b/stdlib/array/from_test.flux @@ -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() +}