InfluxElixir.Client.Local.SQLFold (InfluxElixir v0.1.40)

Copy Markdown View Source

What the engine's optimizer finds when it folds the constants of a SQL query, for InfluxElixir.Client.Local (verified against InfluxDB 3 Core).

A CAST of a constant that cannot be performed (CAST('abc' AS INT), CAST(3000000000 AS INT), a float outside the integer's range) is evaluated while the plan is simplified, so it fails the query before a row is read, wherever it stands (the select list, WHERE, ORDER BY, an aggregate's argument, an expression nothing reads) and whatever the table holds: status 500,

Optimizer rule 'simplify_expressions' failed
caused by
Arrow error: Cast error: Can't cast value 3000000000 to type Int32

A cast of a column fails per value instead (InfluxElixir.Client.Local.SQLCast). An expression that fails at run time on a constant (a division by zero, an abs or a negation of the smallest integer) is not folded; it fails when a row is evaluated.

Summary

Functions

The optimizer's error for the first constant cast the query cannot perform, or :ok. The query has its parameters bound.

Whether a constant sub-expression of expr divides the smallest integer of a type by -1 ((-9223372036854775807 - 1) / -1), which overflows.

The smallest integer, as text, whose negation a constant sub-expression of expr performs (-(-9223372036854775807 - 1)), or nil. A constant that fails some other way is not one.

Functions

check(query)

The optimizer's error for the first constant cast the query cannot perform, or :ok. The query has its parameters bound.

division_overflow?(division)

@spec division_overflow?(InfluxElixir.Client.Local.SQLExpr.t()) :: boolean()

Whether a constant sub-expression of expr divides the smallest integer of a type by -1 ((-9223372036854775807 - 1) / -1), which overflows.

negation_overflow(neg)

@spec negation_overflow(InfluxElixir.Client.Local.SQLExpr.t()) :: binary() | nil

The smallest integer, as text, whose negation a constant sub-expression of expr performs (-(-9223372036854775807 - 1)), or nil. A constant that fails some other way is not one.