├── .codecov.yml ├── .dockerignore ├── .editorconfig ├── .gitattributes ├── .github ├── pull_request_template.md ├── semantic.yml └── workflows │ ├── semantic.yml │ └── stale.yml ├── .gitignore ├── .goreleaser.yml ├── .hugo_build.lock ├── .thurston.asc ├── CONTRIBUTING.md ├── Dockerfile_build ├── LICENSE ├── Makefile ├── README.md ├── a.flux ├── array ├── array.go ├── array_test.go ├── binary.gen.go ├── binary.gen.go.tmpl ├── binary.go ├── binary.tmpldata ├── builder.gen.go ├── builder.gen.go.tmpl ├── builder.go ├── conditional.gen.go ├── conditional.gen.go.tmpl ├── repeat.gen.go ├── repeat.gen.go.tmpl ├── repeat.go ├── repeat_test.go ├── types.tmpldata ├── unary.gen.go ├── unary.gen.go.tmpl └── unary.tmpldata ├── arrow ├── allocator.go ├── arrow_test.go ├── bool.go ├── float.go ├── int.go ├── repeat.go ├── string.go ├── table_buffer.go ├── uint.go └── utils.go ├── ast ├── ast.go ├── asttest │ ├── cmp.go │ ├── cmpopts.go │ ├── doc.go │ └── gen.go ├── astutil │ ├── format.go │ └── format_test.go ├── copy_test.go ├── duration_test.go ├── edit │ ├── match.go │ ├── match_test.go │ ├── option_editor.go │ ├── option_editor_test.go │ ├── task_editor.go │ └── task_editor_test.go ├── errors.go ├── errors_test.go ├── helpers.go ├── json.go ├── json_test.go ├── testcase │ ├── testcase.go │ └── testcase_test.go ├── walk.go └── walk_test.go ├── benchmarks └── flux │ ├── README.md │ ├── config.toml │ ├── curl-format.txt │ └── telegraf.conf ├── bounds.go ├── bounds_test.go ├── cmd └── flux │ ├── cmd │ └── test.go │ ├── execute.go │ ├── fmt.go │ ├── main.go │ ├── repl.go │ ├── test.go │ ├── test_test.go │ └── testdata │ ├── fluxtest.root │ ├── pkga │ ├── fluxtest.root │ └── pkga_test.flux │ ├── pkgb │ └── pkgb_test.flux │ └── test_test.flux ├── codes └── codes.go ├── compile.go ├── compiler.go ├── compiler ├── compiler.go ├── compiler_test.go ├── doc.go ├── reference_counts.md ├── runtime.go ├── runtime_test.go └── vectorized_test.go ├── complete ├── complete.go └── complete_test.go ├── csv ├── dialect.go ├── result.go ├── result_internal_test.go └── result_test.go ├── dependencies.go ├── dependencies ├── bigtable │ ├── bigtable.go │ └── provider_test.go ├── dependencies.go ├── dependenciestest │ └── dependencies.go ├── feature │ └── flagger.go ├── filesystem │ ├── ioutil.go │ ├── service.go │ ├── systemfs.go │ └── systemfs_test.go ├── http │ ├── http.go │ └── http_test.go ├── influxdb │ ├── errors.go │ ├── http.go │ ├── http_provider_test.go │ ├── http_test.go │ ├── provider.go │ └── provider_test.go ├── iox │ └── client.go ├── mqtt │ ├── dialer_test.go │ └── mqtt.go ├── secret │ ├── empty_secret_service.go │ ├── environment_secret_service.go │ ├── secret_service.go │ └── secret_service_test.go ├── testing │ ├── testing.go │ └── testing_test.go └── url │ ├── validator.go │ └── validator_test.go ├── dependency ├── dependency.go └── dependency_test.go ├── dialect.go ├── docs ├── Alerts.md ├── CompilationExecution.md ├── Datasets.md ├── DeadmanAlert.md ├── Executor.md ├── Language.md ├── NewFlux_Comentary.md ├── Outputs.md ├── Overview.md ├── Plan.md ├── Planner.md ├── Query.md ├── QueryLifecycle.md ├── Release.md ├── Resources.md ├── SPEC.md ├── StandardLibrary.md ├── Transpiler.md ├── TypeInference.md ├── VirtualMachine.md ├── compilation_execution.svg ├── fluxdoc.md ├── new_flux_ideas_and_guide.md ├── storage_research.md ├── strings.md └── user_docs │ ├── 9-minutes-to-flux.md │ ├── flux-by-example.md │ └── images │ ├── image1.png │ ├── image2.png │ ├── image3.png │ ├── image4.png │ └── image5.png ├── errors.go ├── etc ├── checkdocs.sh ├── checkfmt.sh ├── checkgenerate.sh ├── checkprepared.sh ├── checkreproducibility.sh ├── checktidy.sh ├── fixup_docs_version.sh ├── gen_docs.sh └── spawn-containers.sh ├── examples ├── README.md └── library │ ├── README.md │ └── library_example_test.go ├── execute ├── README.md ├── aggregate.go ├── aggregate_test.go ├── allocator.go ├── bounds.go ├── bounds_test.go ├── chunk_builder.go ├── closer.go ├── concurrency_quota_test.go ├── dataset.go ├── dataset_test.go ├── dependencies.go ├── dispatcher.go ├── dispatcher_test.go ├── execute_test.go ├── executetest │ ├── aggregate.go │ ├── allocator.go │ ├── compile.go │ ├── dataset.go │ ├── dependencies.go │ ├── doc.go │ ├── output.go │ ├── result.go │ ├── selector.go │ ├── source.go │ ├── table.go │ ├── table_test.go │ ├── transformation.go │ └── yield.go ├── executor.go ├── executor_test.go ├── expression_internal_test.go ├── expression_test.go ├── format.go ├── group_key.go ├── group_key_builder.go ├── group_key_builder_test.go ├── group_lookup.go ├── group_transformation.go ├── group_transformation_test.go ├── metadata.go ├── narrow_state_transformation.go ├── narrow_state_transformation_test.go ├── narrow_transformation.go ├── narrow_transformation_test.go ├── parallel_test.go ├── profiler.go ├── profiler_test.go ├── queue.go ├── recover.go ├── recover_debug.go ├── result.go ├── ring.go ├── ring_test.go ├── row_fn.go ├── row_fn_test.go ├── rowreader.go ├── selector.go ├── selector_test.go ├── source.go ├── source_iterator.go ├── table.go ├── table │ ├── buffered.go │ ├── buffered_builder.go │ ├── buffered_builder_test.go │ ├── buffered_internal_test.go │ ├── buffered_test.go │ ├── builder_cache.go │ ├── builder_cache_test.go │ ├── chunk.go │ ├── copy.go │ ├── diff.go │ ├── diff_test.go │ ├── iterator.go │ ├── profiler_result.go │ ├── sort.go │ ├── static │ │ └── static.go │ ├── stringify.go │ ├── stringify_test.go │ └── utils.go ├── table_internal_test.go ├── table_test.go ├── transformation.go ├── transport.go ├── transport_internal_test.go ├── transport_test.go ├── trigger.go ├── vector_fn.go ├── window.go └── window_test.go ├── fluxinit ├── init.go └── static │ ├── static.go │ └── static_test.go ├── go.mod ├── go.sum ├── gotool.sh ├── group_mode.go ├── install_flatc.sh ├── internal ├── arrowutil │ ├── array_values.gen.go │ ├── array_values.gen.go.tmpl │ ├── builder.gen.go │ ├── builder.gen.go.tmpl │ ├── compare.gen.go │ ├── compare.gen.go.tmpl │ ├── constant.gen.go │ ├── constant.gen.go.tmpl │ ├── copy.gen.go │ ├── copy.gen.go.tmpl │ ├── filter.gen.go │ ├── filter.gen.go.tmpl │ ├── gen.go │ ├── iterator.gen.go │ ├── iterator.gen.go.tmpl │ ├── iterator.gen_test.go │ ├── iterator.gen_test.go.tmpl │ ├── iterator_test.go │ └── types.tmpldata ├── cmd │ ├── builtin │ │ ├── cmd │ │ │ ├── generate.go │ │ │ └── root.go │ │ └── main.go │ ├── calls │ │ └── main.go │ ├── cmpgen │ │ └── main.go │ ├── errcheck │ │ └── errcheck.go │ ├── headless_repl │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── Makefile │ │ ├── README.md │ │ ├── main.go │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── lsp_suggestion_helper.rs │ │ │ ├── main.rs │ │ │ ├── processes │ │ │ ├── coordinator_impl.rs │ │ │ ├── flux_server_impl.rs │ │ │ ├── invoke_go.rs │ │ │ ├── lsp_invoke.rs │ │ │ ├── lsp_server_impl.rs │ │ │ ├── mod.rs │ │ │ └── process_completion.rs │ │ │ └── utils │ │ │ ├── mod.rs │ │ │ └── process_response.rs │ ├── influxql-decode │ │ ├── main.go │ │ ├── v1.go │ │ └── v2.go │ └── tablediff │ │ └── tablediff.go ├── date │ └── date.go ├── debug │ ├── assert_off.go │ ├── assert_on.go │ └── util.go ├── errors │ ├── errors.go │ ├── errors_test.go │ ├── std.go │ └── unwrap_test.go ├── execute │ ├── dataset │ │ └── dataset.go │ ├── groupkey │ │ ├── groupkey.go │ │ ├── groupkey_test.go │ │ ├── lookup.go │ │ └── lookup_test.go │ └── table │ │ ├── arrow_builder.go │ │ ├── buffered_builder.go │ │ ├── builder_cache.go │ │ ├── chunk.go │ │ ├── copy.go │ │ ├── diff.go │ │ ├── iterator.go │ │ ├── mask.go │ │ ├── mask_test.go │ │ ├── sort.go │ │ ├── stream.go │ │ ├── stream_test.go │ │ ├── stringify.go │ │ └── utils.go ├── fbsemantic │ ├── doc.go │ ├── gen.go │ ├── semantic.fbs │ └── semantic_generated.go ├── feature │ ├── flags.go │ ├── flags.yml │ └── gen.go ├── function │ ├── arguments.go │ └── function.go ├── gen │ ├── input.go │ └── input_test.go ├── influxql │ ├── decoder.go │ ├── decoder_test.go │ └── response.go ├── jaeger │ ├── jaeger.go │ └── jaeger_test.go ├── line │ ├── result.go │ └── result_test.go ├── moving_average │ ├── array_container.go │ └── exponential_moving_average.go ├── mutable │ ├── numericarray.go │ └── numericarray_test.go ├── operation │ ├── spec.go │ └── spec_test.go ├── parser │ ├── strconv.go │ └── strconv_test.go ├── pkg │ ├── feature │ │ ├── README.md │ │ ├── cmd │ │ │ └── feature │ │ │ │ ├── main.go │ │ │ │ └── strings.go │ │ ├── doc.go │ │ ├── feature.go │ │ ├── feature_test.go │ │ ├── flag.go │ │ ├── metrics.go │ │ └── metrics_test.go │ └── syncutil │ │ └── wait_group.go ├── spec │ ├── build.go │ └── build_test.go ├── token │ ├── fileset.go │ ├── token.go │ └── token_test.go ├── tools │ ├── go.mod │ ├── go.sum │ └── tools.go ├── types.tmpldata └── zoneinfo │ ├── LICENSE │ ├── export_test.go │ ├── internal_test.go │ ├── zoneinfo.go │ ├── zoneinfo_clock.go │ ├── zoneinfo_clock_test.go │ ├── zoneinfo_read.go │ ├── zoneinfo_test.go │ ├── zoneinfo_unix.go │ └── zoneinfo_windows.go ├── interpreter ├── doc.go ├── importer.go ├── interpreter.go ├── interpreter_test.go ├── interptest │ └── eval.go ├── package.go └── package_test.go ├── interval ├── bounds.go ├── bounds_test.go ├── window.go └── window_test.go ├── iocounter ├── counter.go └── writer.go ├── lang ├── compiler.go ├── compiler_test.go ├── execopts_test.go ├── query.go └── query_test.go ├── libflux ├── .dockerignore ├── Cargo.lock ├── Cargo.toml ├── Polymorphic_Labels.md ├── README.md ├── build.sh ├── c │ ├── .gitignore │ ├── Makefile │ └── main.c ├── flux-core │ ├── Cargo.toml │ ├── benches │ │ └── scanner.rs │ ├── src │ │ ├── ast │ │ │ ├── check │ │ │ │ ├── mod.rs │ │ │ │ └── tests.rs │ │ │ ├── mod.rs │ │ │ ├── tests.rs │ │ │ └── walk │ │ │ │ ├── mod.rs │ │ │ │ └── tests.rs │ │ ├── bin │ │ │ ├── README.md │ │ │ ├── analyze_query_log.rs │ │ │ └── fluxdoc.rs │ │ ├── db.rs │ │ ├── doc │ │ │ ├── example.rs │ │ │ └── mod.rs │ │ ├── errors.rs │ │ ├── formatter │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── lib.rs │ │ ├── map.rs │ │ ├── parser │ │ │ ├── mod.rs │ │ │ ├── strconv.rs │ │ │ ├── tests.rs │ │ │ └── tests │ │ │ │ ├── arrow_function.rs │ │ │ │ ├── attributes.rs │ │ │ │ ├── errors.rs │ │ │ │ ├── from.rs │ │ │ │ ├── literals.rs │ │ │ │ ├── objects.rs │ │ │ │ ├── operator_precedence.rs │ │ │ │ ├── property_list.rs │ │ │ │ ├── stack_overflow.flux │ │ │ │ ├── stack_overflow_2.flux │ │ │ │ ├── strings.rs │ │ │ │ └── types.rs │ │ ├── scanner │ │ │ ├── mod.rs │ │ │ ├── scanner.rl │ │ │ ├── scanner_generated.rs │ │ │ ├── tests.rs │ │ │ ├── token.rs │ │ │ ├── unicode.rl │ │ │ └── unicode.rl.COPYING │ │ └── semantic │ │ │ ├── bootstrap.rs │ │ │ ├── check.rs │ │ │ ├── convert.rs │ │ │ ├── env.rs │ │ │ ├── flatbuffers │ │ │ ├── mod.rs │ │ │ ├── semantic_generated.rs │ │ │ ├── tests.rs │ │ │ └── types.rs │ │ │ ├── formatter │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ │ ├── fresh.rs │ │ │ ├── fs.rs │ │ │ ├── import.rs │ │ │ ├── infer.rs │ │ │ ├── mod.rs │ │ │ ├── nodes.rs │ │ │ ├── sub.rs │ │ │ ├── symbols.rs │ │ │ ├── tests.rs │ │ │ ├── tests │ │ │ ├── labels.rs │ │ │ └── vectorize.rs │ │ │ ├── types.rs │ │ │ ├── vectorize.rs │ │ │ └── walk │ │ │ ├── _walk.rs │ │ │ ├── mod.rs │ │ │ ├── test_utils.rs │ │ │ └── walk_mut.rs │ └── tests │ │ └── analyze_test.rs ├── flux │ ├── Cargo.toml │ ├── FLUXDOC.md │ ├── benches │ │ ├── analyze.rs │ │ ├── basic.rs │ │ ├── everything.flux │ │ └── formatter.rs │ ├── build.rs │ ├── src │ │ ├── cffi.rs │ │ └── lib.rs │ └── templates │ │ ├── base.html │ │ ├── home.html │ │ ├── package.html │ │ └── value.html ├── go │ └── libflux │ │ ├── README.md │ │ ├── analyze.go │ │ ├── analyze_test.go │ │ ├── bench_test.go │ │ ├── buildinfo.gen.go │ │ ├── gen.go │ │ ├── internal │ │ └── buildinfo │ │ │ └── main.go │ │ ├── link_dynamic.go │ │ ├── link_static.go │ │ ├── parser.go │ │ ├── parser_test.go │ │ └── testdata │ │ └── bench.flux ├── include │ └── influxdata │ │ └── flux.h └── publish.sh ├── memory ├── allocator.go └── allocator_test.go ├── metadata └── metadata.go ├── mock ├── administration.go ├── compiler.go ├── dependency.go ├── doc.go ├── executor.go ├── influxdb_provider.go ├── mqtt_provider.go ├── program.go ├── query.go ├── secret_service.go ├── source.go ├── time.go ├── transformation.go └── transport.go ├── operation.go ├── parser ├── doc.go ├── gofuzz.go ├── grammar.md ├── libflux_parser.go ├── parser.go ├── parser_test.go ├── strconv.go └── strconv_test.go ├── pkg-config.sh ├── plan ├── attributes.go ├── attributes_test.go ├── bounds.go ├── bounds_test.go ├── builder.go ├── builtin_test.go ├── collation.go ├── cost.go ├── format.go ├── format_test.go ├── heuristic_planner.go ├── heuristic_planner_test.go ├── logical.go ├── logical_test.go ├── parallel.go ├── pattern.go ├── pattern_test.go ├── physical.go ├── physical_test.go ├── plantest │ ├── cmp.go │ ├── doc.go │ ├── rules.go │ ├── spec.go │ └── spec │ │ ├── mock.go │ │ └── plan.go ├── registration.go ├── rules.go ├── rules_test.go ├── triggers.go ├── triggers_test.go ├── types.go ├── types_test.go ├── walk.go ├── walk_test.go └── yield.go ├── prep-release.sh ├── query.go ├── querytest ├── README.md ├── compile.go ├── doc.go └── execute.go ├── release.sh ├── repl ├── compiler.go └── repl.go ├── resource_management.go ├── result.go ├── result_iterator.go ├── result_iterator_test.go ├── result_test.go ├── runtime.go ├── runtime ├── analyze_libflux.go ├── analyze_libflux_test.go ├── builtins_test.go ├── global.go ├── importer.go ├── lookup.go ├── lookup_test.go ├── parse.go ├── runtime.go └── runtime_test.go ├── rust-toolchain.toml ├── rustfmt.toml ├── semantic ├── ast.go ├── ast_test.go ├── doc.go ├── flatbuffers.go ├── flatbuffers_deserialize.go ├── flatbuffers_test.go ├── format.go ├── format_test.go ├── graph.go ├── monotype.go ├── monotype_test.go ├── polytype.go ├── semantictest │ ├── cmp.go │ └── doc.go ├── symbol_test.go ├── types.go ├── utils.go └── walk.go ├── stdlib ├── README.md ├── array │ ├── array.flux │ ├── array.go │ ├── array_test.flux │ ├── array_test.go │ ├── from.go │ ├── from_test.flux │ └── from_test.go ├── bitwise │ ├── bitwise.flux │ ├── bitwise.go │ └── bitwise_test.flux ├── contrib │ ├── README.md │ ├── RohanSreerama5 │ │ ├── images │ │ │ ├── csvData.png │ │ │ ├── data.png │ │ │ ├── overview.png │ │ │ └── pythonScript.png │ │ └── naiveBayesClassifier │ │ │ ├── README.md │ │ │ ├── bayes_test.flux │ │ │ ├── inData.csv │ │ │ ├── naiveBayesClassifier.flux │ │ │ ├── outData.csv │ │ │ ├── placeholder.go │ │ │ ├── script.py │ │ │ └── zoo_data.csv │ ├── anaisdg │ │ ├── anomalydetection │ │ │ ├── mad.flux │ │ │ ├── mad_test.flux │ │ │ └── placeholder.go │ │ └── statsmodels │ │ │ ├── linearreg.flux │ │ │ ├── linearreg_test.flux │ │ │ └── placeholder.go │ ├── bonitoo-io │ │ ├── alerta │ │ │ ├── alerta.flux │ │ │ ├── alerta_test.go │ │ │ └── placeholder.go │ │ ├── hex │ │ │ ├── README.md │ │ │ ├── hex.flux │ │ │ ├── hex.go │ │ │ └── hex_test.go │ │ ├── servicenow │ │ │ ├── README.md │ │ │ ├── placeholder.go │ │ │ ├── servicenow.flux │ │ │ └── servicenow_test.go │ │ ├── tickscript │ │ │ ├── README.md │ │ │ ├── alert_test.flux │ │ │ ├── alert_with_topic_test.flux │ │ │ ├── deadman_empty_test.flux │ │ │ ├── deadman_threshold_test.flux │ │ │ ├── placeholder.go │ │ │ └── tickscript.flux │ │ ├── victorops │ │ │ ├── README.md │ │ │ ├── placeholder.go │ │ │ ├── victorops.flux │ │ │ └── victorops_test.go │ │ └── zenoss │ │ │ ├── README.md │ │ │ ├── placeholder.go │ │ │ ├── zenoss.flux │ │ │ └── zenoss_test.go │ ├── chobbs │ │ └── discord │ │ │ ├── README.md │ │ │ ├── discord.flux │ │ │ ├── discord_test.go │ │ │ └── placeholder.go │ ├── jsternberg │ │ └── influxdb │ │ │ ├── influxdb.flux │ │ │ └── influxdb.go │ ├── qxip │ │ ├── clickhouse │ │ │ ├── README.md │ │ │ ├── clickhouse.flux │ │ │ └── placeholder.go │ │ ├── hash │ │ │ ├── README.md │ │ │ ├── cityhash.go │ │ │ ├── hash.flux │ │ │ ├── hash.go │ │ │ └── hash_test.go │ │ ├── iox │ │ │ ├── iox.flux │ │ │ └── placeholder.go │ │ └── logql │ │ │ ├── README.md │ │ │ ├── logql.flux │ │ │ └── placeholder.go │ ├── rhajek │ │ └── bigpanda │ │ │ ├── README.md │ │ │ ├── bigpanda.flux │ │ │ ├── bigpanda_test.go │ │ │ └── placeholder.go │ ├── sranka │ │ ├── opsgenie │ │ │ ├── README.md │ │ │ ├── opsgenie.flux │ │ │ ├── opsgenie_test.go │ │ │ ├── responders_to_json.go │ │ │ └── responders_to_json_test.go │ │ ├── sensu │ │ │ ├── README.md │ │ │ ├── sensu.flux │ │ │ ├── sensu_test.go │ │ │ ├── to_sensu_name.go │ │ │ └── to_sensu_name_test.go │ │ ├── teams │ │ │ ├── README.md │ │ │ ├── placeholder.go │ │ │ ├── teams.flux │ │ │ └── teams_test.go │ │ ├── telegram │ │ │ ├── README.md │ │ │ ├── placeholder.go │ │ │ ├── telegram.flux │ │ │ └── telegram_test.go │ │ └── webexteams │ │ │ ├── README.md │ │ │ ├── placeholder.go │ │ │ ├── webexteams.flux │ │ │ └── webexteams_test.go │ └── tomhollingworth │ │ └── events │ │ ├── README.md │ │ ├── duration.flux │ │ ├── duration.go │ │ ├── duration_test.flux │ │ ├── duration_test.go │ │ └── duration_with_stop_test.flux ├── csv │ ├── csv.flux │ ├── csv_test.flux │ ├── from.go │ ├── from_internal_test.go │ └── from_test.go ├── date │ ├── boundaries │ │ ├── boundaries.flux │ │ └── placeholder.go │ ├── date.flux │ ├── date.go │ ├── date_test.flux │ ├── date_test.go │ ├── durations.go │ ├── durations_test.flux │ ├── hour_duration_test.flux │ ├── hour_time_test.flux │ ├── microsecond_duration_test.flux │ ├── microsecond_time_test.flux │ ├── millisecond_duration_test.flux │ ├── millisecond_test.flux │ ├── minute_duration_test.flux │ ├── minute_time_test.flux │ ├── month_day_duration_test.flux │ ├── month_day_time_test.flux │ ├── month_duration_test.flux │ ├── month_time_test.flux │ ├── nanosecond_duration_test.flux │ ├── nanosecond_time_test.flux │ ├── quarter_duration_test.flux │ ├── quarter_time_test.flux │ ├── scale_test.flux │ ├── second_duration_test.flux │ ├── second_time_test.flux │ ├── truncate_duration_test.flux │ ├── truncate_time_test.flux │ ├── week_day_duration_test.flux │ ├── week_day_time_test.flux │ ├── week_duration_test.flux │ ├── week_time_test.flux │ ├── year_day_duration_test.flux │ ├── year_day_time_test.flux │ ├── year_duration_test.flux │ └── year_time_test.flux ├── dict │ ├── dict.flux │ ├── dict.go │ ├── dict_insert_remove_test.flux │ ├── dict_lit_lambda_test.flux │ ├── dict_lit_test.flux │ ├── dict_test.flux │ ├── dict_test.go │ ├── empty_dict_lambda_test.flux │ └── empty_dict_lit_test.flux ├── doc.go ├── experimental │ ├── aggregate │ │ ├── aggregate.flux │ │ ├── aggregate_test.flux │ │ └── placeholder.go │ ├── alignTime_test.flux │ ├── array │ │ ├── array.flux │ │ ├── array_test.flux │ │ └── placeholder.go │ ├── bigtable │ │ ├── bigtable.flux │ │ ├── bigtable_rewrite.go │ │ ├── bigtable_test.go │ │ ├── from.go │ │ └── rowreader.go │ ├── bitwise │ │ ├── bitwise.flux │ │ ├── bitwise_test.flux │ │ └── placeholder.go │ ├── catch.go │ ├── chain.go │ ├── chain_test.go │ ├── count.go │ ├── count_test.flux │ ├── csv │ │ ├── csv.flux │ │ └── placeholder.go │ ├── date │ │ └── boundaries │ │ │ ├── boundaries.flux │ │ │ ├── boundaries_test.flux │ │ │ └── placeholder.go │ ├── diff.go │ ├── diff_test.flux │ ├── distinct.go │ ├── distinct_test.flux │ ├── dynamic │ │ ├── dynamic.flux │ │ ├── dynamic.go │ │ ├── dynamic_test.flux │ │ └── json.go │ ├── experimental.flux │ ├── experimental_test.flux │ ├── fill.go │ ├── fill_test.flux │ ├── first.go │ ├── first_test.flux │ ├── geo │ │ ├── README.md │ │ ├── asTracks_test.flux │ │ ├── filterRowsNotStrict_test.flux │ │ ├── filterRowsPivoted_test.flux │ │ ├── filterRowsStrict_test.flux │ │ ├── geo.flux │ │ ├── geo.go │ │ ├── geo_internal_test.go │ │ ├── getgrid_test.go │ │ ├── getlevel_test.go │ │ ├── gridFilterLevel_test.flux │ │ ├── gridFilter_test.flux │ │ ├── groupByArea_test.flux │ │ ├── s2CellIDToken_test.go │ │ ├── s2CellLatLon_test.go │ │ ├── shapeDataWithFilter_test.flux │ │ ├── shapeData_test.flux │ │ ├── st.go │ │ ├── stContains_test.go │ │ ├── stDistance_test.go │ │ ├── stLength_test.go │ │ ├── st_contains_linestring_test.flux │ │ ├── st_contains_test.flux │ │ ├── st_distance_linestring_test.flux │ │ ├── st_distance_test.flux │ │ ├── st_dwithin_linestring_test.flux │ │ ├── st_dwithin_test.flux │ │ ├── st_intersects_linestring_test.flux │ │ ├── st_length_linestring_test.flux │ │ ├── strictFilter_test.flux │ │ ├── totalDistance_test.flux │ │ └── units_miles_test.flux │ ├── group.go │ ├── group_test.flux │ ├── group_test.go │ ├── histogram.go │ ├── histogram_quantile.go │ ├── histogram_quantile_test.flux │ ├── histogram_test.flux │ ├── http │ │ ├── get_test.go │ │ ├── http.flux │ │ ├── http_experimental.go │ │ └── requests │ │ │ ├── placeholder.go │ │ │ └── requests.flux │ ├── influxdb │ │ ├── influxdb.flux │ │ ├── influxdb.go │ │ └── influxdb_test.go │ ├── integral.go │ ├── integral_test.flux │ ├── iox │ │ ├── iox.flux │ │ ├── iox.go │ │ ├── iox_test.flux │ │ └── source.go │ ├── join.go │ ├── join_right_side_more_cols_test.flux │ ├── join_test.flux │ ├── join_test.go │ ├── json │ │ ├── json.flux │ │ ├── json.go │ │ ├── json_test.flux │ │ └── json_test.go │ ├── kama_test.flux │ ├── kaufmansAMA.go │ ├── last.go │ ├── last_test.flux │ ├── max.go │ ├── max_test.flux │ ├── mean.go │ ├── mean_test.flux │ ├── min.go │ ├── min_test.flux │ ├── mode.go │ ├── mode_test.flux │ ├── mqtt │ │ ├── mqtt.flux │ │ ├── mqtt.go │ │ ├── mqtt_test.flux │ │ ├── publish.go │ │ ├── publish_test.go │ │ ├── to.go │ │ └── to_test.go │ ├── object_keys.go │ ├── object_keys_test.go │ ├── oee │ │ ├── apq_test.flux │ │ ├── computeapq_test.flux │ │ ├── oee.flux │ │ └── placeholder.go │ ├── polyline │ │ ├── polyline.flux │ │ ├── polyline_test.flux │ │ ├── rdp.go │ │ └── rdp │ │ │ └── rdp.go │ ├── preview.go │ ├── preview_test.flux │ ├── prometheus │ │ ├── prometheus.flux │ │ ├── prometheus_histogramQuantile_test.flux │ │ ├── prometheus_test.go │ │ └── scrape.go │ ├── quantile.go │ ├── quantile_test.flux │ ├── query │ │ ├── from.flux │ │ └── placeholder.go │ ├── record │ │ ├── record.flux │ │ ├── record.go │ │ └── record_test.flux │ ├── set.go │ ├── set_test.flux │ ├── set_test.go │ ├── skew.go │ ├── skew_test.flux │ ├── spread.go │ ├── spread_test.flux │ ├── stddev.go │ ├── stddev_test.flux │ ├── sum.go │ ├── sum_test.flux │ ├── table │ │ ├── fill.go │ │ ├── fill_test.flux │ │ ├── fill_test.go │ │ └── table.flux │ ├── unique.go │ ├── unique_test.flux │ ├── unpivot.go │ ├── usage │ │ ├── placeholder.go │ │ └── usage.flux │ ├── window.go │ └── window_test.flux ├── flux_test.go ├── fluxtest.root ├── gen.go ├── generate │ ├── from.go │ ├── from_test.flux │ ├── from_test.go │ └── generate.flux ├── http │ ├── basic_auth.go │ ├── basic_auth_test.go │ ├── http.flux │ ├── http_path_encode_endpoint_test.flux │ ├── path_encode.go │ ├── path_encode_test.go │ ├── post.go │ ├── post_test.go │ └── requests │ │ ├── requests.flux │ │ ├── requests.go │ │ └── requests_test.go ├── influxdata │ └── influxdb │ │ ├── buckets.go │ │ ├── buckets_test.go │ │ ├── builtin_test.go │ │ ├── cardinality.go │ │ ├── cardinality_test.go │ │ ├── consts.go │ │ ├── errors.go │ │ ├── from.go │ │ ├── from_test.go │ │ ├── influxdb.flux │ │ ├── internal │ │ └── testutil │ │ │ └── testing.go │ │ ├── monitor │ │ ├── check_test.flux │ │ ├── deadman_add_test.flux │ │ ├── deadman_sub_test.flux │ │ ├── monitor.flux │ │ ├── notify_test.flux │ │ ├── placeholder.go │ │ ├── state_changes_any_to_any_same_source_timestamp_test.flux │ │ ├── state_changes_any_to_any_test.flux │ │ ├── state_changes_big_any_to_any_test.flux │ │ ├── state_changes_big_info_to_ok_test.flux │ │ ├── state_changes_big_ok_to_info_test.flux │ │ ├── state_changes_custom_any_to_any_test.flux │ │ ├── state_changes_info_to_any_test.flux │ │ ├── state_changes_invalid_any_to_any_test.flux │ │ └── state_changes_test.flux │ │ ├── provider.go │ │ ├── rowmetric.go │ │ ├── rules.go │ │ ├── rules_test.go │ │ ├── sample │ │ ├── alignToNow_test.flux │ │ ├── list_test.flux │ │ ├── placeholder.go │ │ └── sample.flux │ │ ├── schema │ │ ├── influxFieldsAsCols_test.flux │ │ ├── influxRawQuery_test.flux │ │ ├── placeholder.go │ │ ├── schema.flux │ │ └── schema_test.flux │ │ ├── secrets │ │ ├── get.go │ │ ├── get_test.go │ │ ├── secrets.flux │ │ └── secrets_test.flux │ │ ├── source.go │ │ ├── tasks │ │ ├── last_success_duration_no_option_test.flux │ │ ├── last_success_duration_option_test.flux │ │ ├── last_success_with_option_test.flux │ │ ├── last_success_without_option_test.flux │ │ ├── tasks.flux │ │ ├── tasks.go │ │ └── tasks_test.go │ │ ├── to.go │ │ ├── to_test.flux │ │ ├── to_test.go │ │ ├── v1 │ │ ├── databases.go │ │ ├── databases_test.go │ │ ├── from_influx_json.go │ │ ├── from_influx_json_test.go │ │ ├── rules.go │ │ └── v1.flux │ │ ├── wide_to.go │ │ └── wide_to_test.go ├── internal │ ├── boolean │ │ ├── boolean.flux │ │ └── boolean.go │ ├── debug │ │ ├── debug.flux │ │ ├── debug_test.flux │ │ ├── feature.go │ │ ├── get_option.go │ │ ├── null.go │ │ ├── opaque.go │ │ ├── pass.go │ │ ├── sink.go │ │ └── slurp.go │ ├── gen │ │ ├── gen.flux │ │ ├── tables.go │ │ └── tables_test.flux │ ├── influxql │ │ ├── influxql.flux │ │ └── placeholder.go │ ├── location │ │ ├── location.flux │ │ └── placeholder.go │ ├── promql │ │ ├── changes.go │ │ ├── date_functions.go │ │ ├── empty_table.go │ │ ├── extrapolated_rate.go │ │ ├── histogram_quantile.go │ │ ├── histogram_quantile_test.go │ │ ├── holt_winters.go │ │ ├── instant_rate.go │ │ ├── join.md │ │ ├── join_test.flux │ │ ├── join_test.go │ │ ├── label_replace.go │ │ ├── linear_regression.go │ │ ├── promql.flux │ │ ├── resets.go │ │ └── timestamp.go │ ├── testing │ │ ├── placeholder.go │ │ ├── testing.flux │ │ └── testing_test.flux │ └── testutil │ │ ├── testutil.flux │ │ └── testutil.go ├── interpolate │ ├── interpolate.flux │ ├── interpolate_test.flux │ ├── interpolate_test.go │ └── linear.go ├── join │ ├── equijoin.go │ ├── equijoin_test.go │ ├── join.flux │ ├── join.go │ ├── join_fn.go │ ├── join_key.go │ ├── join_test.flux │ ├── large_join_test.flux │ ├── merge_join.go │ ├── merge_join_test.go │ ├── sort_merge_join.go │ └── sort_merge_join_test.go ├── json │ ├── encode.go │ ├── encode_test.go │ └── json.flux ├── kafka │ ├── kafka.flux │ ├── to.go │ └── to_test.go ├── math │ ├── math.flux │ ├── math.go │ ├── math_test.flux │ └── math_test.go ├── packages.go ├── pagerduty │ ├── pagerduty.flux │ ├── pagerduty.go │ ├── pagerduty_test.flux │ └── pagerduty_test.go ├── planner │ ├── aggregate_window_max_eval_test.flux │ ├── aggregate_window_max_push_test.flux │ ├── aggregate_window_min_eval_test.flux │ ├── aggregate_window_min_push_test.flux │ ├── bare_count_eval_test.flux │ ├── bare_count_push_test.flux │ ├── bare_last_test.flux │ ├── bare_max_eval_test.flux │ ├── bare_max_push_test.flux │ ├── bare_mean_eval_test.flux │ ├── bare_mean_push_test.flux │ ├── bare_min_eval_test.flux │ ├── bare_min_push_test.flux │ ├── bare_sum_eval_test.flux │ ├── bare_sum_push_test.flux │ ├── group_agg_test.flux │ ├── group_agg_uneven_keys_test.flux │ ├── group_count_eval_test.flux │ ├── group_count_push_test.flux │ ├── group_first_last_test.flux │ ├── group_max_eval_test.flux │ ├── group_max_push_test.flux │ ├── group_max_test.flux │ ├── group_min_eval_test.flux │ ├── group_min_max_table_test.flux │ ├── group_min_push_test.flux │ ├── group_min_test.flux │ ├── group_sum_eval_test.flux │ ├── group_sum_push_test.flux │ ├── placeholder.go │ ├── planner.flux │ ├── window_count_eval_test.flux │ ├── window_count_push_test.flux │ ├── window_eval_test.flux │ ├── window_group_agg_eval_test.flux │ ├── window_group_agg_push_test.flux │ ├── window_max_eval_test.flux │ ├── window_max_push_test.flux │ ├── window_mean_eval_test.flux │ ├── window_mean_push_test.flux │ ├── window_min_eval_test.flux │ ├── window_min_push_test.flux │ ├── window_push_test.flux │ ├── window_sum_eval_test.flux │ └── window_sum_push_test.flux ├── profiler │ ├── placeholder.go │ └── profiler.flux ├── pushbullet │ ├── placeholder.go │ └── pushbullet.flux ├── regexp │ ├── regexp.flux │ ├── regexp.go │ ├── regexp_test.go │ └── replaceAllString_test.flux ├── runtime │ ├── compat_go1.11.go │ ├── runtime.flux │ ├── runtime.go │ ├── version.go │ ├── version_internal_test.go │ └── version_test.go ├── sampledata │ ├── placeholder.go │ ├── sampledata.flux │ └── sampledata_test.flux ├── slack │ ├── slack.flux │ ├── slack.go │ └── slack_test.go ├── socket │ ├── from.go │ ├── from_private_test.go │ ├── from_test.go │ └── socket.flux ├── sql │ ├── awsathena.go │ ├── bigquery.go │ ├── clickhouse.go │ ├── enabled.go │ ├── enabled_fipsonly.go │ ├── errors.go │ ├── from.go │ ├── from_private_test.go │ ├── hdb.go │ ├── hdb_test.go │ ├── iox.go │ ├── mssql.go │ ├── mssql_azure.go │ ├── mssql_azure_fipsonly.go │ ├── mssql_fipsonly.go │ ├── mysql.go │ ├── open.go │ ├── postgres.go │ ├── snowflake.go │ ├── snowflake_fipsonly.go │ ├── snowflake_test.go │ ├── source_validator.go │ ├── source_validator_private_test.go │ ├── sql.flux │ ├── sql_test.flux │ ├── sql_test.go │ ├── sqlite.go │ ├── sqlite_test.go │ ├── to.go │ ├── to_privates_test.go │ ├── to_test.go │ └── vertica.go ├── strings │ ├── compat.go │ ├── strings.flux │ ├── strings.go │ ├── strings_test.flux │ └── strings_test.go ├── system │ ├── system.flux │ └── time.go ├── testing.go ├── testing │ ├── assert_empty.go │ ├── assert_empty_test.go │ ├── assert_equals.go │ ├── assert_equals_test.go │ ├── basics │ │ ├── basics_test.flux │ │ └── placeholder.go │ ├── chronograf │ │ ├── aggregate_window_count_test.flux │ │ ├── aggregate_window_mean_test.flux │ │ ├── aggregate_window_median_test.flux │ │ ├── buckets_test.flux │ │ ├── measurement_tag_keys_test.flux │ │ └── placeholder.go │ ├── expect │ │ ├── expect.flux │ │ └── planner.go │ ├── extend_test.flux │ ├── influxql │ │ ├── aggregate_group_by_time_test.flux │ │ ├── cumulative_sum_test.flux │ │ ├── elapsed_test.flux │ │ ├── filter_by_regex_tag_test.flux │ │ ├── filter_by_values_with_and_test.flux │ │ ├── placeholder.go │ │ ├── regex_measurement_test.flux │ │ ├── selector_test.flux │ │ └── series_agg_test.flux │ ├── kapacitor │ │ ├── combine_pivot_test.flux │ │ ├── delete_drop_test.flux │ │ ├── eval_map_with_test.flux │ │ ├── fill_default_test.flux │ │ ├── flatten_pivot_test.flux │ │ ├── noop_yield_test.flux │ │ └── placeholder.go │ ├── pandas │ │ ├── capitalize_strings_toUpper_test.flux │ │ ├── cat_strings_joinStr_test.flux │ │ ├── center_strings_joinStr_test.flux │ │ ├── contains_filter_by_regex_match_test.flux │ │ ├── count_string_countStr_test.flux │ │ ├── endswith_strings_regexp_hasSuffix_test.flux │ │ ├── extract_regexp_findStringIndex_test.flux │ │ ├── extract_regexp_findString_test.flux │ │ ├── get_strings_substring_test.flux │ │ ├── ljust_string_joinStr_test.flux │ │ ├── lower_strings_toLower_test.flux │ │ ├── lstrip_string_trimLeft_test.flux │ │ ├── partition_strings_splitN_test.flux │ │ ├── placeholder.go │ │ ├── repeat_strings_repeat_test.flux │ │ ├── replace_strings_replace_test.flux │ │ ├── rstrip_string_trimRight_test.flux │ │ ├── startswith_strings_regexp_hasPrefix_test.flux │ │ ├── strip_strings_trimLeftRight_test.flux │ │ └── title_strings_title_test.flux │ ├── prometheus │ │ ├── histogramQuantile_test.flux │ │ └── placeholder.go │ ├── promql │ │ ├── changes_test.flux │ │ ├── dayOfMonth_test.flux │ │ ├── dayOfWeek_test.flux │ │ ├── daysInMonth_test.flux │ │ ├── emptyTable_test.flux │ │ ├── extrapolatedRate_counter_rate_test.flux │ │ ├── extrapolatedRate_nocounter_test.flux │ │ ├── extrapolatedRate_norate_test.flux │ │ ├── histogramQuantile_test.flux │ │ ├── holtWinters_test.flux │ │ ├── hour_test.flux │ │ ├── instantRate_test.flux │ │ ├── labelReplace_empty_dst_test.flux │ │ ├── labelReplace_full_string_match_test.flux │ │ ├── labelReplace_multiple_groups_test.flux │ │ ├── labelReplace_src_empty_test.flux │ │ ├── labelReplace_src_nonexistent_test.flux │ │ ├── labelReplace_src_not_matched_test.flux │ │ ├── labelReplace_sub_string_match_test.flux │ │ ├── linearRegression_nopredict_test.flux │ │ ├── linearRegression_predict_test.flux │ │ ├── minute_test.flux │ │ ├── month_test.flux │ │ ├── placeholder.go │ │ ├── quantile_neg_test.flux │ │ ├── quantile_pos_test.flux │ │ ├── quantile_test.flux │ │ ├── resets_test.flux │ │ ├── timestamp_test.flux │ │ └── year_test.flux │ ├── testing.flux │ ├── testing_test.flux │ └── usage │ │ ├── api_test.flux │ │ ├── duration_test.flux │ │ ├── placeholder.go │ │ ├── reads_test.flux │ │ ├── storage_test.flux │ │ └── writes_test.flux ├── timezone │ ├── timezone.flux │ └── timezone.go ├── types │ ├── is_type.go │ ├── is_type_test.flux │ ├── is_type_test.go │ └── types.flux └── universe │ ├── aggregate_empty_window_count_test.flux │ ├── aggregate_empty_window_first_test.flux │ ├── aggregate_empty_window_last_test.flux │ ├── aggregate_empty_window_max_test.flux │ ├── aggregate_empty_window_mean_test.flux │ ├── aggregate_empty_window_min_test.flux │ ├── aggregate_empty_window_sum_test.flux │ ├── aggregate_fill_window_test.flux │ ├── aggregate_window.gen.go │ ├── aggregate_window.gen.go.tmpl │ ├── aggregate_window.go │ ├── aggregate_window__offset_test.flux │ ├── aggregate_window_max_test.flux │ ├── aggregate_window_mean_test.flux │ ├── aggregate_window_median_test.flux │ ├── aggregate_window_test.flux │ ├── chande_momentum_oscillator.go │ ├── chande_momentum_oscillator_test.go │ ├── cmo_test.flux │ ├── columns.go │ ├── columns_test.flux │ ├── columns_test.go │ ├── contains.go │ ├── contains_test.flux │ ├── contains_test.go │ ├── count.go │ ├── count_test.flux │ ├── count_test.go │ ├── cov_test.flux │ ├── covariance.go │ ├── covariance_missing_column_1_test.flux │ ├── covariance_missing_column_2_test.flux │ ├── covariance_test.flux │ ├── covariance_test.go │ ├── cumulative_sum.go │ ├── cumulative_sum_test.flux │ ├── cumulative_sum_test.go │ ├── data_test.go │ ├── derivative.gen.go │ ├── derivative.gen.go.tmpl │ ├── derivative.go │ ├── derivative_test.flux │ ├── derivative_test.go │ ├── die.go │ ├── die_test.go │ ├── difference.go │ ├── difference_columns_test.flux │ ├── difference_keepfirst_test.flux │ ├── difference_nonnegative_test.flux │ ├── difference_one_value_test.flux │ ├── difference_panic_test.flux │ ├── difference_test.flux │ ├── difference_test.go │ ├── display.go │ ├── display_test.flux │ ├── distinct.go │ ├── distinct_test.flux │ ├── distinct_test.go │ ├── double_exponential_moving_average_test.flux │ ├── drop_after_rename_test.flux │ ├── drop_before_rename_test.flux │ ├── drop_fn_test.flux │ ├── drop_newname_after_test.flux │ ├── drop_newname_before_test.flux │ ├── drop_non_existent_test.flux │ ├── drop_referenced_test.flux │ ├── drop_unused_test.flux │ ├── dual_impl_spec.go │ ├── dual_impl_spec_test.go │ ├── duplicate_overwrite_test.flux │ ├── duplicate_test.flux │ ├── dynamic_query_test.flux │ ├── elapsed.go │ ├── elapsed_median_test.flux │ ├── elapsed_test.flux │ ├── elapsed_test.go │ ├── exponential_moving_average.go │ ├── exponential_moving_average_test.flux │ ├── exponential_moving_average_test.go │ ├── fill.gen.go │ ├── fill.gen.go.tmpl │ ├── fill.go │ ├── fill_test.flux │ ├── fill_test.go │ ├── filter.go │ ├── filter_by_regex_compile_test.flux │ ├── filter_by_regex_function_test.flux │ ├── filter_by_regex_test.flux │ ├── filter_by_tags_test.flux │ ├── filter_drop_empty_test.flux │ ├── filter_keep_empty_test.flux │ ├── filter_mixed_empty_test.flux │ ├── filter_partial_pushdown_test.flux │ ├── filter_test.go │ ├── first.go │ ├── first_test.flux │ ├── first_test.go │ ├── group.go │ ├── group_by_field_test.flux │ ├── group_by_irregular_test.flux │ ├── group_except_test.flux │ ├── group_nulls_test.flux │ ├── group_test.flux │ ├── group_test.go │ ├── group_ungroup_test.flux │ ├── highestAverage_test.flux │ ├── highestCurrent_test.flux │ ├── highestMax_test.flux │ ├── histogram.go │ ├── histogram_quantile.go │ ├── histogram_quantile_test.flux │ ├── histogram_quantile_test.go │ ├── histogram_test.flux │ ├── histogram_test.go │ ├── holt_winters.go │ ├── holt_winters │ └── holt_winters.go │ ├── holt_winters_panic_test.flux │ ├── holt_winters_test.flux │ ├── holt_winters_test.go │ ├── hour_selection.go │ ├── hour_selection_test.flux │ ├── hour_selection_test.go │ ├── increase_test.flux │ ├── integral.go │ ├── integral_test.flux │ ├── integral_test.go │ ├── join.go │ ├── join_across_measurements_test.flux │ ├── join_agg_test.flux │ ├── join_fill_panic_test.flux │ ├── join_mismatched_schema_test.flux │ ├── join_missing_on_col_test.flux │ ├── join_panic_test.flux │ ├── join_test.flux │ ├── join_test.go │ ├── join_two_same_sources_test.flux │ ├── join_unsorted_columns_test.flux │ ├── join_use_previous_test.flux │ ├── kama_test.flux │ ├── kama_v2_test.flux │ ├── kaufmansAMA.go │ ├── kaufmansAMA_test.go │ ├── keep_fn_test.flux │ ├── keep_non_existent_only_test.flux │ ├── keep_non_existent_test.flux │ ├── keep_test.flux │ ├── ker_test.flux │ ├── key_values.go │ ├── key_values_host_name_test.flux │ ├── key_values_test.flux │ ├── key_values_test.go │ ├── keys.go │ ├── keys_test.flux │ ├── keys_test.go │ ├── last.go │ ├── last_test.flux │ ├── last_test.go │ ├── length.go │ ├── length_test.go │ ├── limit.go │ ├── limit_offset_test.flux │ ├── limit_test.flux │ ├── limit_test.go │ ├── lowestAverage_test.flux │ ├── lowestCurrent_test.flux │ ├── lowestMin_test.flux │ ├── map.go │ ├── map_internal_test.go │ ├── map_test.flux │ ├── map_test.go │ ├── map_vectorize_conditionals_test.flux │ ├── map_vectorize_const_test.flux │ ├── map_vectorize_equality_test.flux │ ├── map_vectorize_float_test.flux │ ├── map_vectorize_unary_test.flux │ ├── map_vectorized.go │ ├── math_fn_constant_test.flux │ ├── math_m_max_test.flux │ ├── max.go │ ├── max_test.flux │ ├── max_test.go │ ├── max_time_test.flux │ ├── mean.go │ ├── mean_test.flux │ ├── mean_test.go │ ├── median_column_test.flux │ ├── median_compression_test.flux │ ├── median_method_test.flux │ ├── median_test.flux │ ├── merge_filter_flag_off_test.flux │ ├── merge_filter_flag_on_test.flux │ ├── merge_filter_test.flux │ ├── meta_query_keys_test.flux │ ├── min.go │ ├── min_test.flux │ ├── min_test.go │ ├── mode.go │ ├── mode_string_test.flux │ ├── mode_test.flux │ ├── mode_test.go │ ├── moving_average.go │ ├── moving_average_test.flux │ ├── moving_average_test.go │ ├── multiple_range_test.flux │ ├── parallel.go │ ├── parse_regex_test.flux │ ├── pivot.gen.go │ ├── pivot.gen.go.tmpl │ ├── pivot.go │ ├── pivot_col_order_test.flux │ ├── pivot_fields_test.flux │ ├── pivot_internal_test.go │ ├── pivot_mean_test.flux │ ├── pivot_table_test.flux │ ├── pivot_task_test_test.flux │ ├── pivot_test.flux │ ├── pivot_test.go │ ├── quantile.go │ ├── quantile_agg_test.flux │ ├── quantile_aggregate_test.flux │ ├── quantile_defaults_test.flux │ ├── quantile_tdigest_test.flux │ ├── quantile_test.flux │ ├── quantile_test.go │ ├── range.go │ ├── range_nsecs_test.flux │ ├── range_stop_test.flux │ ├── range_test.flux │ ├── range_test.go │ ├── reduce.go │ ├── reduce_noref_test.flux │ ├── reduce_test.flux │ ├── reduce_test.go │ ├── relative_strength_index.go │ ├── relative_strength_index_test.flux │ ├── relative_strength_index_test.go │ ├── rename_fn_test.flux │ ├── rename_multiple_test.flux │ ├── rename_test.flux │ ├── rowfn_with_import_test.flux │ ├── sample.go │ ├── sample_test.flux │ ├── sample_test.go │ ├── schema_functions.go │ ├── schema_functions_test.go │ ├── schema_mutators.go │ ├── selector_preserve_time_test.flux │ ├── set.go │ ├── set_new_column_test.flux │ ├── set_test.flux │ ├── set_test.go │ ├── shift.go │ ├── shift2.go │ ├── shift_negative_duration_test.flux │ ├── shift_test.flux │ ├── shift_test.go │ ├── show_all_tag_keys_test.flux │ ├── simple_max_test.flux │ ├── skew.go │ ├── skew_test.flux │ ├── skew_test.go │ ├── sort.go │ ├── sort2_test.flux │ ├── sort_limit.go │ ├── sort_limit_test.flux │ ├── sort_limit_test.go │ ├── sort_rules_test.flux │ ├── sort_test.flux │ ├── sort_test.go │ ├── spread.go │ ├── spread_test.flux │ ├── spread_test.go │ ├── state_count_test.flux │ ├── state_duration_test.flux │ ├── state_tracking.go │ ├── state_tracking_test.go │ ├── stddev.go │ ├── stddev_test.flux │ ├── stddev_test.go │ ├── string_interp_test.flux │ ├── string_max_test.flux │ ├── string_sort_test.flux │ ├── string_test.flux │ ├── sum.go │ ├── sum_test.flux │ ├── sum_test.go │ ├── table_fns.go │ ├── table_fns_findcolumn_map_test.flux │ ├── table_fns_findrecord_map_test.flux │ ├── table_fns_test.flux │ ├── table_fns_test.go │ ├── tail.go │ ├── tail_offset_test.flux │ ├── tail_test.flux │ ├── tail_test.go │ ├── task_per_line_test.flux │ ├── time_weighted_avg_test.flux │ ├── timed_moving_average_test.flux │ ├── to_convert_test.flux │ ├── today_test.flux │ ├── top_test.flux │ ├── transformations.go │ ├── triple_exponential_derivative.go │ ├── triple_exponential_derivative_test.flux │ ├── triple_exponential_derivative_test.go │ ├── triple_exponential_moving_average_test.flux │ ├── typeconv.go │ ├── typeconv_test.go │ ├── union.go │ ├── union2.go │ ├── union_heterogeneous_test.flux │ ├── union_test.flux │ ├── union_test.go │ ├── unique.go │ ├── unique_test.flux │ ├── unique_test.go │ ├── universe.flux │ ├── universe_truncateTimeColumn_test.flux │ ├── window.go │ ├── window2.go │ ├── window_aggregate_test.flux │ ├── window_default_start_align_test.flux │ ├── window_default_test.flux │ ├── window_generate_empty_test.flux │ ├── window_group_mean_ungroup_test.flux │ ├── window_location_test.flux │ ├── window_null_test.flux │ ├── window_start_bound_test.flux │ ├── window_test.flux │ ├── window_test.go │ ├── yield.go │ ├── yield_test.flux │ └── yield_test.go ├── time.go ├── time_test.go ├── tools └── tools.go └── values ├── array.go ├── array_test.go ├── binary.gen.go ├── binary.gen.go.tmpl ├── binary.go ├── binary_test.go ├── bool.go ├── conditional.gen.go ├── conditional.gen.go.tmpl ├── dict.go ├── dict_test.go ├── display.go ├── display_test.go ├── dynamic.go ├── function.go ├── gen.go ├── object.go ├── object_test.go ├── objects └── table.go ├── option.go ├── package.go ├── scope.go ├── time.go ├── time_test.go ├── types.tmpldata ├── unary.gen.go ├── unary.gen.go.tmpl ├── values.go ├── values_test.go ├── valuestest └── scope.go ├── vector.go ├── vector_test.go ├── vector_values.gen.go └── vector_values.gen.go.tmpl /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | target: auto 6 | threshold: 5 7 | base: auto 8 | patch: 9 | default: 10 | target: auto 11 | threshold: 5 12 | base: auto 13 | informational: true 14 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | libflux/target/ 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.go.tmpl] 8 | indent_style = tab 9 | 10 | [Makefile] 11 | indent_style = tab 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | internal/fbsemantic/semantic_generated.go binary merge=theirs 2 | ast/internal/fbast/ast_generated.go binary merge=theirs 3 | libflux/go/libflux/buildinfo.gen.go binary merge=theirs 4 | libflux/scanner.c binary merge=theirs 5 | libflux/core/src/semantic/flatbuffers/semantic_generated.rs binary merge=theirs 6 | libflux/core/src/ast/flatbuffers/ast_generated.rs binary merge=theirs 7 | libflux/flux/src/benches/everything.flux binary merge=theirs 8 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Checklist 2 | 3 | Dear Author :wave:, the following checks should be completed (or explicitly dismissed) before merging. 4 | 5 | - [ ] ✏️ Write a PR description, regardless of triviality, to include the _value_ of this PR 6 | - [ ] 🔗 Reference related issues 7 | - [ ] 🏃 Test cases are included to exercise the new code 8 | - [ ] 🧪 If **new packages** are being introduced to stdlib, link to Working Group discussion notes and ensure it lands under `experimental/` 9 | - [ ] 📖 If **language features** are changing, ensure `docs/Spec.md` has been updated 10 | 11 | Dear Reviewer(s) :wave:, you are responsible (among others) for ensuring the completeness and quality of the above before approval. 12 | -------------------------------------------------------------------------------- /.github/semantic.yml: -------------------------------------------------------------------------------- 1 | # docs: https://github.com/probot/semantic-pull-requests#configuration 2 | # Always validate the PR title AND all the commits 3 | titleOnly: true 4 | titleAndCommits: false 5 | -------------------------------------------------------------------------------- /.github/workflows/semantic.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Semantic PR and Commit Messages" 3 | 4 | on: 5 | pull_request: 6 | types: [opened, reopened, synchronize, edited] 7 | 8 | jobs: 9 | semantic: 10 | with: 11 | CHECK_PR_TITLE_OR_ONE_COMMIT: false 12 | uses: influxdata/validate-semantic-github-messages/.github/workflows/semantic.yml@main 13 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. 2 | # 3 | # You can adjust the behavior by modifying this file. 4 | # For more information, see: 5 | # https://github.com/actions/stale 6 | name: Mark stale issues and pull requests 7 | 8 | on: 9 | schedule: 10 | - cron: '21 1 * * *' 11 | 12 | jobs: 13 | stale: 14 | 15 | runs-on: ubuntu-latest 16 | permissions: 17 | issues: write 18 | pull-requests: write 19 | 20 | steps: 21 | - uses: actions/stale@v5 22 | with: 23 | repo-token: ${{ secrets.GITHUB_TOKEN }} 24 | stale-issue-message: 'This issue has had no recent activity and will be closed soon.' 25 | stale-pr-message: 'This PR has had no recent activity and will be closed soon.' 26 | stale-issue-label: 'no-issue-activity' 27 | stale-pr-label: 'no-pr-activity' 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /vendor 3 | **/target 4 | /dist 5 | .DS_Store 6 | .netrc 7 | .vscode 8 | .vs 9 | .tern-project 10 | .idea 11 | /coverage.txt 12 | /libflux/lib 13 | /libflux/pkg 14 | /libflux/site/node_modules 15 | /libflux/.cache 16 | /libflux/go/libflux/hack.gen.go 17 | /release-notes.txt 18 | cmake-build-debug 19 | /generated_docs 20 | /stdlib-compiled 21 | 22 | # exclude any files with the name flux but 23 | # include any directories that share the same name. 24 | **/flux 25 | !**/flux/ 26 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | project_name: flux 2 | builds: 3 | - goos: 4 | - linux 5 | goarch: 6 | - amd64 7 | main: ./cmd/flux 8 | env: 9 | - GO111MODULE=on 10 | - CGO_ENABLED=1 11 | - PKG_CONFIG=/go/bin/pkg-config 12 | ldflags: -s -w -X main.commit={{.Commit}} 13 | binary: flux 14 | 15 | archives: 16 | - format: tar.gz 17 | wrap_in_directory: true 18 | format_overrides: 19 | - goos: windows 20 | format: zip 21 | name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' 22 | files: 23 | - LICENSE 24 | - README.md 25 | 26 | 27 | release: 28 | prerelease: auto 29 | name_template: "v{{.Version}}" 30 | extra_files: 31 | - glob: ./generated_docs/*.json 32 | 33 | -------------------------------------------------------------------------------- /.hugo_build.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/.hugo_build.lock -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2018 InfluxData Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /a.flux: -------------------------------------------------------------------------------- 1 | import "array" 2 | import "internal/debug" 3 | 4 | array.from(rows: [{}]) 5 | |> debug.sink() 6 | -------------------------------------------------------------------------------- /array/repeat.gen.go.tmpl: -------------------------------------------------------------------------------- 1 | package array 2 | 3 | import ( 4 | "github.com/apache/arrow/go/v7/arrow/memory" 5 | ) 6 | 7 | {{range .}}{{if .ArrowType}} 8 | func {{.Name}}Repeat(v {{.PrimitiveType}}, isNull bool, n int, mem memory.Allocator) *{{.Name}} { 9 | b := New{{.Name}}Builder(mem) 10 | b.Resize(n) 11 | if isNull { 12 | for i := 0; i < n; i++ { 13 | b.AppendNull() 14 | } 15 | } else { 16 | for i := 0; i < n; i++ { 17 | b.Append(v) 18 | } 19 | } 20 | return b.New{{.Name}}Array() 21 | } 22 | {{end}}{{end}} 23 | -------------------------------------------------------------------------------- /array/repeat.go: -------------------------------------------------------------------------------- 1 | package array 2 | 3 | import "github.com/apache/arrow/go/v7/arrow/memory" 4 | 5 | func StringRepeat(v string, n int, mem memory.Allocator) *String { 6 | sv := stringValue{ 7 | data: mem.Allocate(len(v)), 8 | mem: mem, 9 | rc: 1, 10 | } 11 | copy(sv.data, v) 12 | return &String{ 13 | value: &sv, 14 | length: n, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /array/unary.tmpldata: -------------------------------------------------------------------------------- 1 | { 2 | "Ops":[ 3 | { 4 | "Name": "UnarySub", 5 | "Op": "-", 6 | "Types": ["Int", "Float"] 7 | } 8 | ], 9 | "EqualityOps":[ 10 | { 11 | "Name": "Exists", 12 | "Op": "exists", 13 | "Types": ["Int", "Uint", "Float", "String", "Boolean", "Time"] 14 | }, 15 | { 16 | "Name": "Not", 17 | "Op": "not", 18 | "Types": ["Boolean"] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /arrow/allocator.go: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/memory" 5 | arrowmemory "github.com/apache/arrow/go/v7/arrow/memory" 6 | ) 7 | 8 | func NewAllocator(a memory.Allocator) arrowmemory.Allocator { 9 | return a 10 | } 11 | -------------------------------------------------------------------------------- /arrow/bool.go: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/array" 5 | "github.com/InfluxCommunity/flux/memory" 6 | ) 7 | 8 | func NewBool(vs []bool, alloc memory.Allocator) *array.Boolean { 9 | b := NewBoolBuilder(alloc) 10 | b.Resize(len(vs)) 11 | for _, v := range vs { 12 | b.UnsafeAppend(v) 13 | } 14 | a := b.NewBooleanArray() 15 | b.Release() 16 | return a 17 | } 18 | 19 | func BoolSlice(arr *array.Boolean, i, j int) *array.Boolean { 20 | return Slice(arr, int64(i), int64(j)).(*array.Boolean) 21 | } 22 | 23 | func NewBoolBuilder(a memory.Allocator) *array.BooleanBuilder { 24 | if a == nil { 25 | a = memory.DefaultAllocator 26 | } 27 | return array.NewBooleanBuilder(a) 28 | } 29 | -------------------------------------------------------------------------------- /arrow/float.go: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/array" 5 | "github.com/InfluxCommunity/flux/memory" 6 | ) 7 | 8 | func NewFloat(vs []float64, alloc memory.Allocator) *array.Float { 9 | b := NewFloatBuilder(alloc) 10 | b.Resize(len(vs)) 11 | for _, v := range vs { 12 | b.UnsafeAppend(v) 13 | } 14 | a := b.NewFloatArray() 15 | b.Release() 16 | return a 17 | } 18 | 19 | func FloatSlice(arr *array.Float, i, j int) *array.Float { 20 | return Slice(arr, int64(i), int64(j)).(*array.Float) 21 | } 22 | 23 | func NewFloatBuilder(a memory.Allocator) *array.FloatBuilder { 24 | if a == nil { 25 | a = memory.DefaultAllocator 26 | } 27 | return array.NewFloatBuilder(a) 28 | } 29 | -------------------------------------------------------------------------------- /arrow/int.go: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/array" 5 | "github.com/InfluxCommunity/flux/memory" 6 | ) 7 | 8 | func NewInt(vs []int64, alloc memory.Allocator) *array.Int { 9 | b := NewIntBuilder(alloc) 10 | b.Resize(len(vs)) 11 | for _, v := range vs { 12 | b.UnsafeAppend(v) 13 | } 14 | a := b.NewIntArray() 15 | b.Release() 16 | return a 17 | } 18 | 19 | func IntSlice(arr *array.Int, i, j int) *array.Int { 20 | return Slice(arr, int64(i), int64(j)).(*array.Int) 21 | } 22 | 23 | func NewIntBuilder(a memory.Allocator) *array.IntBuilder { 24 | if a == nil { 25 | a = memory.DefaultAllocator 26 | } 27 | return array.NewIntBuilder(a) 28 | } 29 | -------------------------------------------------------------------------------- /arrow/string.go: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/array" 5 | "github.com/InfluxCommunity/flux/memory" 6 | ) 7 | 8 | func NewString(vs []string, alloc memory.Allocator) *array.String { 9 | b := NewStringBuilder(alloc) 10 | b.Resize(len(vs)) 11 | sz := 0 12 | for _, v := range vs { 13 | sz += len(v) 14 | } 15 | b.ReserveData(sz) 16 | for _, v := range vs { 17 | b.Append(v) 18 | } 19 | a := b.NewStringArray() 20 | b.Release() 21 | return a 22 | } 23 | 24 | func StringSlice(arr *array.String, i, j int) *array.String { 25 | return Slice(arr, int64(i), int64(j)).(*array.String) 26 | } 27 | 28 | func NewStringBuilder(a memory.Allocator) *array.StringBuilder { 29 | if a == nil { 30 | a = memory.DefaultAllocator 31 | } 32 | return array.NewStringBuilder(a) 33 | } 34 | -------------------------------------------------------------------------------- /arrow/uint.go: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/array" 5 | "github.com/InfluxCommunity/flux/memory" 6 | ) 7 | 8 | func NewUint(vs []uint64, alloc memory.Allocator) *array.Uint { 9 | b := NewUintBuilder(alloc) 10 | b.Resize(len(vs)) 11 | for _, v := range vs { 12 | b.UnsafeAppend(v) 13 | } 14 | a := b.NewUintArray() 15 | b.Release() 16 | return a 17 | } 18 | 19 | func UintSlice(arr *array.Uint, i, j int) *array.Uint { 20 | return Slice(arr, int64(i), int64(j)).(*array.Uint) 21 | } 22 | 23 | func NewUintBuilder(a memory.Allocator) *array.UintBuilder { 24 | if a == nil { 25 | a = memory.DefaultAllocator 26 | } 27 | return array.NewUintBuilder(a) 28 | } 29 | -------------------------------------------------------------------------------- /ast/asttest/cmp.go: -------------------------------------------------------------------------------- 1 | package asttest 2 | 3 | import ( 4 | "regexp" 5 | 6 | "github.com/google/go-cmp/cmp" 7 | ) 8 | 9 | var CmpOptions = []cmp.Option{ 10 | cmp.Comparer(func(x, y *regexp.Regexp) bool { 11 | if x == nil && y == nil { 12 | return true 13 | } 14 | if x == nil || y == nil { 15 | return false 16 | } 17 | return x.String() == y.String() 18 | }), 19 | } 20 | -------------------------------------------------------------------------------- /ast/asttest/doc.go: -------------------------------------------------------------------------------- 1 | // Package asttest implements utilities for testing the abstract syntax tree. 2 | package asttest 3 | -------------------------------------------------------------------------------- /ast/asttest/gen.go: -------------------------------------------------------------------------------- 1 | package asttest 2 | 3 | import ( 4 | "regexp" 5 | 6 | "github.com/google/go-cmp/cmp" 7 | ) 8 | 9 | //go:generate go run github.com/InfluxCommunity/flux/internal/cmd/cmpgen cmpopts.go 10 | 11 | var CompareOptions = append(IgnoreBaseNodeOptions, 12 | cmp.Comparer(func(x, y *regexp.Regexp) bool { return x.String() == y.String() }), 13 | ) 14 | -------------------------------------------------------------------------------- /ast/astutil/format.go: -------------------------------------------------------------------------------- 1 | package astutil 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/InfluxCommunity/flux/ast" 7 | "github.com/InfluxCommunity/flux/runtime" 8 | ) 9 | 10 | // Format will format the AST to a string. 11 | func Format(f *ast.File) (string, error) { 12 | pkg := &ast.Package{ 13 | Files: []*ast.File{f}, 14 | } 15 | if f.Package != nil && f.Package.Name != nil { 16 | pkg.Package = f.Package.Name.Name 17 | } 18 | data, err := json.Marshal(pkg) 19 | if err != nil { 20 | return "", err 21 | } 22 | hdl, err := runtime.Default.JSONToHandle(data) 23 | if err != nil { 24 | return "", err 25 | } 26 | return hdl.Format() 27 | } 28 | -------------------------------------------------------------------------------- /benchmarks/flux/curl-format.txt: -------------------------------------------------------------------------------- 1 | \n 2 | time_starttransfer: %{time_starttransfer}\n 3 | size_download: %{size_download}\n 4 | time_total: %{time_total}\n 5 | \n 6 | -------------------------------------------------------------------------------- /bounds.go: -------------------------------------------------------------------------------- 1 | package flux 2 | 3 | import "time" 4 | 5 | type Bounds struct { 6 | Start Time 7 | Stop Time 8 | Now time.Time 9 | } 10 | 11 | // IsEmpty reports whether the given bounds 12 | // are empty, i.e., if start >= stop. 13 | func (b Bounds) IsEmpty() bool { 14 | return b.Start.Time(b.Now).Equal(b.Stop.Time(b.Now)) || b.Start.Time(b.Now).After(b.Stop.Time(b.Now)) 15 | } 16 | 17 | // HasZero returns true if the given bounds contain a Go zero time value as either Start or Stop. 18 | func (b Bounds) HasZero() bool { 19 | return b.Start.IsZero() || b.Stop.IsZero() 20 | } 21 | -------------------------------------------------------------------------------- /cmd/flux/repl.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/repl" 7 | ) 8 | 9 | func replE(ctx context.Context, opts ...repl.Option) error { 10 | r := repl.New(ctx, opts...) 11 | r.Run() 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /cmd/flux/testdata/fluxtest.root: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testdata", 3 | "tags": [ 4 | "a", 5 | "b", 6 | "c", 7 | "fail" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /cmd/flux/testdata/pkga/fluxtest.root: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pkga", 3 | "tags": [ 4 | "foo" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /cmd/flux/testdata/pkga/pkga_test.flux: -------------------------------------------------------------------------------- 1 | package pkga_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | 7 | testcase bar { 8 | option testing.tags = ["foo"] 9 | array.from(rows: [{}]) 10 | } 11 | 12 | testcase untagged_extends extends "testdata/test_test.untagged" { 13 | option testing.tags = ["foo"] 14 | // Note this test is tagged with foo because of the package level 15 | // option statement 16 | super() 17 | } 18 | 19 | testcase duplicate { 20 | want = array.from(rows: [{_value: 1}]) 21 | got = array.from(rows: [{_value: 1}]) 22 | 23 | testing.diff(want, got) 24 | } 25 | -------------------------------------------------------------------------------- /cmd/flux/testdata/pkgb/pkgb_test.flux: -------------------------------------------------------------------------------- 1 | package pkgb_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | 7 | testcase duplicate { 8 | want = array.from(rows: [{_value: 1}]) 9 | got = array.from(rows: [{_value: 1}]) 10 | 11 | testing.diff(want, got) 12 | } 13 | -------------------------------------------------------------------------------- /cmd/flux/testdata/test_test.flux: -------------------------------------------------------------------------------- 1 | package test_test 2 | 3 | 4 | import "array" 5 | import "testing" 6 | 7 | testcase a { 8 | option testing.tags = ["a"] 9 | 10 | array.from(rows: [{}]) 11 | } 12 | testcase ab { 13 | option testing.tags = ["a", "b"] 14 | 15 | array.from(rows: [{}]) 16 | } 17 | testcase abc { 18 | option testing.tags = ["a", "b", "c"] 19 | 20 | array.from(rows: [{}]) 21 | } 22 | 23 | testcase fails { 24 | option testing.tags = ["fail"] 25 | 26 | want = array.from(rows: [{_value: 1}]) 27 | got = array.from(rows: [{_value: 0}]) 28 | 29 | testing.diff(want, got) 30 | } 31 | testcase untagged { 32 | array.from(rows: [{}]) 33 | } -------------------------------------------------------------------------------- /compiler/doc.go: -------------------------------------------------------------------------------- 1 | // The compiler package provides a compiler and Go runtime for a subset of the Flux language. 2 | // Only pure functions are supported by the compiler. 3 | // A function is compiled and then may be called repeatedly with different arguments. 4 | // The function must be pure meaning it has no side effects. Other language features are not supported. 5 | // 6 | // This runtime is not portable by design. The runtime consists of Go types that have been constructed based on the Flux function being compiled. 7 | // Those types are not serializable and cannot be transported to other systems or environments. 8 | // This design is intended to limit the scope under which compilation must be supported. 9 | package compiler 10 | -------------------------------------------------------------------------------- /csv/result_internal_test.go: -------------------------------------------------------------------------------- 1 | package csv 2 | 3 | import "sync/atomic" 4 | 5 | func (d *tableDecoder) IsDone() bool { 6 | return d.empty || atomic.LoadInt32(&d.used) != 0 7 | } 8 | -------------------------------------------------------------------------------- /dependencies/bigtable/provider_test.go: -------------------------------------------------------------------------------- 1 | package bigtable_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux/dependencies/bigtable" 8 | ) 9 | 10 | func TestGetNoProvider(t *testing.T) { 11 | ctx := context.Background() 12 | 13 | got := bigtable.GetProvider(ctx) 14 | if _, ok := got.(bigtable.ErrorProvider); !ok { 15 | t.Fatalf("expected error provider, got:\n%T", got) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dependencies/feature/flagger.go: -------------------------------------------------------------------------------- 1 | package feature 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/internal/feature" 7 | ) 8 | 9 | type ( 10 | Flagger = feature.Flagger 11 | Flag = feature.Flag 12 | ) 13 | 14 | // Inject injects a Flagger to the context.Context. 15 | func Inject(ctx context.Context, flagger Flagger) context.Context { 16 | return feature.Inject(ctx, flagger) 17 | } 18 | 19 | type Dependency struct { 20 | Flagger Flagger 21 | } 22 | 23 | func (d Dependency) Inject(ctx context.Context) context.Context { 24 | return Inject(ctx, d.Flagger) 25 | } 26 | 27 | // Flags returns all feature flags. 28 | func Flags() []Flag { 29 | return feature.Flags() 30 | } 31 | 32 | // ByKey returns the Flag corresponding to the given key. 33 | func ByKey(k string) (Flag, bool) { 34 | return feature.ByKey(k) 35 | } 36 | 37 | type Metrics = feature.Metrics 38 | 39 | // SetMetrics sets the metric store for feature flags. 40 | func SetMetrics(m Metrics) { 41 | feature.SetMetrics(m) 42 | } 43 | -------------------------------------------------------------------------------- /dependencies/filesystem/ioutil.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "context" 5 | "io" 6 | "os" 7 | ) 8 | 9 | // ReadFile will open the file from the service and read 10 | // the entire contents. 11 | func ReadFile(ctx context.Context, filename string) ([]byte, error) { 12 | fs, err := Get(ctx) 13 | if err != nil { 14 | return nil, err 15 | } 16 | f, err := fs.Open(filename) 17 | if err != nil { 18 | return nil, err 19 | } 20 | defer func() { _ = f.Close() }() 21 | return io.ReadAll(f) 22 | } 23 | 24 | // OpenFile will open the file from the service. 25 | func OpenFile(ctx context.Context, filename string) (File, error) { 26 | fs, err := Get(ctx) 27 | if err != nil { 28 | return nil, err 29 | } 30 | return fs.Open(filename) 31 | } 32 | 33 | // Stat will retrieve the os.FileInfo for a file. 34 | func Stat(ctx context.Context, filename string) (os.FileInfo, error) { 35 | fs, err := Get(ctx) 36 | if err != nil { 37 | return nil, err 38 | } 39 | f, err := fs.Open(filename) 40 | if err != nil { 41 | return nil, err 42 | } 43 | defer func() { _ = f.Close() }() 44 | return f.Stat() 45 | } 46 | -------------------------------------------------------------------------------- /dependencies/filesystem/systemfs.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | // SystemFS implements the filesystem.Service by proxying all requests 8 | // to the filesystem. 9 | var SystemFS Service = systemFS{} 10 | 11 | type systemFS struct{} 12 | 13 | func (systemFS) Open(fpath string) (File, error) { 14 | f, err := os.Open(fpath) 15 | if err != nil { 16 | return nil, err 17 | } 18 | return f, nil 19 | } 20 | -------------------------------------------------------------------------------- /dependencies/influxdb/provider_test.go: -------------------------------------------------------------------------------- 1 | package influxdb_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux/dependencies/influxdb" 8 | "github.com/google/go-cmp/cmp" 9 | ) 10 | 11 | func TestGetProvider(t *testing.T) { 12 | want := influxdb.HttpProvider{ 13 | DefaultConfig: influxdb.Config{ 14 | Host: "http://localhost:8086", 15 | }, 16 | } 17 | ctx := influxdb.Dependency{ 18 | Provider: want, 19 | }.Inject(context.Background()) 20 | 21 | got := influxdb.GetProvider(ctx) 22 | if !cmp.Equal(want, got) { 23 | t.Fatalf("unexpected provider -want/+got:\n%s", cmp.Diff(want, got)) 24 | } 25 | } 26 | 27 | func TestGetNoProvider(t *testing.T) { 28 | ctx := context.Background() 29 | 30 | got := influxdb.GetProvider(ctx) 31 | if _, ok := got.(influxdb.ErrorProvider); !ok { 32 | t.Fatalf("expected error provider, got:\n%T", got) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dependencies/secret/empty_secret_service.go: -------------------------------------------------------------------------------- 1 | package secret 2 | 3 | import ( 4 | "context" 5 | "github.com/InfluxCommunity/flux/codes" 6 | "github.com/InfluxCommunity/flux/internal/errors" 7 | ) 8 | 9 | func (ess EmptySecretService) LoadSecret(ctx context.Context, k string) (string, error) { 10 | return "", errors.Newf(codes.NotFound, "secret key %q not found", k) 11 | } 12 | 13 | // Secret service that always reports no secrets exist 14 | type EmptySecretService struct { 15 | } 16 | -------------------------------------------------------------------------------- /dependencies/secret/environment_secret_service.go: -------------------------------------------------------------------------------- 1 | package secret 2 | 3 | import ( 4 | "context" 5 | "os" 6 | ) 7 | 8 | func (ess EnvironmentSecretService) LoadSecret(ctx context.Context, k string) (string, error) { 9 | return os.Getenv(k), nil 10 | } 11 | 12 | // Secret service that retrieve the system environment variables. 13 | type EnvironmentSecretService struct { 14 | } 15 | -------------------------------------------------------------------------------- /dependencies/secret/secret_service.go: -------------------------------------------------------------------------------- 1 | package secret 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | // Service generalizes the process of looking up secrets based on a key. 8 | type Service interface { 9 | // LoadSecret retrieves the secret value v found at key k given the calling context ctx. 10 | LoadSecret(ctx context.Context, k string) (string, error) 11 | } 12 | -------------------------------------------------------------------------------- /dependencies/secret/secret_service_test.go: -------------------------------------------------------------------------------- 1 | package secret_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux/mock" 8 | ) 9 | 10 | func TestSecret_Service(t *testing.T) { 11 | ss := mock.SecretService{"key": "val"} 12 | val, err := ss.LoadSecret(context.Background(), "key") 13 | if err != nil { 14 | t.Fatal(err) 15 | } 16 | if val != "val" { 17 | t.Error("secret service returned wrong value") 18 | } 19 | 20 | if _, err = ss.LoadSecret(context.Background(), "k"); err == nil { 21 | t.Error("secret service should have errored on key lookup") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /dependency/dependency_test.go: -------------------------------------------------------------------------------- 1 | package dependency_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux/dependency" 8 | ) 9 | 10 | type Dependency struct { 11 | InjectFn func(ctx context.Context) context.Context 12 | } 13 | 14 | func (d *Dependency) Inject(ctx context.Context) context.Context { 15 | return d.InjectFn(ctx) 16 | } 17 | 18 | type CloseFunc func() error 19 | 20 | func (f CloseFunc) Close() error { 21 | return f() 22 | } 23 | 24 | func TestOnFinish(t *testing.T) { 25 | closed := false 26 | _, span := dependency.Inject(context.Background(), &Dependency{ 27 | InjectFn: func(ctx context.Context) context.Context { 28 | dependency.OnFinish(ctx, CloseFunc(func() error { 29 | closed = true 30 | return nil 31 | })) 32 | return ctx 33 | }, 34 | }) 35 | 36 | if closed { 37 | t.Fatal("finish hook should not have been executed, but was") 38 | } 39 | span.Finish() 40 | if !closed { 41 | t.Fatal("finish hook did not execute") 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /dialect.go: -------------------------------------------------------------------------------- 1 | package flux 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/codes" 5 | "github.com/InfluxCommunity/flux/internal/errors" 6 | ) 7 | 8 | // Dialect describes how to encode results. 9 | type Dialect interface { 10 | // Encoder creates an encoder for the results 11 | Encoder() MultiResultEncoder 12 | // DialectType report the type of the dialect 13 | DialectType() DialectType 14 | } 15 | 16 | // DialectType is the name of a query result dialect. 17 | type DialectType string 18 | type CreateDialect func() Dialect 19 | 20 | type DialectMappings map[DialectType]CreateDialect 21 | 22 | func (m DialectMappings) Add(t DialectType, c CreateDialect) error { 23 | if _, ok := m[t]; ok { 24 | return errors.Newf(codes.Internal, "duplicate dialect mapping for %q", t) 25 | } 26 | m[t] = c 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /docs/Plan.md: -------------------------------------------------------------------------------- 1 | # Plan DAG 2 | 3 | The plan is represented as a DAG, where each node performs an operation and produces a result. 4 | The plan DAG is separate and distinct from the query DAG. 5 | The plan DAG specifies details about how the query will be executed, while the query DAG only specifies what the query is. 6 | 7 | There may be multiple roots to the DAG where each root represents a source of data. 8 | A root or source node may retrieve data from multiple different systems. 9 | Primarily data will be read from the storage interface, but may be streamed from the write ingest system or potentially external systems as well. 10 | 11 | The leaves of the DAG represent the results of the operation. 12 | The results are collected and returned. 13 | 14 | -------------------------------------------------------------------------------- /docs/Query.md: -------------------------------------------------------------------------------- 1 | # Query DAG 2 | 3 | The query is represented as a DAG, where each node represents an operation to be performed. 4 | 5 | There may be multiple roots to the DAG where each root represents a source of data. 6 | Root nodes will specify whether they are selecting data from the database or consuming data as a stream. 7 | 8 | The leaves of the DAG represent the results of the operation. 9 | A result node may be added as a child to any node to make that intermediate representation a finalized result. 10 | 11 | ## Specification 12 | 13 | A query DAG consists of a set of nodes and a set of edges that form a directed acyclic graph (DAG). 14 | 15 | Each node has the following properties: 16 | 17 | * ID - A unique identifier for the node within the graph. 18 | * Kind - The kind of operation the node performs. 19 | * Spec - The spec, specifies the parameters provided to the node detailing the specifics of the operation. 20 | The parameters vary by the kind of node. 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/Release.md: -------------------------------------------------------------------------------- 1 | ### Creating Release tag 2 | We are using semantic versioning with the format "vMajor.Minor.Patch" 3 | 4 | ```sh 5 | git tag -s v0.0.1 6 | make release 7 | ``` 8 | 9 | -------------------------------------------------------------------------------- /docs/user_docs/images/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/docs/user_docs/images/image1.png -------------------------------------------------------------------------------- /docs/user_docs/images/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/docs/user_docs/images/image2.png -------------------------------------------------------------------------------- /docs/user_docs/images/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/docs/user_docs/images/image3.png -------------------------------------------------------------------------------- /docs/user_docs/images/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/docs/user_docs/images/image4.png -------------------------------------------------------------------------------- /docs/user_docs/images/image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/docs/user_docs/images/image5.png -------------------------------------------------------------------------------- /errors.go: -------------------------------------------------------------------------------- 1 | package flux 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/codes" 5 | "github.com/InfluxCommunity/flux/internal/errors" 6 | ) 7 | 8 | type Error = errors.Error 9 | 10 | // ErrorCode returns the error code for the given error. 11 | // If the error is not a flux.Error, this will return 12 | // Unknown for the code. If the error is a flux.Error 13 | // and its code is Inherit, then this will return the 14 | // wrapped error's code. 15 | func ErrorCode(err error) codes.Code { 16 | return errors.Code(err) 17 | } 18 | 19 | // ErrorDocURL returns the DocURL associated with this error 20 | // if one exists. This will return the outermost DocURL 21 | // associated with this error unless the code is Inherit. 22 | // If the code for an error is Inherit, this will return 23 | // the DocURL for the nested error if it exists. 24 | func ErrorDocURL(err error) string { 25 | return errors.DocURL(err) 26 | } 27 | -------------------------------------------------------------------------------- /etc/checkdocs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | stdlib=${FLUX_STDLIB_DIR-./stdlib} 6 | fluxdoc=${FLUXDOC-fluxdoc} 7 | 8 | # Lint the docs to ensure they are valid 9 | $fluxdoc lint --dir ${stdlib} 10 | -------------------------------------------------------------------------------- /etc/checkgenerate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | make cleangenerate 6 | make generate 7 | 8 | status=$(git status --porcelain) 9 | if [ -n "$status" ]; then 10 | >&2 echo "generated code is not accurate, please run make generate" 11 | >&2 echo "ragel version is: $(ragel --version)" 12 | >&2 echo -e "Files changed:\n$status" 13 | >&2 git diff 14 | exit 1 15 | fi 16 | -------------------------------------------------------------------------------- /etc/checkprepared.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script's purpose is to check that any needed changes to the source 4 | # have been made prerelease. 5 | # 6 | # For example we check that all instances of 'introduced: NEXT' in the docs 7 | # have been replaced with a version instead. 8 | 9 | # Make sure we are at the repo root 10 | DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)/.. 11 | cd $DIR 12 | 13 | EXIT=0 14 | while read f 15 | do 16 | # Check for any 'introduced: NEXT' or 'deprecated: NEXT' comments that still exist 17 | grep '^//[[:space:]]*\(introduced\|deprecated\):[[:space:]]\+NEXT[[:space:]]*$' $f > /dev/null 18 | ret=$? 19 | if [ $ret -eq 0 ] 20 | then 21 | EXIT=1 22 | echo "$f contains 'introduced: NEXT' or 'deprecated: NEXT'" 23 | fi 24 | done < <(find ./stdlib -name '*.flux') 25 | 26 | if [ $EXIT -ne 0 ] 27 | then 28 | echo "Flux not prepared for release. Run ./prep_release.sh to start the release preparation process." 29 | fi 30 | exit $EXIT 31 | -------------------------------------------------------------------------------- /etc/checkreproducibility.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | check_library_hash() { 6 | md5sum libflux/target/*/libflux.a 7 | } 8 | 9 | # Ensure the build tree is clean (it should be) and then build 10 | # the libflux library. 11 | make clean 12 | make libflux 13 | 14 | check_library_hash > md5sum.txt 15 | trap "rm -f md5sum.txt" EXIT 16 | 17 | make clean 18 | make libflux 19 | 20 | if ! diff -u md5sum.txt <(check_library_hash); then 21 | echo "Build produced two different hashes when built twice" 2>&1 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /etc/checktidy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export GO111MODULE=on 6 | go mod tidy 7 | 8 | if ! git --no-pager diff --exit-code -- go.mod go.sum; then 9 | >&2 echo "modules are not tidy, please run 'go mod tidy'" 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /etc/fixup_docs_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Make sure we are at the repo root 4 | DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd) 5 | cd $DIR/.. 6 | 7 | # Version is the first and only arg, remove the 'v' prefix. 8 | version=${1//v/} 9 | 10 | while read f 11 | do 12 | # Replace any 'introduced: NEXT' or 'deprecated: NEXT' comment with the actual version 13 | perl -pi -e "s,^//\s*(introduced|deprecated):\s+NEXT\s*$,// \1: $version\n,g" $f 14 | done < <(find ./stdlib -name '*.flux') 15 | -------------------------------------------------------------------------------- /etc/gen_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | stdlib=${FLUX_STDLIB_SRC-./stdlib} 6 | fluxdoc=${FLUXDOC-fluxdoc} 7 | gendir=${DOCS_GEN_DIR-./generated_docs} 8 | full_docs="${gendir}/flux-docs-full.json" 9 | short_docs="${gendir}/flux-docs-short.json" 10 | 11 | # Generate docs JSON files 12 | mkdir -p "${gendir}" 13 | $fluxdoc dump --dir ${stdlib} --output ${full_docs} --nested 14 | $fluxdoc dump --dir ${stdlib} --output ${short_docs} --short 15 | 16 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Flux Examples 2 | 3 | This folder contains a list of usage examples related to the Flux repo. 4 | 5 | - [library](library): Use Flux as a standalone library in your Go programs. 6 | - [fluxpipe](https://github.com/metrico/fluxpipe): Stand-alone Flux API for serverless workers and embedded datasources. 7 | -------------------------------------------------------------------------------- /execute/closer.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | // Closer is an interface to be implemented for a resource 4 | // that will be closed at a defined time. 5 | type Closer interface { 6 | // Close is invoked when the resource will no longer be used. 7 | Close() error 8 | } 9 | 10 | // Close is a convenience method that will take an error and a 11 | // Closer. This will call the Close method on the Closer. If the 12 | // error is nil, it will return any error from the Close method. 13 | // If the error was not nil, it will return the error. 14 | func Close(err error, c Closer) error { 15 | if e := c.Close(); e != nil && err == nil { 16 | err = e 17 | } 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /execute/execute_test.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import ( 4 | "context" 5 | "github.com/InfluxCommunity/flux/plan" 6 | "go.uber.org/zap" 7 | ) 8 | 9 | // ConcurrencyQuotaFromPlan exposes the concurrency quota, supporting test 10 | // cases in execute_test. The test cases there cannot be in the execute package 11 | // due to circular dependencies. 12 | func ConcurrencyQuotaFromPlan(ctx context.Context, p *plan.Spec, logger *zap.Logger) int { 13 | es := &executionState{ 14 | p: p, 15 | ctx: ctx, 16 | resources: p.Resources, 17 | logger: logger, 18 | } 19 | 20 | es.chooseDefaultResources(ctx, es.p) 21 | 22 | return es.resources.ConcurrencyQuota 23 | } 24 | -------------------------------------------------------------------------------- /execute/executetest/allocator.go: -------------------------------------------------------------------------------- 1 | package executetest 2 | 3 | import ( 4 | arrowmem "github.com/apache/arrow/go/v7/arrow/memory" 5 | 6 | "github.com/InfluxCommunity/flux/memory" 7 | ) 8 | 9 | var UnlimitedAllocator = &memory.ResourceAllocator{ 10 | Allocator: Allocator{}, 11 | } 12 | 13 | // Allocator is an allocator for use in test. When a buffer is freed the 14 | // contents are overwritten with a predictable pattern to help detect 15 | // use-after-free scenarios. 16 | type Allocator struct{} 17 | 18 | func (Allocator) Allocate(size int) []byte { 19 | return arrowmem.DefaultAllocator.Allocate(size) 20 | } 21 | 22 | func (a Allocator) Reallocate(size int, b []byte) []byte { 23 | b1 := a.Allocate(size) 24 | copy(b1, b) 25 | a.Free(b) 26 | return b1 27 | } 28 | 29 | func (a Allocator) Free(b []byte) { 30 | var pattern = [...]byte{0x00, 0x33, 0xcc, 0xff} 31 | for i := range b { 32 | b[i] = pattern[i%len(pattern)] 33 | } 34 | arrowmem.DefaultAllocator.Free(b) 35 | } 36 | -------------------------------------------------------------------------------- /execute/executetest/doc.go: -------------------------------------------------------------------------------- 1 | // Package executetest contains utilities for testing the query execution phase. 2 | package executetest 3 | -------------------------------------------------------------------------------- /execute/group_key.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/internal/execute/groupkey" 6 | "github.com/InfluxCommunity/flux/values" 7 | ) 8 | 9 | func NewGroupKey(cols []flux.ColMeta, values []values.Value) flux.GroupKey { 10 | return groupkey.New(cols, values) 11 | } 12 | -------------------------------------------------------------------------------- /execute/group_lookup.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/internal/execute/groupkey" 5 | ) 6 | 7 | type GroupLookup = groupkey.Lookup 8 | 9 | // NewGroupLookup constructs a GroupLookup. 10 | func NewGroupLookup() *GroupLookup { 11 | return groupkey.NewLookup() 12 | } 13 | 14 | type RandomAccessGroupLookup = groupkey.RandomAccessLookup 15 | 16 | // NewRandomAccessGroupLookup constructs a RandomAccessGroupLookup. 17 | func NewRandomAccessGroupLookup() *RandomAccessGroupLookup { 18 | return groupkey.NewRandomAccessLookup() 19 | } 20 | -------------------------------------------------------------------------------- /execute/metadata.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/metadata" 7 | ) 8 | 9 | func RecordEvent(ctx context.Context, key string) { 10 | if HaveExecutionDependencies(ctx) { 11 | deps := GetExecutionDependencies(ctx) 12 | deps.Metadata.ReadWriteView(func(meta *metadata.Metadata) { 13 | if _, ok := meta.Get(key); !ok { 14 | meta.Add(key, true) 15 | } 16 | }) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /execute/recover_debug.go: -------------------------------------------------------------------------------- 1 | //go:build debug 2 | // +build debug 3 | 4 | package execute 5 | 6 | func (es *executionState) recover() {} 7 | func (d *poolDispatcher) recover() {} 8 | -------------------------------------------------------------------------------- /execute/rowreader.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/values" 8 | ) 9 | 10 | type RowReader interface { 11 | Next() bool 12 | GetNextRow() ([]values.Value, error) 13 | ColumnNames() []string 14 | ColumnTypes() []flux.ColType 15 | SetColumns([]interface{}) 16 | io.Closer 17 | } 18 | -------------------------------------------------------------------------------- /execute/table/buffered_internal_test.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import "sync/atomic" 4 | 5 | // IsDone is used to allow the tests to access internal parts 6 | // of the table structure for the table tests. 7 | // This method can only be used by asserting that it exists 8 | // through an anonymous interface. This should not be used 9 | // outside of testing code because there is no guarantee 10 | // on the safety of this method. 11 | func (b *BufferedTable) IsDone() bool { 12 | return len(b.Buffers) == 0 || atomic.LoadInt32(&b.used) != 0 13 | } 14 | -------------------------------------------------------------------------------- /execute/table/iterator.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import "github.com/InfluxCommunity/flux" 4 | 5 | type Iterator []flux.Table 6 | 7 | func (t Iterator) Do(f func(flux.Table) error) error { 8 | for _, tbl := range t { 9 | if err := f(tbl); err != nil { 10 | return err 11 | } 12 | } 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /execute/table/profiler_result.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | ) 6 | 7 | type ProfilerResult struct { 8 | tables Iterator 9 | } 10 | 11 | func NewProfilerResult(tables ...flux.Table) ProfilerResult { 12 | return ProfilerResult{tables} 13 | } 14 | 15 | func (r *ProfilerResult) Name() string { 16 | return "_profiler" 17 | } 18 | 19 | func (r *ProfilerResult) Tables() flux.TableIterator { 20 | return r.tables 21 | } 22 | -------------------------------------------------------------------------------- /execute/table/sort.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/internal/execute/groupkey" 6 | ) 7 | 8 | // Sort will read a TableIterator and produce another TableIterator 9 | // where the keys are sorted. 10 | // 11 | // This method will buffer all of the data since it needs to ensure 12 | // all of the tables are read to avoid any deadlocks. Be careful 13 | // using this method in performance sensitive areas. 14 | func Sort(tables flux.TableIterator) (flux.TableIterator, error) { 15 | groups := groupkey.NewLookup() 16 | if err := tables.Do(func(table flux.Table) error { 17 | buffered, err := Copy(table) 18 | if err != nil { 19 | return err 20 | } 21 | groups.Set(buffered.Key(), buffered) 22 | return nil 23 | }); err != nil { 24 | return nil, err 25 | } 26 | 27 | var buffered []flux.Table 28 | groups.Range(func(_ flux.GroupKey, value interface{}) error { 29 | buffered = append(buffered, value.(flux.Table)) 30 | return nil 31 | }) 32 | return Iterator(buffered), nil 33 | } 34 | -------------------------------------------------------------------------------- /execute/table/utils.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/array" 6 | "github.com/InfluxCommunity/flux/codes" 7 | "github.com/InfluxCommunity/flux/internal/errors" 8 | ) 9 | 10 | // Values returns the array from the column reader as an array.Array. 11 | func Values(cr flux.ColReader, j int) array.Array { 12 | switch typ := cr.Cols()[j].Type; typ { 13 | case flux.TInt: 14 | return cr.Ints(j) 15 | case flux.TUInt: 16 | return cr.UInts(j) 17 | case flux.TFloat: 18 | return cr.Floats(j) 19 | case flux.TString: 20 | return cr.Strings(j) 21 | case flux.TBool: 22 | return cr.Bools(j) 23 | case flux.TTime: 24 | return cr.Times(j) 25 | default: 26 | panic(errors.Newf(codes.Internal, "unimplemented column type: %s", typ)) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /execute/table_internal_test.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import "sync/atomic" 4 | 5 | func (t *ColListTable) IsDone() bool { 6 | return t.nrows == 0 || atomic.LoadInt32(&t.used) != 0 7 | } 8 | -------------------------------------------------------------------------------- /execute/transport_internal_test.go: -------------------------------------------------------------------------------- 1 | package execute 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/execute/table" 6 | ) 7 | 8 | func NewProcessMsg(tbl flux.Table) ProcessMsg { 9 | return &processMsg{table: tbl} 10 | } 11 | 12 | func NewProcessChunkMsg(chunk table.Chunk) ProcessChunkMsg { 13 | return &processChunkMsg{chunk: chunk} 14 | } 15 | 16 | func NewFlushKeyMsg(key flux.GroupKey) FlushKeyMsg { 17 | return &flushKeyMsg{key: key} 18 | } 19 | 20 | func NewFinishMsg(err error) FinishMsg { 21 | return &finishMsg{err: err} 22 | } 23 | -------------------------------------------------------------------------------- /fluxinit/init.go: -------------------------------------------------------------------------------- 1 | // Package fluxinit is used to initialize the flux library for compilation and 2 | // execution of Flux. The FluxInit function should be called exactly once in a 3 | // process. 4 | package fluxinit 5 | 6 | import ( 7 | "github.com/InfluxCommunity/flux/runtime" 8 | _ "github.com/InfluxCommunity/flux/stdlib" 9 | ) 10 | 11 | // The FluxInit() function prepares the runtime for compilation and execution 12 | // of Flux. This is a costly step and should only be performed if the intention 13 | // is to compile and execute flux code. 14 | // 15 | // This package imports the standard library. These modules register themselves 16 | // in go init() functions. This package must ensure all required standard 17 | // library functions are imported. 18 | // 19 | // As a convenience, the fluxinit/static package can be imported for use cases 20 | // where static initialization is okay, such as tests. 21 | 22 | func FluxInit() { 23 | runtime.FinalizeBuiltIns() 24 | } 25 | -------------------------------------------------------------------------------- /fluxinit/static/static.go: -------------------------------------------------------------------------------- 1 | // The fluxinit/static package can be imported in test cases and other uses 2 | // cases where it is okay to always initialize flux. 3 | package static 4 | 5 | import ( 6 | "github.com/InfluxCommunity/flux/fluxinit" 7 | ) 8 | 9 | func init() { 10 | fluxinit.FluxInit() 11 | } 12 | -------------------------------------------------------------------------------- /fluxinit/static/static_test.go: -------------------------------------------------------------------------------- 1 | package static_test 2 | 3 | import ( 4 | "testing" 5 | 6 | _ "github.com/InfluxCommunity/flux/fluxinit/static" 7 | ) 8 | 9 | func TestBuiltins(t *testing.T) { 10 | t.Log("Testing that importing builtins does not panic") 11 | } 12 | -------------------------------------------------------------------------------- /gotool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script will execute a module in the internal/tools 4 | # directory and execute it within the current working directory. 5 | # 6 | # The script will create an exec script that contains the current 7 | # working directory. This script gets passed as the -exec argument 8 | # to go run so it is used for executing the compiled go binary. 9 | # It then changes into the tool directory so it can use the module 10 | # dependencies in the tool module. 11 | # 12 | # This allows us to specify tool dependencies using go modules without 13 | # it getting added to the flux module itself. 14 | 15 | if [ "$#" -eq 0 ]; then 16 | echo "gotool.sh requires one or more arguments" 1>&2 17 | exit 1 18 | fi 19 | 20 | tool_dir=$(go list -m -f '{{.Dir}}')/internal/tools 21 | script_file=$(mktemp) 22 | trap '{ rm -f "$script_file"; }' EXIT 23 | 24 | cat > "$script_file" < 0 { 25 | // At least one value is null, but not all so 26 | // not constant by definition. 27 | return false 28 | } 29 | 30 | {{if eq .Name "String"}} 31 | return arr.IsConstant() 32 | {{else}} 33 | // All values are non-null so check if they are all the same. 34 | v := arr.Value(0) 35 | for i, n := 1, arr.Len(); i < n; i++ { 36 | if arr.Value(i) != v { 37 | return false 38 | } 39 | } 40 | return true 41 | {{end}} 42 | } 43 | {{end}} 44 | -------------------------------------------------------------------------------- /internal/arrowutil/filter.gen.go.tmpl: -------------------------------------------------------------------------------- 1 | package arrowutil 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/apache/arrow/go/v7/arrow/bitutil" 7 | "github.com/apache/arrow/go/v7/arrow/memory" 8 | "github.com/InfluxCommunity/flux/array" 9 | ) 10 | 11 | func Filter(arr array.Array, bitset []byte, mem memory.Allocator) array.Array { 12 | switch arr := arr.(type) { 13 | {{range .}} 14 | case *{{.Type}}: 15 | return Filter{{.Name}}s(arr, bitset, mem) 16 | {{end}} 17 | default: 18 | panic(fmt.Errorf("unsupported array data type: %s", arr.DataType())) 19 | } 20 | } 21 | 22 | {{range .}} 23 | func Filter{{.Name}}s(arr *{{.Type}}, bitset []byte, mem memory.Allocator) *{{.Type}} { 24 | n := bitutil.CountSetBits(bitset, 0, len(bitset)) 25 | b := New{{.Name}}Builder(mem) 26 | b.Resize(n) 27 | for i := 0; i < len(bitset); i++ { 28 | if bitutil.BitIsSet(bitset, i) { 29 | if arr.IsValid(i) { 30 | b.{{.Append}}(arr.{{.Value}}(i)) 31 | } else { 32 | b.AppendNull() 33 | } 34 | } 35 | } 36 | return b.{{.NewArray}}() 37 | } 38 | {{end}} 39 | -------------------------------------------------------------------------------- /internal/arrowutil/gen.go: -------------------------------------------------------------------------------- 1 | package arrowutil 2 | 3 | //go:generate -command tmpl ../../gotool.sh github.com/benbjohnson/tmpl 4 | //go:generate tmpl -data=@types.tmpldata -o array_values.gen.go array_values.gen.go.tmpl 5 | //go:generate tmpl -data=@types.tmpldata -o builder.gen.go builder.gen.go.tmpl 6 | //go:generate tmpl -data=@types.tmpldata -o compare.gen.go compare.gen.go.tmpl 7 | //go:generate tmpl -data=@types.tmpldata -o constant.gen.go constant.gen.go.tmpl 8 | //go:generate tmpl -data=@types.tmpldata -o copy.gen.go copy.gen.go.tmpl 9 | //go:generate tmpl -data=@types.tmpldata -o iterator.gen.go iterator.gen.go.tmpl 10 | //go:generate tmpl -data=@types.tmpldata -o iterator.gen_test.go iterator.gen_test.go.tmpl 11 | //go:generate tmpl -data=@types.tmpldata -o filter.gen.go filter.gen.go.tmpl 12 | -------------------------------------------------------------------------------- /internal/arrowutil/iterator_test.go: -------------------------------------------------------------------------------- 1 | package arrowutil_test 2 | 3 | import ( 4 | "math/rand" 5 | "strings" 6 | ) 7 | 8 | func generateInt() int64 { 9 | return int64(rand.Intn(201) - 100) 10 | } 11 | 12 | func generateUint() uint64 { 13 | return uint64(rand.Intn(201) - 100) 14 | } 15 | 16 | func generateFloat() float64 { 17 | return rand.NormFloat64() * 50 18 | } 19 | 20 | func generateBoolean() bool { 21 | return rand.Intn(2) != 0 22 | } 23 | 24 | func generateString() string { 25 | var buf strings.Builder 26 | for i := 0; i < 3; i++ { 27 | chars := 62 28 | if i == 0 { 29 | chars = 52 30 | } 31 | switch n := rand.Intn(chars); { 32 | case n >= 0 && n < 26: 33 | buf.WriteByte('A' + byte(n)) 34 | case n >= 26 && n < 52: 35 | buf.WriteByte('a' + byte(n-26)) 36 | case n >= 52: 37 | buf.WriteByte('0' + byte(n-52)) 38 | } 39 | } 40 | return buf.String() 41 | } 42 | -------------------------------------------------------------------------------- /internal/cmd/builtin/cmd/root.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | // rootCmd represents the base command when called without any subcommands 11 | var rootCmd = &cobra.Command{ 12 | Use: "builtin", 13 | } 14 | 15 | // Execute adds all child commands to the root command and sets flags appropriately. 16 | // This is called by main.main(). It only needs to happen once to the rootCmd. 17 | func Execute() { 18 | if err := rootCmd.Execute(); err != nil { 19 | fmt.Println(err) 20 | os.Exit(1) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /internal/cmd/builtin/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/InfluxCommunity/flux/internal/cmd/builtin/cmd" 4 | 5 | func main() { 6 | cmd.Execute() 7 | } 8 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/.gitignore: -------------------------------------------------------------------------------- 1 | *.flux 2 | real_lsp_log 3 | lsp 4 | bin 5 | main 6 | ../../../go.mod 7 | ../../../go.sum 8 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "flux_rustyline" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | name = "caller" 10 | 11 | [[bin]] 12 | name = "repl" 13 | path = "src/main.rs" 14 | 15 | [dependencies] 16 | rustyline = "9.1.2" 17 | base64 = "0.13.0" 18 | tower-lsp = "0.17.0" 19 | lsp-types = "=0.91.1" 20 | serde_json = "1.0" 21 | scoped_threadpool = "0.1.9" 22 | rustyline-derive = "0.6.0" 23 | unicode-width = "0.1.9" 24 | regex = "1" 25 | log = "0.4.17" 26 | pretty_env_logger = "0.4.0" 27 | once_cell = "1.13.1" 28 | anyhow = "1.0.61" 29 | thiserror = "1.0.32" 30 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/Makefile: -------------------------------------------------------------------------------- 1 | main: main.go 2 | go build main.go 3 | cargo build 4 | 5 | 6 | 7 | clean: 8 | rm main 9 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() -> anyhow::Result<(), anyhow::Error> { 2 | caller::possible_main()?; 3 | Ok(()) 4 | } 5 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/src/processes/lsp_server_impl.rs: -------------------------------------------------------------------------------- 1 | use crate::{invoke_go, CommandHint}; 2 | use std::collections::HashSet; 3 | use std::io::Write; 4 | use std::process::{exit, ChildStdin, ChildStdout}; 5 | use std::sync::mpsc::Receiver; 6 | use std::sync::{Arc, RwLock}; 7 | use std::thread; 8 | use std::time::Duration; 9 | 10 | pub fn read_lsp( 11 | stdout: ChildStdout, 12 | hints: Arc>>, 13 | ) -> Result<(), anyhow::Error> { 14 | thread::spawn(move || { 15 | invoke_go::read_json_rpc(stdout, hints).expect("TODO: panic message"); 16 | }); 17 | Ok(()) 18 | } 19 | 20 | pub fn write_lsp( 21 | mut stdin: ChildStdin, 22 | rx_processed: Receiver, 23 | ) -> Result<(), anyhow::Error> { 24 | thread::spawn(move || loop { 25 | thread::sleep(Duration::from_millis(1)); 26 | //if the coordinator thread has quit 27 | if let Ok(resp) = rx_processed.recv() { 28 | write!(&mut stdin, "{}", resp).unwrap(); 29 | } else { 30 | exit(101) 31 | } 32 | }); 33 | Ok(()) 34 | } 35 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/src/processes/mod.rs: -------------------------------------------------------------------------------- 1 | pub use coordinator_impl::run; 2 | pub use invoke_go::{read_json_rpc, start_go}; 3 | pub use lsp_invoke::{add_headers, formulate_request, start_lsp, LSPError, LSPRequestType}; 4 | pub use process_completion::process_completions_response; 5 | mod coordinator_impl; 6 | pub mod flux_server_impl; 7 | pub mod invoke_go; 8 | pub mod lsp_invoke; 9 | mod lsp_server_impl; 10 | pub mod process_completion; 11 | 12 | //run once tag 13 | // intellij lsp plug in 14 | // 15 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/src/utils/mod.rs: -------------------------------------------------------------------------------- 1 | mod process_response; 2 | 3 | // pub use hint_rotation::hinter_helper; 4 | pub use process_response::process_response_flux; 5 | -------------------------------------------------------------------------------- /internal/cmd/headless_repl/src/utils/process_response.rs: -------------------------------------------------------------------------------- 1 | use serde_json::Value; 2 | #[allow(unreachable_code)] 3 | pub fn process_response_flux(response: &str) -> Result<(), anyhow::Error> { 4 | if let Ok(a) = serde_json::from_str::(response) { 5 | //flux result 6 | 7 | println!( 8 | "\n{}", 9 | serde_json::to_string(&a["result"]["Result"])?.replace('\"', "") 10 | ); 11 | return Ok(()); 12 | } else { 13 | //error case 14 | println!("{}", response); 15 | return Ok(()); 16 | } 17 | Ok(()) 18 | } 19 | -------------------------------------------------------------------------------- /internal/cmd/influxql-decode/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/pkg/errors" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | var version int 12 | var rootCmd = &cobra.Command{ 13 | Use: "influxql-decode", 14 | Short: "InfluxQL JSON -> v1 line protocol format or v2 csv format.", 15 | Long: "Decode InfluxQL JSON output files and convert them to v1 line protocol format or v2 csv format.", 16 | RunE: func(cmd *cobra.Command, args []string) error { 17 | if len(args) == 0 { 18 | return cmd.Help() 19 | } 20 | switch version { 21 | case 1: 22 | return v1(cmd, args) 23 | case 2: 24 | return v2(cmd, args) 25 | default: 26 | return errors.New("Target version can only be 1 or 2.") 27 | } 28 | }, 29 | } 30 | 31 | func init() { 32 | rootCmd.PersistentFlags().IntVarP(&version, "version", "v", 2, 33 | "target version") 34 | } 35 | 36 | func main() { 37 | if err := rootCmd.Execute(); err != nil { 38 | fmt.Println(err) 39 | os.Exit(1) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /internal/cmd/influxql-decode/v2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/InfluxCommunity/flux/csv" 7 | "github.com/InfluxCommunity/flux/internal/influxql" 8 | "github.com/InfluxCommunity/flux/memory" 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func v2(cmd *cobra.Command, args []string) error { 13 | for _, arg := range args { 14 | f, err := os.Open(arg) 15 | if err != nil { 16 | return err 17 | } 18 | 19 | dec := influxql.NewResultDecoder(&memory.ResourceAllocator{}) 20 | results, err := dec.Decode(f) 21 | if err != nil { 22 | return err 23 | } 24 | 25 | enc := csv.NewMultiResultEncoder(csv.DefaultEncoderConfig()) 26 | if _, err := enc.Encode(os.Stdout, results); err != nil { 27 | return err 28 | } 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /internal/errors/std.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import "errors" 4 | 5 | // Is is a wrapper around the errors.Is function. 6 | func Is(err, target error) bool { 7 | return errors.Is(err, target) 8 | } 9 | 10 | // As is a wrapper around the errors.As function. 11 | func As(err error, target interface{}) bool { 12 | return errors.As(err, target) 13 | } 14 | -------------------------------------------------------------------------------- /internal/execute/table/buffered_builder.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/execute/table" 6 | "github.com/apache/arrow/go/v7/arrow/memory" 7 | ) 8 | 9 | const BufferSize = table.BufferSize 10 | 11 | type BufferedBuilder = table.BufferedBuilder 12 | 13 | func GetBufferedBuilder(key flux.GroupKey, cache *BuilderCache) (builder *BufferedBuilder, created bool) { 14 | return table.GetBufferedBuilder(key, cache) 15 | } 16 | 17 | func NewBufferedBuilder(key flux.GroupKey, mem memory.Allocator) *BufferedBuilder { 18 | return table.NewBufferedBuilder(key, mem) 19 | } 20 | -------------------------------------------------------------------------------- /internal/execute/table/builder_cache.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/execute/table" 5 | ) 6 | 7 | type ( 8 | Builder = table.Builder 9 | BuilderCache = table.BuilderCache 10 | ) 11 | -------------------------------------------------------------------------------- /internal/execute/table/chunk.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/arrow" 6 | "github.com/InfluxCommunity/flux/execute/table" 7 | ) 8 | 9 | type Chunk = table.Chunk 10 | 11 | func ChunkFromBuffer(buf arrow.TableBuffer) Chunk { 12 | return table.ChunkFromBuffer(buf) 13 | } 14 | 15 | func ChunkFromReader(cr flux.ColReader) Chunk { 16 | return table.ChunkFromReader(cr) 17 | } 18 | -------------------------------------------------------------------------------- /internal/execute/table/copy.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/execute/table" 6 | ) 7 | 8 | // Copy returns a buffered copy of the table and consumes the 9 | // input table. If the input table is already buffered, it "consumes" 10 | // the input and returns the same table. 11 | // 12 | // The buffered table can then be copied additional times using the 13 | // BufferedTable.Copy method. 14 | // 15 | // This method should be used sparingly if at all. It will retain 16 | // each of the buffers of data coming out of a table so the entire 17 | // table is materialized in memory. For large datasets, this could 18 | // potentially cause a problem. The allocator is meant to catch when 19 | // this happens and prevent it. 20 | func Copy(t flux.Table) (flux.BufferedTable, error) { 21 | return table.Copy(t) 22 | } 23 | -------------------------------------------------------------------------------- /internal/execute/table/diff.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/execute/table" 6 | ) 7 | 8 | // Diff will perform a diff between two table iterators. 9 | // This will sort the tables within the table iterators and produce 10 | // a diff of the full output. 11 | func Diff(want, got flux.TableIterator, opts ...DiffOption) string { 12 | return table.Diff(want, got, opts...) 13 | } 14 | 15 | type DiffOption = table.DiffOption 16 | 17 | func DiffContext(n int) DiffOption { 18 | return table.DiffContext(n) 19 | } 20 | -------------------------------------------------------------------------------- /internal/execute/table/iterator.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import "github.com/InfluxCommunity/flux/execute/table" 4 | 5 | type Iterator = table.Iterator 6 | -------------------------------------------------------------------------------- /internal/execute/table/sort.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/execute/table" 6 | ) 7 | 8 | // Sort will read a TableIterator and produce another TableIterator 9 | // where the keys are sorted. 10 | // 11 | // This method will buffer all of the data since it needs to ensure 12 | // all of the tables are read to avoid any deadlocks. Be careful 13 | // using this method in performance sensitive areas. 14 | func Sort(tables flux.TableIterator) (flux.TableIterator, error) { 15 | return table.Sort(tables) 16 | } 17 | -------------------------------------------------------------------------------- /internal/execute/table/stringify.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/execute/table" 6 | ) 7 | 8 | // Stringify will read a table and turn it into a human-readable string. 9 | func Stringify(t flux.Table) string { 10 | return table.Stringify(t) 11 | } 12 | -------------------------------------------------------------------------------- /internal/execute/table/utils.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/array" 6 | "github.com/InfluxCommunity/flux/execute/table" 7 | ) 8 | 9 | func Values(cr flux.ColReader, j int) array.Array { 10 | return table.Values(cr, j) 11 | } 12 | -------------------------------------------------------------------------------- /internal/fbsemantic/doc.go: -------------------------------------------------------------------------------- 1 | // Package fbsemantic contains code generated by the FlatBuffers compiler for serializing the semantic graph. 2 | package fbsemantic 3 | -------------------------------------------------------------------------------- /internal/fbsemantic/gen.go: -------------------------------------------------------------------------------- 1 | package fbsemantic 2 | 3 | //go:generate flatc --go --gen-onefile --go-namespace fbsemantic ./semantic.fbs 4 | //go:generate go fmt ./semantic_generated.go 5 | -------------------------------------------------------------------------------- /internal/feature/gen.go: -------------------------------------------------------------------------------- 1 | package feature 2 | 3 | //go:generate -command feature go run github.com/InfluxCommunity/flux/internal/pkg/feature/cmd/feature 4 | //go:generate feature -in flags.yml -out flags.go 5 | -------------------------------------------------------------------------------- /internal/influxql/response.go: -------------------------------------------------------------------------------- 1 | package influxql 2 | 3 | // Response contains the collection of results for a query. 4 | type Response struct { 5 | Results []Result `json:"results,omitempty"` 6 | Err string `json:"error,omitempty"` 7 | } 8 | 9 | // Result represents a resultset returned from a single statement. 10 | // Rows represents a list of rows that can be sorted consistently by name/tag. 11 | type Result struct { 12 | // StatementID is just the statement's position in the query. It's used 13 | // to combine statement results if they're being buffered in memory. 14 | StatementID int `json:"statement_id"` 15 | Series []*Series `json:"series,omitempty"` 16 | Partial bool `json:"partial,omitempty"` 17 | Err string `json:"error,omitempty"` 18 | } 19 | 20 | // Series represents a series of rows that share the same group key returned from the execution of a statement. 21 | type Series struct { 22 | Name string `json:"name,omitempty"` 23 | Tags map[string]string `json:"tags,omitempty"` 24 | Columns []string `json:"columns,omitempty"` 25 | Values [][]interface{} `json:"values,omitempty"` 26 | Partial bool `json:"partial,omitempty"` 27 | } 28 | -------------------------------------------------------------------------------- /internal/jaeger/jaeger.go: -------------------------------------------------------------------------------- 1 | package jaeger 2 | 3 | import ( 4 | "github.com/opentracing/opentracing-go" 5 | "github.com/uber/jaeger-client-go" 6 | ) 7 | 8 | // InfoFromSpan returns the traceID and if it was sampled from the span, given 9 | // it is a jaeger span. It returns whether a span associated with the context 10 | // has been found. 11 | func InfoFromSpan(span opentracing.Span) (traceID string, sampled bool, found bool) { 12 | type ctxWithInfo interface { 13 | TraceID() jaeger.TraceID 14 | IsSampled() bool 15 | } 16 | if ctx, ok := span.Context().(ctxWithInfo); ok { 17 | traceID = ctx.TraceID().String() 18 | sampled = ctx.IsSampled() 19 | found = true 20 | } 21 | return 22 | } 23 | -------------------------------------------------------------------------------- /internal/pkg/feature/feature.go: -------------------------------------------------------------------------------- 1 | package feature 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type key int 8 | 9 | const flaggerKey key = iota 10 | 11 | // Flagger returns flag values. 12 | type Flagger interface { 13 | // FlagValue returns the value for a given flag. 14 | FlagValue(ctx context.Context, flag Flag) interface{} 15 | } 16 | 17 | // Inject will inject the Flagger into the context. 18 | func Inject(ctx context.Context, flagger Flagger) context.Context { 19 | return context.WithValue(ctx, flaggerKey, flagger) 20 | } 21 | 22 | // GetFlagger returns the Flagger for this context or the default flagger. 23 | func GetFlagger(ctx context.Context) Flagger { 24 | flagger := ctx.Value(flaggerKey) 25 | if flagger == nil { 26 | return defaultFlagger{} 27 | } 28 | return flagger.(Flagger) 29 | } 30 | 31 | // defaultFlagger returns a flagger that always returns default values. 32 | type defaultFlagger struct{} 33 | 34 | // FlagValue returns the default value for the flag. 35 | // It never returns an error. 36 | func (defaultFlagger) FlagValue(_ context.Context, flag Flag) interface{} { 37 | return flag.Default() 38 | } 39 | -------------------------------------------------------------------------------- /internal/pkg/feature/metrics.go: -------------------------------------------------------------------------------- 1 | package feature 2 | 3 | type Metrics interface { 4 | Inc(key string, value interface{}) 5 | } 6 | 7 | type discardMetrics struct{} 8 | 9 | func (discardMetrics) Inc(key string, value interface{}) {} 10 | 11 | var metrics Metrics = discardMetrics{} 12 | 13 | // SetMetrics sets the metric store for feature flags. 14 | func SetMetrics(m Metrics) { 15 | if m == nil { 16 | metrics = discardMetrics{} 17 | } else { 18 | metrics = m 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /internal/pkg/syncutil/wait_group.go: -------------------------------------------------------------------------------- 1 | package syncutil 2 | 3 | import "sync" 4 | 5 | // WaitGroup is a custom sync.WaitGroup that handles functions that return errors. 6 | type WaitGroup struct { 7 | wg sync.WaitGroup 8 | err error 9 | errMu sync.Mutex 10 | } 11 | 12 | // Do starts a new goroutine and executes the function within that goroutine. 13 | // This will not execute the function if an error has already occurred. 14 | func (wg *WaitGroup) Do(fn func() error) { 15 | wg.errMu.Lock() 16 | if wg.err != nil { 17 | wg.errMu.Unlock() 18 | return 19 | } 20 | wg.errMu.Unlock() 21 | 22 | wg.wg.Add(1) 23 | go wg.do(fn) 24 | } 25 | 26 | func (wg *WaitGroup) do(fn func() error) { 27 | defer wg.wg.Done() 28 | if err := fn(); err != nil { 29 | wg.errMu.Lock() 30 | if wg.err == nil { 31 | wg.err = err 32 | } 33 | wg.errMu.Unlock() 34 | } 35 | } 36 | 37 | // Wait waits for all of the goroutines started with Do to finish. It returns 38 | // the first error encountered, but will wait for the remaining goroutines to finish. 39 | func (wg *WaitGroup) Wait() error { 40 | wg.wg.Wait() 41 | return wg.err 42 | } 43 | -------------------------------------------------------------------------------- /internal/tools/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/InfluxCommunity/flux/internal/tools 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/benbjohnson/tmpl v1.0.0 7 | github.com/goreleaser/goreleaser v0.182.1 8 | github.com/influxdata/changelog v1.1.0 9 | gopkg.in/yaml.v3 v3.0.1 // indirect 10 | honnef.co/go/tools v0.3.2 11 | ) 12 | -------------------------------------------------------------------------------- /internal/tools/tools.go: -------------------------------------------------------------------------------- 1 | package tools 2 | 3 | import ( 4 | _ "github.com/benbjohnson/tmpl" 5 | _ "github.com/goreleaser/goreleaser" 6 | _ "github.com/influxdata/changelog" 7 | _ "honnef.co/go/tools/cmd/staticcheck" 8 | ) 9 | 10 | // This package specifies the list of go tool dependencies that we rely on. 11 | // Specifying these paths here ensures that they stay in the go.mod file and 12 | // allow us to use go run to execute them which allows us to ensure that these 13 | // tools use a consistent version rather than whatever is on the developer's 14 | // machine. 15 | -------------------------------------------------------------------------------- /internal/zoneinfo/internal_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package zoneinfo 6 | 7 | var OrigZoneSources = zoneSources 8 | 9 | func forceZipFileForTesting(zipOnly bool) { 10 | zoneSources = make([]string, len(OrigZoneSources)) 11 | copy(zoneSources, OrigZoneSources) 12 | if zipOnly { 13 | zoneSources = zoneSources[len(zoneSources)-1:] 14 | } 15 | } 16 | 17 | func (l *Location) Lookup(sec int64) (name string, offset int, start, end int64, isDST bool) { 18 | return l.lookup(sec) 19 | } 20 | -------------------------------------------------------------------------------- /internal/zoneinfo/zoneinfo_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix || (darwin && !ios) || dragonfly || freebsd || (linux && !android) || netbsd || openbsd || solaris 6 | // +build aix darwin,!ios dragonfly freebsd linux,!android netbsd openbsd solaris 7 | 8 | // Parse "zoneinfo" time zone file. 9 | // This is a fairly standard file format used on OS X, Linux, BSD, Sun, and others. 10 | // See tzfile(5), https://en.wikipedia.org/wiki/Zoneinfo, 11 | // and ftp://munnari.oz.au/pub/oldtz/ 12 | 13 | package zoneinfo 14 | 15 | import ( 16 | "runtime" 17 | ) 18 | 19 | // Many systems use /usr/share/zoneinfo, Solaris 2 has 20 | // /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ. 21 | var zoneSources = []string{ 22 | "/usr/share/zoneinfo/", 23 | "/usr/share/lib/zoneinfo/", 24 | "/usr/lib/locale/TZ/", 25 | runtime.GOROOT() + "/lib/time/zoneinfo.zip", 26 | } 27 | -------------------------------------------------------------------------------- /internal/zoneinfo/zoneinfo_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package zoneinfo 6 | 7 | import ( 8 | "runtime" 9 | ) 10 | 11 | var zoneSources = []string{ 12 | runtime.GOROOT() + "/lib/time/zoneinfo.zip", 13 | } 14 | -------------------------------------------------------------------------------- /interpreter/doc.go: -------------------------------------------------------------------------------- 1 | // Package interpreter provides the implementation of the Flux interpreter. 2 | package interpreter 3 | -------------------------------------------------------------------------------- /interpreter/importer.go: -------------------------------------------------------------------------------- 1 | package interpreter 2 | 3 | // Importer produces a package given an import path 4 | type Importer interface { 5 | ImportPackageObject(path string) (*Package, error) 6 | } 7 | -------------------------------------------------------------------------------- /interpreter/interptest/eval.go: -------------------------------------------------------------------------------- 1 | package interptest 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/codes" 7 | "github.com/InfluxCommunity/flux/internal/errors" 8 | "github.com/InfluxCommunity/flux/interpreter" 9 | "github.com/InfluxCommunity/flux/runtime" 10 | "github.com/InfluxCommunity/flux/values" 11 | ) 12 | 13 | func Eval(ctx context.Context, itrp *interpreter.Interpreter, scope values.Scope, importer interpreter.Importer, src string) ([]interpreter.SideEffect, error) { 14 | node, err := runtime.AnalyzeSource(ctx, src) 15 | if err != nil { 16 | return nil, errors.Wrap(err, codes.Inherit, "could not analyze program") 17 | } 18 | return itrp.Eval(ctx, node, scope, importer) 19 | } 20 | -------------------------------------------------------------------------------- /iocounter/counter.go: -------------------------------------------------------------------------------- 1 | package iocounter 2 | 3 | // Counter counts a number of bytes during an IO operation. 4 | type Counter interface { 5 | Count() int64 6 | } 7 | -------------------------------------------------------------------------------- /iocounter/writer.go: -------------------------------------------------------------------------------- 1 | package iocounter 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // Writer is counter for io.Writer 8 | type Writer struct { 9 | io.Writer 10 | count int64 11 | } 12 | 13 | func (c *Writer) Write(buf []byte) (int, error) { 14 | n, err := c.Writer.Write(buf) 15 | c.count += int64(n) 16 | return n, err 17 | } 18 | 19 | // Count function return counted bytes 20 | func (c *Writer) Count() int64 { 21 | return c.count 22 | } 23 | -------------------------------------------------------------------------------- /libflux/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !entry.sh 3 | -------------------------------------------------------------------------------- /libflux/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["flux-core", "flux"] 3 | 4 | # https://rustwasm.github.io/docs/book/reference/code-size.html#optimizing-builds-for-code-size 5 | [profile.release] 6 | lto = true 7 | opt-level = 'z' 8 | -------------------------------------------------------------------------------- /libflux/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Make sure our working dir is the dir of the script 6 | DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd) 7 | cd $DIR 8 | 9 | # Home dir of the docker user 10 | SRC_DIR=/src 11 | 12 | # Host user ids 13 | uid=$(id -u) 14 | gid=$(id -g) 15 | 16 | imagename=flux-rust-builder-img 17 | 18 | # Build new docker image 19 | docker build \ 20 | -f Dockerfile \ 21 | -t $imagename \ 22 | --build-arg UID=$uid \ 23 | --build-arg GID=$gid \ 24 | $DIR 25 | 26 | # Run docker container to perform build 27 | docker run \ 28 | --rm \ 29 | --name $imagename \ 30 | -v "$DIR:$SRC_DIR" \ 31 | -v "$DIR/.cache:/home/builder/.cache" \ 32 | --env AR=llvm-ar \ 33 | $imagename wasm-pack build --scope influxdata "$@" 34 | -------------------------------------------------------------------------------- /libflux/c/.gitignore: -------------------------------------------------------------------------------- 1 | /libflux_memory_tester_static 2 | /libflux_memory_tester_dynamic 3 | 4 | -------------------------------------------------------------------------------- /libflux/c/Makefile: -------------------------------------------------------------------------------- 1 | VALGRIND = valgrind 2 | VALGRIND_ARGS = --leak-check=full --error-exitcode=1 3 | 4 | BIN_STATIC = libflux_memory_tester_static 5 | BIN_DYNAMIC = libflux_memory_tester_dynamic 6 | 7 | SOURCES = *.c 8 | 9 | TARGET_DIR = $(PWD)/../target 10 | INCLUDE_DIR = $(PWD)/../include 11 | 12 | test-valgrind: $(BIN_STATIC) $(BIN_DYNAMIC) 13 | $(VALGRIND) $(VALGRIND_ARGS) ./$(BIN_STATIC) 14 | LD_LIBRARY_PATH=$(TARGET_DIR)/debug $(VALGRIND) $(VALGRIND_ARGS) ./$(BIN_DYNAMIC) 15 | 16 | $(BIN_STATIC): $(SOURCES) 17 | $(CC) -g -Wall -Werror $(SOURCES) -I$(INCLUDE_DIR) \ 18 | $(TARGET_DIR)/debug/libflux.a \ 19 | -o $@ -lpthread -lm -ldl 20 | 21 | $(BIN_DYNAMIC): $(SOURCES) 22 | $(CC) -g -Wall -Werror $(SOURCES) -I$(INCLUDE_DIR) \ 23 | -L $(TARGET_DIR)/debug -lflux \ 24 | -o $@ 25 | 26 | clean: 27 | rm -f $(BIN_STATIC) $(BIN_DYNAMIC) 28 | 29 | .PHONY: test-valgrind clean 30 | -------------------------------------------------------------------------------- /libflux/flux-core/benches/scanner.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate criterion; 3 | extern crate fluxcore; 4 | 5 | use criterion::{black_box, Criterion}; 6 | use fluxcore::scanner; 7 | 8 | const FLUX: &str = r#"from(bucket: "benchtest") 9 | # Here's a random comment 10 | |> range(start: -10m) 11 | |> map(fn: (r) => ({r with square: r._value * r._value}))"#; 12 | 13 | /// Create a Scanner with pre-determined text, and scan every token 14 | /// until EOF. 15 | fn scanner_scan(c: &mut Criterion) { 16 | c.bench_function("scanner.scan", |b| { 17 | b.iter(black_box(|| { 18 | let mut s = scanner::Scanner::new(FLUX); 19 | loop { 20 | let token = s.scan(); 21 | if token.tok == scanner::TokenType::Eof { 22 | break; 23 | } 24 | } 25 | })); 26 | }); 27 | } 28 | 29 | criterion_group!(scanner, scanner_scan); 30 | criterion_main!(scanner); 31 | -------------------------------------------------------------------------------- /libflux/flux-core/src/bin/README.md: -------------------------------------------------------------------------------- 1 | # Fluxdoc 2 | 3 | We have a fluxdoc command that can lint Flux source code for correct documentation. 4 | 5 | ## Usage 6 | 7 | First compile the stdlib to a temporary directory. Starting from the root of the Flux repo run these commands. 8 | 9 | cd libflux 10 | cargo run --bin fluxc -- stdlib -o ../stdlib-compiled -s ../stdlib 11 | 12 | That will take about a minute and only needs to be run again if the types of Flux functions change. 13 | 14 | Second run the fluxdoc lint command 15 | 16 | cargo run --bin fluxdoc --features=doc -- lint -s ../stdlib-compiled -d 17 | 18 | A list of errors will be reported otherwise the output will be empty. 19 | 20 | ## Updating Exceptions List 21 | 22 | In the file `libflux/flux-core/src/bin/fluxdoc.rs` at the end is a list of packages that are exceptions. 23 | Once a package is passing lint it should be removed from that list. 24 | 25 | -------------------------------------------------------------------------------- /libflux/flux-core/src/scanner/unicode.rl.COPYING: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2001-2018 Adrian Thurston et al. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /libflux/flux-core/src/semantic/walk/test_utils.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | ast, 3 | parser::parse_string, 4 | semantic::{convert, nodes}, 5 | }; 6 | 7 | pub fn compile(source: &str) -> nodes::Package { 8 | let file = parse_string("".to_string(), source); 9 | ast::check::check(ast::walk::Node::File(&file)).expect("errors on parsing"); 10 | let ast_pkg = ast::Package { 11 | base: file.base.clone(), 12 | path: "".to_string(), 13 | package: "main".to_string(), 14 | files: vec![file], 15 | }; 16 | convert::convert_package(&ast_pkg, &Default::default(), &Default::default()).unwrap() 17 | } 18 | -------------------------------------------------------------------------------- /libflux/flux/benches/analyze.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate criterion; 3 | extern crate flux; 4 | 5 | use criterion::{black_box, Criterion}; 6 | 7 | fn analyze_mean(c: &mut Criterion) { 8 | let mut group = c.benchmark_group("analyze"); 9 | group.bench_function("analyze_mean", |b| { 10 | let source = r#" 11 | from(bucket:"test") 12 | |> range(start: 2022-01-12T13:03:43.223Z, stop: 2022-03-22T11:03:12.223Z) 13 | |> filter(fn: (r) => r._measurement == "test" and r.id == "MYID") 14 | |> mean()"#; 15 | let pkg = flux::parse("".into(), source); 16 | b.iter(black_box(|| { 17 | flux::analyze(&pkg, Default::default()).unwrap(); 18 | })); 19 | }); 20 | group.finish(); 21 | } 22 | 23 | criterion_group!(analyze, analyze_mean); 24 | criterion_main!(analyze); 25 | -------------------------------------------------------------------------------- /libflux/flux/benches/formatter.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate criterion; 3 | extern crate flux; 4 | 5 | use criterion::{black_box, Criterion}; 6 | use flux::formatter::format; 7 | 8 | fn format_everything(c: &mut Criterion) { 9 | let flux = include_str!("./everything.flux"); 10 | c.bench_function("format_everything.flux", |b| { 11 | b.iter(black_box(|| { 12 | format(flux).unwrap(); 13 | })); 14 | }); 15 | } 16 | 17 | criterion_group!(formatter, format_everything,); 18 | criterion_main!(formatter); 19 | -------------------------------------------------------------------------------- /libflux/flux/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}Home{% endblock title %} 3 | {% block content %} 4 | Flux Standard Library 5 | {% endblock content %} 6 | -------------------------------------------------------------------------------- /libflux/flux/templates/package.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}{{ name}}{% endblock title %} 3 | {% block breadcrumb %} 4 | 10 | {% endblock breadcrumb %} 11 | {% block content %} 12 |

