Skip to content

Function Support

synthaicode edited this page Oct 26, 2025 · 7 revisions

Function Support (C# to ksqlDB)

This page lists the C# methods and properties that the LINQ-to-ksql translator maps to ksqlDB functions. Only query-usable mappings are included.

String

C# ksqlDB Notes
s.Substring(start, length) SUBSTRING(s, start, length)
s.Replace(oldValue, newValue) REPLACE(s, oldValue, newValue)
string.Concat(a, b, ...) CONCAT(a, b, ...)
s.IndexOf(sub) INSTR(s, sub)
s.Trim() TRIM(s)
s.Split(delim) SPLIT(s, delim)
s.PadLeft(len, pad) LPAD(s, len, pad)
s.PadRight(len, pad) RPAD(s, len, pad)
s.ToUpper() UPPER(s)
s.ToLower() LOWER(s)
Left(s, n) SUBSTRING(s, 1, n) helper
Right(s, n) SUBSTRING(s, LEN(s)-n+1, n) helper; implementation clamps lower bound to 1

Math

C# ksqlDB Notes
Math.Round(x, p) ROUND(x, p)
Math.Floor(x) FLOOR(x)
Math.Ceiling(x) CEIL(x)
Math.Abs(x) ABS(x)
Math.Log(x) LOG(x)
Math.Exp(x) EXP(x)
Math.Pow(x, y) POWER(x, y)
Math.Sqrt(x) SQRT(x)

Date/Time (TIMESTAMP inputs)

C# ksqlDB Notes
dt.Year EXTRACT(YEAR FROM dt)
dt.Month EXTRACT(MONTH FROM dt)
dt.Day DAYOFMONTH(dt)
dt.Hour EXTRACT(HOUR FROM dt)
dt.Minute EXTRACT(MINUTE FROM dt)
dt.Second EXTRACT(SECOND FROM dt)
dt.DayOfWeek DAYOFWEEK(dt)
dt.DayOfYear DAYOFYEAR(dt)
WeekOfYear(dt) CAST(FORMAT_TIMESTAMP(dt, 'w', 'UTC') AS INT)

Aggregates (LINQ)

C# ksqlDB Notes
query.Sum(x => x.F) SUM(F)
query.Average(x => x.F) AVG(F)
query.Min(x => x.F) MIN(F)
query.Max(x => x.F) MAX(F)
query.Count() COUNT(*)
query.Count(x => cond) SUM(CASE WHEN cond THEN 1 ELSE 0 END) conditional count emulation
query.EarliestByOffset(x => x.F) EARLIEST_BY_OFFSET(F) first value by Kafka offset within group/window
query.LatestByOffset(x => x.F) LATEST_BY_OFFSET(F) last value by Kafka offset within group/window
Clone this wiki locally