




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which symbol is used to start a single‑line comment in Flux? A) # B) // C) -- D) /* Answer: B Explanation: In Flux, a double slash (//) begins a single‑line comment; everything after it on the same line is ignored. Question 2. What does the pipe forward operator (|>) do in a Flux script? A) Assigns a variable B) Filters rows based on a condition C) Passes the output of one function as the input to the next D) Terminates the script Answer: C Explanation: The |> operator chains functions by sending the result of the left expression as the first argument to the function on the right. Question 3. Which of the following is a valid way to declare a variable named “temp” with the integer value 25? A) var temp = 25; B) let temp = 25;
C) const temp = 25; D) temp := 25; Answer: A Explanation: Flux uses the var keyword followed by the variable name, an equals sign, and the value; statements end with a semicolon. Question 4. Which data type would you use to store a timestamp such as “2024- 03 - 15T12:00:00Z” in Flux? A) string B) int C) time D) duration Answer: C Explanation: The time type represents absolute timestamps in Flux. Question 5. How do you write a multi‑line comment in Flux? A) /* comment */ B) // comment C) D) # comment # Answer: A
A) read(bucket: "environment") B) from(bucket: "environment") C) get(bucket: "environment") D) source(bucket: "environment") Answer: B Explanation: The from() function specifies the source bucket for a query. Question 9. How can you limit a query to the last 30 minutes relative to now? A) range(start: - 30m) B) range(start: now() - 30m) C) range(start: - 30m, stop: now()) D) Both A and C Answer: D Explanation: range(start: - 30m) implicitly stops at now(). Explicitly setting stop to now() is also valid. Question 10. Which of the following predicates correctly filters rows where the tag “location” equals “office”? A) r.location == "office" B) r._tag == "office" C) r["location"] == "office"
D) Both A and C Answer: D Explanation: Both dot and bracket notation can be used to reference a tag column. Question 11. What is the result type of the map() function when applied to a stream? A) A single scalar value B) A new stream with transformed rows C) A table of aggregated sums D) None of the above Answer: B Explanation: map() applies a transformation to each row and returns a new stream. Question 12. Which function would you use to calculate the mean of a numeric column named “_value”? A) mean(column: "_value") B) avg(column: "_value") C) sum(column: "_value") / count() D) Both A and C Answer: A
Question 15. What does the group() function do when called with group(columns: ["location"])? A) Removes duplicate rows based on “location” B) Sorts rows by “location” C) Creates separate tables for each distinct “location” value D) Adds a new column named “location” Answer: C Explanation: group() partitions the stream into tables keyed by the specified columns. Question 16. Which operator is used to combine two streams side‑by‑side based on matching timestamps? A) join() B) union() C) merge() D) concat() Answer: A Explanation: join() aligns rows from two streams on a common column, typically _time. Question 17. How would you rename the column “_value” to “temperature” in the output? A) rename(columns: {"_value": "temperature"})
B) as("_value", "temperature") C) change("_value", "temperature") D) map(r => ({temperature: r._value})) Answer: A Explanation: The rename() function takes a map of old to new column names. Question 18. Which function can be used to fill missing values in a time series with the previous known value? A) fill(value: 0) B) fill(usePrevious: true) C) fill(column: "_value", usePrevious: true) D) fill(method: "previous") Answer: C Explanation: fill() with usePrevious: true fills nulls using the last non‑null value for the specified column. Question 19. In the context of the range() function, what does the variable v.timeRangeStart represent? A) The start time supplied by the user B) The current system time C) The earliest timestamp in the bucket D) A constant zero value
Question 22. Which of the following literals represents a duration of 2 hours in Flux? A) 2h B) 2: C) duration(hours:2) D) "2h" Answer: A Explanation: Duration literals are written as a number followed by a unit, e.g., 2h. Question 23. How would you limit the output to the first 10 rows after all other operations? A) limit(n:10) B) top(n:10) C) head(n:10) D) Both A and C Answer: A Explanation: limit() restricts the number of rows returned; head() is not a Flux function. Question 24. Which statement correctly adds a new column “status” with the constant string “OK” to every row? A) map(fn: (r) => ({r with status: "OK"}))
B) map(fn: (r) => ({status: "OK"})) C) set(column: "status", value: "OK") D) Both A and C Answer: D Explanation: Both the map expression using record spread and the set() function can add a constant column. Question 25. Which function would you use to calculate the cumulative sum of a field over time? A) cumulativeSum() B) sum() C) integral() D) runningSum() Answer: A Explanation: cumulativeSum() returns a running total for each row based on the specified column. Question 26. What is the purpose of the yield() function in a Flux script? A) To output the final table to the client B) To pause execution until a condition is met C) To write data back to InfluxDB D) To convert a table to JSON
Question 29. Which function is used to combine multiple tables into a single table without aligning on timestamps? A) union() B) join() C) concat() D) merge() Answer: A Explanation: union() simply concatenates tables; rows are not matched on any column. Question 30. What does the window() function do in a Flux query? A) Splits a stream into fixed‑size time windows for aggregation B) Opens a graphical user interface window C) Filters rows based on a numeric range D) Changes the time zone of timestamps Answer: A Explanation: window() creates sub‑tables representing time intervals, often used before mean(), sum(), etc. Question 31. Which of the following expressions correctly casts a string “123” to an integer?
A) int(v: "123") B) toInt("123") C) cast(v: "123", to: int) D) Both A and C Answer: D Explanation: int(v: "123") and cast(v: "123", to: int) both perform the conversion. Question 32. How would you write a query that returns rows where the numeric field “_value” is greater than 50? A) filter(fn: (r) => r._value > 50) B) where(r._value > 50) C) filter(r => r._value > 50) D) Both A and C Answer: A Explanation: filter() expects a function argument; the arrow syntax must be explicit. Question 33. Which keyword is used to define a custom function that takes two parameters, a and b, and returns their product? A) func B) def
Explanation: The org parameter is supplied directly in the from() call. Question 36. How can you compute the 95th percentile of a field “_value”? A) percentile(column: "_value", percentile: 95.0) B) quantile(column: "_value", q: 0.95) C) top(n: 95, column: "_value") D) Both A and B Answer: D Explanation: Both percentile() and quantile() can calculate the 95th percentile; percentile uses a value out of 100, while quantile uses a fraction. Question 37. Which function can be used to convert a timestamp from UTC to a specific time zone, such as “America/New_York”? A) timeShift(duration: - 5h) B) timeShift(offset: - 5h) C) experimental.toTimeZone(tz: "America/New_York") D) setTimezone(tz: "America/New_York") Answer: C Explanation: The experimental toTimeZone() function changes the time zone of a timestamp.
Question 38. What does the distinct() function return when applied to the column “host”? A) All rows where “host” appears only once B) A table containing each unique “host” value exactly once C) The count of distinct hosts D) None of the above Answer: B Explanation: distinct(column: "host") produces a table with one row per unique value in that column. Question 39. Which of the following statements correctly creates a variable named “threshold” with a floating‑point value of 12.34? A) var threshold = 12.34; B) var threshold = float(v: 12.34); C) var threshold = 12.34f; D) Both A and B Answer: A Explanation: Flux automatically infers the type as float when a decimal literal is used; explicit casting is unnecessary. Question 40. In Flux, what does the experimental package prefix indicate? A) Functions that are stable and production‑ready
D) Both A and C Answer: D Explanation: sort() defaults to ascending; explicitly setting desc: false also works. Question 43. Which of the following correctly adds a tag called “region” with the value “us‑west” to every row? A) set(key: "region", value: "us-west") B) set(column: "region", value: "us-west") C) map(fn: (r) => ({r with region: "us-west"})) D) Both B and C Answer: D Explanation: set(column: "region", value: "us-west") adds a new column (tag) with the constant value; the map approach also works. Question 44. What does the keep() function do when supplied with columns: ["_time", "_value"]? A) Removes all columns except those listed B) Keeps only rows where those columns are non‑null C) Renames the listed columns to generic names D) None of the above Answer: A
Explanation: keep() retains only the specified columns in the output. Question 45. Which function can be used to write data back to an InfluxDB bucket from a Flux script? A) to(bucket: "target") B) write(bucket: "target") C) to(bucket: "target", org: "my-org") D) Both A and C Answer: D Explanation: The to() function writes the stream to a bucket; the org parameter can be supplied optionally. Question 46. How would you calculate the rate of change per second for a counter field “bytes_sent”? A) derivative(unit: 1s, nonNegative: true) B) difference() |> map(fn: (r) => r._value / 1s) C) derivative(unit: 1s) D) Both A and C (assuming default nonNegative) Answer: D Explanation: derivative(unit: 1s) computes the per‑second change; setting nonNegative: true is optional for counters.