mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
A broad documentation pass across the areas LanceDB Enterprise and Embedded diverge on most: **Data Curation** -- GPU Function execution, Slurm scheduling (and what Slurm is, for readers new to it), blob late materialization as its own page, joins, aggregation/profiling, sampling, near-duplicate detection, chunking, distributed shuffle, and IVF-partition clustering. **Feature Engineering** -- computed columns and materialized views, restructured to lead with the Function-based path and show the SQL form side by side with Python throughout; a single Auto Refresh page instead of duplicating scheduling details on every refresh page; adaptive execution; checkpointing; GPU and Slurm placement for refresh workers; a Training Cache page for the PyTorch data loader's automatic cache benefit. **Security & Governance** -- an Audit Log reference (schema, access, grants), Secrets promoted to an ordinary catalog object with their own SQL DDL and a vending/rotation guide, and privilege-table fixes verified against the authorization source. **Deployment & Maintenance** -- Horizontal Scaling and OpenTelemetry moved into a real Deployment area; Automated Cleanup folded into Intelligent Auto-Maintenance (every other maintenance decision already lived there); RTE Compaction and Advanced Conflict Resolution documented in depth. **Landing page** -- the Enterprise feature comparison table reorganized (several redundant or stale rows removed, several new areas added), and the "why Enterprise" bullets replaced with ones tied to a concrete page (Performance, Scale, Fault tolerance, Multicloud deployment, Simplify operations) instead of vague promises. Plus a full pass addressing lancedb-gatekeeper's review: a real test-safety bug (a quickstart test could silently overwrite and delete a deployment's own `frames` table), a fabricated SQL statement with no backing implementation, an actual dedup-guarantee bug in `take_row_ids`, and dozens of documentation-accuracy fixes verified against source rather than taken on faith -- each either fixed, or left with an explicit note on why it needs a feature or deployment owner's sign-off instead of being guessed at. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018PXMCbRH6i5w47TsjeEUMT --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
154 lines
4.7 KiB
Plaintext
154 lines
4.7 KiB
Plaintext
---
|
|
title: "Scalar functions"
|
|
sidebarTitle: "Scalar Functions"
|
|
description: "The per-row function set: math, string, regex, date/time, array, struct, and what Lance adds."
|
|
icon: calculator
|
|
keywords: ["scalar functions", "string functions", "math functions", "regex", "array functions", "json"]
|
|
availability:
|
|
embedded: unavailable
|
|
enterprise: available
|
|
---
|
|
|
|
Functions that take a value and return a value, one row at a time. The set is
|
|
based on DataFusion's registration plus Lance and deployment-specific
|
|
functions. The names below are selected examples, not an exhaustive catalog
|
|
for every deployment. Availability depends on the deployed version and build.
|
|
|
|
For per-group functions see [Aggregation](/sql/dql/aggregation); for per-window,
|
|
[Window functions](/sql/dql/window).
|
|
|
|
## Math {#math}
|
|
|
|
```text
|
|
abs ceil floor round trunc signum power sqrt cbrt exp
|
|
ln log log2 log10 factorial gcd lcm pi random nanvl
|
|
isnan iszero cot degrees radians to_degrees to_radians
|
|
sin cos tan asin acos atan atan2
|
|
sinh cosh tanh asinh acosh atanh
|
|
```
|
|
|
|
## String {#string}
|
|
|
|
```text
|
|
ascii bit_length btrim chr concat concat_ws contains ends_with
|
|
starts_with levenshtein lower upper ltrim rtrim octet_length
|
|
repeat replace split_part to_hex uuid
|
|
```
|
|
|
|
Unicode-aware variants:
|
|
|
|
```text
|
|
character_length find_in_set initcap left right lpad rpad
|
|
reverse strpos substr substr_index substring translate
|
|
```
|
|
|
|
<Note>
|
|
For keyword matching on a text column, [`contains_tokens`](/sql/dql/contains-tokens)
|
|
is index-accelerated where `contains` and `LIKE` are not.
|
|
</Note>
|
|
|
|
## Regular expressions {#regex}
|
|
|
|
```text
|
|
regexp_count regexp_instr regexp_like regexp_match regexp_replace
|
|
```
|
|
|
|
## Date and time {#datetime}
|
|
|
|
```text
|
|
current_date current_time date_bin date_part date_trunc
|
|
from_unixtime to_unixtime make_date make_time to_char
|
|
to_date to_time to_local_time
|
|
```
|
|
|
|
`date_bin` is the one worth knowing for analytics: it buckets timestamps into
|
|
fixed-width intervals, which is how you build a time series without a
|
|
self-join.
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
SELECT date_bin(INTERVAL '1 hour', created_at) AS hour, count(*)
|
|
FROM events
|
|
GROUP BY hour
|
|
ORDER BY hour
|
|
```
|
|
</CodeGroup>
|
|
|
|
## Arrays and maps {#arrays}
|
|
|
|
```text
|
|
make_array array_has array_filter array_transform array_any_match
|
|
array_compact array_normalize array_slice arrays_zip cardinality
|
|
flatten range generate_series
|
|
```
|
|
|
|
```text
|
|
map map_keys map_values map_entries map_extract
|
|
```
|
|
|
|
Distance functions over arrays: `cosine_distance`, `distance`,
|
|
`exact_distance`, `inner_product`. Only `distance` and `exact_distance`
|
|
take an options string, and only `distance` can plan as vector search; see
|
|
[Vector distance functions](/sql/dql/vector-distance).
|
|
|
|
## Structs and fields {#structs}
|
|
|
|
```text
|
|
named_struct get_field coalesce nullif nvl nvl2 greatest least
|
|
union_extract union_tag
|
|
```
|
|
|
|
## Crypto and encoding {#crypto}
|
|
|
|
```text
|
|
digest md5 sha224 sha256 sha384 sha512 encode decode
|
|
```
|
|
|
|
## Type functions {#type}
|
|
|
|
```text
|
|
arrow_cast arrow_try_cast arrow_typeof arrow_field arrow_metadata
|
|
with_metadata version
|
|
```
|
|
|
|
Use `arrow_typeof` to inspect the Arrow data type of a column or expression:
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
SELECT arrow_typeof(vector) FROM documents LIMIT 1
|
|
-- FixedSizeList(Field { name: "item", data_type: Float32, .. }, 1536)
|
|
```
|
|
</CodeGroup>
|
|
|
|
`arrow_cast` casts to an Arrow type by name, reaching types SQL has no spelling
|
|
for. See [Data types](/sql/data-types).
|
|
|
|
## What Lance adds {#lance}
|
|
|
|
These are registered by Lance on top of DataFusion's set, each with its own
|
|
reference page:
|
|
|
|
| | |
|
|
| --- | --- |
|
|
| [`contains_tokens`](/sql/dql/contains-tokens) | index-accelerated keyword predicate, usable in `WHERE` |
|
|
| [`ivf_partition`](/sql/dql/ivf-partition) | assign each row to its trained IVF index partition |
|
|
| [`blob_descriptor`](/sql/dql/blob-descriptor) | a BlobV2 column's payload location, without reading it |
|
|
| [JSON accessors](/sql/dql/json-functions) | `json_get` and its typed variants, `json_extract`, and more |
|
|
|
|
### Geospatial {#geo}
|
|
|
|
<Warning>
|
|
Lance defines `st_*` functions on GeoArrow, but they sit behind a build feature
|
|
**LanceDB does not ship**. Calling one returns an error naming the missing
|
|
feature rather than an unknown-function error, and the spatial index is gated
|
|
the same way.
|
|
</Warning>
|
|
|
|
## Additional scalar functions {#escape-hatch}
|
|
|
|
SQL queries can call functions registered with the server, including functions
|
|
not listed on this page. Consult
|
|
[DataFusion's scalar function reference](https://datafusion.apache.org/user-guide/sql/scalar_functions.html)
|
|
for version 54. Functions documented for a newer DataFusion release may not be
|
|
available in your LanceDB Enterprise version.
|