-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autogenerated Flux code does not use "aggregateWindow" #13775
Comments
@nathanielc There seems to be a special case when using
returns this error for me:
The query seems OK as far as I can tell. Is there a Flux query you would suggest we generate instead? Maybe also relevant: before we had special handling of
Without the value conversion, the following error is thrown:
If we can fix or work around that first error above, should we still be using Every other function I tested with |
@chnn The median function should work, so that is a bug on our side that we will fix. As for the Median is not the only function like this and as we add more functions these kinds of problems are going to arise. It seems like we will have a general problem of the UI constructing Flux scripts and the users data not being to correct data type based on the function they want to use. Do you think there is a general solution to this problem on the UI? Something like allowing the user to select type conversion functions? Or possibly the UI auto inserting them when it discovers a type mismatch? |
See for fixing the median aggregateWindow issue influxdata/flux#1244 |
We could certainly build features like that in the UI, and they seem generally useful to me for the query building experience as a whole. They would mesh well with some other updates we are making to the query builder at the moment. For schema mismatches though, the approach that seems to most appealing to me is to attempt converting values to the expected type automatically, either via an explicit In the case of autogenerated queries, the conversion seems either necessary or harmless/idempotent. In the case of a user writing queries in an interactive environment, it still seems desirable. It seems like the current UX is
With automatic value conversion it seems like this flow could be reduced to step 1 only in many cases. I'm not sure I understand the full picture though—what would be lost by attempting to convert values for a user automatically in a case like this? |
In general it is not safe to convert between numeric types. Not all integers can be represented as floats, so if a user has really large ints in their data and they are autoconverted to floats, we destroy the accuracy of the results. This is the motivation for making users explicitly convert types because the assumption is that only the user knows the domain well enough to know if it is safe to convert between the types. So concretely the median function doesn't support ints because the algorithm would just convert the ints to floats before doing anything, which is not a safe operation. In other words the functions are only implemented for numeric types for which it is safe to implement. As for the user experience we hope to extend Flux's type system to understand these kinds of collisions, so the workflow could be similar to finding a syntax error in a Flux script, thus reducing the steps/time a user spends to find/fix the issue. |
Gotcha, makes sense. Seems appealing to automate some of the troubleshooting around this, along the lines of
Or perhaps just suggesting the fix, clippy style. I'll bring it up with @russorat. If we do something like this in the UI, it would be helpful to have a some more information in the schema mismatch error. Perhaps a specific error code and some information about the line/col in the user's Flux script where the error originates? Don't know how hard it is to track that information. |
Use the query builder to create a Flux query and add at least one function.
For example click:
This code is generated
The above code can be simplified to use
aggregateWindow
like:As users will likely learn Flux best by example I think it is important to introduce good concepts in the Flux code we generate. Using
aggregateWindow
is something we want users to learn to do. This way they do not have to mange the groups so directly.Previously only aggregate functions like
mean
could be used withaggregateWindow
while selector functions likemax
could not. This is no longer the case and so I think we should push users to learnaggregateWindow
.The text was updated successfully, but these errors were encountered: