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

Copy Markdown View Source

The literals and names of a SQL text, as DataFusion reads them (verified against InfluxDB 3 Core):

  • '...' is a string, in which a doubled quote is one quote: a quoted literal is a string, full stop — re-typing '08338636' as an integer would drop the leading zero and change the type
  • "..." is always an identifier, never a string: host = "x" compares the column host with the column x
  • a bare true, false or number is typed; anything else bare is a name
  • $name is a placeholder; a name is word characters in any script

The text reaching here has been through InfluxElixir.Client.Local.SQLLexer and InfluxElixir.Client.Local.SQLIdentifiers, so a double-quoted token that is left holds a name that needs its quotes.

Summary

Types

A literal or placeholder as the parser keeps it.

Functions

The text between a literal's quotes, with a doubled quote one quote. The quotes are one byte each, so the cut is by bytes, as every offset here is.

Types a bare literal: integer, then float, else leaves it as a string.

Whether the text is a float literal (1.5, .5, 1e5); an integer is not.

The value of a number token (1.5, .5, 1., 1e5, or digits only), read as a Rust f64 is: correctly rounded, 0.0 on underflow, and :nonfinite past the largest double, which the engine holds as infinity.

Whether the text is one "..." identifier.

The name a "..." identifier holds, a doubled quote one quote.

Whether the text is an integer literal.

Whether the text is a string, a boolean or a number, one past the range of a double (1e400) included.

Whether the text is a $name placeholder.

The $name placeholder's name, or nil.

A float literal's value, with the {float, rest} of Float.parse/1, or :error.

text as a '...' literal, a quote doubled.

How the engine words a column name in an error: bare when it is a lower case word, otherwise quoted with its quotes doubled.

Whether the text is one '...' literal, not two joined by an operator.

'it''s''s body is the text it's.

A literal as a value: a quoted one is a string, only a bare one is typed, $name is {:param, name}.

Types

value()

@type value() :: number() | binary() | boolean() | {:param, binary()}

A literal or placeholder as the parser keeps it.

Functions

body(text)

@spec body(binary()) :: binary()

The text between a literal's quotes, with a doubled quote one quote. The quotes are one byte each, so the cut is by bytes, as every offset here is.

coerce(text)

@spec coerce(binary()) :: number() | binary()

Types a bare literal: integer, then float, else leaves it as a string.

float?(text)

@spec float?(binary()) :: boolean()

Whether the text is a float literal (1.5, .5, 1e5); an integer is not.

float_value(text)

@spec float_value(binary()) :: float() | :nonfinite

The value of a number token (1.5, .5, 1., 1e5, or digits only), read as a Rust f64 is: correctly rounded, 0.0 on underflow, and :nonfinite past the largest double, which the engine holds as infinity.

identifier?(text)

@spec identifier?(binary()) :: boolean()

Whether the text is one "..." identifier.

identifier_name(text)

@spec identifier_name(binary()) :: binary()

The name a "..." identifier holds, a doubled quote one quote.

integer?(text)

@spec integer?(binary()) :: boolean()

Whether the text is an integer literal.

literal?(text)

@spec literal?(binary()) :: boolean()

Whether the text is a string, a boolean or a number, one past the range of a double (1e400) included.

param?(text)

@spec param?(binary()) :: boolean()

Whether the text is a $name placeholder.

param_name(text)

@spec param_name(binary()) :: binary() | nil

The $name placeholder's name, or nil.

parse_float(text)

@spec parse_float(binary()) :: {float(), binary()} | :error

A float literal's value, with the {float, rest} of Float.parse/1, or :error.

quote_text(text)

@spec quote_text(binary()) :: binary()

text as a '...' literal, a quote doubled.

render_identifier(name)

@spec render_identifier(binary()) :: binary()

How the engine words a column name in an error: bare when it is a lower case word, otherwise quoted with its quotes doubled.

string?(text)

@spec string?(binary()) :: boolean()

Whether the text is one '...' literal, not two joined by an operator.

unescape(body)

@spec unescape(binary()) :: binary()

'it''s''s body is the text it's.

value(text)

@spec value(binary()) :: value()

A literal as a value: a quoted one is a string, only a bare one is typed, $name is {:param, name}.