Name

asnumber — Provides a type hint to the containing element that it is expecting a number value.

Syntax

asnumber(expr)
              

The ASNUMBER function has the following arguments:

expr

The child expression that is expected to return a number data type value.

Description

This function provides a type hint to the child expression that a number data type value is expected. If the expression does not provide a number valued result then an error will be raised.

This function is required in situations where the data type of the enclosed expression can not determined by the parser at compile time. This is typically due to an expression that is evaluated at runtime to determine a column from a data table, such as with the column, eval, tablelist, tablemap or tablerange functions. The type hint provided by the ASNUMBER function is then used for the semantic analysis required to complete the expression compilation.

No conversion of the data value returned by the child expression is attempted, and if the child data type does not match the hint an error will be generated. For type hinting with data conversion see the number function.

Examples

See the example Table range lookup with a non-literal value in the tablerange function for details about how this function is used.