{{ name }}

13 | {{ doc | safe }} 14 |
    15 | {% for v in values %} 16 |
  • {{v.name}}
  • 17 | {% endfor %} 18 |
19 | {% endblock content %} 20 | 21 | {% block sidebar %} 22 | Packages: 23 |
    24 | {% for p in packages %} 25 |
  • {{p.name}}
  • 26 | {% endfor %} 27 |
28 | {% endblock sidebar%} 29 | -------------------------------------------------------------------------------- /libflux/flux/templates/value.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block title %}{{ name }}{% endblock title %} 3 | {% block breadcrumb %} 4 | 10 | {% endblock breadcrumb %} 11 | {% block content %} 12 |

{{ name }}

13 |
{{name}} : {{ typ }}
14 | {{ doc | safe }} 15 | 16 |
17 | 18 | 28 | {% endblock content %} 29 | -------------------------------------------------------------------------------- /libflux/go/libflux/gen.go: -------------------------------------------------------------------------------- 1 | package libflux 2 | 3 | //go:generate go run ./internal/buildinfo 4 | -------------------------------------------------------------------------------- /libflux/go/libflux/link_dynamic.go: -------------------------------------------------------------------------------- 1 | //go:build !static_build 2 | // +build !static_build 3 | 4 | package libflux 5 | 6 | // #cgo pkg-config: flux 7 | import "C" 8 | -------------------------------------------------------------------------------- /libflux/go/libflux/link_static.go: -------------------------------------------------------------------------------- 1 | //go:build static_build 2 | // +build static_build 3 | 4 | package libflux 5 | 6 | // #cgo pkg-config: --static flux 7 | // #cgo LDFLAGS: -static 8 | import "C" 9 | -------------------------------------------------------------------------------- /libflux/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Make sure our working dir is the dir of the script 6 | DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd) 7 | cd $DIR 8 | 9 | # Clean out any old build artifacts 10 | rm -rf parser/pkg 11 | 12 | # Build the WASM package 13 | ./build.sh 14 | 15 | # Publish the package 16 | cd parser/pkg 17 | yarn publish --non-interactive --no-git-tag-version 18 | -------------------------------------------------------------------------------- /mock/administration.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/execute" 8 | "github.com/InfluxCommunity/flux/memory" 9 | ) 10 | 11 | // Administration is a mock implementation of the execute.Administration interface. 12 | // This may be used for tests that require implementation of this interface. 13 | type Administration struct { 14 | ctx context.Context 15 | } 16 | 17 | func AdministrationWithContext(ctx context.Context) *Administration { 18 | return &Administration{ctx: ctx} 19 | } 20 | 21 | func (a *Administration) Context() context.Context { 22 | return a.ctx 23 | } 24 | 25 | func (a *Administration) ResolveTime(qt flux.Time) execute.Time { 26 | return execute.Now() 27 | } 28 | 29 | func (a *Administration) StreamContext() execute.StreamContext { 30 | return nil 31 | } 32 | 33 | func (a *Administration) Allocator() memory.Allocator { 34 | return &memory.ResourceAllocator{} 35 | } 36 | 37 | func (a *Administration) Parents() []execute.DatasetID { 38 | return nil 39 | } 40 | 41 | func (a *Administration) ParallelOpts() execute.ParallelOpts { 42 | return execute.ParallelOpts{Group: -1, Factor: 0} 43 | } 44 | -------------------------------------------------------------------------------- /mock/compiler.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | ) 8 | 9 | var _ flux.Compiler = Compiler{} 10 | 11 | type Compiler struct { 12 | CompileFn func(ctx context.Context) (flux.Program, error) 13 | Type flux.CompilerType 14 | } 15 | 16 | func (c Compiler) Compile(ctx context.Context, runtime flux.Runtime) (flux.Program, error) { 17 | return c.CompileFn(ctx) 18 | } 19 | func (c Compiler) CompilerType() flux.CompilerType { 20 | if c.Type == "" { 21 | return "mockCompiler" 22 | } 23 | return c.Type 24 | } 25 | -------------------------------------------------------------------------------- /mock/dependency.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import "context" 4 | 5 | type Dependency struct { 6 | InjectFn func(ctx context.Context) context.Context 7 | } 8 | 9 | func (d Dependency) Inject(ctx context.Context) context.Context { 10 | return d.InjectFn(ctx) 11 | } 12 | -------------------------------------------------------------------------------- /mock/doc.go: -------------------------------------------------------------------------------- 1 | // Package mock contains mock implementations of the query package interfaces for testing. 2 | package mock 3 | -------------------------------------------------------------------------------- /mock/influxdb_provider.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/dependencies/influxdb" 7 | ) 8 | 9 | type InfluxDBProvider struct { 10 | influxdb.UnimplementedProvider 11 | WriterForFn func(ctx context.Context, conf influxdb.Config) (influxdb.Writer, error) 12 | } 13 | 14 | var _ influxdb.Provider = &InfluxDBProvider{} 15 | 16 | func (m InfluxDBProvider) WriterFor(ctx context.Context, conf influxdb.Config) (influxdb.Writer, error) { 17 | return m.WriterForFn(ctx, conf) 18 | } 19 | -------------------------------------------------------------------------------- /mock/mqtt_provider.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/dependencies/mqtt" 7 | ) 8 | 9 | type MqttDialer struct { 10 | DialFn func(ctx context.Context, brokers []string, options mqtt.Options) (mqtt.Client, error) 11 | } 12 | 13 | func (m MqttDialer) Dial(ctx context.Context, brokers []string, options mqtt.Options) (mqtt.Client, error) { 14 | return m.DialFn(ctx, brokers, options) 15 | } 16 | 17 | type MqttClient struct { 18 | PublishFn func(ctx context.Context, topic string, qos byte, retain bool, payload interface{}) error 19 | CloseFn func() error 20 | } 21 | 22 | func (m MqttClient) Publish(ctx context.Context, topic string, qos byte, retain bool, payload interface{}) error { 23 | return m.PublishFn(ctx, topic, qos, retain, payload) 24 | } 25 | 26 | func (m MqttClient) Close() error { 27 | if m.CloseFn == nil { 28 | return nil 29 | } 30 | return m.CloseFn() 31 | } 32 | -------------------------------------------------------------------------------- /mock/program.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/memory" 8 | ) 9 | 10 | // Program is a mock program that can be returned by the mock compiler. 11 | // It will construct a mock query that will then be passed to ExecuteFn. 12 | type Program struct { 13 | StartFn func(ctx context.Context, alloc memory.Allocator) (*Query, error) 14 | ExecuteFn func(ctx context.Context, q *Query, alloc memory.Allocator) 15 | } 16 | 17 | func (p *Program) Start(ctx context.Context, alloc memory.Allocator) (flux.Query, error) { 18 | startFn := p.StartFn 19 | if startFn == nil { 20 | var cancel func() 21 | ctx, cancel = context.WithCancel(ctx) 22 | startFn = func(ctx context.Context, alloc memory.Allocator) (*Query, error) { 23 | results := make(chan flux.Result) 24 | q := &Query{ 25 | ResultsCh: results, 26 | CancelFn: cancel, 27 | Canceled: make(chan struct{}), 28 | } 29 | go func() { 30 | defer close(results) 31 | if p.ExecuteFn != nil { 32 | p.ExecuteFn(ctx, q, alloc) 33 | } 34 | }() 35 | return q, nil 36 | } 37 | } 38 | return startFn(ctx, alloc) 39 | } 40 | -------------------------------------------------------------------------------- /mock/secret_service.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | "github.com/InfluxCommunity/flux/codes" 6 | "github.com/InfluxCommunity/flux/internal/errors" 7 | ) 8 | 9 | type SecretService map[string]string 10 | 11 | func (s SecretService) LoadSecret(ctx context.Context, k string) (string, error) { 12 | v, ok := s[k] 13 | if ok { 14 | return v, nil 15 | } 16 | return "", errors.Newf(codes.NotFound, "secret key %q not found", k) 17 | } 18 | -------------------------------------------------------------------------------- /mock/source.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | "github.com/InfluxCommunity/flux/execute" 6 | "github.com/InfluxCommunity/flux/plan" 7 | ) 8 | 9 | // Source is a mock source that performs the given functions. 10 | // By default it does nothing. 11 | type Source struct { 12 | execute.ExecutionNode 13 | AddTransformationFn func(transformation execute.Transformation) 14 | RunFn func(ctx context.Context) 15 | } 16 | 17 | func (s *Source) AddTransformation(t execute.Transformation) { 18 | if s.AddTransformationFn != nil { 19 | s.AddTransformationFn(t) 20 | } 21 | } 22 | 23 | func (s *Source) Run(ctx context.Context) { 24 | if s.RunFn != nil { 25 | s.RunFn(ctx) 26 | } 27 | } 28 | 29 | // CreateMockFromSource will register a mock "from" source. Use it like this in the init() 30 | // of your test: 31 | // 32 | // execute.RegisterSource(influxdb.FromKind, mock.CreateMockFromSource) 33 | func CreateMockFromSource(spec plan.ProcedureSpec, id execute.DatasetID, ctx execute.Administration) (execute.Source, error) { 34 | return &Source{}, nil 35 | } 36 | -------------------------------------------------------------------------------- /mock/time.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import "github.com/InfluxCommunity/flux/values" 4 | 5 | // AscendingTimeProvider provides ascending timestamps every nanosecond 6 | // starting from Start. 7 | type AscendingTimeProvider struct { 8 | Start int64 9 | } 10 | 11 | func (atp *AscendingTimeProvider) CurrentTime() values.Time { 12 | t := values.Time(atp.Start) 13 | atp.Start++ 14 | return t 15 | } 16 | -------------------------------------------------------------------------------- /mock/transport.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/codes" 6 | "github.com/InfluxCommunity/flux/execute" 7 | "github.com/InfluxCommunity/flux/internal/errors" 8 | ) 9 | 10 | type Transport struct { 11 | ProcessMessageFn func(m execute.Message) error 12 | } 13 | 14 | func (t *Transport) ProcessMessage(m execute.Message) error { 15 | return t.ProcessMessageFn(m) 16 | } 17 | 18 | func (t *Transport) RetractTable(id execute.DatasetID, key flux.GroupKey) error { 19 | return errors.New(codes.Unimplemented) 20 | } 21 | func (t *Transport) Process(id execute.DatasetID, tbl flux.Table) error { 22 | return errors.New(codes.Unimplemented) 23 | } 24 | func (t *Transport) UpdateWatermark(id execute.DatasetID, ts execute.Time) error { 25 | return errors.New(codes.Unimplemented) 26 | } 27 | func (t *Transport) UpdateProcessingTime(id execute.DatasetID, ts execute.Time) error { 28 | return errors.New(codes.Unimplemented) 29 | } 30 | func (t *Transport) Finish(id execute.DatasetID, err error) { 31 | } 32 | -------------------------------------------------------------------------------- /operation.go: -------------------------------------------------------------------------------- 1 | package flux 2 | 3 | // OperationSpec specifies an operation as part of a query. 4 | type OperationSpec interface { 5 | // Kind returns the kind of the operation. 6 | Kind() OperationKind 7 | } 8 | 9 | // OperationKind denotes the kind of operations. 10 | type OperationKind string 11 | -------------------------------------------------------------------------------- /parser/doc.go: -------------------------------------------------------------------------------- 1 | // Package parser implements a parser for Flux source files. Input is provided 2 | // by a string and output is an abstract-syntax tree (AST) representing the 3 | // Flux source. 4 | // 5 | // The parser accepts a larger language than is syntactically permitted and 6 | // will embed any errors from parsing the source into the AST itself. 7 | package parser 8 | -------------------------------------------------------------------------------- /parser/gofuzz.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | package parser 5 | 6 | import "github.com/InfluxCommunity/flux/ast" 7 | 8 | // Fuzz will run the parser on the input data and return 1 on success and 0 on failure. 9 | func Fuzz(data []byte) int { 10 | pkg := ParseSource(string(data)) 11 | if ast.Check(pkg) > 0 { 12 | return 0 13 | } 14 | return 1 15 | } 16 | -------------------------------------------------------------------------------- /parser/libflux_parser.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/ast" 5 | "github.com/InfluxCommunity/flux/internal/token" 6 | "github.com/InfluxCommunity/flux/libflux/go/libflux" 7 | ) 8 | 9 | func parseFile(f *token.File, src []byte) (*ast.File, error) { 10 | astFile := libflux.Parse(f.Name(), string(src)) 11 | defer astFile.Free() 12 | 13 | data, err := astFile.MarshalJSON() 14 | if err != nil { 15 | return nil, err 16 | } 17 | 18 | node, err := ast.UnmarshalNode(data) 19 | if err != nil { 20 | return nil, err 21 | } 22 | 23 | file := node.(*ast.Package).Files[0] 24 | 25 | // The go parser will not fill in the imports if there are 26 | // none so we remove them here to retain compatibility. 27 | if len(file.Imports) == 0 { 28 | file.Imports = nil 29 | } 30 | return file, nil 31 | } 32 | -------------------------------------------------------------------------------- /pkg-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | tmpdir=$(mktemp -d) 4 | trap "{ rm -rf ${tmpdir}; }" EXIT 5 | 6 | # "go build" can be noisy, and when Go invokes pkg-config (by calling this script) it will merge stdout and stderr. 7 | # Discard any output unless "go build" terminates with an error. 8 | go build -o ${tmpdir}/pkg-config github.com/influxdata/pkg-config &> ${tmpdir}/go_build_output 9 | if [ "$?" -ne 0 ]; then 10 | cat ${tmpdir}/go_build_output 1>&2 11 | exit 1 12 | fi 13 | 14 | ${tmpdir}/pkg-config "$@" 15 | -------------------------------------------------------------------------------- /plan/builtin_test.go: -------------------------------------------------------------------------------- 1 | package plan_test 2 | 3 | import ( 4 | // We need to init flux for the tests to work. 5 | _ "github.com/InfluxCommunity/flux/fluxinit/static" 6 | ) 7 | -------------------------------------------------------------------------------- /plan/cost.go: -------------------------------------------------------------------------------- 1 | package plan 2 | 3 | type Statistics struct { 4 | Cardinality int64 5 | GroupCardinality int64 6 | } 7 | 8 | // Cost stores various dimensions of the cost of a query plan 9 | type Cost struct { 10 | Disk int64 11 | CPU int64 12 | GPU int64 13 | MEM int64 14 | NET int64 15 | } 16 | 17 | // Add two cost structures together 18 | func Add(a Cost, b Cost) Cost { 19 | return Cost{ 20 | Disk: a.Disk + b.Disk, 21 | CPU: a.CPU + b.CPU, 22 | GPU: a.GPU + b.GPU, 23 | MEM: a.MEM + b.MEM, 24 | NET: a.NET + b.NET, 25 | } 26 | } 27 | 28 | type DefaultCost struct { 29 | } 30 | 31 | func (c DefaultCost) Cost(inStats []Statistics) (Cost, Statistics) { 32 | return Cost{}, Statistics{} 33 | } 34 | -------------------------------------------------------------------------------- /plan/plantest/doc.go: -------------------------------------------------------------------------------- 1 | // Package plantest contains utilities for testing each query planning phase 2 | package plantest 3 | -------------------------------------------------------------------------------- /plan/plantest/spec.go: -------------------------------------------------------------------------------- 1 | package plantest 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/plan" 5 | "github.com/InfluxCommunity/flux/plan/plantest/spec" 6 | ) 7 | 8 | // 9 | // Export the plan/plantest/spec types and functions. This is isolated so it 10 | // can be used in testing code for /execute, where the full plantest 11 | // dependencies cause an import cycle. 12 | // 13 | 14 | type PlanSpec = spec.PlanSpec 15 | type MockProcedureSpec = spec.MockProcedureSpec 16 | 17 | func CreatePlanSpec(ps *PlanSpec) *plan.Spec { 18 | return spec.CreatePlanSpec(ps) 19 | } 20 | 21 | func CreateLogicalMockNode(id string) *plan.LogicalNode { 22 | return spec.CreateLogicalMockNode(id) 23 | } 24 | 25 | func CreatePhysicalMockNode(id string) *plan.PhysicalPlanNode { 26 | return spec.CreatePhysicalMockNode(id) 27 | } 28 | -------------------------------------------------------------------------------- /plan/rules.go: -------------------------------------------------------------------------------- 1 | package plan 2 | 3 | import "context" 4 | 5 | // Rule is transformation rule for a query operation 6 | type Rule interface { 7 | // Name of this rule (must be unique). 8 | Name() string 9 | 10 | // Pattern for this rule to match against. 11 | Pattern() Pattern 12 | 13 | // Rewrite an operation into an equivalent one. 14 | // The returned node is the new root of the sub tree. 15 | // The boolean return value should be true if anything changed during the rewrite. 16 | Rewrite(context.Context, Node) (Node, bool, error) 17 | } 18 | -------------------------------------------------------------------------------- /plan/yield.go: -------------------------------------------------------------------------------- 1 | package plan 2 | 3 | // DefaultYieldName is the name of a result that doesn't 4 | // have any name assigned. 5 | const DefaultYieldName = "_result" 6 | 7 | // YieldProcedureSpec is a special procedure that has the side effect of 8 | // returning a result to the client. 9 | type YieldProcedureSpec interface { 10 | YieldName() string 11 | } 12 | 13 | const generatedYieldKind = "generatedYield" 14 | 15 | // GeneratedYieldProcedureSpec provides a special planner-generated yield for queries that don't 16 | // have explicit calls to yield(). 17 | type GeneratedYieldProcedureSpec struct { 18 | DefaultCost 19 | Name string 20 | } 21 | 22 | func (y *GeneratedYieldProcedureSpec) Kind() ProcedureKind { 23 | return generatedYieldKind 24 | } 25 | 26 | func (y *GeneratedYieldProcedureSpec) Copy() ProcedureSpec { 27 | return &GeneratedYieldProcedureSpec{Name: y.Name} 28 | } 29 | 30 | func (y *GeneratedYieldProcedureSpec) YieldName() string { 31 | return y.Name 32 | } 33 | -------------------------------------------------------------------------------- /prep-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Run this script to prepare a Flux release 4 | # 5 | # This script is responsible for creating a commit that finalizes any changes 6 | # to the source that need to be made before a release. 7 | # 8 | # The following optional dependencies are helpful if available. 9 | # 10 | # - `hub`, which will submit PRs for the update branches automatically if 11 | # available. 12 | 13 | DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd) 14 | cd $DIR 15 | 16 | set -e 17 | 18 | version=$(./gotool.sh github.com/influxdata/changelog nextver) 19 | 20 | git checkout -b prep-release/$version 21 | 22 | ./etc/fixup_docs_version.sh $version 23 | make generate 24 | 25 | message="build(flux): prepare Flux release for $version" 26 | 27 | git commit -am "$message" 28 | git push 29 | 30 | if ! command -v hub &> /dev/null 31 | then 32 | echo "hub is not installed. Cannot open github PRs automatically." 33 | echo "Pull requests will have to be manually created." 34 | HAS_HUB=0 35 | else 36 | HAS_HUB=1 37 | fi 38 | 39 | if [ $HAS_HUB -eq 1 ] 40 | then 41 | hub pull-request -m "$message" 42 | fi 43 | -------------------------------------------------------------------------------- /querytest/doc.go: -------------------------------------------------------------------------------- 1 | // Package querytest contains utilities for testing the query end-to-end. 2 | package querytest 3 | -------------------------------------------------------------------------------- /querytest/execute.go: -------------------------------------------------------------------------------- 1 | package querytest 2 | 3 | import ( 4 | "context" 5 | "io" 6 | 7 | "github.com/InfluxCommunity/flux" 8 | "github.com/InfluxCommunity/flux/dependency" 9 | "github.com/InfluxCommunity/flux/execute/executetest" 10 | "github.com/InfluxCommunity/flux/memory" 11 | "github.com/InfluxCommunity/flux/runtime" 12 | ) 13 | 14 | type Querier struct{} 15 | 16 | func (q *Querier) Query(ctx context.Context, w io.Writer, c flux.Compiler, d flux.Dialect) (int64, error) { 17 | program, err := c.Compile(ctx, runtime.Default) 18 | if err != nil { 19 | return 0, err 20 | } 21 | ctx, deps := dependency.Inject(ctx, executetest.NewTestExecuteDependencies()) 22 | defer deps.Finish() 23 | query, err := program.Start(ctx, memory.DefaultAllocator) 24 | if err != nil { 25 | return 0, err 26 | } 27 | results := flux.NewResultIteratorFromQuery(query) 28 | defer results.Release() 29 | 30 | encoder := d.Encoder() 31 | return encoder.Encode(w, results) 32 | } 33 | 34 | func NewQuerier() *Querier { 35 | return &Querier{} 36 | } 37 | -------------------------------------------------------------------------------- /repl/compiler.go: -------------------------------------------------------------------------------- 1 | package repl 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/internal/operation" 8 | "github.com/InfluxCommunity/flux/lang" 9 | "github.com/InfluxCommunity/flux/plan" 10 | ) 11 | 12 | // CompilerType specific to the Flux REPL 13 | const CompilerType = "REPL" 14 | 15 | // Compiler specific to the Flux REPL 16 | type Compiler struct { 17 | Spec *operation.Spec `json:"spec"` 18 | } 19 | 20 | func (c Compiler) Compile(ctx context.Context, runtime flux.Runtime) (flux.Program, error) { 21 | planner := plan.PlannerBuilder{}.Build() 22 | ps, err := planner.Plan(ctx, c.Spec) 23 | if err != nil { 24 | return nil, err 25 | } 26 | 27 | return &lang.Program{ 28 | PlanSpec: ps, 29 | }, err 30 | } 31 | 32 | func (c Compiler) CompilerType() flux.CompilerType { 33 | return CompilerType 34 | } 35 | 36 | func AddCompilerToMappings(mappings flux.CompilerMappings) error { 37 | return mappings.Add(CompilerType, func() flux.Compiler { 38 | return new(Compiler) 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /resource_management.go: -------------------------------------------------------------------------------- 1 | package flux 2 | 3 | // ResourceManagement defines how the query should consume avaliable resources. 4 | type ResourceManagement struct { 5 | // ConcurrencyQuota is the number of concurrency workers allowed to process this query. 6 | // A zero value indicates the planner can pick the optimal concurrency. 7 | ConcurrencyQuota int `json:"concurrency_quota"` 8 | // MemoryBytesQuota is the number of bytes of RAM this query may consume. 9 | // There is a small amount of overhead memory being consumed by a query that will not be counted towards this limit. 10 | // A zero value indicates unlimited. 11 | MemoryBytesQuota int64 `json:"memory_bytes_quota"` 12 | } 13 | -------------------------------------------------------------------------------- /runtime/analyze_libflux.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/libflux/go/libflux" 8 | "github.com/InfluxCommunity/flux/semantic" 9 | ) 10 | 11 | // AnalyzeSource parses and analyzes the given Flux source, 12 | // using libflux. 13 | func AnalyzeSource(ctx context.Context, fluxSrc string) (*semantic.Package, error) { 14 | ast := libflux.ParseString(fluxSrc) 15 | return AnalyzePackage(ctx, ast) 16 | } 17 | 18 | func AnalyzePackage(ctx context.Context, astPkg flux.ASTHandle) (*semantic.Package, error) { 19 | hdl := astPkg.(*libflux.ASTPkg) 20 | defer hdl.Free() 21 | 22 | options := libflux.NewOptions(ctx) 23 | sem, err := libflux.AnalyzeWithOptions(hdl, options) 24 | if err != nil { 25 | return nil, err 26 | } 27 | defer sem.Free() 28 | bs, err := sem.MarshalFB() 29 | if err != nil { 30 | return nil, err 31 | } 32 | return semantic.DeserializeFromFlatBuffer(bs) 33 | } 34 | -------------------------------------------------------------------------------- /runtime/analyze_libflux_test.go: -------------------------------------------------------------------------------- 1 | package runtime_test 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "testing" 7 | 8 | "github.com/InfluxCommunity/flux/runtime" 9 | ) 10 | 11 | func TestAnalyzeSource(t *testing.T) { 12 | tcs := []struct { 13 | name string 14 | flx string 15 | err error 16 | }{ 17 | { 18 | name: "success", 19 | flx: `x = 10`, 20 | }, 21 | { 22 | name: "failure", 23 | flx: `x = 10 + "foo"`, 24 | err: errors.New("error @1:10-1:15: expected int but found string"), 25 | }, 26 | } 27 | for _, tc := range tcs { 28 | tc := tc 29 | t.Run(tc.name, func(t *testing.T) { 30 | ctx := context.Background() 31 | _, err := runtime.AnalyzeSource(ctx, tc.flx) 32 | if err != nil { 33 | if tc.err == nil { 34 | t.Fatalf("expected no error, got %v", err) 35 | } 36 | if want, got := tc.err.Error(), err.Error(); want != got { 37 | t.Fatalf("wanted error %q, got %q", want, got) 38 | } 39 | return 40 | } 41 | if tc.err != nil { 42 | t.Fatalf("expected error %q, got none", tc.err) 43 | } 44 | }) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /runtime/parse.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/libflux/go/libflux" 8 | "github.com/InfluxCommunity/flux/parser" 9 | ) 10 | 11 | // Parse parses a Flux script and produces an ast.Package. 12 | func Parse(ctx context.Context, flux string) (flux.ASTHandle, error) { 13 | astPkg, err := parser.ParseToHandle(ctx, []byte(flux)) 14 | if err != nil { 15 | return nil, err 16 | } 17 | return astPkg, nil 18 | } 19 | 20 | func ParseToJSON(ctx context.Context, flux string) ([]byte, error) { 21 | h, err := Parse(ctx, flux) 22 | if err != nil { 23 | return nil, err 24 | } 25 | return parser.HandleToJSON(h) 26 | } 27 | 28 | func MergePackages(dst, src flux.ASTHandle) error { 29 | dstPkg, srcPkg := dst.(*libflux.ASTPkg), src.(*libflux.ASTPkg) 30 | return libflux.MergePackages(dstPkg, srcPkg) 31 | } 32 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.68" 3 | components = ["rustfmt", "clippy"] 4 | targets = [ 5 | "wasm32-unknown-unknown", 6 | "x86_64-unknown-linux-musl", 7 | "aarch64-unknown-linux-musl", 8 | "x86_64-pc-windows-gnu", 9 | "x86_64-apple-darwin", 10 | ] 11 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/rustfmt.toml -------------------------------------------------------------------------------- /semantic/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | The semantic package provides a graph structure that represents the meaning of a Flux script. 3 | An AST is converted into a semantic graph for use with other systems. 4 | Using a semantic graph representation of the Flux, enables highlevel meaning to be specified programatically. 5 | 6 | The semantic structures are to be designed to facilitate the interpretation and compilation of Flux. 7 | 8 | For example since Flux uses the javascript AST structures, arguments to a function are represented as a single positional argument that is always an object expression. 9 | The semantic graph validates that the AST correctly follows these semantics, and use structures that are strongly typed for this expectation. 10 | */ 11 | package semantic 12 | -------------------------------------------------------------------------------- /semantic/semantictest/doc.go: -------------------------------------------------------------------------------- 1 | // Package semantictest contains utilities for testing the semantic package. 2 | package semantictest 3 | -------------------------------------------------------------------------------- /semantic/symbol_test.go: -------------------------------------------------------------------------------- 1 | package semantic_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux/runtime" 8 | "github.com/InfluxCommunity/flux/semantic" 9 | ) 10 | 11 | func TestSymbol(t *testing.T) { 12 | tcs := []struct { 13 | name string 14 | fluxSrc string 15 | err error 16 | }{ 17 | { 18 | name: "isType", 19 | fluxSrc: ` 20 | import "types" 21 | x = types.isType(v: 1, type: "string") 22 | `, 23 | }, 24 | } 25 | for _, tc := range tcs { 26 | tc := tc 27 | t.Run(tc.name, func(t *testing.T) { 28 | ctx := context.Background() 29 | pkg, err := runtime.AnalyzeSource(ctx, tc.fluxSrc) 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | 34 | call := pkg.Files[0].Body[0].(*semantic.NativeVariableAssignment).Init.(*semantic.CallExpression) 35 | property := call.Callee.(*semantic.MemberExpression).Property 36 | if property != semantic.NewSymbol("isType@types") { 37 | t.Fatalf("Expected the `isType` call to resolve to the module type: got:\n%v", property) 38 | } 39 | }) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /semantic/types.go: -------------------------------------------------------------------------------- 1 | package semantic 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | // Nature is the primitive description of a type. 8 | type Nature int 9 | 10 | const ( 11 | Invalid Nature = iota 12 | String 13 | Bytes 14 | Int 15 | UInt 16 | Float 17 | Bool 18 | Time 19 | Duration 20 | Regexp 21 | Array 22 | Object 23 | Function 24 | Dictionary 25 | Dynamic 26 | Vector 27 | Stream 28 | ) 29 | 30 | var natureNames = []string{ 31 | Invalid: "invalid", 32 | String: "string", 33 | Bytes: "bytes", 34 | Int: "int", 35 | UInt: "uint", 36 | Float: "float", 37 | Bool: "bool", 38 | Time: "time", 39 | Duration: "duration", 40 | Regexp: "regexp", 41 | Array: "array", 42 | Object: "object", 43 | Function: "function", 44 | Dictionary: "dictionary", 45 | Dynamic: "dynamic", 46 | Vector: "vector", 47 | Stream: "stream", 48 | } 49 | 50 | func (n Nature) String() string { 51 | if int(n) < len(natureNames) { 52 | return natureNames[n] 53 | } 54 | return "nature" + strconv.Itoa(int(n)) 55 | } 56 | -------------------------------------------------------------------------------- /stdlib/array/from_test.go: -------------------------------------------------------------------------------- 1 | package array_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | _ "github.com/InfluxCommunity/flux/fluxinit/static" 8 | "github.com/InfluxCommunity/flux/runtime" 9 | ) 10 | 11 | func TestArrayFrom_ReceiveTableObjectIsError(t *testing.T) { 12 | src := `import "array" 13 | array.from(rows: array.from(rows: [{}]))` 14 | _, _, err := runtime.Eval(context.Background(), src) 15 | if err == nil { 16 | t.Fatal("expected error, got none") 17 | } 18 | 19 | if want, got := "error @2:21-2:43: expected [{}] (array) but found stream[{}] (argument rows)", err.Error(); want != got { 20 | t.Errorf("wanted error %q, got %q", want, got) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /stdlib/contrib/RohanSreerama5/images/csvData.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/stdlib/contrib/RohanSreerama5/images/csvData.png -------------------------------------------------------------------------------- /stdlib/contrib/RohanSreerama5/images/data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/stdlib/contrib/RohanSreerama5/images/data.png -------------------------------------------------------------------------------- /stdlib/contrib/RohanSreerama5/images/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/stdlib/contrib/RohanSreerama5/images/overview.png -------------------------------------------------------------------------------- /stdlib/contrib/RohanSreerama5/images/pythonScript.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfluxCommunity/flux/b8a2175e4448396fefde0310d7b422ea93949e26/stdlib/contrib/RohanSreerama5/images/pythonScript.png -------------------------------------------------------------------------------- /stdlib/contrib/RohanSreerama5/naiveBayesClassifier/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package naiveBayesClassifier 6 | -------------------------------------------------------------------------------- /stdlib/contrib/anaisdg/anomalydetection/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package anomalydetection 6 | -------------------------------------------------------------------------------- /stdlib/contrib/anaisdg/statsmodels/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package statsmodels 6 | -------------------------------------------------------------------------------- /stdlib/contrib/bonitoo-io/alerta/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package alerta 6 | -------------------------------------------------------------------------------- /stdlib/contrib/bonitoo-io/servicenow/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package servicenow 6 | -------------------------------------------------------------------------------- /stdlib/contrib/bonitoo-io/tickscript/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package tickscript 6 | -------------------------------------------------------------------------------- /stdlib/contrib/bonitoo-io/victorops/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package victorops 6 | -------------------------------------------------------------------------------- /stdlib/contrib/bonitoo-io/zenoss/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package zenoss 6 | -------------------------------------------------------------------------------- /stdlib/contrib/chobbs/discord/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package discord 6 | -------------------------------------------------------------------------------- /stdlib/contrib/qxip/clickhouse/README.md: -------------------------------------------------------------------------------- 1 | # ClickHouse Flux Package 2 | 3 | Use this package to interact with ClickHouse HTTP APIs. 4 | 5 | ## clickhouse.query 6 | 7 | `clickhouse.query` executes a POST query against a ClickHouse HTTP Interface. 8 | 9 | Parameters: 10 | 11 | | Name | Type | Description | 12 | | ---- | ---- | ----------- | 13 | | url | string | ClickHouse HTTP/S URL. Default http://127.0.0.1:8123 | 14 | | query | string | ClickHouse query to execute. | 15 | | limit | string | Query limit. Default is 100. | 16 | | max_bytes | string | Query stepping. Default is 10000000. | 17 | | format | string | Query output format. Default CSVWithNames | 18 | 19 | Example: 20 | 21 | ``` 22 | import "contrib/qxip/clickhouse" 23 | 24 | clickhouse.query( 25 | url: "https://play@play.clickhouse.com", 26 | query: "SELECT version()" 27 | ) 28 | ``` 29 | 30 | 31 | ## Contact 32 | 33 | - Author: Lorenzo Mangani / qxip 34 | - Email: lorenzo.mangani@gmail.com 35 | - Github: [@metrico](https://github.com/metrico) 36 | - Website: [@qryn](https://qryn.dev) 37 | -------------------------------------------------------------------------------- /stdlib/contrib/qxip/clickhouse/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package clickhouse 6 | -------------------------------------------------------------------------------- /stdlib/contrib/qxip/iox/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package iox 6 | -------------------------------------------------------------------------------- /stdlib/contrib/qxip/logql/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package logql 6 | -------------------------------------------------------------------------------- /stdlib/contrib/rhajek/bigpanda/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package bigpanda 6 | -------------------------------------------------------------------------------- /stdlib/contrib/sranka/teams/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package teams 6 | -------------------------------------------------------------------------------- /stdlib/contrib/sranka/telegram/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package telegram 6 | -------------------------------------------------------------------------------- /stdlib/contrib/sranka/webexteams/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package webexteams 6 | -------------------------------------------------------------------------------- /stdlib/date/boundaries/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package boundaries 6 | -------------------------------------------------------------------------------- /stdlib/date/date_test.flux: -------------------------------------------------------------------------------- 1 | package date_test 2 | 3 | 4 | import "date" 5 | import "testing" 6 | import "array" 7 | import "timezone" 8 | 9 | testcase date_timeable { 10 | option now = () => 2021-03-01T00:00:00Z 11 | 12 | want = array.from(rows: [{_value: 2}]) 13 | got = array.from(rows: [{_value: date.month(t: -1mo)}]) 14 | 15 | testing.diff(want: want, got: got) 16 | } 17 | 18 | testcase time_location { 19 | option location = timezone.location(name: "Asia/Kolkata") 20 | 21 | want = array.from(rows: [{_time: 2021-03-01T05:30:00Z}]) 22 | got = array.from(rows: [{_time: date.time(t: 2021-03-01T00:00:00Z)}]) 23 | 24 | testing.diff(want: want, got: got) 25 | } 26 | 27 | testcase duration_location { 28 | option location = timezone.location(name: "Asia/Kolkata") 29 | option now = () => 2021-03-01T00:00:00Z 30 | 31 | want = array.from(rows: [{_time: 2021-03-01T06:30:00Z}, {_time: 2021-04-09T06:30:00Z}]) 32 | got = array.from(rows: [{_time: date.time(t: 1h)}, {_time: date.time(t: 1mo1w1d1h)}]) 33 | 34 | testing.diff(want: want, got: got) 35 | } 36 | -------------------------------------------------------------------------------- /stdlib/date/scale_test.flux: -------------------------------------------------------------------------------- 1 | package date_test 2 | 3 | 4 | import "array" 5 | import "date" 6 | import "testing" 7 | 8 | option now = () => 2022-05-10T00:00:00Z 9 | 10 | scaleTime = (d, n) => date.add(to: now(), d: date.scale(d: d, n: n)) 11 | 12 | testcase scale { 13 | got = 14 | array.from( 15 | rows: [ 16 | {_value: scaleTime(d: 1h, n: 1)}, 17 | {_value: scaleTime(d: 1h, n: 2)}, 18 | {_value: scaleTime(d: 1h, n: 3)}, 19 | {_value: scaleTime(d: 1h, n: 4)}, 20 | ], 21 | ) 22 | 23 | want = 24 | array.from( 25 | rows: [ 26 | {_value: 2022-05-10T01:00:00Z}, 27 | {_value: 2022-05-10T02:00:00Z}, 28 | {_value: 2022-05-10T03:00:00Z}, 29 | {_value: 2022-05-10T04:00:00Z}, 30 | ], 31 | ) 32 | 33 | testing.diff(want, got) |> yield() 34 | } 35 | -------------------------------------------------------------------------------- /stdlib/dict/empty_dict_lit_test.flux: -------------------------------------------------------------------------------- 1 | package dict_test 2 | 3 | 4 | import "testing" 5 | import "dict" 6 | import "csv" 7 | 8 | codes = [:] 9 | inData = 10 | " 11 | #datatype,string,long,dateTime:RFC3339,string,string,long 12 | #group,false,false,false,true,true,false 13 | #default,_result,,,,, 14 | ,result,table,_time,_measurement,_field,_value 15 | ,,0,2018-05-22T19:53:26Z,_m,_f,0 16 | ,,0,2018-05-22T19:53:36Z,_m,_f,0 17 | " 18 | outData = 19 | " 20 | #datatype,string,long,dateTime:RFC3339,string,string,long,long 21 | #group,false,false,false,true,true,false,false 22 | #default,_result,,,,,, 23 | ,result,table,_time,_measurement,_field,_value,code 24 | ,,0,2018-05-22T19:53:26Z,_m,_f,0,2 25 | ,,0,2018-05-22T19:53:36Z,_m,_f,0,2 26 | " 27 | 28 | testcase dict_empty_lit { 29 | got = 30 | csv.from(csv: inData) 31 | |> testing.load() 32 | |> range(start: 2018-05-22T19:53:26Z) 33 | |> drop(columns: ["_start", "_stop"]) 34 | |> map(fn: (r) => ({r with code: dict.get(dict: codes, key: 1, default: 2)})) 35 | want = csv.from(csv: outData) 36 | 37 | testing.diff(got, want) 38 | } 39 | -------------------------------------------------------------------------------- /stdlib/experimental/aggregate/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package aggregate 6 | -------------------------------------------------------------------------------- /stdlib/experimental/array/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package array 6 | -------------------------------------------------------------------------------- /stdlib/experimental/bitwise/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package bitwise 6 | -------------------------------------------------------------------------------- /stdlib/experimental/count.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | countSignature := runtime.MustLookupBuiltinType("experimental", "count") 11 | runtime.RegisterPackageValue("experimental", "count", flux.MustValue(flux.FunctionValue("count", universe.CreateCountOpSpec, countSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/csv/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package csv 6 | -------------------------------------------------------------------------------- /stdlib/experimental/date/boundaries/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package boundaries 6 | -------------------------------------------------------------------------------- /stdlib/experimental/distinct.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | distinctSignature := runtime.MustLookupBuiltinType("experimental", "distinct") 11 | runtime.RegisterPackageValue("experimental", "distinct", flux.MustValue(flux.FunctionValue("distinct", universe.CreateDistinctOpSpec, distinctSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/fill.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | fillSignature := runtime.MustLookupBuiltinType("experimental", "fill") 11 | runtime.RegisterPackageValue("experimental", "fill", flux.MustValue(flux.FunctionValue("fill", universe.CreateFillOpSpec, fillSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/first.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | firstSignature := runtime.MustLookupBuiltinType("experimental", "first") 11 | runtime.RegisterPackageValue("experimental", "first", flux.MustValue(flux.FunctionValue("first", universe.CreateFirstOpSpec, firstSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/geo/geo_internal_test.go: -------------------------------------------------------------------------------- 1 | package geo 2 | 3 | import "github.com/InfluxCommunity/flux/values" 4 | 5 | // TODO(ales.pour@bonitoo.io): This is exposed so the tests have access to the functions. 6 | var Functions = map[string]values.Function{ 7 | "getGrid": generateGetGridFunc(), 8 | "getLevel": generateGetLevelFunc(), 9 | "s2CellIDToken": generateS2CellIDTokenFunc(), 10 | "s2CellLatLon": generateS2CellLatLonFunc(), 11 | "stContains": generateSTContainsFunc(), 12 | "stDistance": generateSTDistanceFunc(), 13 | "stLength": generateSTLengthFunc(), 14 | } 15 | -------------------------------------------------------------------------------- /stdlib/experimental/histogram.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | histogramSignature := runtime.MustLookupBuiltinType("experimental", "histogram") 11 | runtime.RegisterPackageValue("experimental", "histogram", flux.MustValue(flux.FunctionValue("histogram", universe.CreateHistogramOpSpec, histogramSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/histogram_quantile.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | histogramQuantileSignature := runtime.MustLookupBuiltinType("experimental", "histogramQuantile") 11 | runtime.RegisterPackageValue("experimental", "histogramQuantile", flux.MustValue(flux.FunctionValue("histogramQuantile", universe.CreateHistogramQuantileOpSpec, histogramQuantileSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/http/requests/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package requests 6 | -------------------------------------------------------------------------------- /stdlib/experimental/integral.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | integralSignature := runtime.MustLookupBuiltinType("experimental", "integral") 11 | runtime.RegisterPackageValue("experimental", "integral", flux.MustValue(flux.FunctionValue("integral", universe.CreateIntegralOpSpec, integralSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/iox/iox.go: -------------------------------------------------------------------------------- 1 | package iox 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/codes" 5 | "github.com/InfluxCommunity/flux/internal/errors" 6 | "github.com/InfluxCommunity/flux/internal/function" 7 | "github.com/InfluxCommunity/flux/values" 8 | ) 9 | 10 | const pkgpath = "experimental/iox" 11 | 12 | func init() { 13 | b := function.ForPackage(pkgpath) 14 | b.Register("from", func(args *function.Arguments) (values.Value, error) { 15 | return nil, errors.New(codes.Unimplemented, "iox.from() is not implemented outside cloud 2.x") 16 | }) 17 | b.RegisterSource("sql", SqlKind, createSqlProcedureSpec) 18 | } 19 | -------------------------------------------------------------------------------- /stdlib/experimental/iox/iox_test.flux: -------------------------------------------------------------------------------- 1 | package iox_test 2 | 3 | 4 | import "array" 5 | import "testing" 6 | import "experimental/iox" 7 | 8 | testcase iox_sql_interval_testcase { 9 | got = 10 | array.from( 11 | rows: [ 12 | {_value: "12y3mo4w"}, 13 | {_value: "12d34h5m"}, 14 | {_value: "123s56ms"}, 15 | {_value: "123us56ns"}, 16 | ], 17 | ) 18 | |> map(fn: (r) => ({_value: iox.sqlInterval(d: duration(v: r._value))})) 19 | 20 | want = 21 | array.from( 22 | rows: [ 23 | {_value: "12 years 3 months 4 weeks"}, 24 | {_value: "1 weeks 6 days 10 hours 5 minutes"}, 25 | {_value: "2 minutes 3 seconds 56 milliseconds"}, 26 | {_value: "123 microseconds 56 nanoseconds"}, 27 | ], 28 | ) 29 | 30 | testing.diff(got: got, want: want) 31 | } 32 | -------------------------------------------------------------------------------- /stdlib/experimental/kaufmansAMA.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | kamaSignature := runtime.MustLookupBuiltinType("experimental", "kaufmansAMA") 11 | runtime.RegisterPackageValue("experimental", "kaufmansAMA", flux.MustValue(flux.FunctionValue("kaufmansAMA", universe.CreatekamaOpSpec, kamaSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/last.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | lastSignature := runtime.MustLookupBuiltinType("experimental", "last") 11 | runtime.RegisterPackageValue("experimental", "last", flux.MustValue(flux.FunctionValue("last", universe.CreateLastOpSpec, lastSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/max.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | maxSignature := runtime.MustLookupBuiltinType("experimental", "max") 11 | runtime.RegisterPackageValue("experimental", "max", flux.MustValue(flux.FunctionValue("max", universe.CreateMaxOpSpec, maxSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/mean.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | meanSignature := runtime.MustLookupBuiltinType("experimental", "mean") 11 | runtime.RegisterPackageValue("experimental", "mean", flux.MustValue(flux.FunctionValue("mean", universe.CreateMeanOpSpec, meanSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/min.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | minSignature := runtime.MustLookupBuiltinType("experimental", "min") 11 | runtime.RegisterPackageValue("experimental", "min", flux.MustValue(flux.FunctionValue("min", universe.CreateMinOpSpec, minSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/mode.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | modeSignature := runtime.MustLookupBuiltinType("experimental", "mode") 11 | runtime.RegisterPackageValue("experimental", "mode", flux.MustValue(flux.FunctionValue("mode", universe.CreateModeOpSpec, modeSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/mqtt/mqtt_test.flux: -------------------------------------------------------------------------------- 1 | package mqtt_test 2 | 3 | 4 | import "array" 5 | import "experimental/mqtt" 6 | import "testing" 7 | 8 | testcase integration_mqtt_pub { 9 | option testing.tags = ["integration_write"] 10 | 11 | got = 12 | array.from( 13 | rows: [ 14 | { 15 | ok: 16 | mqtt.publish( 17 | broker: "tcp://127.0.0.1:1883", 18 | topic: "test/topic", 19 | message: "smoke test", 20 | qos: 0, 21 | retain: false, 22 | clientid: "fluxtest", 23 | ), 24 | }, 25 | ], 26 | ) 27 | want = array.from(rows: [{ok: true}]) 28 | 29 | testing.diff(want: want, got: got) |> yield() 30 | } 31 | -------------------------------------------------------------------------------- /stdlib/experimental/object_keys.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/codes" 7 | "github.com/InfluxCommunity/flux/runtime" 8 | 9 | "github.com/InfluxCommunity/flux/internal/errors" 10 | "github.com/InfluxCommunity/flux/semantic" 11 | "github.com/InfluxCommunity/flux/values" 12 | ) 13 | 14 | func init() { 15 | runtime.RegisterPackageValue("experimental", "objectKeys", values.NewFunction( 16 | "objectKeys", 17 | runtime.MustLookupBuiltinType("experimental", "objectKeys"), 18 | func(ctx context.Context, args values.Object) (values.Value, error) { 19 | o, ok := args.Get("o") 20 | if !ok { 21 | return nil, errors.New(codes.Invalid, "missing parameter \"o\"") 22 | } 23 | if o.Type().Nature() != semantic.Object { 24 | return nil, errors.New(codes.Invalid, "parameter \"o\" is not an object") 25 | } 26 | obj := o.Object() 27 | keys := make([]values.Value, 0, obj.Len()) 28 | obj.Range(func(name string, _ values.Value) { 29 | keys = append(keys, values.NewString(name)) 30 | }) 31 | return values.NewArrayWithBacking(semantic.NewArrayType(semantic.BasicString), keys), nil 32 | }, 33 | false, 34 | )) 35 | } 36 | -------------------------------------------------------------------------------- /stdlib/experimental/object_keys_test.go: -------------------------------------------------------------------------------- 1 | package experimental_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux/dependencies/dependenciestest" 8 | "github.com/InfluxCommunity/flux/dependency" 9 | "github.com/InfluxCommunity/flux/runtime" 10 | ) 11 | 12 | func TestObjectKeys(t *testing.T) { 13 | script := ` 14 | import "experimental" 15 | import "internal/testutil" 16 | 17 | o = {a: 1, b: 2, c: 3} 18 | experimental.objectKeys(o: o) == ["a", "b", "c"] or testutil.fail() 19 | ` 20 | ctx, deps := dependency.Inject(context.Background(), dependenciestest.Default()) 21 | defer deps.Finish() 22 | if _, _, err := runtime.Eval(ctx, script); err != nil { 23 | t.Fatal("evaluation of objectKeys failed: ", err) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /stdlib/experimental/oee/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package oee 6 | -------------------------------------------------------------------------------- /stdlib/experimental/quantile.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | quantileSignature := runtime.MustLookupBuiltinType("experimental", "quantile") 11 | runtime.RegisterPackageValue("experimental", "quantile", flux.MustValue(flux.FunctionValue("quantile", universe.CreateQuantileOpSpec, quantileSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/query/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package query 6 | -------------------------------------------------------------------------------- /stdlib/experimental/skew.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | skewSignature := runtime.MustLookupBuiltinType("experimental", "skew") 11 | runtime.RegisterPackageValue("experimental", "skew", flux.MustValue(flux.FunctionValue("skew", universe.CreateSkewOpSpec, skewSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/spread.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | spreadSignature := runtime.MustLookupBuiltinType("experimental", "spread") 11 | runtime.RegisterPackageValue("experimental", "spread", flux.MustValue(flux.FunctionValue("spread", universe.CreateSpreadOpSpec, spreadSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/stddev.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | stddevSignature := runtime.MustLookupBuiltinType("experimental", "stddev") 11 | runtime.RegisterPackageValue("experimental", "stddev", flux.MustValue(flux.FunctionValue("stddev", universe.CreateStddevOpSpec, stddevSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/sum.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | sumSignature := runtime.MustLookupBuiltinType("experimental", "sum") 11 | runtime.RegisterPackageValue("experimental", "sum", flux.MustValue(flux.FunctionValue("sum", universe.CreateSumOpSpec, sumSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/table/table.flux: -------------------------------------------------------------------------------- 1 | // Package table provides tools working with Flux tables. 2 | // 3 | // ## Metadata 4 | // introduced: 0.115.0 5 | // 6 | package table 7 | 8 | 9 | // fill adds a single row to empty tables in a stream of tables. 10 | // 11 | // Columns that are in the group key are filled with the column value defined in the group key. 12 | // Columns not in the group key are filled with a null value. 13 | // 14 | // ## Parameters 15 | // - tables: Input data. Default is piped-forward data (`<-`). 16 | // 17 | // ## Examples 18 | // ### Fill empty tables 19 | // ``` 20 | // import "experimental/table" 21 | // import "sampledata" 22 | // 23 | // data = sampledata.int() 24 | // |> filter(fn: (r) => r.tag != "t2", onEmpty: "keep") 25 | // 26 | // < data 27 | // > |> table.fill() 28 | // ``` 29 | // 30 | // ## Metadata 31 | // tags: transformations,table 32 | // 33 | builtin fill : (<-tables: stream[A]) => stream[A] where A: Record 34 | -------------------------------------------------------------------------------- /stdlib/experimental/unique.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | uniqueSignature := runtime.MustLookupBuiltinType("experimental", "unique") 11 | runtime.RegisterPackageValue("experimental", "unique", flux.MustValue(flux.FunctionValue("unique", universe.CreateUniqueOpSpec, uniqueSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/experimental/usage/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package usage 6 | -------------------------------------------------------------------------------- /stdlib/experimental/window.go: -------------------------------------------------------------------------------- 1 | package experimental 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | "github.com/InfluxCommunity/flux/stdlib/universe" 7 | ) 8 | 9 | func init() { 10 | windowSignature := runtime.MustLookupBuiltinType("experimental", "_window") 11 | runtime.RegisterPackageValue("experimental", "_window", flux.MustValue(flux.FunctionValue("window", universe.CreateWindowOpSpec, windowSignature))) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/fluxtest.root: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flux", 3 | "tags": [ 4 | "integration_injection", 5 | "integration_write", 6 | "integration_read", 7 | "skip" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /stdlib/gen.go: -------------------------------------------------------------------------------- 1 | package stdlib 2 | 3 | //go:generate go generate ../libflux/go/libflux 4 | //go:generate go run github.com/InfluxCommunity/flux/internal/cmd/builtin generate --go-pkg github.com/InfluxCommunity/flux/stdlib 5 | -------------------------------------------------------------------------------- /stdlib/http/basic_auth.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | "encoding/base64" 6 | "fmt" 7 | 8 | "github.com/InfluxCommunity/flux/interpreter" 9 | "github.com/InfluxCommunity/flux/runtime" 10 | "github.com/InfluxCommunity/flux/values" 11 | ) 12 | 13 | func init() { 14 | runtime.RegisterPackageValue("http", "basicAuth", basicAuthFunc) 15 | } 16 | 17 | const ( 18 | basicAuthUsernameArg = "u" 19 | basicAuthPasswordArg = "p" 20 | ) 21 | 22 | var basicAuthFunc = values.NewFunction( 23 | "basicAuth", 24 | runtime.MustLookupBuiltinType("http", "basicAuth"), 25 | func(ctx context.Context, args values.Object) (values.Value, error) { 26 | return interpreter.DoFunctionCall(BasicAuth, args) 27 | }, 28 | false, 29 | ) 30 | 31 | func BasicAuth(args interpreter.Arguments) (values.Value, error) { 32 | u, err := args.GetRequiredString(basicAuthUsernameArg) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | p, err := args.GetRequiredString(basicAuthPasswordArg) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | combined := fmt.Sprintf("%s:%s", u, p) 43 | v := base64.StdEncoding.EncodeToString([]byte(combined)) 44 | return values.NewString("Basic " + v), nil 45 | } 46 | -------------------------------------------------------------------------------- /stdlib/http/basic_auth_test.go: -------------------------------------------------------------------------------- 1 | package http_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/InfluxCommunity/flux/interpreter" 7 | "github.com/InfluxCommunity/flux/stdlib/http" 8 | "github.com/InfluxCommunity/flux/values" 9 | ) 10 | 11 | func TestBasicAuth(t *testing.T) { 12 | u, p := "me", "mypassword" 13 | want := values.NewString("Basic bWU6bXlwYXNzd29yZA==") 14 | 15 | args := interpreter.NewArguments(values.NewObjectWithValues( 16 | map[string]values.Value{ 17 | "u": values.NewString(u), 18 | "p": values.NewString(p), 19 | }), 20 | ) 21 | got, err := http.BasicAuth(args) 22 | if err != nil { 23 | t.Fatalf("unexpected error: %s", err) 24 | } 25 | 26 | if !want.Equal(got) { 27 | t.Fatalf("unexpected value -want/+got:\n\t- %#v\n\t+ %#v", want, got) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /stdlib/http/path_encode.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | "net/url" 6 | 7 | "github.com/InfluxCommunity/flux/interpreter" 8 | "github.com/InfluxCommunity/flux/runtime" 9 | "github.com/InfluxCommunity/flux/values" 10 | ) 11 | 12 | func init() { 13 | runtime.RegisterPackageValue("http", "pathEscape", pathEscapeFunc) 14 | } 15 | 16 | const inputStringArg = "inputString" 17 | 18 | var pathEscapeFunc = values.NewFunction( 19 | "pathEscape", 20 | runtime.MustLookupBuiltinType("http", "pathEscape"), 21 | func(ctx context.Context, args values.Object) (values.Value, error) { 22 | return interpreter.DoFunctionCall(PathEncode, args) 23 | }, 24 | false, 25 | ) 26 | 27 | func PathEncode(args interpreter.Arguments) (values.Value, error) { 28 | inputString, err := args.GetRequiredString(inputStringArg) 29 | if err != nil { 30 | return nil, err 31 | } 32 | return values.NewString(url.PathEscape(inputString)), nil 33 | } 34 | -------------------------------------------------------------------------------- /stdlib/http/path_encode_test.go: -------------------------------------------------------------------------------- 1 | package http_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/InfluxCommunity/flux/interpreter" 7 | "github.com/InfluxCommunity/flux/stdlib/http" 8 | "github.com/InfluxCommunity/flux/values" 9 | ) 10 | 11 | func TestPathEscape(t *testing.T) { 12 | inputString := "random:/#" 13 | want := values.NewString("random:%2F%23") 14 | 15 | args := interpreter.NewArguments(values.NewObjectWithValues( 16 | map[string]values.Value{ 17 | "inputString": values.NewString(inputString), 18 | }), 19 | ) 20 | 21 | got, err := http.PathEncode(args) 22 | if err != nil { 23 | t.Fatalf("unexpected error: %s", err) 24 | } 25 | 26 | if !want.Equal(got) { 27 | t.Fatalf("unexpected value -want/+got:\n\t- %#v\n\t+ %#v", want, got) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/builtin_test.go: -------------------------------------------------------------------------------- 1 | package influxdb_test 2 | 3 | import ( 4 | // We need to init flux for the tests to work. 5 | _ "github.com/InfluxCommunity/flux/fluxinit/static" 6 | ) 7 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/consts.go: -------------------------------------------------------------------------------- 1 | package influxdb 2 | 3 | const ( 4 | DefaultMeasurementColLabel = "_measurement" 5 | DefaultFieldColLabel = "_field" 6 | ) 7 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/monitor/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package monitor 6 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/provider.go: -------------------------------------------------------------------------------- 1 | package influxdb 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/dependencies/influxdb" 7 | ) 8 | 9 | type ( 10 | Dependency = influxdb.Dependency 11 | Provider = influxdb.Provider 12 | UnimplementedProvider = influxdb.UnimplementedProvider 13 | ) 14 | 15 | func GetProvider(ctx context.Context) Provider { 16 | return influxdb.GetProvider(ctx) 17 | } 18 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/rowmetric.go: -------------------------------------------------------------------------------- 1 | package influxdb 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/InfluxCommunity/flux/dependencies/influxdb" 7 | ) 8 | 9 | // RowMetric is a Metric 10 | type RowMetric struct { 11 | NameStr string 12 | Tags []*influxdb.Tag 13 | Fields []*influxdb.Field 14 | TS time.Time 15 | } 16 | 17 | func (r RowMetric) Time() time.Time { 18 | return r.TS 19 | } 20 | 21 | func (r RowMetric) Name() string { 22 | return r.NameStr 23 | } 24 | 25 | func (r RowMetric) TagList() []*influxdb.Tag { 26 | return r.Tags 27 | } 28 | 29 | func (r RowMetric) FieldList() []*influxdb.Field { 30 | return r.Fields 31 | } 32 | 33 | var _ influxdb.Metric = &RowMetric{} 34 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/sample/list_test.flux: -------------------------------------------------------------------------------- 1 | package sample_test 2 | 3 | 4 | import "influxdata/influxdb/sample" 5 | import "csv" 6 | import "testing" 7 | 8 | expected = 9 | " 10 | #group,false,false,false 11 | #datatype,string,long,boolean 12 | #default,_result,, 13 | ,result,table,_value 14 | ,,0,true 15 | " 16 | 17 | testcase sample_list { 18 | got = 19 | sample.list() 20 | |> count(column: "name") 21 | |> map(fn: (r) => ({_value: r.name > 0})) 22 | want = csv.from(csv: expected) 23 | 24 | testing.diff(got: got, want: want) 25 | } 26 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/sample/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package sample 6 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/schema/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package schema 6 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/secrets/secrets.flux: -------------------------------------------------------------------------------- 1 | // Package secrets functions for working with sensitive secrets managed by InfluxDB. 2 | // 3 | // ## Metadata 4 | // introduced: 0.41.0 5 | // tags: secrets,security 6 | // 7 | package secrets 8 | 9 | 10 | // get retrieves a secret from the InfluxDB secret store. 11 | // 12 | // ## Parameters 13 | // - key: Secret key to retrieve. 14 | // 15 | // ## Examples 16 | // 17 | // ### Retrive a key from the InfluxDB secret store 18 | // ```no_run 19 | // import "influxdata/influxdb/secrets" 20 | // 21 | // secrets.get(key: "KEY_NAME") 22 | // ``` 23 | // 24 | // ### Populate sensitive credentials with secrets// 25 | // ```no_run 26 | // import "sql" 27 | // import "influxdata/influxdb/secrets" 28 | // 29 | // username = secrets.get(key: "POSTGRES_USERNAME") 30 | // password = secrets.get(key: "POSTGRES_PASSWORD") 31 | // 32 | // sql.from( 33 | // driverName: "postgres", 34 | // dataSourceName: "postgresql://${username}:${password}@localhost", 35 | // query: "SELECT * FROM example-table", 36 | // ) 37 | // ``` 38 | // 39 | builtin get : (key: string) => string 40 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/secrets/secrets_test.flux: -------------------------------------------------------------------------------- 1 | package secrets_test 2 | 3 | 4 | import "testing" 5 | import "influxdata/influxdb/secrets" 6 | import "csv" 7 | 8 | option now = () => 2030-01-01T00:00:00Z 9 | 10 | inData = 11 | " 12 | #datatype,string,long,dateTime:RFC3339,double,string,string 13 | #group,false,false,false,false,true,true 14 | #default,_result,,,,, 15 | ,result,table,_time,_value,_field,_measurement 16 | ,,0,2018-05-22T19:53:26Z,1.83,load1,system 17 | " 18 | outData = 19 | " 20 | #datatype,string,long,dateTime:RFC3339,double,string,string,string 21 | #group,false,false,false,false,true,true,false 22 | #default,_result,,,,,, 23 | ,result,table,_time,_value,_field,_measurement,token 24 | ,,0,2018-05-22T19:53:26Z,1.83,load1,system,mysecrettoken 25 | " 26 | token = secrets.get(key: "token") 27 | 28 | // Passes in flux, fails in C2 and OSS 29 | testcase secrets { 30 | got = 31 | csv.from(csv: inData) 32 | |> testing.load() 33 | |> set(key: "token", value: token) 34 | |> drop(columns: ["_start", "_stop"]) 35 | want = csv.from(csv: outData) 36 | 37 | testing.diff(got, want) 38 | } 39 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/tasks/last_success_duration_no_option_test.flux: -------------------------------------------------------------------------------- 1 | package tasks_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | import "influxdata/influxdb/tasks" 7 | import "csv" 8 | 9 | option now = () => 2020-09-08T09:00:00Z 10 | 11 | outData = 12 | " 13 | #datatype,string,long,dateTime:RFC3339 14 | #group,false,false,false 15 | #default,_result,, 16 | ,result,table,_time 17 | ,,0,2020-09-07T09:00:00Z 18 | " 19 | t_last_success = () => array.from(rows: [{_time: tasks.lastSuccess(orTime: -1d)}]) 20 | 21 | testcase last_success_duration_no_option { 22 | tables = t_last_success() 23 | got = tables 24 | want = csv.from(csv: outData) 25 | 26 | testing.diff(got, want) 27 | } 28 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/tasks/last_success_duration_option_test.flux: -------------------------------------------------------------------------------- 1 | package tasks_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | import "influxdata/influxdb/tasks" 7 | import "csv" 8 | 9 | option now = () => 2020-09-08T09:00:00Z 10 | option tasks.lastSuccessTime = 2020-09-08T08:00:00Z 11 | 12 | outData = 13 | " 14 | #datatype,string,long,dateTime:RFC3339 15 | #group,false,false,false 16 | #default,_result,, 17 | ,result,table,_time 18 | ,,0,2020-09-08T08:00:00Z 19 | " 20 | t_last_success = () => array.from(rows: [{_time: tasks.lastSuccess(orTime: -1d)}]) 21 | 22 | testcase last_success_duration_option { 23 | tables = t_last_success() 24 | got = tables 25 | want = csv.from(csv: outData) 26 | 27 | testing.diff(got, want) 28 | } 29 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/tasks/last_success_with_option_test.flux: -------------------------------------------------------------------------------- 1 | package tasks_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | import "influxdata/influxdb/tasks" 7 | import "csv" 8 | 9 | option now = () => 2020-09-08T09:00:00Z 10 | option tasks.lastSuccessTime = 2020-09-08T08:00:00Z 11 | 12 | outData = 13 | " 14 | #datatype,string,long,dateTime:RFC3339 15 | #group,false,false,false 16 | #default,_result,, 17 | ,result,table,_time 18 | ,,0,2020-09-08T08:00:00Z 19 | " 20 | t_last_success = () => array.from(rows: [{_time: tasks.lastSuccess(orTime: now())}]) 21 | 22 | testcase last_success_with_option { 23 | tables = t_last_success() 24 | got = tables 25 | want = csv.from(csv: outData) 26 | 27 | testing.diff(got, want) 28 | } 29 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/tasks/last_success_without_option_test.flux: -------------------------------------------------------------------------------- 1 | package tasks_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | import "influxdata/influxdb/tasks" 7 | import "csv" 8 | 9 | option now = () => 2020-09-08T09:00:00Z 10 | 11 | outData = 12 | " 13 | #datatype,string,long,dateTime:RFC3339 14 | #group,false,false,false 15 | #default,_result,, 16 | ,result,table,_time 17 | ,,0,2020-09-08T09:00:00Z 18 | " 19 | t_last_success = () => array.from(rows: [{_time: tasks.lastSuccess(orTime: now())}]) 20 | 21 | testcase last_success_without_option { 22 | tables = t_last_success() 23 | got = tables 24 | want = csv.from(csv: outData) 25 | 26 | testing.diff(got, want) 27 | } 28 | -------------------------------------------------------------------------------- /stdlib/influxdata/influxdb/v1/rules.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/plan" 7 | ) 8 | 9 | type DatabasesRemoteRule struct{} 10 | 11 | func (p DatabasesRemoteRule) Name() string { 12 | return "influxdata/influxdb.DatabasesRemoteRule" 13 | } 14 | 15 | func (p DatabasesRemoteRule) Pattern() plan.Pattern { 16 | return plan.MultiSuccessor(DatabasesKind) 17 | } 18 | 19 | func (p DatabasesRemoteRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, bool, error) { 20 | spec := node.ProcedureSpec().(*DatabasesProcedureSpec) 21 | if spec.Host == nil { 22 | return node, false, nil 23 | } 24 | 25 | return plan.CreateUniquePhysicalNode(ctx, "databasesRemote", &DatabasesRemoteProcedureSpec{ 26 | DatabasesProcedureSpec: spec, 27 | }), true, nil 28 | } 29 | -------------------------------------------------------------------------------- /stdlib/internal/boolean/boolean.flux: -------------------------------------------------------------------------------- 1 | // Package boolean provides constants for true and false values. 2 | // 3 | // ## Metadata 4 | // introduced: 0.129.0 5 | package boolean 6 | 7 | 8 | // true is a constant that is the truth value. 9 | builtin true : bool 10 | 11 | // false is a constant that is the false value. 12 | builtin false : bool 13 | -------------------------------------------------------------------------------- /stdlib/internal/boolean/boolean.go: -------------------------------------------------------------------------------- 1 | package boolean 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/runtime" 5 | "github.com/InfluxCommunity/flux/values" 6 | ) 7 | 8 | func init() { 9 | runtime.RegisterPackageValue("internal/boolean", "true", values.NewBool(true)) 10 | runtime.RegisterPackageValue("internal/boolean", "false", values.NewBool(false)) 11 | } 12 | -------------------------------------------------------------------------------- /stdlib/internal/debug/feature.go: -------------------------------------------------------------------------------- 1 | package debug 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/internal/feature" 7 | featurepkg "github.com/InfluxCommunity/flux/internal/pkg/feature" 8 | "github.com/InfluxCommunity/flux/interpreter" 9 | "github.com/InfluxCommunity/flux/runtime" 10 | "github.com/InfluxCommunity/flux/values" 11 | ) 12 | 13 | func init() { 14 | mt := runtime.MustLookupBuiltinType("internal/debug", "feature") 15 | runtime.RegisterPackageValue("internal/debug", "feature", 16 | values.NewFunction("feature", mt, func(ctx context.Context, args values.Object) (values.Value, error) { 17 | return interpreter.DoFunctionCallContext(Feature, ctx, args) 18 | }, false), 19 | ) 20 | } 21 | 22 | func Feature(ctx context.Context, args interpreter.Arguments) (values.Value, error) { 23 | key, err := args.GetRequiredString("key") 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | flag, ok := feature.ByKey(key) 29 | if !ok { 30 | return values.Null, nil 31 | } 32 | 33 | flagger := featurepkg.GetFlagger(ctx) 34 | v := flagger.FlagValue(ctx, flag) 35 | if iv, ok := v.(int); ok { 36 | v = int64(iv) 37 | } 38 | return values.New(v), nil 39 | } 40 | -------------------------------------------------------------------------------- /stdlib/internal/debug/opaque.go: -------------------------------------------------------------------------------- 1 | package debug 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux" 5 | "github.com/InfluxCommunity/flux/runtime" 6 | ) 7 | 8 | const OpaqueKind = "internal/debug.opaque" 9 | 10 | type OpaqueOpSpec struct{} 11 | 12 | func init() { 13 | opaqueSig := runtime.MustLookupBuiltinType("internal/debug", "opaque") 14 | 15 | runtime.RegisterPackageValue("internal/debug", "opaque", flux.MustValue(flux.FunctionValue(OpaqueKind, createOpaqueOpSpec, opaqueSig))) 16 | // opaque uses the same procedure spec and transformation as pass, so we only need to 17 | // create and register the op spec here. 18 | } 19 | 20 | func createOpaqueOpSpec(args flux.Arguments, a *flux.Administration) (flux.OperationSpec, error) { 21 | if err := a.AddParentFromArgs(args); err != nil { 22 | return nil, err 23 | } 24 | 25 | return new(OpaqueOpSpec), nil 26 | } 27 | 28 | func (s *OpaqueOpSpec) Kind() flux.OperationKind { 29 | return OpaqueKind 30 | } 31 | -------------------------------------------------------------------------------- /stdlib/internal/gen/gen.flux: -------------------------------------------------------------------------------- 1 | // Package gen provides methods for generating data. 2 | // 3 | // ## Metadata 4 | // introduced: 0.50.0 5 | package gen 6 | 7 | 8 | // tables generates a stream of table data. 9 | // 10 | // ## Parameters 11 | // - n: Number of rows to generate. 12 | // - nulls: Percentage chance that a null value will be used in the input. Valid value range is `[0.0 - 1.0]`. 13 | // - tags: Set of tags with their cardinality to generate. 14 | // - seed: Pass seed to tables generator to get the very same sequence each time. 15 | builtin tables : ( 16 | n: int, 17 | ?nulls: float, 18 | ?tags: [{name: string, cardinality: int}], 19 | ?seed: int, 20 | ) => stream[{A with _time: time, _value: float}] 21 | -------------------------------------------------------------------------------- /stdlib/internal/gen/tables_test.flux: -------------------------------------------------------------------------------- 1 | package gen 2 | 3 | 4 | import "array" 5 | import "testing" 6 | import "internal/gen" 7 | import "internal/debug" 8 | 9 | option now = () => 2030-01-01T00:00:00Z 10 | 11 | testcase gen_tables_seed { 12 | got = 13 | gen.tables(n: 5, seed: 123) 14 | |> drop(columns: ["_time"]) 15 | 16 | want = 17 | array.from( 18 | rows: [ 19 | {_value: -39.7289264835779}, 20 | {_value: 3.561659508431711}, 21 | {_value: 34.956531511845476}, 22 | {_value: -53.72013420347799}, 23 | {_value: 49.20701082669753}, 24 | ], 25 | ) 26 | 27 | testing.diff(got: got, want: want) 28 | } 29 | -------------------------------------------------------------------------------- /stdlib/internal/influxql/influxql.flux: -------------------------------------------------------------------------------- 1 | // Package influxql provides constants for working with InfluxQL. 2 | // 3 | // ## Metadata 4 | // introduced: 0.60.0 5 | package influxql 6 | 7 | 8 | // epoch is the absolute time that all InfluxQL time and duration values use as a zero reference. 9 | epoch = 1970-01-01T00:00:00Z 10 | 11 | // minTime is the earliest time InfluxQL can represent. 12 | minTime = 1677-09-21T00:12:43.145224194Z 13 | 14 | // maxTime is the latest time InfluxQL can represent. 15 | maxTime = 2262-04-11T23:47:16.854775806Z 16 | -------------------------------------------------------------------------------- /stdlib/internal/influxql/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package influxql 6 | -------------------------------------------------------------------------------- /stdlib/internal/location/location.flux: -------------------------------------------------------------------------------- 1 | // Package location loads a timezone based on a location name. 2 | // 3 | // ## Metadata 4 | // introduced: 0.149.0 5 | package location 6 | 7 | 8 | // location loads a timezone based on a location name. 9 | option location = {zone: "UTC", offset: 0h} 10 | -------------------------------------------------------------------------------- /stdlib/internal/location/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package location 6 | -------------------------------------------------------------------------------- /stdlib/internal/testing/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package testing 6 | -------------------------------------------------------------------------------- /stdlib/internal/testing/testing_test.flux: -------------------------------------------------------------------------------- 1 | package testing 2 | 3 | 4 | import "array" 5 | import "experimental" 6 | import "regexp" 7 | import "testing" 8 | import internalTesting "internal/testing" 9 | 10 | testcase test_assert_matches { 11 | internalTesting.assertMatches(got: "44444", want: /4+/) 12 | } 13 | 14 | testcase test_assert_matches_should_error { 15 | testing.shouldError( 16 | fn: () => internalTesting.assertMatches(got: "", want: /4+/), 17 | want: /Regex `4\+` does not match ``/, 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /stdlib/internal/testutil/testutil.flux: -------------------------------------------------------------------------------- 1 | // Package testutil provides helper function for writing test cases. 2 | // 3 | // ## Metadata 4 | // introduced: 0.68.0 5 | package testutil 6 | 7 | 8 | // fail causes the current script to fail. 9 | builtin fail : () => bool 10 | 11 | // yield is the identity function. 12 | // 13 | // ## Parameters 14 | // - v: Any value. 15 | builtin yield : (<-v: A) => A 16 | 17 | // makeRecord is the identity function, but breaks the type connection from input to output. 18 | // 19 | // ## Parameters 20 | // - o: Record value. 21 | builtin makeRecord : (o: A) => B where A: Record, B: Record 22 | 23 | // makeAny constructs any value based on a type description as a string. 24 | // 25 | // ## Parameters 26 | // - typ: Description of the type to create. 27 | builtin makeAny : (typ: string) => A 28 | -------------------------------------------------------------------------------- /stdlib/json/json.flux: -------------------------------------------------------------------------------- 1 | // Package json provides tools for working with JSON. 2 | // 3 | // ## Metadata 4 | // introduced: 0.40.0 5 | // 6 | package json 7 | 8 | 9 | // encode converts a value into JSON bytes. 10 | // 11 | // This function encodes Flux types as follows: 12 | // 13 | // - **time** values in [RFC3339](https://docs.influxdata.com/influxdb/cloud/reference/glossary/#rfc3339-timestamp) format 14 | // - **duration** values in number of milliseconds since the Unix epoch 15 | // - **regexp** values as their string representation 16 | // - **bytes** values as base64-encoded strings 17 | // - **function** values are not encoded and produce an error 18 | // 19 | // ## Parameters 20 | // - v: Value to convert. 21 | // 22 | // ## Examples 23 | // 24 | // ### Encode a value as JSON bytes 25 | // ```no_run 26 | // import "json" 27 | // 28 | // jsonData = {foo: "bar", baz: 123, quz: [4, 5, 6]} 29 | // 30 | // json.encode(v: jsonData) 31 | // 32 | // // Returns [123 34 98 97 122 34 58 49 50 51 44 34 102 111 111 34 58 34 98 97 114 34 44 34 113 117 122 34 58 91 52 44 53 44 54 93 125] 33 | // ``` 34 | // 35 | // ## Metadata 36 | // tags: type-conversions 37 | // 38 | builtin encode : (v: A) => bytes 39 | -------------------------------------------------------------------------------- /stdlib/math/math_test.flux: -------------------------------------------------------------------------------- 1 | package math_test 2 | 3 | 4 | import "array" 5 | import "math" 6 | import "testing" 7 | 8 | xytest = (rows, fn, epsilon=0.000000001, nansEqual=true) => { 9 | data = array.from(rows: rows) 10 | got = 11 | data 12 | |> map(fn: (r) => ({_value: fn(x: r.x, y: r.y)})) 13 | want = 14 | data 15 | |> map(fn: (r) => ({_value: r._value})) 16 | 17 | return testing.diff(got: got, want: want, epsilon: epsilon, nansEqual: nansEqual) 18 | } 19 | 20 | testcase atan2 { 21 | xytest( 22 | fn: math.atan2, 23 | rows: [ 24 | // 3 4 5 triangle, 51.13 deg 25 | {y: 4.0, x: 3.0, _value: 0.9272952180016122}, 26 | // 30 60 90 triangle, 60 deg 27 | {y: math.sqrt(x: 3.0), x: 1.0, _value: math.pi / 3.0}, 28 | // 30 60 90 triangle, 30 deg 29 | {y: 1.0, x: math.sqrt(x: 3.0), _value: math.pi / 6.0}, 30 | ], 31 | ) 32 | } 33 | testcase dim { 34 | xytest(fn: math.dim, rows: [{x: 10.0, y: 5.0, _value: 5.0}, {x: 10.0, y: 15.0, _value: 0.0}]) 35 | } 36 | -------------------------------------------------------------------------------- /stdlib/planner/bare_last_test.flux: -------------------------------------------------------------------------------- 1 | package planner_test 2 | 3 | 4 | import "testing" 5 | import "planner" 6 | import "csv" 7 | 8 | input = 9 | " 10 | #datatype,string,long,dateTime:RFC3339,string,string,long 11 | #group,false,false,false,true,true,false 12 | #default,_result,,,,, 13 | ,result,table,_time,_measurement,_field,_value 14 | ,,0,2020-10-30T00:00:01Z,m,f,1 15 | ,,0,2020-10-30T00:00:09Z,m,f,9 16 | " 17 | output = 18 | " 19 | #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,string,string 20 | #group,false,false,true,true,false,false,true,true 21 | #default,_result,,,,,,, 22 | ,result,table,_start,_stop,_time,_value,_field,_measurement 23 | ,,0,2020-10-30T00:00:01Z,2020-10-30T00:00:09Z,2020-10-30T00:00:01Z,1,f,m 24 | " 25 | 26 | testcase bare_last { 27 | got = 28 | csv.from(csv: input) 29 | |> testing.load() 30 | |> range(start: 2020-10-30T00:00:01Z, stop: 2020-10-30T00:00:09Z) 31 | |> last() 32 | want = csv.from(csv: output) 33 | 34 | testing.diff(got, want) 35 | } 36 | -------------------------------------------------------------------------------- /stdlib/planner/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package planner 6 | -------------------------------------------------------------------------------- /stdlib/planner/planner.flux: -------------------------------------------------------------------------------- 1 | // Package planner provides an API for interacting with the Flux engine planner. 2 | package planner 3 | 4 | 5 | // disableLogicalRules is a set of logical planner rules that should NOT be applied. 6 | option disableLogicalRules = [""] 7 | 8 | // disablePhysicalRules is a set of physical planner rules that should NOT be applied. 9 | option disablePhysicalRules = [""] 10 | -------------------------------------------------------------------------------- /stdlib/profiler/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package profiler 6 | -------------------------------------------------------------------------------- /stdlib/pushbullet/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package pushbullet 6 | -------------------------------------------------------------------------------- /stdlib/runtime/compat_go1.11.go: -------------------------------------------------------------------------------- 1 | //go:build !go1.12 2 | // +build !go1.12 3 | 4 | package runtime 5 | 6 | import ( 7 | "github.com/InfluxCommunity/flux/values" 8 | ) 9 | 10 | func Version() (values.Value, error) { 11 | return nil, errBuildInfoNotPresent 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/runtime/runtime.flux: -------------------------------------------------------------------------------- 1 | // Package runtime provides information about the current Flux runtime. 2 | // 3 | // introduce: 0.38.0 4 | // 5 | package runtime 6 | 7 | 8 | // version returns the current Flux version. 9 | // 10 | // ## Examples 11 | // ### Return the Flux version in a stream of tables 12 | // ``` 13 | // import "array" 14 | // import "runtime" 15 | // 16 | // > array.from(rows: [{version: runtime.version()}]) 17 | // ``` 18 | // 19 | builtin version : () => string 20 | -------------------------------------------------------------------------------- /stdlib/runtime/runtime.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/codes" 5 | "github.com/InfluxCommunity/flux/internal/errors" 6 | "github.com/InfluxCommunity/flux/runtime" 7 | "github.com/InfluxCommunity/flux/values" 8 | ) 9 | 10 | const versionFuncName = "version" 11 | 12 | var errBuildInfoNotPresent = errors.New(codes.NotFound, "build info is not present") 13 | 14 | func init() { 15 | runtime.RegisterPackageValue("runtime", versionFuncName, values.NewFunction( 16 | versionFuncName, 17 | runtime.MustLookupBuiltinType("runtime", versionFuncName), 18 | Version, 19 | false, 20 | )) 21 | } 22 | -------------------------------------------------------------------------------- /stdlib/runtime/version.go: -------------------------------------------------------------------------------- 1 | //go:build go1.12 2 | // +build go1.12 3 | 4 | package runtime 5 | 6 | import ( 7 | "context" 8 | "runtime/debug" 9 | 10 | "github.com/InfluxCommunity/flux/values" 11 | ) 12 | 13 | const modulePath = "github.com/InfluxCommunity/flux" 14 | 15 | // readBuildInfo is used for reading the build information 16 | // from the binary. This exists to overwrite the value for unit 17 | // tests. 18 | var readBuildInfo = debug.ReadBuildInfo 19 | 20 | // Version returns the flux runtime version as a string. 21 | func Version(ctx context.Context, args values.Object) (values.Value, error) { 22 | bi, ok := readBuildInfo() 23 | if !ok { 24 | return nil, errBuildInfoNotPresent 25 | } 26 | 27 | // Find the module in the build info. 28 | var m debug.Module 29 | if bi.Main.Path == modulePath { 30 | m = bi.Main 31 | } else { 32 | for _, dep := range bi.Deps { 33 | if dep.Path == modulePath { 34 | m = *dep 35 | break 36 | } 37 | } 38 | } 39 | 40 | // Retrieve the version from the module. 41 | v := m.Version 42 | if m.Replace != nil { 43 | // If the module has been replaced, take the version from it. 44 | v = m.Replace.Version 45 | } 46 | return values.NewString(v), nil 47 | } 48 | -------------------------------------------------------------------------------- /stdlib/runtime/version_internal_test.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | import "runtime/debug" 4 | 5 | var buildInfo *debug.BuildInfo 6 | 7 | func SetBuildInfo(bi *debug.BuildInfo) { 8 | buildInfo = bi 9 | } 10 | 11 | func init() { 12 | readBuildInfo = func() (*debug.BuildInfo, bool) { 13 | ok := buildInfo != nil 14 | return buildInfo, ok 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /stdlib/sampledata/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package sampledata 6 | -------------------------------------------------------------------------------- /stdlib/sql/enabled.go: -------------------------------------------------------------------------------- 1 | //go:build !fipsonly 2 | 3 | package sql 4 | 5 | // isDriverEnabled indicates if a given database driver is enabled. 6 | // It is only intended to be used in test suites. 7 | // 8 | // This is a stopgap until all data base drivers can be supported 9 | // in a FIPS compliant manner. Once that happens, it can be removed 10 | // if desired. 11 | func isDriverEnabled(driver string) bool { 12 | // All drivers are enabled in non-FIPS builds. 13 | return true 14 | } 15 | 16 | // disabledDriverError returns the error a driver gives when it is disabled. 17 | func disabledDriverError(driver string) error { 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /stdlib/sql/enabled_fipsonly.go: -------------------------------------------------------------------------------- 1 | //go:build fipsonly 2 | 3 | package sql 4 | 5 | // isDriverEnabled indicates if a given database driver is enabled. 6 | // It is only intended to be used in test suites. 7 | // 8 | // This is a stopgap until all data base drivers can be supported 9 | // in a FIPS compliant manner. Once that happens, it can be removed 10 | // if desired. 11 | func isDriverEnabled(driver string) bool { 12 | switch driver { 13 | case "mssql", "sqlserver", "snowflake": 14 | return false 15 | default: 16 | return true 17 | } 18 | } 19 | 20 | // disabledDriverError returns the error a driver gives when it is disabled. 21 | func disabledDriverError(driver string) error { 22 | switch driver { 23 | case "mssql", "sqlserver": 24 | return errMssqlDisabled 25 | case "snowflake": 26 | return errSnowflakeDisabled 27 | default: 28 | return nil 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /stdlib/sql/errors.go: -------------------------------------------------------------------------------- 1 | package sql 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/codes" 5 | "github.com/InfluxCommunity/flux/internal/errors" 6 | ) 7 | 8 | // ErrorDriverDisabled indicates a given database driver is disabled. 9 | var ErrorDriverDisabled = errors.New(codes.Unimplemented, "database driver disabled") 10 | -------------------------------------------------------------------------------- /stdlib/sql/hdb_test.go: -------------------------------------------------------------------------------- 1 | package sql 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | func TestHdb_IfNoExist(t *testing.T) { 9 | // test table with fqn 10 | q := hdbAddIfNotExist("stores.orders_copy", "CREATE TABLE stores.orders_copy (ORDER_ID BIGINT)") 11 | if !strings.HasPrefix(q, "DO") || !strings.Contains(q, "(:SCHEMA_NAME)") || !strings.Contains(q, "(:TABLE_NAME)") { 12 | t.Fail() 13 | } 14 | // test table in default schema 15 | q = hdbAddIfNotExist("orders_copy", "CREATE TABLE orders_copy (ORDER_ID BIGINT)") 16 | if !strings.HasPrefix(q, "DO") || strings.Contains(q, "(:SCHEMA_NAME)") || !strings.Contains(q, "(:TABLE_NAME)") { 17 | t.Fail() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /stdlib/sql/mssql_azure_fipsonly.go: -------------------------------------------------------------------------------- 1 | //go:build fipsonly 2 | 3 | package sql 4 | 5 | import "database/sql" 6 | 7 | func mssqlOpenFunction(driverName, dataSourceName string) openFunc { 8 | return func() (*sql.DB, error) { return nil, errMssqlDisabled } 9 | } 10 | -------------------------------------------------------------------------------- /stdlib/sql/source_validator_private_test.go: -------------------------------------------------------------------------------- 1 | package sql 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/InfluxCommunity/flux/dependencies/url" 7 | ) 8 | 9 | func TestLocalhostIsInvalid(t *testing.T) { 10 | validator := url.PrivateIPValidator{} 11 | if validateDataSource(validator, "mock", "postgres://localhost/database") == nil { 12 | t.Error("localhost is a private ip; expected validator to fail") 13 | } 14 | } 15 | 16 | func TestLocalhostIsValidForBigQuery(t *testing.T) { 17 | validator := url.PrivateIPValidator{} 18 | if validateDataSource(validator, "bigquery", "bigquery://localhost/") != nil { 19 | t.Error("bigquery DSNs contain no host info; expected validator to pass") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /stdlib/strings/compat.go: -------------------------------------------------------------------------------- 1 | package strings 2 | 3 | import "strings" 4 | 5 | // replaceAll implements strings.ReplaceAll for go 1.11 and 6 | // earlier. The function was added in go 1.12 and it is an 7 | // alias to calling strings.Replace with an argument of -1. 8 | // 9 | // This function may be removed when InfluxDB 1.x no longer 10 | // uses go 1.11 for its builds. 11 | func replaceAll(s string, old string, new string) string { 12 | return strings.Replace(s, old, new, -1) 13 | } 14 | -------------------------------------------------------------------------------- /stdlib/system/system.flux: -------------------------------------------------------------------------------- 1 | // Package system provides functions for reading values from the system. 2 | // 3 | // ## Metadata 4 | // introduced: 0.18.0 5 | // 6 | package system 7 | 8 | 9 | // time returns the current system time. 10 | // 11 | // ## Examples 12 | // 13 | // ### Return a stream of tables with the current system time 14 | // ``` 15 | // import "array" 16 | // import "system" 17 | // 18 | // array.from(rows:[{time: system.time()}]) 19 | // ``` 20 | // 21 | // ## Metadata 22 | // tags: date/time 23 | // 24 | builtin time : () => time 25 | -------------------------------------------------------------------------------- /stdlib/system/time.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "github.com/InfluxCommunity/flux/runtime" 8 | "github.com/InfluxCommunity/flux/semantic" 9 | "github.com/InfluxCommunity/flux/values" 10 | ) 11 | 12 | var systemTimeFuncName = "time" 13 | 14 | func init() { 15 | runtime.RegisterPackageValue("system", systemTimeFuncName, values.NewFunction( 16 | systemTimeFuncName, 17 | semantic.NewFunctionType(semantic.BasicTime, nil), 18 | func(ctx context.Context, args values.Object) (values.Value, error) { 19 | return values.NewTime(values.ConvertTime(time.Now().UTC())), nil 20 | }, 21 | false, 22 | )) 23 | } 24 | -------------------------------------------------------------------------------- /stdlib/testing/basics/basics_test.flux: -------------------------------------------------------------------------------- 1 | package basics 2 | 3 | 4 | import "testing" 5 | 6 | testcase addition { 7 | got = 1 + 1 8 | want = 2 9 | 10 | testing.assertEqualValues(got, want) 11 | } 12 | -------------------------------------------------------------------------------- /stdlib/testing/basics/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package basics 6 | -------------------------------------------------------------------------------- /stdlib/testing/chronograf/buckets_test.flux: -------------------------------------------------------------------------------- 1 | package chronograf_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | inData = 8 | " 9 | #datatype,string,long,string,string,string,string,long,dateTime:RFC3339,string,string 10 | #group,false,false,true,false,false,false,false,false,true,true 11 | #default,_result,,0389eade5af4b000,,,,,,, 12 | ,result,table,organizationID,name,id,retentionPolicy,retentionPeriod,_time,_field,_measurement 13 | ,,0,,A,0389eade5b34b000,,0,1970-01-01T00:00:00Z,a,aa 14 | ,,0,,B,042ed3f42d42e000,,0,1970-01-01T00:00:00Z,b,bb 15 | " 16 | outData = 17 | " 18 | #datatype,string,long,string 19 | #group,false,false,false 20 | #default,_result,, 21 | ,result,table,_value 22 | ,,0,A 23 | ,,0,B 24 | " 25 | 26 | testcase buckets { 27 | got = 28 | csv.from(csv: inData) 29 | |> rename(columns: {name: "_value"}) 30 | |> keep(columns: ["_value"]) 31 | want = csv.from(csv: outData) 32 | 33 | testing.diff(got, want) 34 | } 35 | -------------------------------------------------------------------------------- /stdlib/testing/chronograf/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package chronograf 6 | -------------------------------------------------------------------------------- /stdlib/testing/expect/expect.flux: -------------------------------------------------------------------------------- 1 | // Package expect includes functions to mark 2 | // any expectations for a testcase to be satisfied 3 | // before the testcase finishes running. 4 | // 5 | // These functions are intended to be called at the 6 | // beginning of a testcase, but it doesn't really 7 | // matter when they get invoked within the testcase. 8 | package expect 9 | 10 | 11 | // planner will cause the present testcase to 12 | // expect the given planner rules will be invoked 13 | // exactly as many times as the number given. 14 | // 15 | // The key is the name of the planner rule. 16 | // 17 | // ## Parameters 18 | // - rules: Mapping of rules names to expected counts. 19 | builtin planner : (rules: [string:int]) => {} 20 | -------------------------------------------------------------------------------- /stdlib/testing/extend_test.flux: -------------------------------------------------------------------------------- 1 | package testing_test 2 | 3 | 4 | import "testing" 5 | import "array" 6 | 7 | testcase test_option_extension extends "flux/testing/testing_test.test_option" { 8 | // Set irrelevant option before the test 9 | // to ensure we can without causing an error 10 | option before = 1 11 | 12 | super() 13 | 14 | // Set irrelevant option after the test 15 | // to ensure we can without causing an error 16 | option after = 1 17 | } 18 | -------------------------------------------------------------------------------- /stdlib/testing/influxql/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package influxql 6 | -------------------------------------------------------------------------------- /stdlib/testing/kapacitor/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package kapacitor 6 | -------------------------------------------------------------------------------- /stdlib/testing/pandas/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package pandas 6 | -------------------------------------------------------------------------------- /stdlib/testing/prometheus/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package prometheus 6 | -------------------------------------------------------------------------------- /stdlib/testing/promql/emptyTable_test.flux: -------------------------------------------------------------------------------- 1 | package promql_test 2 | 3 | 4 | import "testing" 5 | import "internal/promql" 6 | import "csv" 7 | 8 | option now = () => 2030-01-01T00:00:00Z 9 | 10 | outData = 11 | " 12 | #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double 13 | #group,false,true,true,true,false,false 14 | #default,_result,0,1970-01-01T00:00:00Z,1970-01-01T00:00:00Z,, 15 | ,result,table,_start,_stop,_time,_value 16 | " 17 | 18 | testcase emptyTable { 19 | table = promql.emptyTable() 20 | got = table 21 | want = csv.from(csv: outData) 22 | 23 | testing.diff(got, want) 24 | } 25 | -------------------------------------------------------------------------------- /stdlib/testing/promql/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package promql 6 | -------------------------------------------------------------------------------- /stdlib/testing/testing_test.flux: -------------------------------------------------------------------------------- 1 | package testing_test 2 | 3 | 4 | import internalTesting "internal/testing" 5 | import "testing" 6 | import "experimental" 7 | import "array" 8 | import "csv" 9 | import "json" 10 | 11 | testcase test_option { 12 | // Option value in parent test case 13 | // See extend_test.flux that contains a test case 14 | // that extends this test case 15 | option x = 1 16 | 17 | want = array.from(rows: [{_value: 1}]) 18 | got = array.from(rows: [{_value: x}]) 19 | 20 | testing.diff(want: want, got: got) 21 | } 22 | 23 | testcase succeed_on_non_empty_result { 24 | // Just to make sure we yield something to `error` 25 | testing.assertEqualValues(got: 0, want: 0) 26 | 27 | // non-empty result 28 | array.from(rows: [{}]) 29 | } 30 | 31 | testcase test_should_error { 32 | testing.shouldError(fn: () => die(msg: "error message"), want: /error message$/) 33 | } 34 | 35 | testcase test_should_error_should_error_when_no_error { 36 | got = experimental.catch(fn: () => testing.shouldError(fn: () => "abc", want: /error message$/)) 37 | 38 | internalTesting.assertMatches(got: got.msg, want: /shouldError expected an error/) 39 | } 40 | -------------------------------------------------------------------------------- /stdlib/testing/usage/placeholder.go: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT: This file is autogenerated via the builtin command. 2 | // 3 | // This file ensures that this directory is a Go package 4 | 5 | package usage 6 | -------------------------------------------------------------------------------- /stdlib/timezone/timezone.go: -------------------------------------------------------------------------------- 1 | package timezone 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/codes" 5 | "github.com/InfluxCommunity/flux/internal/errors" 6 | "github.com/InfluxCommunity/flux/internal/function" 7 | "github.com/InfluxCommunity/flux/internal/zoneinfo" 8 | "github.com/InfluxCommunity/flux/values" 9 | ) 10 | 11 | const pkgpath = "timezone" 12 | 13 | func Location(args *function.Arguments) (values.Value, error) { 14 | name, err := args.GetRequiredString("name") 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | if _, err := zoneinfo.LoadLocation(name); err != nil { 20 | return nil, errors.Wrap(err, codes.Invalid) 21 | } 22 | return values.BuildObjectWithSize(2, func(set values.ObjectSetter) error { 23 | set("zone", values.NewString(name)) 24 | set("offset", values.NewDuration(values.Duration{})) 25 | return nil 26 | }) 27 | } 28 | 29 | func init() { 30 | b := function.ForPackage(pkgpath) 31 | b.Register("location", Location) 32 | } 33 | -------------------------------------------------------------------------------- /stdlib/universe/covariance_missing_column_1_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | inData = 8 | " 9 | #datatype,string,long,dateTime:RFC3339,double,string 10 | #group,false,false,false,false,true 11 | #default,_result,,,, 12 | ,result,table,_time,x,_measurement 13 | ,,0,2018-05-22T19:53:26Z,0,cpu 14 | ,,0,2018-05-22T19:53:36Z,0,cpu 15 | ,,0,2018-05-22T19:53:46Z,2,cpu 16 | ,,0,2018-05-22T19:53:56Z,7,cpu 17 | " 18 | 19 | testcase covariance_missing_column_1 { 20 | testing.shouldError( 21 | fn: () => 22 | csv.from(csv: inData) 23 | |> covariance(columns: ["x", "r"]) 24 | |> tableFind(fn: (key) => true), 25 | want: /covariance: specified column does not exist in table: r$/, 26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /stdlib/universe/covariance_missing_column_2_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | inData = 8 | " 9 | #datatype,string,long,dateTime:RFC3339,double,string 10 | #group,false,false,false,false,true 11 | #default,_result,,,, 12 | ,result,table,_time,y,_measurement 13 | ,,0,2018-05-22T19:53:26Z,0,cpu 14 | ,,0,2018-05-22T19:53:36Z,0,cpu 15 | ,,0,2018-05-22T19:53:46Z,2,cpu 16 | ,,0,2018-05-22T19:53:56Z,7,cpu 17 | " 18 | 19 | testcase covariance_missing_column_2 { 20 | testing.shouldError( 21 | fn: () => 22 | csv.from(csv: inData) 23 | |> covariance(columns: ["x", "r"]) 24 | |> tableFind(fn: (key) => true), 25 | want: /covariance: specified column does not exist in table: x$/, 26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /stdlib/universe/die.go: -------------------------------------------------------------------------------- 1 | package universe 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux" 7 | "github.com/InfluxCommunity/flux/codes" 8 | "github.com/InfluxCommunity/flux/interpreter" 9 | "github.com/InfluxCommunity/flux/runtime" 10 | "github.com/InfluxCommunity/flux/values" 11 | ) 12 | 13 | const DieKind = "die" 14 | 15 | func init() { 16 | runtime.RegisterPackageValue("universe", DieKind, Die()) 17 | } 18 | 19 | func Die() values.Function { 20 | return values.NewFunction( 21 | DieKind, 22 | runtime.MustLookupBuiltinType("universe", DieKind), 23 | func(ctx context.Context, args values.Object) (values.Value, error) { 24 | return interpreter.DoFunctionCallContext(func(ctx context.Context, args interpreter.Arguments) (values.Value, error) { 25 | msg, err := args.GetRequiredString("msg") 26 | if err != nil { 27 | return nil, err 28 | } else { 29 | return nil, &flux.Error{ 30 | Code: codes.Invalid, 31 | Msg: msg, 32 | } 33 | } 34 | }, ctx, args) 35 | }, false, 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /stdlib/universe/die_test.go: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "github.com/InfluxCommunity/flux" 8 | "github.com/InfluxCommunity/flux/codes" 9 | "github.com/InfluxCommunity/flux/dependencies/dependenciestest" 10 | "github.com/InfluxCommunity/flux/dependency" 11 | "github.com/InfluxCommunity/flux/stdlib/universe" 12 | "github.com/InfluxCommunity/flux/values" 13 | "github.com/google/go-cmp/cmp" 14 | ) 15 | 16 | func TestDie(t *testing.T) { 17 | t.Run("die test", func(t *testing.T) { 18 | dieFn := universe.Die() 19 | 20 | fluxArg := values.NewObjectWithValues(map[string]values.Value{"msg": values.NewString("this is an error message")}) 21 | 22 | ctx, deps := dependency.Inject(context.Background(), dependenciestest.Default()) 23 | defer deps.Finish() 24 | _, got := dieFn.Call(ctx, fluxArg) 25 | 26 | if got == nil { 27 | t.Fatal("this function should produce an error") 28 | } 29 | 30 | want := &flux.Error{ 31 | Code: codes.Invalid, 32 | Msg: "this is an error message", 33 | } 34 | 35 | if !cmp.Equal(want, got) { 36 | t.Fatalf("unexpected result -want/+got\n\n%s\n\n", cmp.Diff(want, got)) 37 | } 38 | }) 39 | } 40 | -------------------------------------------------------------------------------- /stdlib/universe/difference_one_value_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | option now = () => 2030-01-01T00:00:00Z 8 | 9 | inData = 10 | " 11 | #datatype,string,long,dateTime:RFC3339,double,string,string,string,string 12 | #group,false,false,false,false,true,true,true,true 13 | #default,_result,,,,,,, 14 | ,result,table,_time,_value,_field,_measurement,cpu,host 15 | ,,0,2018-05-22T19:53:26Z,1,usage_guest,cpu,cpu-total,host.local 16 | " 17 | outData = 18 | " 19 | #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string 20 | #group,false,false,true,true,false,false,true,true,true,true 21 | #default,_result,0,2018-05-22T19:53:26Z,2030-01-01T00:00:00Z,,,usage_guest,cpu,cpu-total,host.local 22 | ,result,table,_start,_stop,_time,_value,_field,_measurement,cpu,host 23 | " 24 | 25 | testcase difference_one_value { 26 | got = 27 | csv.from(csv: inData) 28 | |> testing.load() 29 | |> range(start: 2018-05-22T19:53:26Z) 30 | |> difference(nonNegative: true) 31 | want = csv.from(csv: outData) 32 | 33 | testing.diff(got, want) 34 | } 35 | -------------------------------------------------------------------------------- /stdlib/universe/display.go: -------------------------------------------------------------------------------- 1 | package universe 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/codes" 7 | "github.com/InfluxCommunity/flux/internal/errors" 8 | "github.com/InfluxCommunity/flux/runtime" 9 | "github.com/InfluxCommunity/flux/values" 10 | ) 11 | 12 | func init() { 13 | runtime.RegisterPackageValue("universe", "display", values.NewFunction( 14 | "display", 15 | runtime.MustLookupBuiltinType("universe", "display"), 16 | func(ctx context.Context, args values.Object) (values.Value, error) { 17 | v, ok := args.Get("v") 18 | if !ok { 19 | return nil, errors.New(codes.Invalid, "missing argument v") 20 | } 21 | return values.NewString(values.DisplayString(v)), nil 22 | }, 23 | false, 24 | )) 25 | } 26 | -------------------------------------------------------------------------------- /stdlib/universe/map_internal_test.go: -------------------------------------------------------------------------------- 1 | package universe 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/execute" 7 | "github.com/apache/arrow/go/v7/arrow/memory" 8 | ) 9 | 10 | func NewMapTransformation(ctx context.Context, id execute.DatasetID, spec *MapProcedureSpec, mem memory.Allocator) (execute.Transformation, execute.Dataset, error) { 11 | return newMapTransformation(ctx, id, spec, mem) 12 | } 13 | -------------------------------------------------------------------------------- /stdlib/universe/pivot_internal_test.go: -------------------------------------------------------------------------------- 1 | package universe 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/InfluxCommunity/flux/execute" 7 | "github.com/InfluxCommunity/flux/memory" 8 | ) 9 | 10 | // TODO(jsternberg): This is exposed so the tests have access 11 | // to the new transformation. This method should not be used 12 | // externally as the new pivot is not meant to be exposed publicly 13 | // at the moment and the name will probably change when it is exposed. 14 | func NewSortedPivotTransformation(ctx context.Context, spec SortedPivotProcedureSpec, id execute.DatasetID, alloc memory.Allocator) (execute.Transformation, execute.Dataset, error) { 15 | return newSortedPivotTransformation(ctx, spec, id, alloc) 16 | } 17 | -------------------------------------------------------------------------------- /stdlib/universe/shift2.go: -------------------------------------------------------------------------------- 1 | package universe 2 | -------------------------------------------------------------------------------- /stdlib/universe/simple_max_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | option now = () => 2030-01-01T00:00:00Z 8 | 9 | inData = 10 | " 11 | #datatype,string,long,dateTime:RFC3339,string,string,double 12 | #group,false,false,false,true,true,false 13 | #default,_result,,,,, 14 | ,result,table,_time,_measurement,_field,_value 15 | ,,0,2018-04-17T00:00:00Z,m1,f1,42 16 | ,,0,2018-04-17T00:00:01Z,m1,f1,43 17 | " 18 | outData = 19 | " 20 | #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,dateTime:RFC3339,double 21 | #group,false,false,true,true,true,true,false,false 22 | #default,_result,,,,,,, 23 | ,result,table,_start,_stop,_measurement,_field,_time,_value 24 | ,,0,2018-04-17T00:00:00Z,2030-01-01T00:00:00Z,m1,f1,2018-04-17T00:00:01Z,43 25 | " 26 | 27 | testcase simple_max { 28 | got = 29 | csv.from(csv: inData) 30 | |> testing.load() 31 | |> range(start: 2018-04-17T00:00:00Z) 32 | |> max(column: "_value") 33 | want = csv.from(csv: outData) 34 | 35 | testing.diff(got, want) 36 | } 37 | -------------------------------------------------------------------------------- /stdlib/universe/string_interp_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "array" 5 | import "testing" 6 | import "csv" 7 | 8 | testcase string_interpolation { 9 | string = "a" 10 | int = 1 11 | float = 0.1 12 | bool = true 13 | duration = 1h 14 | time = 2020-01-01T01:01:01Z 15 | 16 | got = 17 | array.from( 18 | rows: [ 19 | {_value: "string ${string}"}, 20 | {_value: "int ${int}"}, 21 | {_value: "float ${float}"}, 22 | {_value: "bool ${bool}"}, 23 | {_value: "duration ${duration}"}, 24 | {_value: "time ${time}"}, 25 | ], 26 | ) 27 | want = 28 | array.from( 29 | rows: [ 30 | {_value: "string a"}, 31 | {_value: "int 1"}, 32 | {_value: "float 0.1"}, 33 | {_value: "bool true"}, 34 | {_value: "duration 1h"}, 35 | {_value: "time 2020-01-01T01:01:01.000000000Z"}, 36 | ], 37 | ) 38 | 39 | testing.diff(got: got, want: want) 40 | } 41 | -------------------------------------------------------------------------------- /stdlib/universe/string_max_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | inData = 8 | " 9 | #datatype,string,long,dateTime:RFC3339,string,string,string,string,string,string,string 10 | #group,false,false,false,false,true,true,true,true,true,true 11 | #default,_result,,,,,,,,, 12 | ,result,table,_time,_value,_field,_measurement,device,fstype,host,path 13 | ,,0,2018-05-22T19:54:16Z,13F2,used_percent,disk,disk1,apfs,host.local,/ 14 | ,,0,2018-05-22T19:53:56Z,2COTDe,used_percent,disk,disk1,apfs,host.local,/ 15 | ,,0,2018-05-22T19:54:06Z,cLnSkNMI,used_percent,disk,disk1,apfs,host.local,/ 16 | ,,0,2018-05-22T19:53:26Z,a,used_percent,disk,disk1,apfs,host.local,/ 17 | ,,0,2018-05-22T19:53:46Z,b,used_percent,disk,disk1,apfs,host.local,/ 18 | ,,0,2018-05-22T19:53:36Z,k9ngm,used_percent,disk,disk1,apfs,host.local,/ 19 | " 20 | 21 | testcase string_max { 22 | testing.shouldError( 23 | fn: () => 24 | csv.from(csv: inData) 25 | |> max() 26 | |> tableFind(fn: (key) => true), 27 | want: 28 | /max: invalid use of function: \*universe.MaxSelector has no implementation for type string$/, 29 | ) 30 | } 31 | -------------------------------------------------------------------------------- /stdlib/universe/string_test.flux: -------------------------------------------------------------------------------- 1 | package universe_test 2 | 3 | 4 | import "testing" 5 | import "csv" 6 | 7 | testcase label_to_string { 8 | testing.assertEqualValues(got: string(v: .myLabel), want: "myLabel") 9 | } 10 | -------------------------------------------------------------------------------- /stdlib/universe/transformations.go: -------------------------------------------------------------------------------- 1 | // Package universe contains the implementations for the builtin transformation functions. 2 | package universe 3 | -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | // +build tools 2 | 3 | package tools 4 | 5 | import ( 6 | _ "github.com/influxdata/pkg-config" 7 | ) 8 | 9 | // This package specifies the list of go tool dependencies that downstream 10 | // dependencies will need to build Flux. 11 | -------------------------------------------------------------------------------- /values/array_test.go: -------------------------------------------------------------------------------- 1 | package values_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/InfluxCommunity/flux/semantic" 7 | "github.com/InfluxCommunity/flux/values" 8 | ) 9 | 10 | func TestArrayEqual(t *testing.T) { 11 | r := values.NewArray(semantic.NewArrayType(semantic.BasicInt)) 12 | r.Append(values.NewInt(1)) 13 | l := values.NewArray(semantic.NewArrayType(semantic.BasicInt)) 14 | l.Append(values.NewInt(1)) 15 | 16 | if !l.Equal(r) { 17 | t.Fatal("expected arrays to be equal") 18 | } 19 | 20 | l.Set(0, values.NewInt(2)) 21 | if l.Equal(r) { 22 | t.Fatal("expected arrays to be unequal") 23 | } 24 | 25 | r.Set(0, values.NewInt(2)) 26 | if !l.Equal(r) { 27 | t.Fatal("expected objects to be equal") 28 | } 29 | l.Append(values.NewInt(1)) 30 | if l.Equal(r) { 31 | t.Fatal("expected objects to be unequal") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /values/bool.go: -------------------------------------------------------------------------------- 1 | package values 2 | 3 | import "github.com/InfluxCommunity/flux/semantic" 4 | 5 | var ( 6 | trueValue Value = value{ 7 | t: semantic.BasicBool, 8 | v: true, 9 | } 10 | falseValue Value = value{ 11 | t: semantic.BasicBool, 12 | v: false, 13 | } 14 | ) 15 | 16 | func NewBool(v bool) Value { 17 | if v { 18 | return trueValue 19 | } 20 | return falseValue 21 | } 22 | -------------------------------------------------------------------------------- /values/gen.go: -------------------------------------------------------------------------------- 1 | package values 2 | 3 | //go:generate -command tmpl ../gotool.sh github.com/benbjohnson/tmpl 4 | //go:generate tmpl -data=@types.tmpldata -o vector_values.gen.go vector_values.gen.go.tmpl 5 | //go:generate tmpl -data=@types.tmpldata -o conditional.gen.go conditional.gen.go.tmpl 6 | //go:generate tmpl -data=@../array/unary.tmpldata -o unary.gen.go unary.gen.go.tmpl 7 | -------------------------------------------------------------------------------- /values/option.go: -------------------------------------------------------------------------------- 1 | package values 2 | 3 | // Option is a value that has been declared as an option within the 4 | // package. An option can be modified by another package from outside 5 | // of the scope that the option was originally defined in, but it will 6 | // affect the original scope it was defined in. 7 | type Option struct { 8 | Value 9 | } 10 | -------------------------------------------------------------------------------- /values/package.go: -------------------------------------------------------------------------------- 1 | package values 2 | 3 | type Package interface { 4 | Object 5 | 6 | // Name returns the package name. 7 | Name() string 8 | 9 | // Path returns the canonical import path for this package. 10 | Path() string 11 | } 12 | 13 | // SetOption will set an option on the package and return 14 | // the value representing the option. 15 | func SetOption(p Package, name string, v Value) (Value, bool) { 16 | // TODO(jsternberg): Setting an invalid option on a package wasn't previously 17 | // an error so it continues to not be an error. We should probably find a way 18 | // to make it so setting an invalid option is an error. 19 | opt, ok := p.Get(name) 20 | if ok { 21 | if opt, ok := opt.(*Option); ok { 22 | opt.Value = v 23 | return opt, ok 24 | } 25 | } 26 | return opt, false 27 | } 28 | -------------------------------------------------------------------------------- /values/valuestest/scope.go: -------------------------------------------------------------------------------- 1 | package valuestest 2 | 3 | import ( 4 | "github.com/InfluxCommunity/flux/runtime" 5 | "github.com/InfluxCommunity/flux/values" 6 | "github.com/google/go-cmp/cmp" 7 | ) 8 | 9 | // ComparableScope is a representation of a Scope 10 | // that is easily compared with the cmp package. 11 | type ComparableScope struct { 12 | Values map[string]values.Value 13 | Child *ComparableScope 14 | } 15 | 16 | // ScopeTransformer converts a scope to a ComparableScope. 17 | var ScopeTransformer = cmp.Transformer("Scope", func(s values.Scope) *ComparableScope { 18 | var sc *ComparableScope = nil 19 | for { 20 | if s != nil { 21 | sc = &ComparableScope{ 22 | Values: make(map[string]values.Value), 23 | Child: sc, 24 | } 25 | s.LocalRange(func(k string, v values.Value) { 26 | sc.Values[k] = v 27 | }) 28 | s = s.Pop() 29 | } else { 30 | break 31 | } 32 | } 33 | return sc 34 | }) 35 | 36 | // Scope returns a scope that contains the prelude. 37 | func Scope() values.Scope { 38 | return runtime.Prelude() 39 | } 40 | -------------------------------------------------------------------------------- /values/vector.go: -------------------------------------------------------------------------------- 1 | package values 2 | 3 | import ( 4 | arrow "github.com/InfluxCommunity/flux/array" 5 | "github.com/InfluxCommunity/flux/semantic" 6 | ) 7 | 8 | type Vector interface { 9 | Value 10 | ElementType() semantic.MonoType 11 | Arr() arrow.Array 12 | IsRepeat() bool 13 | } 14 | --------------------------------------------------------------------------------