Files
lancedb/docs/web/sql/dql/functions.mdx
T
Yang Cen af23585259 docs(sql): clarify JSON scalar index eligibility (#5306)
The JSON function reference promises index acceleration for every
accessor. Document the key and type requirements for typed lookups,
explain serialized ordering for `json_extract`, and link to `EXPLAIN` so
readers can check their plan.

Checked the examples against LanceDB's pinned Lance implementation and
verified the documentation link and `git diff --check`.

Related to lance-format/lance#8806.
2026-12-01 00:35:43 +08:00

62 lines
2.5 KiB
Plaintext

---
title: "Functions"
sidebarTitle: "Functions"
description: "Where to find each kind of function, and the dialect version they come from."
icon: function
keywords: ["functions", "datafusion", "scalar", "aggregate", "window", "fts", "table function"]
availability:
embedded: unavailable
enterprise: available
---
LanceDB executes SQL with [Apache DataFusion](https://datafusion.apache.org),
currently **version 54**. The function set is DataFusion's default registration
plus what Lance adds.
| | |
| --- | --- |
| [Scalar functions](/sql/dql/scalar-functions) | per row: math, string, regex, date/time, array, struct{/* Draft until JSON columns reach early access: restore ", JSON" */} |
| [Aggregate functions](/sql/dql/aggregation#functions) | per group: `count`, `sum`, statistical, approximate |
| [Window functions](/sql/dql/window#functions) | per window: ranking, offset, running aggregates |
| [Table functions](#table-functions) | produce a relation rather than a value |
<Note>
Function availability is version-specific. DataFusion adds functions in most
releases, so one documented on `main` may not exist in 54. When a name is not
recognised, check it against the reference for that version before assuming a
bug.
</Note>
## Table functions {#table-functions}
A table function appears in `FROM` and produces a relation, which is what lets
it return columns a scalar function has nowhere to put. Each has its own
reference page:
| | |
| --- | --- |
| [`fts(table, query)`](/sql/dql/fts) | full-text search, with a relevance score alongside the matching rows |
| [`dedupe(table, column, ...)`](/sql/dql/dedupe) | one representative row per near-duplicate group |
| [`duplicate_pairs(table, column, ...)`](/sql/dql/duplicate-pairs) | every close pair, before resolving into groups |
| [`generate_series(start, stop)`](/sql/dql/generate-series) | rows from a range |
`_score`, the relevance pseudo-column `fts()` produces, is not a function;
see [Data types](/sql/data-types#pseudo-columns).
## What Lance accelerates {#accelerated}
`contains_tokens` uses an index rather than scanning, which is the difference
between a fast predicate and a slow one:
| | Index used |
| --- | --- |
| [`contains_tokens`](/sql/dql/contains-tokens) | full-text index |
{/*
Draft until JSON columns reach early access; restore "Two function families" above.
| [Typed JSON accessors on the indexed key](/sql/dql/json-functions) | JSON scalar index |
*/}
Confirm with [`EXPLAIN`](/sql/dql/explain): an accelerated predicate shows an
index node rather than a `LanceScan` followed by a filter.