Skip to content

Commit 8b1f050

Browse files
committed
Tweaks
1 parent eb2b574 commit 8b1f050

1 file changed

Lines changed: 25 additions & 31 deletions

File tree

website/docs/reference/sql/scalar_functions.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ sidebar_position: 6
1010
Spice is built on [Apache DataFusion](https://datafusion.apache.org/) and uses the PostgreSQL dialect, even when querying datasources with different SQL dialects.
1111
:::
1212

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.
1414

1515
## Function Categories
1616

17-
- Math Functions
18-
- Conditional Functions
19-
- String Functions
20-
- Binary String Functions
21-
- Regular Expression Functions
22-
- Time and Date Functions
23-
- Array Functions
24-
- Struct Functions
25-
- Map Functions
26-
- Hashing Functions
27-
- Union Functions
28-
- Other Functions
17+
- [Math Functions](#math-functions)
18+
- [Conditional Functions](#conditional-functions)
19+
- [String Functions](#string-functions)
20+
- [Binary String Functions](#binary-string-functions)
21+
- [Regular Expression Functions](#regular-expression-functions)
22+
- [Time and Date Functions](#time-and-date-functions)
23+
- [Array Functions](#array-functions)
24+
- [Struct Functions](#struct-functions)
25+
- [Map Functions](#map-functions)
26+
- [Hashing Functions](#hashing-functions)
27+
- [Union Functions](#union-functions)
28+
- [Other Functions](#other-functions)
2929

3030
---
3131

@@ -504,15 +504,13 @@ trunc(numeric_expression[, decimal_places])
504504

505505
---
506506

507-
For more information and examples, see the [DataFusion math functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#mathematical-functions).
508-
509507
## Conditional Functions
510508

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.
512510

513511
## String Functions
514512

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:
516514

517515
### `ascii`
518516

@@ -1415,23 +1413,21 @@ uuid()
14151413

14161414
---
14171415

1418-
For more information and examples, see the [DataFusion string functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#string-functions).
1419-
14201416
## Binary String Functions
14211417

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.
14231419

14241420
## Regular Expression Functions
14251421

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.
14271423

14281424
## Time and Date Functions
14291425

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.
14311427

14321428
## Array Functions
14331429

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:
14351431

14361432
### `array_any_value`
14371433

@@ -1642,28 +1638,26 @@ array_element(array, index)
16421638

16431639
---
16441640

1645-
For more information and examples, see the [DataFusion array functions documentation](https://datafusion.apache.org/docs/user-guide/sql/functions/#array-functions).
1646-
16471641
## Struct Functions
16481642

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.
16501644

16511645
## Map Functions
16521646

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.
16541648

16551649
## Hashing Functions
16561650

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.
16581652

16591653
## Union Functions
16601654

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`.
16621656

16631657
## Other Functions
16641658

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.
16661660

16671661
---
16681662

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

Comments
 (0)