From adfece559fc11fda0ed4644f7b74d2f71423b82d Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Thu, 19 Feb 2026 16:49:03 -0600 Subject: [PATCH] docs(sql): add FLOAT/REAL type casting and precision info - Add FLOAT and REAL to numeric types table - Document precision differences (~7 vs ~15 significant digits) - Add warning about precision loss when casting to FLOAT - Note PostgreSQL behavior difference Note: DAR-584 referenced Cloud Dedicated, but this behavior is shared across all InfluxDB 3 products via DataFusion SQL engine. Closes DAR-584 --- content/shared/sql-reference/data-types.md | 39 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/content/shared/sql-reference/data-types.md b/content/shared/sql-reference/data-types.md index 4d6c714d4..056a384ba 100644 --- a/content/shared/sql-reference/data-types.md +++ b/content/shared/sql-reference/data-types.md @@ -61,11 +61,13 @@ during query execution and returned in query results. The following numeric types are supported: -| SQL data type | Arrow data type | Description | -| :-------------- | :-------------- | :--------------------------- | -| BIGINT | INT64 | 64-bit signed integer | -| BIGINT UNSIGNED | UINT64 | 64-bit unsigned integer | -| DOUBLE | FLOAT64 | 64-bit floating-point number | +| SQL data type | Arrow data type | Description | +| :-------------- | :-------------- | :----------------------------------------- | +| BIGINT | INT64 | 64-bit signed integer | +| BIGINT UNSIGNED | UINT64 | 64-bit unsigned integer | +| DOUBLE | FLOAT64 | 64-bit floating-point number (~15 digits) | +| FLOAT | FLOAT32 | 32-bit floating-point number (~7 digits) | +| REAL | FLOAT32 | 32-bit floating-point number (alias for FLOAT) | ### Integers @@ -101,11 +103,22 @@ Unsigned integer literals are comprised of an integer cast to the `BIGINT UNSIGN ### Floats -InfluxDB SQL supports the 64-bit double floating point values. -Floats can be a decimal point, decimal integer, or decimal fraction. +InfluxDB SQL supports both 32-bit (single precision) and 64-bit (double precision) floating-point values. + +| Type | Precision | Significant Digits | Use Case | +| :----- | :-------- | :----------------- | :------- | +| FLOAT | 32-bit | ~7 digits | Memory-efficient storage when full precision isn't needed | +| DOUBLE | 64-bit | ~15-16 digits | Default for most numeric operations | + +> [!Note] +> InfluxDB stores float field values as 64-bit (FLOAT64) internally. +> Casting to FLOAT (32-bit) may lose precision for values with more than ~7 significant digits. +> Unlike PostgreSQL where FLOAT defaults to double precision, InfluxDB SQL treats FLOAT as single precision (32-bit). ##### Example float literals +Float literals are stored as 64-bit double precision: + ```sql 23.8 -446.89 @@ -113,6 +126,18 @@ Floats can be a decimal point, decimal integer, or decimal fraction. 0.033 ``` +##### Example float casting + +```sql +-- Cast to 32-bit float (may lose precision) +SELECT 3.141592653589793::FLOAT; +-- Returns: 3.1415927 (truncated to ~7 digits) + +-- Cast to 64-bit double (preserves precision) +SELECT 3.141592653589793::DOUBLE; +-- Returns: 3.141592653589793 +``` + ## Date and time data types InfluxDB SQL supports the following DATE/TIME data types: