Help us shape the future of Go! Take the 2026 Go Developer Survey

kernel

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package kernel implements the whole-column operations a transform plan runs. Each kernel reads its arguments as Arrow datums, leaves them for the caller to release, and returns a new datum the caller owns. A null in is a null out. The package depends on Arrow alone, so it can leave filament without change.

Names follow the yaml grammar: to_date is ToDate, year is Year, lower is Lower. Only conversions between types carry the To prefix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Abs is the absolute value.

func Add

func Add(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Add sums two numbers.

func And

func And(ctx context.Context, args []compute.Datum) (compute.Datum, error)

And is true where both are true.

func Ceil

func Ceil(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Ceil rounds up to a whole number.

func Coalesce

func Coalesce(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Coalesce takes, per row, the first argument that is not null. Arguments share one type; a literal is broadcast to the column length.

func Compare added in v0.29.0

func Compare(op Op) func(context.Context, []compute.Datum) (compute.Datum, error)

Compare is Arrow's comparison for op. A null on either side compares to null.

func CompareDecimalText added in v0.29.0

func CompareDecimalText(op Op) func(context.Context, []compute.Datum) (compute.Datum, error)

CompareDecimalText is the comparison for decimals arrowbatch carries as utf8 rather than decimal128. Both sides are read as exact numbers, so "1.0" equals "1.00" and "10" is greater than "9". A null on either side compares to null. NaN is above every number and equal to itself, and Infinity and -Infinity sit at the ends, as PostgreSQL orders numeric.

func Concat

func Concat(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Concat joins its arguments end to end for every row. Any argument may be a column or a literal; a null in any column part gives a null row.

func Day

func Day(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Day returns the day of the month of each value, 1 through 31.

func Div

func Div(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Div fails the batch on integer division by zero, as Arrow's checked divide does.

func Floor

func Floor(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Floor rounds down to a whole number.

func IfElse

func IfElse(ctx context.Context, mask *array.Boolean, then, els arrow.Array) (arrow.Array, error)

IfElse returns then where mask is true and els everywhere else, including where mask is null, which matches SQL CASE. then and els must share a type. utf8 has a direct path; every other type goes through concatenate and take.

func IsNull

func IsNull(ctx context.Context, args []compute.Datum) (compute.Datum, error)

IsNull is true where the column has no value. It reads validity itself; the registry's is_null lacks a kernel for some column types, decimal among them.

func Length

func Length(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Length counts the characters, not bytes, of every value of a utf8 column.

func Lower

func Lower(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Lower lowercases every value of a utf8 column.

func Md5

func Md5(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Md5 is the MD5 digest of one or more columns.

func Month

func Month(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Month returns the calendar month of each value, 1 through 12.

func Mul

func Mul(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Mul multiplies two numbers.

func Not

func Not(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Not flips a boolean column.

func Or

func Or(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Or is true where either is true.

func RegexExtract

func RegexExtract(ctx context.Context, args []compute.Datum) (compute.Datum, error)

RegexExtract returns the first match of the pattern in each value, or the given capture group of it. A row with no match is null.

func RegexMatch

func RegexMatch(ctx context.Context, args []compute.Datum) (compute.Datum, error)

RegexMatch reports, per row, whether a utf8 column matches the pattern.

func RegexReplace

func RegexReplace(ctx context.Context, args []compute.Datum) (compute.Datum, error)

RegexReplace rewrites every match of the pattern in each value, expanding $1-style group references in the replacement.

func Replace

func Replace(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Replace swaps every occurrence of find with with in every value of a utf8 column. Both are literals.

func Round

func Round(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Round rounds to the given number of decimal places, halves to even.

func Sha1

func Sha1(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Sha1 is the SHA-1 digest of one or more columns.

func Sha256

func Sha256(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Sha256 is the SHA-256 digest of one or more columns.

func Sha512

func Sha512(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Sha512 is the SHA-512 digest of one or more columns.

func Sub

func Sub(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Sub subtracts the second number from the first.

func Substring

func Substring(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Substring slices every value of a utf8 column by character position, counting from 1 as SQL does. Without a length it runs to the end.

func ToDate

func ToDate(ctx context.Context, args []compute.Datum) (compute.Datum, error)

ToDate parses every value of a utf8 column as an ISO date. A value that does not parse fails the whole batch rather than becoming null.

func Trim

func Trim(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Trim removes leading and trailing whitespace from every value of a utf8 column.

func Upper

func Upper(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Upper uppercases every value of a utf8 column.

func Year

func Year(ctx context.Context, args []compute.Datum) (compute.Datum, error)

Year returns the calendar year of each value in a date or timestamp column, as int64.

Types

type Op added in v0.29.0

type Op uint8

Op is a comparison operator.

const (
	Eq Op = iota
	Neq
	Gt
	Gte
	Lt
	Lte
)

Comparison operators, named after the yaml grammar.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL