You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/reference/sql/scalar_functions.md
+25-31Lines changed: 25 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,22 +10,22 @@ sidebar_position: 6
10
10
Spice is built on [Apache DataFusion](https://datafusion.apache.org/) and uses the PostgreSQL dialect, even when querying datasources with different SQL dialects.
11
11
:::
12
12
13
-
Scalar functions in Spice.ai SQL help transform, compute, and manipulate data at the row level. These functions are evaluated for each row in a query result and return a single value per invocation. Spice.ai supports a broad set of scalar functions, including math, string, conditional, date/time, array, struct, map, regular expression, and hashing functions. The implementation is based on [Apache DataFusion](https://datafusion.apache.org/docs/user-guide/sql/functions/), and the function set closely follows the PostgreSQL dialect.
13
+
Scalar functions help transform, compute, and manipulate data at the row level. These functions are evaluated for each row in a query result and return a single value per invocation. Spice.ai supports a broad set of scalar functions, including math, string, conditional, date/time, array, struct, map, regular expression, and hashing functions. The function set closely follows the PostgreSQL dialect.
For more information and examples, see the [DataFusion math functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#mathematical-functions).
508
-
509
507
## Conditional Functions
510
508
511
-
Conditional functions help handle null values, select among alternatives, and compare multiple expressions. Functions such as `coalesce`, `greatest`, `least`, and `nullif` are supported. These are useful for data cleaning and conditional logic in queries. See the [DataFusion conditional functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#conditional-functions) for more information.
509
+
Conditional functions help handle null values, select among alternatives, and compare multiple expressions. Functions such as `coalesce`, `greatest`, `least`, and `nullif` are supported. These are useful for data cleaning and conditional logic in queries.
512
510
513
511
## String Functions
514
512
515
-
String functions in Spice.ai SQL help manipulate, analyze, and transform text data. These functions operate on string expressions, which can be constants, columns, or results of other functions. The implementation is based on [Apache DataFusion](https://datafusion.apache.org/docs/user-guide/sql/functions/#string-functions) and closely follows the PostgreSQL dialect. The following string functions are supported:
513
+
String functions in Spice.ai SQL help manipulate, analyze, and transform text data. These functions operate on string expressions, which can be constants, columns, or results of other functions. The implementation closely follows the PostgreSQL dialect. The following string functions are supported:
516
514
517
515
### `ascii`
518
516
@@ -1415,23 +1413,21 @@ uuid()
1415
1413
1416
1414
---
1417
1415
1418
-
For more information and examples, see the [DataFusion string functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#string-functions).
1419
-
1420
1416
## Binary String Functions
1421
1417
1422
-
Binary string functions help encode and decode binary data, such as base64 and hexadecimal conversions. These are useful for working with encoded data or binary blobs. See the [DataFusion binary string functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#binary-string-functions).
1418
+
Binary string functions help encode and decode binary data, such as base64 and hexadecimal conversions. These are useful for working with encoded data or binary blobs.
1423
1419
1424
1420
## Regular Expression Functions
1425
1421
1426
-
Regular expression functions help match, extract, and replace patterns in strings. Spice.ai uses a PCRE-like regular expression syntax. Functions such as `regexp_like`, `regexp_match`, and `regexp_replace` are available. For syntax and examples, refer to the [DataFusion regular expression functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#regular-expression-functions).
1422
+
Regular expression functions help match, extract, and replace patterns in strings. Spice.ai uses a PCRE-like regular expression syntax. Functions such as `regexp_like`, `regexp_match`, and `regexp_replace` are available.
1427
1423
1428
1424
## Time and Date Functions
1429
1425
1430
-
Time and date functions help extract, format, and manipulate temporal data. Functions include `current_date`, `now`, `date_part`, `date_trunc`, and various conversion functions. These are essential for time series analysis and working with timestamps. See the [DataFusion time and date functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#date-and-time-functions).
1426
+
Time and date functions help extract, format, and manipulate temporal data. Functions include `current_date`, `now`, `date_part`, `date_trunc`, and various conversion functions. These are essential for time series analysis and working with timestamps.
1431
1427
1432
1428
## Array Functions
1433
1429
1434
-
Array functions in Spice.ai SQL help construct, transform, and query array data types. These functions operate on array expressions, which can be constants, columns, or results of other functions. The implementation is based on [Apache DataFusion](https://datafusion.apache.org/docs/user-guide/sql/functions/#array-functions) and closely follows the PostgreSQL dialect. The following array functions are supported:
1430
+
Array functions in Spice.ai SQL help construct, transform, and query array data types. These functions operate on array expressions, which can be constants, columns, or results of other functions. The implementation closely follows the PostgreSQL dialect. The following array functions are supported:
For more information and examples, see the [DataFusion array functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#array-functions).
1646
-
1647
1641
## Struct Functions
1648
1642
1649
-
Struct functions help construct and access structured data types (Arrow structs). Functions such as `struct`, `named_struct`, and `get_field` are supported. These are useful for working with nested or composite data. See the [DataFusion struct functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#struct-functions).
1643
+
Struct functions help construct and access structured data types (Arrow structs). Functions such as `struct`, `named_struct`, and `get_field` are supported. These are useful for working with nested or composite data.
1650
1644
1651
1645
## Map Functions
1652
1646
1653
-
Map functions help construct and query key-value data structures. Functions include `map`, `map_extract`, `map_keys`, and `map_values`. These are useful for semi-structured or JSON-like data. For more information, see the [DataFusion map functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#map-functions).
1647
+
Map functions help construct and query key-value data structures. Functions include `map`, `map_extract`, `map_keys`, and `map_values`. These are useful for semi-structured or JSON-like data.
1654
1648
1655
1649
## Hashing Functions
1656
1650
1657
-
Hashing functions help compute cryptographic hashes and checksums, such as `md5`, `sha256`, and `digest`. These are useful for data integrity, fingerprinting, and security applications. See the [DataFusion hashing functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#hashing-functions).
1651
+
Hashing functions help compute cryptographic hashes and checksums, such as `md5`, `sha256`, and `digest`. These are useful for data integrity, fingerprinting, and security applications.
1658
1652
1659
1653
## Union Functions
1660
1654
1661
-
Union functions help work with union (variant) data types, such as extracting the value or tag from a union. Functions include `union_extract` and `union_tag`. See the [DataFusion union functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#union-functions).
1655
+
Union functions help work with union (variant) data types, such as extracting the value or tag from a union. Functions include `union_extract` and `union_tag`.
1662
1656
1663
1657
## Other Functions
1664
1658
1665
-
Additional scalar functions include type casting, type inspection, and version reporting. Functions such as `arrow_cast`, `arrow_typeof`, and `version` are available. See the [DataFusion other functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#other-functions).
1659
+
Additional scalar functions include type casting, type inspection, and version reporting. Functions such as `arrow_cast`, `arrow_typeof`, and `version` are available.
1666
1660
1667
1661
---
1668
1662
1669
-
For detailed syntax, argument descriptions, and examples for each function, refer to the [DataFusion SQL functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/). Spice.ai aims for compatibility with DataFusion and PostgreSQL, but some functions or behaviors may differ depending on the underlying engine version. Always consult the linked documentation for authoritative details.
1663
+
Spice.ai aims for compatibility with PostgreSQL, but some functions or behaviors may differ depending on the underlying engine version.
0 commit comments