Function Library
DataChain ships built-in functions in dc.func that run inside the Query Engine as SQL. They never touch Python at runtime and execute at warehouse speed.
All functions are accessed through dc.func after import datachain as dc.
Distance Functions
Array distance functions for vector search and analytics:
cosine_distance(column, reference): cosine distance between two vectorseuclidean_distance(column, reference): Euclidean distancel2_distance(column, reference): L2 (squared Euclidean) distance
Aggregate Functions
Standard SQL aggregates, usable in group_by:
count(): number of rowssum(col): total of a numeric columnavg(col): arithmetic meanmin(col),max(col): minimum/maximum valuecollect(col): gather values into a listconcat(col): concatenate string valuesany_value(col): arbitrary value from the group
Window Functions
Partitioned analytics without leaving the engine:
window(partition_by=, order_by=): creates a window spec (both required)rank(): rank with gaps for tiesdense_rank(): rank without gapsrow_number(): sequential row number within partitionfirst(col): first value in the partition
Path Functions
Work natively with storage paths via dc.func.path.*:
Conditional Functions
SQL-style branching:
case((cond, val), ..., else_=): multi-branch conditionalifelse(cond, true_val, false_val): two-branch conditionalisnone(col): null check
String Functions
String operations via dc.func.string.*:
length(col): string lengthsplit(col, sep): split on separatorreplace(col, old, new): substring replacementregexp_replace(col, pattern, replacement): regex-based replacement. Matching is case-sensitive by default. Prepend the(?i)inline flag to the pattern for case-insensitive matching (e.g.r"(?i)foo").
Numeric / Bit Functions
bit_and(col_a, col_b),bit_or,bit_xor: bitwise operationsbit_hamming_distance(col_a, col_b): Hamming distance between bit vectors
Hash Functions (ClickHouse only)
sip_hash_64(col): SipHash-2-4 producing a 64-bit integerint_hash_64(col): integer hash producing a 64-bit integer