Expand description
Smart constructors for building derivative expressions — useful when writing
a custom Rule, which returns f'(u) as an sqlparser::ast::Expr.
Functions§
- add
a + b, dropping a structurally-zero operand.- cast_
double - Wrap
ein aCAST(... AS DOUBLE). Self-delimiting, so it never needs precedence parentheses as an operand. - div
a / b, folding0 / _ = 0anda / 1 = a.- finite_
num - A numeric literal for a value that might not be finite — the checked
counterpart of
num. Emits the literal ifvis finite, else a typedDiffError::NotImplemented: a non-finite value has no valid SQL literal (inf/NaNare not numbers), so a derivative that would carry one must fail loud, never emit invalid SQL (#33). Use this for every value derived from user input or an arithmetic that can overflow (e.g.ln(base), an out-of-range exponent). This is the single seam through which computed constants become literals. - func
- Build an unqualified scalar function call
name(args...). - func1
f(x)— a unary call, the common case for chain-rule outer derivatives.- mul
a * b, folding0 * _ = 0and1 * b = b(and the mirror cases).- neg
-a, folding-0 = 0and-(-e) = e, and parenthesizing a binary operand (-(a + b),-(a / b)), since unary minus binds tighter than either.- one
- The constant
1.0— the derivative ofwrtitself. - sign
- The mathematical sign of
u, as aCASEthat behaves identically on every engine: - square
e * e.- sub
a - b, dropping a zero right operand and turning0 - binto-b.- zero
- The constant
0.0— the derivative of anything independent ofwrt.