# Flowtide.NET complete application reference > The four Flowtide application guides in one file: streams, SQL, expressions, and connectors. Generated from the maintained guides; edit those files instead of this bundle. The generated .NET API reference and release history are linked separately from [llms.txt](https://koralium.github.io/flowtide/llms.txt). --- Source: [streams.txt](https://koralium.github.io/flowtide/llms/streams.txt) # Building and operating Flowtide streams Flowtide continuously maintains a relational query over changing data. Sources supply initial rows and later changes; operators maintain joins, aggregates, and windows; sinks materialize the result. Updates and deletes can retract previous results. Design output keys and sink behavior for those changes. This reference follows the repository's current APIs. Check package-version compatibility when adapting an example. [SQL](https://koralium.github.io/flowtide/llms/sql.txt), [expressions](https://koralium.github.io/flowtide/llms/expressions.txt), and [connectors](https://koralium.github.io/flowtide/llms/connectors.txt) have separate references. ## A complete development application Create an ASP.NET Core minimal application targeting a supported framework (.NET 8 or .NET 10), then add FlowtideDotNet.AspNetCore. This package brings in the core engine and dependency injection integration. The example uses a constant SQL input and the built-in console sink, so it needs no external database. ```sh dotnet new web -n FlowtideExample cd FlowtideExample dotnet add package FlowtideDotNet.AspNetCore ``` Replace Program.cs with: ```csharp using FlowtideDotNet.AspNetCore.Extensions; using FlowtideDotNet.Core.Sinks; using FlowtideDotNet.DependencyInjection; var builder = WebApplication.CreateBuilder(args); builder.Services.AddFlowtideStream("hello") .AddSqlTextAsPlan(""" INSERT INTO console SELECT id, upper(name) AS name FROM (VALUES (1, 'Ada'), (2, 'Linus')) AS people(id, name); """) .AddConnectors(connectors => connectors.AddConsoleSink("console")) .AddStorage(storage => { storage.AddTemporaryStorage(); }); var app = builder.Build(); app.UseFlowtideUI("/stream"); app.Run(); ``` Run with `dotnet run`. The host runs the stream, the console receives the result, and /stream exposes the monitoring UI. Temporary storage is for development and is removed on disposal. For data that survives restarts, use AddFileStorage or a persistent cloud provider. ## SQL Server to SQL Server Also install FlowtideDotNet.Connector.SqlServer. Configure connection strings named SourceDb and DestinationDb through normal .NET configuration. The SQL below assumes the source database is named appdb and the destination database reporting. Provision the physical tables separately, enable SQL Server Change Tracking on source tables for incremental updates, and include the destination primary key in the projection. ```csharp using FlowtideDotNet.AspNetCore.Extensions; using FlowtideDotNet.Core; using FlowtideDotNet.DependencyInjection; var builder = WebApplication.CreateBuilder(args); var source = builder.Configuration.GetConnectionString("SourceDb") ?? throw new InvalidOperationException("SourceDb is required"); var destination = builder.Configuration.GetConnectionString("DestinationDb") ?? throw new InvalidOperationException("DestinationDb is required"); builder.Services.AddFlowtideStream("orders") .AddSqlTextAsPlan(""" INSERT INTO target.reporting.dbo.OrderSummary SELECT o.orderkey, o.orderdate, u.firstname, u.lastname FROM source.appdb.dbo.orders o LEFT JOIN source.appdb.dbo.users u ON o.userkey = u.userkey; """) .AddVersioningFromPlanHash() .AddConnectors(connectors => { connectors.AddCatalog("source", catalog => catalog.AddSqlServerSource(() => source)); connectors.AddCatalog("target", catalog => catalog.AddSqlServerSink(() => destination)); }) .AddStorage(storage => { storage.AddFileStorage("./state/orders"); }); var app = builder.Build(); app.UseFlowtideUI("/stream"); app.Run(); ``` AddSqlTextAsPlan and AddSqlFileAsPlan obtain table providers from the registered connectors. Connectors with schema discovery can supply planner metadata automatically. Otherwise declare CREATE TABLE metadata or add an ITableProvider. A SQL file must exist at the configured path when the application starts; arrange for it to be copied to the output/publish directory. AddSqlPlan(sql => { ... }) gives access to SqlPlanBuilder for custom schemas, function mappings, or AddPlanAsView. AddPlan(plan) accepts an already constructed Substrait plan. ## Building without dependency injection SqlPlanBuilder compiles SQL. FlowtideBuilder connects the plan to an engine. This standalone example uses local Reservoir persistence: ```csharp using FlowtideDotNet.Core; using FlowtideDotNet.Core.Engine; using FlowtideDotNet.Core.Sinks; using FlowtideDotNet.Storage; using FlowtideDotNet.Storage.Persistence.Reservoir; using FlowtideDotNet.Storage.Persistence.Reservoir.Internal; using FlowtideDotNet.Storage.Persistence.Reservoir.LocalDisk; using FlowtideDotNet.Storage.StateManager; using FlowtideDotNet.Substrait.Sql; var sql = new SqlPlanBuilder(); sql.Sql("INSERT INTO console SELECT 1 AS id, 'hello' AS message;"); var connectors = new ConnectorManager(); connectors.AddConsoleSink("console"); var reservoir = new ReservoirBuilder(); reservoir.SetStorage(new LocalDiskProvider("./state/hello")); await using var stream = new FlowtideBuilder("hello") .AddPlan(sql.GetPlan()) .AddConnectorManager(connectors) .WithStateOptions(new StateManagerOptions { PersistentStorage = new ReservoirPersistentStorage(reservoir), TemporaryStorageOptions = new FileCacheOptions { DirectoryPath = "./temp/hello" } }) .Build(); var running = stream.RunAsync(); Console.ReadLine(); await stream.StopAsync(); await running; ``` With the default scheduler, RunAsync calls StartAsync and drives recurring connector triggers until the stream stops. Keep its task while waiting for shutdown, then stop the stream and await that task. StartAsync alone is appropriate when a custom scheduler is driven externally. The dependency injection hosted service drives the normal run lifecycle. Build/optimization can modify plans, so create a fresh plan for each independent stream build. ## State, checkpoints, and versions State storage is required for joins, aggregates, windows, source positions, and recovery. A checkpoint commits a consistent processing state; after failure the stream can restore that state and replay later input. A watermark tracks progress from contributing sources. Do not equate an arbitrary delay or an arriving row with a committed checkpoint or completed sink write. Reservoir is the storage system used by the current file, temporary, and Azure helpers: - AddFileStorage("./state/orders") persists to local disk; the directory must survive process/container replacement if recovery is required. - AddTemporaryStorage() uses temporary disk for development and tests, with cleanup on disposal. - AddAzureBlobStorage(connectionString, containerName, directoryPath: "orders", localCacheDirectory: "./cache/orders") persists to Azure Blob Storage. Install FlowtideDotNet.Storage.Azure; credential-based and options-delegate overloads are also available. - FasterKV helpers and AddTemporaryDevelopmentStorage are older APIs still found in samples. Prefer the Reservoir helpers for new applications. Storage paths must be isolated between independent streams. Distributed substreams need their own storage keyed by stream and substream. Reservoir builders expose SetCacheSize, SetMaxDataFileSize, SetSnapshotCheckpointInterval, and OldStreamVersionsRetention. Storage configuration also exposes MaxProcessMemory, MinPageCount, ZstdPageCompression, and NoCompression. AddVersioningFromPlanHash(), AddVersioningFromString("v1"), and AddVersioningFromAssembly() configure stream versioning. A changed version starts a separate state version; plan changes need an intentional rebuild and a sink strategy for replacing or reconciling old output. OldStreamVersionsRetention controls previous stored versions when versioning is enabled; deleting old state is separate from cleaning old destination data. [State persistence](https://koralium.github.io/flowtide/docs/statepersistence.md) documents provider options and retention. ## Monitoring, checks, and control - app.UseFlowtideUI("/stream") exposes the built-in UI. - builder.Services.AddHealthChecks().AddFlowtideCheck() integrates with ASP.NET Core health checks; map an endpoint with app.MapHealthChecks("/health"). - OpenTelemetry can subscribe to meters with AddMeter("flowtide.*"). See the [Prometheus](https://koralium.github.io/flowtide/docs/monitoring/prometheus.md) and [Azure Monitor](https://koralium.github.io/flowtide/docs/monitoring/azuremonitor.md) examples. - AddOpenLineageHttp(options => { options.Url = "https://lineage.example/api/v1/lineage"; }) enables lineage reporting; IncludeSchema and OnRequest customize schema reporting and authentication. [OpenLineage](https://koralium.github.io/flowtide/docs/monitoring/openlineage.md) has the full configuration. - WriteCheckFailuresToLogger() and WriteCheckFailuresAsActivity() report SQL data-quality checks. Direct builders expose WithCheckFailureListener and WithCheckStatusListener. Issues and statuses reflect committed checkpoints; null/non-boolean check conditions have specific semantics in the expression reference. - AddCustomOptions((services, streamBuilder) => { ... }) configures underlying engine options, such as SetMinimumTimeBetweenCheckpoint and SetGetTimestampUpdateInterval. - FlowtidePauseOptions through IOptionsMonitor, or app.UseFlowtidePauseResumeEndpoints("/control"), supports pausing/resuming. Pausing retains running state in memory. [Pause and resume](https://koralium.github.io/flowtide/docs/deployment/pauseresume.md) explains configuration binding and endpoints. ## Parallel and distributed streams SetParallelism on FlowtideBuilder enables experimental in-process operator parallelism. Distributed mode is also experimental and splits a plan into substreams with coordinated checkpoints and recovery. DistributedStreamBuilder takes a plan factory, a state-options factory, and a connector-manager factory. DistributeAutomatically(substreamCount: 2) distributes eligible joins on equality keys, grouped aggregates on group keys, and analytic functions on partition keys. Recursive pipelines and joins without equality keys stay together. Each substream must receive a fresh plan and separate state. StartAsync on this host also drives recurring triggers; StopAsync coordinates drain across substreams. Orleans hosting is available through FlowtideDotNet.Cluster.Orleans and AddFlowtideOrleans. StartStreamRequest(sqlText, substreamCount: 4) starts a stream via IStreamGrain. Use durable metadata, reminders, and state for production recovery. Do not substitute the older FlowtideDotNet.Orleans integration without checking its APIs. - [Automatic distribution](https://koralium.github.io/flowtide/docs/distributed/automaticdistribution.md) - [In-process distributed hosting](https://koralium.github.io/flowtide/docs/distributed/inprocess.md) - [Orleans hosting](https://koralium.github.io/flowtide/docs/distributed/orleans.md) - [Orleans sample](https://github.com/koralium/flowtide/tree/main/samples/OrleansSample) ## Testing a stream Install FlowtideDotNet.TestFramework. TestDataTable and AddTestDataTable provide controllable input; TestDataSink and AddTestDataSink capture materialized output. AddStreamTestMonitor registers StreamTestMonitor; await WaitForCheckpoint before asserting output. In ASP.NET Core integration tests, override the same named stream's connectors and storage with WebApplicationFactory.ConfigureTestServices. For Aspire/distributed-process tests, map MapFlowtideTestInformation only when test mode is enabled, and use StreamTestHttpMonitor to await checkpoints. Test inserts, updates, deletes, duplicate rows, empty input, and restart/recovery where relevant. - [Integration testing](https://koralium.github.io/flowtide/docs/testing/integrationtests.md) - [Aspire testing](https://koralium.github.io/flowtide/docs/testing/aspiretesting.md) - [Acceptance test harness](https://github.com/koralium/flowtide/blob/main/tests/FlowtideDotNet.AcceptanceTests/FlowtideAcceptanceBase.cs) --- Source: [sql.txt](https://koralium.github.io/flowtide/llms/sql.txt) # Writing Flowtide SQL Flowtide SQL describes a continuously maintained query. SQL is parsed by SqlPlanBuilder into Substrait, optimized, and run by the .NET engine. It is not SQL sent verbatim to a source database. Sources, destinations, and metadata must match the configured [connectors](https://koralium.github.io/flowtide/llms/connectors.txt). Examples below use logical tables such as users, orders, and output. Supply table-provider metadata or CREATE TABLE declarations for their input columns and register a sink for output. [Expressions](https://koralium.github.io/flowtide/llms/expressions.txt) lists exact supported function signatures. ## Metadata and naming CREATE TABLE declares a table's columns for SQL planning. It does not create a physical source, destination, or connector. Column types can be omitted or declared as any when data is dynamic. ```sql CREATE TABLE users (userkey, firstname, lastname, managerkey); CREATE TABLE orders (orderkey, userkey, amount, order_time TIMESTAMP); INSERT INTO output SELECT userkey, firstname, lastname FROM users; ``` SqlPlanBuilder.AddTableProvider discovers schemas through ITableProvider; AddTableDefinition supplies a NamedStruct directly. Dependency injection's SQL plan helpers add the registered connectors' table providers automatically. SQL Server commonly uses database.schema.table; a catalog adds a leading catalog name. MongoDB uses database.collection by default. Use single quotes for string literals. Double quotes and square brackets quote identifiers, for example `u.[firstname]`. Qualify ambiguous columns with table aliases. Explicit column lists avoid pulling unnecessary columns into state and help control schema changes. ## Outputs and primary keys INSERT INTO declares the sink that receives the changing result. A plan can contain several INSERT statements. Target names are resolved by connector registration; output columns must satisfy that sink's identity and schema requirements. ```sql INSERT INTO output PRIMARY KEY (userkey) SELECT userkey, firstname, lastname FROM users; ``` An optional target column list renames the written columns: ```sql INSERT INTO output (id, name) PRIMARY KEY (id) SELECT userkey, firstname FROM users; ``` Every declared primary key must be part of the written columns. PRIMARY KEY overrides the sink's usual key selection only for connectors that support declared keys; unsupported sinks reject the plan. This clause does not create a primary key in the external database. ## Projection, filters, and joins ```sql INSERT INTO output SELECT o.orderkey, u.firstname || ' ' || u.lastname AS customer, CASE WHEN o.amount >= 100 THEN 'large' ELSE 'small' END AS size FROM orders o LEFT JOIN users u ON o.userkey = u.userkey WHERE o.amount > 0 AND u.userkey IS NOT NULL; ``` SELECT supports expressions, aliases, wildcards, DISTINCT, derived tables, and VALUES inputs. SELECT without FROM is supported for constant data. WHERE keeps rows whose predicate is true; SQL null comparisons require IS NULL/IS NOT NULL or null-safe distinctness predicates. INNER, LEFT, RIGHT, FULL OUTER, and cross joins have acceptance coverage. Equality joins can use efficient merge processing; predicates without usable equality keys can require more expensive nested-loop processing. Outer joins null-pad the missing side, and later inserts, updates, or deletes can change which rows match. Table functions support INNER and LEFT joins; do not use a RIGHT join to a table function. EXISTS, NOT EXISTS, IN, and NOT IN subqueries in filters are supported, including tested correlated forms: ```sql INSERT INTO output SELECT u.userkey FROM users u WHERE EXISTS ( SELECT 1 FROM orders o WHERE o.userkey = u.userkey ); ``` Use the tested filter-subquery forms; do not infer arbitrary scalar-subquery support. See [Select](https://koralium.github.io/flowtide/docs/sql/select/index.md) and [join acceptance tests](https://github.com/koralium/flowtide/blob/main/tests/FlowtideDotNet.AcceptanceTests/JoinTests.cs). ## Views and buffered views CREATE VIEW defines a reusable subplan inside the stream, including views used by multiple outputs or other views. It does not create a view in a connected database. ```sql CREATE VIEW positive_orders AS SELECT orderkey, userkey, amount FROM orders WHERE amount > 0; INSERT INTO output SELECT userkey, sum(amount) AS total FROM positive_orders GROUP BY userkey; ``` `CREATE VIEW name WITH (BUFFERED = true) AS ...` buffers and consolidates changes until a watermark, reducing repeated output whose net value does not change. It can help with clock-dependent expressions using gettimestamp(). The buffer has a progress/latency tradeoff; it is not a time-window definition. ## Grouping and aggregates ```sql INSERT INTO output SELECT userkey, count(*) AS order_count, sum(amount) AS total, max(amount) AS largest, sum(amount) FILTER (WHERE amount >= 100) AS large_order_total FROM orders GROUP BY userkey HAVING sum(amount) > 500; ``` GROUP BY supports columns and tested computed expressions. GROUP BY without measures produces distinct groups. HAVING filters aggregated output. FILTER (WHERE predicate) limits the rows of a particular aggregate. Supported aggregates include count(*), count(DISTINCT expression), sum, sum0, avg, min, max, min_by, max_by, list_agg, list_union_distinct_agg, string_agg, and surrogate_key_int64. Plain count(column) is not implemented. sum/sum0/avg reject DISTINCT. list_agg, list_union_distinct_agg, and string_agg reject DISTINCT and aggregate ORDER BY/WITHIN GROUP ordering. They do not provide an input-arrival-order contract. Check the [expression catalog](https://koralium.github.io/flowtide/llms/expressions.txt) before choosing aggregate modifiers. ## Sets and top N UNION ALL preserves multiplicity; UNION/UNION DISTINCT deduplicate. EXCEPT and INTERSECT support ALL and DISTINCT variants. Align the projected columns across branches. The engine maintains multiplicities as inputs change. ```sql INSERT INTO output SELECT userkey FROM users UNION ALL SELECT userkey FROM orders; ``` TOP selects a maintained top N. Include ORDER BY and a stable tie-breaker for predictable membership: ```sql INSERT INTO output SELECT TOP (10) orderkey, amount FROM orders ORDER BY amount DESC, orderkey ASC; ``` ASC/DESC and NULLS FIRST/NULLS LAST are supported in tested ordering contexts. Treat result rows as a relation: ORDER BY used to select top N or to evaluate a window does not promise an ordered sequence of sink writes. Prefer the documented TOP form when generating code; do not assume another database's LIMIT/FETCH syntax. ## Analytic window functions Analytic functions keep the input rows and compute a value over a partition and optional row frame. The supported functions are sum, avg, row_number, lead, lag, last_value, min_by, max_by, surrogate_key_int64, and session_window. A grouped aggregate's existence does not imply the same function is registered for OVER. ```sql INSERT INTO output SELECT orderkey, userkey, sum(amount) OVER ( PARTITION BY userkey ORDER BY orderkey ROWS BETWEEN 4 PRECEDING AND CURRENT ROW ) AS rolling_total, row_number() OVER ( PARTITION BY userkey ORDER BY amount DESC, orderkey ) AS position FROM orders; ``` row_number() has no arguments and requires ORDER BY. lead/lag take a value, optional offset, and optional default; they also require ordering. last_value/min_by/max_by require ordering and support ROWS frames. sum/avg without ORDER BY cover the entire partition; with ordering and no explicit frame, they default to unbounded preceding through current row. Frame offsets are literal integers. Use explicit ROWS frames instead of assuming RANGE or GROUPS behavior. For the latest row per key, filter an analytic result through a derived table: ```sql INSERT INTO output SELECT orderkey, userkey, amount FROM ( SELECT orderkey, userkey, amount, row_number() OVER ( PARTITION BY userkey ORDER BY order_time DESC, orderkey DESC ) AS rn FROM orders ) ranked WHERE rn = 1; ``` ## Lists and table functions UNNEST expands a list to one row per element, or a map to key/value objects. An INNER JOIN drops inputs with no matching elements; a LEFT JOIN preserves them with a null element. The alias below names the returned element: ```sql INSERT INTO output SELECT u.userkey, tag FROM users u LEFT JOIN UNNEST(list(u.firstname, u.lastname)) tag; ``` Constant table functions can be queried directly, for example `SELECT value FROM UNNEST(list(1, 2, 3)) value`. ## Tumbling and hopping time windows These are table functions over typed timestamps. They add window_start (inclusive) and window_end (exclusive), and can be grouped afterward. They maintain changing results; assigning a row to a window does not by itself expire state or make the window immutable. ```sql INSERT INTO output SELECT window_start, window_end, count(*) AS order_count, sum(o.amount) AS total FROM orders o INNER JOIN tumbling_window(o.order_time, 10, 'MINUTE') GROUP BY window_start, window_end; ``` Replace the table function with `hopping_window(o.order_time, 5, 'MINUTE', 10, 'MINUTE')` for a 10-minute window every 5 minutes. A row may belong to multiple hopping windows. Amounts must be positive integer literals; units are WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, or MICROSECOND. MONTH/YEAR and fractional amounts are not supported. Starts align from year one; WEEK boundaries are Mondays. Null/non-timestamp inputs produce no windows; LEFT JOIN preserves such rows with null window columns. Hopping fanout above 100,000 windows per row is rejected. ## Session windows Sessions depend on neighboring rows, so session_window is an analytic function, not a table function. A gap greater than the configured duration starts a new session; a gap equal to the duration stays in the same session. An inserted event can merge sessions; deletion can split them. ```sql INSERT INTO output SELECT orderkey, userkey, session_window(30, 'MINUTE') OVER ( PARTITION BY userkey ORDER BY order_time ) AS session_start FROM orders; ``` Exactly one ascending timestamp ordering expression is required. Session windows have no explicit ROWS frame. Alternatively group directly by SESSION: ```sql INSERT INTO output SELECT userkey, count(*) AS order_count, session_start(order_time, 30, 'MINUTE') AS window_start, session_end(order_time, 30, 'MINUTE') AS window_end FROM orders GROUP BY userkey, SESSION(order_time, 30, 'MINUTE'); ``` Other group columns define the session partition. Only one SESSION expression is allowed per GROUP BY. window_start is available directly; session_start/session_end must match the grouping's timestamp and gap arguments. The end is the last event timestamp plus the gap. Units are the same fixed-duration units as tumbling/hopping windows. ## Recursive queries A self-referencing WITH query expresses recursive iteration. Use an anchor plus a recursive branch, and ensure the data/query converges. This hierarchy example assumes an acyclic manager relationship: ```sql WITH hierarchy AS ( SELECT userkey, managerkey, 1 AS depth FROM users WHERE managerkey IS NULL UNION ALL SELECT u.userkey, u.managerkey, h.depth + 1 AS depth FROM users u INNER JOIN hierarchy h ON u.managerkey = h.userkey ) INSERT INTO output SELECT userkey, managerkey, depth FROM hierarchy; ``` Changes are maintained through the iteration. Recursion cannot span distributed substreams. See [recursion](https://koralium.github.io/flowtide/docs/sql/recursion.md) and [iteration tests](https://github.com/koralium/flowtide/blob/main/tests/FlowtideDotNet.AcceptanceTests/IterationTests.cs). ## Manual distributed SQL (experimental) Prefer automatic distribution for ordinary queries. SUBSTREAM statements manually assign following statements to a named substream: ```sql SUBSTREAM first; CREATE VIEW shared WITH ( DISTRIBUTED = true, SCATTER_BY = userkey, PARTITION_COUNT = 2 ) AS SELECT userkey FROM users; INSERT INTO output SELECT userkey FROM shared WITH (PARTITION_ID = 0); SUBSTREAM second; INSERT INTO output SELECT userkey FROM shared WITH (PARTITION_ID = 1); ``` Once SUBSTREAM is used, every INSERT must be inside a substream. A distributed view read across substreams must declare SCATTER_BY. PARTITION_ID selects a partition; without it the consumer receives all partitions. This SQL needs a distributed host, not an ordinary single-stream setup. See [substream statements](https://koralium.github.io/flowtide/docs/distributed/sqlsubstreams.md). ## Source and behavior references - [SQL visitor](https://github.com/koralium/flowtide/blob/main/src/FlowtideDotNet.Substrait/Sql/Internal/SqlSubstraitVisitor.cs) - [SQL expression visitor](https://github.com/koralium/flowtide/blob/main/src/FlowtideDotNet.Substrait/Sql/SqlExpressionVisitor.cs) - [SQL planner tests](https://github.com/koralium/flowtide/tree/main/tests/FlowtideDotNet.Substrait.Tests) - [Acceptance tests](https://github.com/koralium/flowtide/tree/main/tests/FlowtideDotNet.AcceptanceTests): AggregateTests, JoinTests, SelectTests, SetTests, TopNTests, TableFunctionTests, WindowFunctionTests, TumblingWindowTests, HoppingWindowTests, SessionWindowTests, and IterationTests. --- Source: [expressions.txt](https://koralium.github.io/flowtide/llms/expressions.txt) # Flowtide expressions and functions This catalog describes SQL names implemented by the current repository. SQL names can differ from Substrait extension names. A Substrait specification defining a function does not imply Flowtide implements it. Functions available as aggregates are not automatically available with OVER, and table functions return rows rather than scalar values. `x`, `y`, and other identifiers below denote expressions. `...` denotes repeated arguments; `[argument]` denotes an optional argument in a signature, not literal SQL. Use the [SQL guide](https://koralium.github.io/flowtide/llms/sql.txt) for complete statements and the [stream guide](https://koralium.github.io/flowtide/llms/streams.txt) for C# integration. ## Values, nulls, and types Runtime values include null, booleans, integers, doubles, decimals, strings, binary data, timestamps, lists, maps, and fixed-schema structs. The planner can also describe date and nested types. Metadata type support and CAST support are separate. Use explicit casts when a function expects a particular runtime type; string inputs are not automatically timestamps. Ordinary comparisons with null can evaluate to null. WHERE keeps only true. AND/OR/NOT use three-valued logic; `IS DISTINCT FROM` and `IS NOT DISTINCT FROM` provide null-safe comparison. Numeric functions generally return null for incompatible inputs, while string and boolean helpers have their own behavior. Do not assume a single null/coercion rule applies to all functions. ## Operators and specialized expressions | SQL form | Purpose | | --- | --- | | x + y, x - y, x * y, x / y, x % y, -x | Numeric arithmetic and negation. Integer division returns a floating result. Decimal inputs use decimal arithmetic where supported. | | x = y, x <> y, x != y, x < y, x <= y, x > y, x >= y | Comparisons. | | x AND y, x OR y, x XOR y, NOT x | Boolean logic. | | x IS NULL, x IS NOT NULL | Null tests. | | x IS DISTINCT FROM y, x IS NOT DISTINCT FROM y | Null-safe inequality/equality. | | x BETWEEN lower AND upper | Inclusive range test. | | x IN (a, b, ...), x NOT IN (a, b, ...) | Membership using SQL null logic. | | EXISTS (query), NOT EXISTS (query), x IN (query), x NOT IN (query) | Supported filter-subquery predicates; see SQL guide. | | x LIKE pattern [ESCAPE character], x NOT LIKE pattern | SQL Server-style patterns: % is any sequence, _ is one character, [ab] is a character set. | | x \|\| y | String concatenation. Null propagates. | | CASE WHEN condition THEN value ... [ELSE value] END | Conditional expression; omitted ELSE yields null. Use the searched CASE form. | | CAST(x AS type) | Convert to STRING, BOOLEAN, INT/INTEGER/SMALLINT/TINYINT, DOUBLE/FLOAT, DECIMAL, or TIMESTAMP. Failed value conversions return null. | | object.field | Access a map or struct field, including nested fields. | | list(x, y, ...) | Construct a list. | | map(key, value, ...) | Construct a map from key/value pairs; keys are converted to strings. | | named_struct('field', value, ...) | Construct a fixed-schema struct; field names must be string literals. | | guid(string) | Parse/normalize a GUID; this is not random GUID generation. | Arithmetic can produce NaN or infinity for division by zero; decimal behavior must be checked separately. Use is_nan/is_finite/is_infinite when those values matter. Do not treat timestamp integer encodings as interchangeable: legacy strftime takes Unix microseconds, while integer-to-TIMESTAMP casting has its own tick conversion. Prefer typed TIMESTAMP values and timestamp_parse/timestamp_format. See [specialized expressions](https://koralium.github.io/flowtide/docs/expressions/specializedexpressions.md) and [cast tests](https://github.com/koralium/flowtide/blob/main/tests/FlowtideDotNet.AcceptanceTests/CastTests.cs). ## Choosing a function category Scalar functions return one value per input row. Aggregate functions maintain one result per group. Window functions use OVER (...) and preserve input rows. Table functions produce rows and belong in FROM or a supported JOIN. Use the generated reference below for exact function signatures and restrictions. Substrait extension names can differ from SQL names; use the SQL spelling in each heading. Details about SQL statements and stream setup remain in the SQL and stream guides. ## Function reference Names and examples use Flowtide SQL. Square brackets in signatures mark optional arguments; they are not literal SQL. Extension signatures, type declarations and required options describe Substrait bindings, not additional SQL arguments. The Flowtide notes and constraints apply to each listed profile. Aggregate, window and table functions are separate capabilities. ## Scalar functions and operators ### ` -x ` **Profile: i64** Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` negate:i64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64 ` - **Required Substrait option overflow:** ` SILENT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: fp64** Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` negate:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` NOT x ` SQL three-valued boolean negation. - **Extension signatures:** ` not:bool ` - **Extension source:** ` extension:io.substrait:functions_boolean ` - **Extension type declaration:** ` (boolean) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/boolean.html) ### ` abs(x) ` **Profile: i64** Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` abs:i64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64 ` - **Required Substrait option overflow:** ` ERROR ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: fp64** Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` abs:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` acos(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` acos:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` acosh(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` acosh:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` asin(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` asin:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` asinh(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` asinh:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` atan(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` atan:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` atan2(y, x) ` Numeric binary operation; mixed numeric inputs are handled dynamically. Decimal and non-decimal results can differ. - **Extension signatures:** ` atan2:fp64_fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64, fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` atanh(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` atanh:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` ceil(x) ` The native double implementation converts the rounded value through Int64. Restrict inputs to finite values whose rounded result fits Int64; infinities and out-of-range values do not have the upstream behavior. - **Extension signatures:** ` ceil:fp64 ` - **Extension source:** ` extension:io.substrait:functions_rounding ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Sql aliases:** ` [ceiling] ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/rounding.html) ### ` check_true(condition, 'message' [, tags...]) ` Planner intrinsic extracted into check relations. Returns true only for boolean true; only boolean false raises an issue. Message must be a string literal. Include a row key in tags for one issue per failing row. - **Extension signatures:** ` check_true:bool_str, check_true:bool_str_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:check ` - **Extension type declaration:** ` (boolean, string) -> boolean; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (boolean, string, any) -> boolean; nullability=DECLARED_OUTPUT ` - **Variadic arguments:** ` min=2 ` - **Literal arguments:** ` [1] ` - **Requires optimizer pass:** ` CheckExtractor ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/check.html) ### ` check_value(value, condition, 'message' [, tags...]) ` Planner intrinsic extracted into check relations. Returns value while recording boolean-false failures; null/non-boolean conditions do not raise an issue. Message must be a string literal. Named tags use key => expression. - **Extension signatures:** ` check_value:any_bool_str, check_value:any_bool_str_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:check ` - **Extension type declaration:** ` (any1, boolean, string) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, boolean, string, any) -> any1?; nullability=DECLARED_OUTPUT ` - **Variadic arguments:** ` min=3 ` - **Literal arguments:** ` [2] ` - **Requires optimizer pass:** ` CheckExtractor ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/check.html) ### ` coalesce(x, ...) ` First non-null argument. - **Extension signatures:** ` coalesce:any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1) -> any1 ` - **Variadic arguments:** ` min=2 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` concat(x, y, ...) ` **Profile: str** Null propagates. Also exposed as the SQL || operator. - **Extension signatures:** ` concat:str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string) -> string ` - **Required Substrait option null_handling:** ` ACCEPT_NULLS ` - **Variadic arguments:** ` min=1 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str** Null propagates. Also exposed as the SQL || operator. - **Extension signatures:** ` concat:str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string) -> string ` - **Required Substrait option null_handling:** ` IGNORE_NULLS ` - **Variadic arguments:** ` min=1 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` cos(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` cos:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` cosh(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` cosh:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` datediff(component, start, end) ` Count crossed component boundaries. - **Extension signatures:** ` datediff:str_ptstz_ptstz ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (string, precision_timestamp_tz<7>, precision_timestamp_tz<7>) -> i64?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` degrees(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` degrees:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` exp(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` exp:i64, exp:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` floor(x) ` The native double implementation converts the rounded value through Int64. Restrict inputs to finite values whose rounded result fits Int64; infinities and out-of-range values do not have the upstream behavior. - **Extension signatures:** ` floor:fp64 ` - **Extension source:** ` extension:io.substrait:functions_rounding ` - **Extension type declaration:** ` (fp64) -> fp64 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/rounding.html) ### ` floor_timestamp_day(timestamp) ` Remove the time-of-day component; incompatible values return null. - **Extension signatures:** ` floor_timestamp_day:ptstz ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz<7>) -> precision_timestamp_tz?<7>; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` from_json(json) ` **Profile: str, vbin** Parse JSON text or UTF-8 binary into dynamic Flowtide values. - **Extension signatures:** ` from_json:str, from_json:vbin ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (binary) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str, vbin** Parse JSON text or UTF-8 binary into dynamic Flowtide values. - **Extension signatures:** ` from_json:str, from_json:vbin ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (binary) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Required Substrait option error_handling:** ` ERROR ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` gettimestamp() ` Planner intrinsic: optimizer replaces the call with a periodically updated timestamp source and joins. Default update interval is one hour; configure SetGetTimestampUpdateInterval. Not supported inside join conditions. - **Extension signatures:** ` gettimestamp: ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` () -> precision_timestamp_tz<7>; nullability=DECLARED_OUTPUT ` - **Requires optimizer pass:** ` TimestampToJoin ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` greatest(x, y, ...) ` Greatest value; a null argument propagates null. Requires at least two arguments. - **Extension signatures:** ` greatest:any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1) -> any1; nullability=MIRROR ` - **Variadic arguments:** ` min=2 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` guid(string) ` Parse a GUID string into its 16-byte .NET GUID representation. Invalid input returns null; this does not generate random GUIDs. - **Extension signatures:** ` parse_guid:str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_guid ` - **Extension type declaration:** ` (string) -> binary?; nullability=DECLARED_OUTPUT ` ### ` is_finite(x) ` Test for a special numeric value. - **Extension signatures:** ` is_finite:fp64 ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (fp64) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` is_infinite(x) ` Test for a special numeric value. - **Extension signatures:** ` is_infinite:fp64 ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (fp64) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` is_nan(x) ` Test for a special numeric value. - **Extension signatures:** ` is_nan:fp64 ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (fp64) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` len(string) ` Counts Unicode text elements (grapheme clusters) using .NET StringInfo. The SQL spelling is len. - **Extension signatures:** ` char_length:str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string) -> i64 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` list_first_difference(first, second) ` First differing element of the first list, or null if none differs. - **Extension signatures:** ` list_first_difference:list_list ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_list ` - **Extension type declaration:** ` (list, list) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/list.html) ### ` list_sort_asc_null_last(list) ` Sort ascending with nulls last. Non-list input returns null. - **Extension signatures:** ` list_sort_asc_null_last:list ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_list ` - **Extension type declaration:** ` (list) -> list?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/list.html) ### ` log10(x) ` **Profile: i64, fp64** These are the implemented upstream option values. The runtime default on_domain_error=NONE returns null; explicit NULL is not declared because its behavior differs. Only the native rounding policy is available. - **Extension signatures:** ` log10:i64, log10:fp64 ` - **Extension source:** ` extension:io.substrait:functions_logarithmic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option on_log_zero:** ` NAN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/logarithmic.html) **Profile: i64, fp64** These are the implemented upstream option values. The runtime default on_domain_error=NONE returns null; explicit NULL is not declared because its behavior differs. Only the native rounding policy is available. - **Extension signatures:** ` log10:i64, log10:fp64 ` - **Extension source:** ` extension:io.substrait:functions_logarithmic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option on_log_zero:** ` ERROR ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/logarithmic.html) **Profile: i64, fp64** These are the implemented upstream option values. The runtime default on_domain_error=NONE returns null; explicit NULL is not declared because its behavior differs. Only the native rounding policy is available. - **Extension signatures:** ` log10:i64, log10:fp64 ` - **Extension source:** ` extension:io.substrait:functions_logarithmic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option on_log_zero:** ` MINUS_INFINITY ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/logarithmic.html) **Profile: i64, fp64** These are the implemented upstream option values. The runtime default on_domain_error=NONE returns null; explicit NULL is not declared because its behavior differs. Only the native rounding policy is available. - **Extension signatures:** ` log10:i64, log10:fp64 ` - **Extension source:** ` extension:io.substrait:functions_logarithmic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` ERROR ` - **Required Substrait option on_log_zero:** ` NAN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/logarithmic.html) **Profile: i64, fp64** These are the implemented upstream option values. The runtime default on_domain_error=NONE returns null; explicit NULL is not declared because its behavior differs. Only the native rounding policy is available. - **Extension signatures:** ` log10:i64, log10:fp64 ` - **Extension source:** ` extension:io.substrait:functions_logarithmic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` ERROR ` - **Required Substrait option on_log_zero:** ` ERROR ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/logarithmic.html) **Profile: i64, fp64** These are the implemented upstream option values. The runtime default on_domain_error=NONE returns null; explicit NULL is not declared because its behavior differs. Only the native rounding policy is available. - **Extension signatures:** ` log10:i64, log10:fp64 ` - **Extension source:** ` extension:io.substrait:functions_logarithmic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` ERROR ` - **Required Substrait option on_log_zero:** ` MINUS_INFINITY ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/logarithmic.html) ### ` lower(string) ` String operation; incompatible input kinds generally yield null. - **Extension signatures:** ` lower:str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string) -> string ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` ltrim(string) ` **Profile: str_str** The native Substrait binding supports an explicit character set as the second argument. Flowtide also has a one-argument whitespace-trimming overload, declared separately in its scalar extension. - **Extension signatures:** ` ltrim:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> string ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str** One-argument whitespace trimming. The standard upstream implementation takes an explicit second character-set argument. - **Extension signatures:** ` ltrim:str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` named_struct('field', value, ...) ` named_struct alternates string-literal field names and values, with an even argument count. The schema cannot express repeating heterogeneous pairs; any plus this argument-pattern restriction describes the native variadic binding. - **Extension signatures:** ` create:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:struct ` - **Extension type declaration:** ` (any) -> flowtide_types.u!dynamic; nullability=DECLARED_OUTPUT ` - **Variadic arguments:** ` min=2 ` ### ` nullif(x, y) ` Return null when equal; otherwise return x. - **Extension signatures:** ` nullif:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> any1?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` power(x, y) ` Numeric binary operation; mixed numeric inputs are handled dynamically. Decimal and non-decimal results can differ. - **Extension signatures:** ` power:fp64_fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64, fp64) -> fp64 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` radians(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` radians:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` regexp_string_split(string, pattern) ` Case-sensitive .NET regular expression splitting with explicit capture. Multiline and dotall modes are disabled; other mode options are not declared. - **Extension signatures:** ` regexp_string_split:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> List ` - **Required Substrait option case_sensitivity:** ` CASE_SENSITIVE ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` replace(string, old, replacement) ` String operation; incompatible input kinds generally yield null. - **Extension signatures:** ` replace:str_str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string, string) -> string ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` round(x) ` One-argument rounding with ties to even, unlike upstream round(value, scale). Double results pass through Int64: use finite inputs with an Int64-representable rounded value. Decimal arithmetic uses System.Decimal (conservatively at most 28 digits). - **Extension signatures:** ` round:i64, round:fp64, round:dec ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_rounding ` - **Extension type declaration:** ` (i64) -> i64?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (decimal) -> decimal?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/rounding.html) ### ` round_calendar(timestamp, operation, component, reference, step) ` Flowtide uses positional string-valued components/operations rather than upstream required enum arguments. Calendar-aligned rounding, for example round_calendar(ts, 'FLOOR', 'MONTH', 'YEAR', 1). - **Extension signatures:** ` round_calendar:ptstz_str_str_str_i64 ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz<7>, string, string, string, i64) -> precision_timestamp_tz?<7>; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` rtrim(string) ` **Profile: str_str** The native Substrait binding supports an explicit character set as the second argument. Flowtide also has a one-argument whitespace-trimming overload, declared separately in its scalar extension. - **Extension signatures:** ` rtrim:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> string ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str** One-argument whitespace trimming. The standard upstream implementation takes an explicit second character-set argument. - **Extension signatures:** ` rtrim:str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` sign(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` sign:i64, sign:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` sin(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` sin:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` sinh(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` sinh:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` sqrt(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` sqrt:i64, sqrt:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> fp64 ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option on_domain_error:** ` NAN ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` starts_with(string, prefix) ` **Profile: str_str** Prefix test; incompatible runtime input kinds return false. - **Extension signatures:** ` starts_with:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> boolean ` - **Required Substrait option case_sensitivity:** ` CASE_SENSITIVE ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str_str** Prefix test; incompatible runtime input kinds return false. - **Extension signatures:** ` starts_with:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> boolean ` - **Required Substrait option case_sensitivity:** ` CASE_INSENSITIVE ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` strftime(unix_microseconds, format) ` Legacy integer Unix-microseconds input, unlike upstream typed-date/time overloads. Use timestamp_format for typed timestamps. - **Extension signatures:** ` strftime:i64_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (i64, string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` string LIKE pattern [ESCAPE character] ` **Profile: str_str** Case-sensitive LIKE. The native runtime also accepts an explicit escape argument and SQL Server-style bracket patterns; the three-argument form is declared in the Flowtide scalar extension. - **Extension signatures:** ` like:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> boolean ` - **Required Substrait option case_sensitivity:** ` CASE_SENSITIVE ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str_str_str** Three-argument LIKE with an explicit escape character. SQL Server-style %/_/bracket patterns are supported. Matching is case-sensitive. - **Extension signatures:** ` like:str_str_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string, string, string) -> boolean?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` string_base64_decode(string) ` Base64 conversion of UTF-8 text. Invalid Base64 input returns null. - **Extension signatures:** ` string_base64_decode:str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` string_base64_encode(string) ` Base64 conversion of UTF-8 text. Invalid Base64 input returns null. - **Extension signatures:** ` string_base64_encode:str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` string_join(separator, list) ` Separator is the first argument. Null list returns null; empty/all-null list returns an empty string; null elements are skipped. - **Extension signatures:** ` string_join:str_list ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string, list) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` string_split(string, separator) ` String operation; incompatible input kinds generally yield null. - **Extension signatures:** ` string_split:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> List ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` strpos(string, substring) ` **Profile: str_str** One-based position, or zero if the substring is absent. - **Extension signatures:** ` strpos:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> i64 ` - **Required Substrait option case_sensitivity:** ` CASE_SENSITIVE ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str_str** One-based position, or zero if the substring is absent. - **Extension signatures:** ` strpos:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> i64 ` - **Required Substrait option case_sensitivity:** ` CASE_INSENSITIVE ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` substring(string, start [, length]) ` **Profile: str_i32, str_i32_i32** Positions are one-based. LEFT_OF_BEGINNING is declared only with an explicit length: the native two-argument overload fails for that mode. - **Extension signatures:** ` substring:str_i32, substring:str_i32_i32 ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, i32, i32) -> string ` - **Extension type declaration:** ` (string, i32) -> string ` - **Required Substrait option negative_start:** ` WRAP_FROM_END ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str_i32_i32** Positions are one-based. LEFT_OF_BEGINNING is declared only with an explicit length: the native two-argument overload fails for that mode. - **Extension signatures:** ` substring:str_i32_i32 ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, i32, i32) -> string ` - **Required Substrait option negative_start:** ` LEFT_OF_BEGINNING ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` tan(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` tan:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` tanh(x) ` Numeric operation. Runtime numeric values use Int64, Double or Decimal; unsupported value kinds yield null. Trigonometric angles use radians. - **Extension signatures:** ` tanh:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` timestamp_add(component, amount, timestamp) ` Add YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND or MICROSECOND. - **Extension signatures:** ` timestamp_add:str_i64_ptstz ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (string, i64, precision_timestamp_tz<7>) -> precision_timestamp_tz?<7>; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` timestamp_extract(component, timestamp) ` Flowtide uses positional string-valued components/operations rather than upstream required enum arguments. Component is a string such as YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or ISO_WEEK; SQL names differ from runtime names. - **Extension signatures:** ` extract:str_ptstz ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (string, precision_timestamp_tz<7>) -> i64?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` timestamp_format(timestamp, format) ` Format typed timestamps with .NET date/time format strings. - **Extension signatures:** ` format:ptstz_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz<7>, string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` timestamp_parse(string, format) ` Parse typed timestamps with .NET date/time format strings, for example yyyy-MM-dd HH:mm:ss. - **Extension signatures:** ` parse_timestamp:str_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (string, string) -> precision_timestamp_tz?<7>; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/datetime.html) ### ` to_json(value) ` Serialize a Flowtide value to JSON text. - **Extension signatures:** ` to_json:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (any) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` to_string(value) ` String operation; incompatible input kinds generally yield null. - **Extension signatures:** ` to_string:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (any) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` trim(string) ` **Profile: str_str** The native Substrait binding supports an explicit character set as the second argument. Flowtide also has a one-argument whitespace-trimming overload, declared separately in its scalar extension. - **Extension signatures:** ` trim:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string) -> string ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) **Profile: str** One-argument whitespace trimming. The standard upstream implementation takes an explicit second character-set argument. - **Extension signatures:** ` trim:str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_string ` - **Extension type declaration:** ` (string) -> string?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` upper(string) ` String operation; incompatible input kinds generally yield null. - **Extension signatures:** ` upper:str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string) -> string ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/string.html) ### ` x % y ` **Profile: i64_i64** Integer remainder with the sign of the dividend. A zero divisor returns null, including for non-null inputs. Null inputs return null. Int64 overflow throws. FLOOR division and other error/overflow policies are not implemented. SQL uses this standard binding when both declared operands are integer types. - **Extension signatures:** ` modulus:i64_i64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64, i64) -> i64 ` - **Required Substrait option division_type:** ` TRUNCATE ` - **Required Substrait option on_domain_error:** ` NULL ` - **Required Substrait option overflow:** ` ERROR ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: dec_dec** Decimal remainder for two declared DECIMAL(P,S) operands with precision at most 28 and valid scales. The result scale is max(S1,S2) and its precision is min(P1-S1,P2-S2)+max(S1,S2), matching the upstream formula within this supported input range. Null inputs return null; decimal division by zero and overflow throw. SQL selects this standard binding when both input precisions and scales are known. Decimal casts currently do not retain these parameters and use the Flowtide profile instead. - **Extension signatures:** ` modulus:dec_dec ` - **Extension source:** ` extension:io.substrait:functions_arithmetic_decimal ` - **Extension type declaration:** ` (decimal, decimal) -> init_scale = max(S1,S2) init_prec = min(P1 - S1, P2 - S2) + init_scale min_scale = min(init_scale, 6) delta = init_prec - 38 prec = min(init_prec, 38) scale_after_borrow = max(init_scale - delta, min_scale) scale = init_prec > 38 ? scale_after_borrow : init_scale DECIMAL ` - **Required Substrait option overflow:** ` ERROR ` - **Decimal precision max:** ` 28 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: fp64_fp64, any_any** Remainder for floating-point, mixed numeric or unresolved decimal/dynamic inputs. Floating-point division by zero produces NaN. Integer values with a zero divisor return null. Decimal arithmetic uses System.Decimal; decimal division by zero and overflow throw. Unsupported value kinds return null. Typed integer SQL operands use the standard arithmetic extension instead; resolved decimal pairs use the standard decimal extension. - **Extension signatures:** ` modulus:fp64_fp64, modulus:any_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, any2) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64, fp64) -> fp64?; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` x * y ` **Profile: i64_i64** Int64 arithmetic wraps on overflow. Narrow integer and FP32 overloads are not declared because the runtime widens those values. - **Extension signatures:** ` multiply:i64_i64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64, i64) -> i64 ` - **Required Substrait option overflow:** ` SILENT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: fp64_fp64** Double arithmetic with the runtime IEEE-754 rounding policy. Other rounding modes are not implemented. - **Extension signatures:** ` multiply:fp64_fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64, fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` x + y ` **Profile: i64_i64** Int64 arithmetic wraps on overflow. Narrow integer and FP32 overloads are not declared because the runtime widens those values. - **Extension signatures:** ` add:i64_i64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64, i64) -> i64 ` - **Required Substrait option overflow:** ` SILENT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: fp64_fp64** Double arithmetic with the runtime IEEE-754 rounding policy. Other rounding modes are not implemented. - **Extension signatures:** ` add:fp64_fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64, fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` x - y ` **Profile: i64_i64** Int64 arithmetic wraps on overflow. Narrow integer and FP32 overloads are not declared because the runtime widens those values. - **Extension signatures:** ` subtract:i64_i64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64, i64) -> i64 ` - **Required Substrait option overflow:** ` SILENT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) **Profile: fp64_fp64** Double arithmetic with the runtime IEEE-754 rounding policy. Other rounding modes are not implemented. - **Extension signatures:** ` subtract:fp64_fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64, fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` x / y ` Floating division. Integer inputs also produce a floating result in Flowtide, so the upstream integer-returning divide overload is not declared here. Division by zero follows runtime floating-point behavior. - **Extension signatures:** ` divide:fp64_fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64, fp64) -> fp64 ` - **Required Substrait option rounding:** ` TIE_TO_EVEN ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/arithmetic.html) ### ` x < y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` lt:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x <= y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` lte:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x <> y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` not_equal:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x = y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` equal:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x > y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` gt:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x >= y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` gte:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x AND y ` Variadic SQL three-valued logic. Zero arguments yield true for AND and false for OR; the upstream implementation permits an empty argument list. - **Extension signatures:** ` and:bool ` - **Extension source:** ` extension:io.substrait:functions_boolean ` - **Extension type declaration:** ` (boolean) -> boolean ` - **Variadic arguments:** ` ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/boolean.html) ### ` x BETWEEN lower AND upper ` Inclusive range test using SQL null semantics. - **Extension signatures:** ` between:any_any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1, any1) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x IS DISTINCT FROM y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` is_distinct_from:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x IS NOT DISTINCT FROM y ` Comparison over runtime values. IS DISTINCT FROM and IS NOT DISTINCT FROM provide null-safe comparisons; ordinary comparisons can return null. - **Extension signatures:** ` is_not_distinct_from:any_any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1, any1) -> boolean; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x IS NOT NULL ` Null test returning a boolean. - **Extension signatures:** ` is_not_null:any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1) -> boolean; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x IS NULL ` Null test returning a boolean. - **Extension signatures:** ` is_null:any ` - **Extension source:** ` extension:io.substrait:functions_comparison ` - **Extension type declaration:** ` (any1) -> boolean; nullability=DECLARED_OUTPUT ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/comparison.html) ### ` x OR y ` Variadic SQL three-valued logic. Zero arguments yield true for AND and false for OR; the upstream implementation permits an empty argument list. - **Extension signatures:** ` or:bool ` - **Extension source:** ` extension:io.substrait:functions_boolean ` - **Extension type declaration:** ` (boolean) -> boolean ` - **Variadic arguments:** ` ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/boolean.html) ### ` x XOR y ` Boolean exclusive OR. - **Extension signatures:** ` xor:bool_bool ` - **Extension source:** ` extension:io.substrait:functions_boolean ` - **Extension type declaration:** ` (boolean, boolean) -> boolean ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/boolean.html) ### ` xxhash128_guid_string(value, ...) ` Non-cryptographic hash over one or more values. xxhash64 returns signed Int64; xxhash128_guid_string returns a GUID-formatted string. - **Extension signatures:** ` xxhash128_guid_string:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_hash ` - **Extension type declaration:** ` (any) -> string; nullability=DECLARED_OUTPUT ` - **Variadic arguments:** ` min=1 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/hash.html) ### ` xxhash64(value, ...) ` Non-cryptographic hash over one or more values. xxhash64 returns signed Int64; xxhash128_guid_string returns a GUID-formatted string. - **Extension signatures:** ` xxhash64:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_hash ` - **Extension type declaration:** ` (any) -> i64; nullability=DECLARED_OUTPUT ` - **Variadic arguments:** ` min=1 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/scalarfunctions/hash.html) ## Aggregate functions ### ` COUNT(*) ` The zero-argument binding counts rows. The one-argument native binding counts non-null values, but ordinary SQL COUNT(x) is currently rejected by the SQL planner; SQL accepts COUNT(*) and COUNT(DISTINCT x). Empty input returns Int64 zero. The DISTINCT form uses the separate count_distinct binding. - **Extension signatures:** ` count:any, count: ` - **Extension source:** ` extension:io.substrait:functions_aggregate_generic ` - **Extension type declaration:** ` (any) -> i64; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` () -> i64; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql count expression:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/generic.html) ### ` COUNT(DISTINCT x) ` Counts distinct non-null values; empty/all-null groups return Int64 zero. This is an exact stateful aggregate with one expression argument, not an approximate distinct count. - **Extension signatures:** ` count_distinct:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_aggregate_generic ` - **Extension type declaration:** ` (any) -> i64; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/generic.html) ### ` avg(x) ` **Profile: fp64** FP64 average ignores null values and returns null for empty/all-null groups. Integer and decimal results differ from their upstream overloads and are declared separately. SQL DISTINCT is rejected. - **Extension signatures:** ` avg:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: i64** Integer average returns a fractional Double; the average of values 1 and 2 is 1.5, instead of truncating to an integer as upstream does. The Int64 sum wraps on overflow before division. Nulls are ignored; empty/all-null groups return null. SQL DISTINCT is rejected. - **Extension signatures:** ` avg:i64 ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: dec** Returns System.Decimal with runtime-computed scale, not the upstream fixed-scale Decimal<38,S>. The opaque result describes the dynamic scale; the actual non-null result kind is decimal. Decimal overflow throws. Use precision at most 28. Nulls are ignored; empty/all-null groups return null. SQL DISTINCT is rejected. - **Extension signatures:** ` avg:dec ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (decimal) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` ERROR ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Decimal precision max:** ` 28 ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: any** Dynamically typed numeric average for any inputs. Integer values produce a fractional Double; decimal values use System.Decimal. Empty/all-null input returns null. Int64 overflow wraps; decimal overflow throws. Null and incompatible inputs are ignored. - **Extension signatures:** ` avg:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` list_agg(x) ` Collects non-null values with weighted duplicates, in ascending Flowtide value order. Empty/all-null groups return an empty list. Aggregate ORDER BY and SQL DISTINCT are rejected. - **Extension signatures:** ` list_agg:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_list ` - **Extension type declaration:** ` (any1) -> list; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` - **Supports order by:** ` false ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/list.html) ### ` list_union_distinct_agg(x) ` Flattens lists and returns distinct elements in ascending Flowtide value order. Null lists are ignored; null elements inside lists are retained once. Empty input returns an empty list. Aggregate ORDER BY and SQL DISTINCT are rejected; deduplication is intrinsic to this function. - **Extension signatures:** ` list_union_distinct_agg:list ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_list ` - **Extension type declaration:** ` (list) -> list; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` - **Supports order by:** ` false ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/list.html) ### ` max(x) ` **Profile: i64, fp64** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. - **Extension signatures:** ` max:i64, max:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: dec** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. - **Extension signatures:** ` max:dec ` - **Extension source:** ` extension:io.substrait:functions_arithmetic_decimal ` - **Extension type declaration:** ` (DECIMAL) -> DECIMAL?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Decimal precision max:** ` 28 ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: ptstz** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. Timestamp values are compared by UTC ticks and retain the chosen value's offset. The runtime uses the standard datetime extension URN for this timestamp profile. - **Extension signatures:** ` max:ptstz ` - **Extension source:** ` extension:io.substrait:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz

) -> precision_timestamp_tz?

; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` - **Timestamp precision:** ` 7 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: any** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. Generic overload for strings, booleans, binary and nested values. Prefer the matching upstream numeric/timestamp signatures above when applicable. - **Extension signatures:** ` max:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` max_by(x, y) ` Returns x at the maximum y; rows with null y are ignored, while the selected x may be null. Empty groups, or groups containing only null y, return null. Do not depend on which row wins tied y. - **Extension signatures:** ` max_by:any_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, any2) -> any1?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` min(x) ` **Profile: i64, fp64** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. - **Extension signatures:** ` min:i64, min:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: dec** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. - **Extension signatures:** ` min:dec ` - **Extension source:** ` extension:io.substrait:functions_arithmetic_decimal ` - **Extension type declaration:** ` (DECIMAL) -> DECIMAL?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Decimal precision max:** ` 28 ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: ptstz** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. Timestamp values are compared by UTC ticks and retain the chosen value's offset. The runtime uses the standard datetime extension URN for this timestamp profile. - **Extension signatures:** ` min:ptstz ` - **Extension source:** ` extension:io.substrait:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz

) -> precision_timestamp_tz?

; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` - **Timestamp precision:** ` 7 ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: any** Ignores null values and returns null for empty/all-null groups. SQL DISTINCT is accepted as a semantic no-op. Native comparison uses Flowtide value ordering. Generic overload for strings, booleans, binary and nested values. Prefer the matching upstream numeric/timestamp signatures above when applicable. - **Extension signatures:** ` min:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` true ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` min_by(x, y) ` Returns x at the minimum y; rows with null y are ignored, while the selected x may be null. Empty groups, or groups containing only null y, return null. Do not depend on which row wins tied y. - **Extension signatures:** ` min_by:any_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, any2) -> any1?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` string_agg(x, separator) ` The separator must be a string literal. Null input values are ignored; values are concatenated in ascending Flowtide string order, retaining duplicates. No contributing values yield null. The current implementation also yields null if all strings and the separator are empty. User-supplied aggregate ORDER BY and SQL DISTINCT are rejected. - **Extension signatures:** ` string_agg:str_str ` - **Extension source:** ` extension:io.substrait:functions_string ` - **Extension type declaration:** ` (string, string (constant)) -> string ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Literal arguments:** ` [1] ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` - **Supports order by:** ` false ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/string.html) ### ` sum(x) ` **Profile: i64, fp64** Ignores null values and returns null for empty/all-null groups. Int64 accumulation wraps on overflow; FP64 accumulation uses IEEE arithmetic. Narrow integers and FP32 are widened internally; the declarations here use native I64/FP64 value kinds. SQL DISTINCT is rejected. - **Extension signatures:** ` sum:i64, sum:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: dec** Uses System.Decimal rather than the upstream Decimal<38,S> accumulator. Use precision at most 28 and require every intermediate and final sum to fit Decimal<28,S>; CLR decimal overflow throws. Null input values are ignored. Empty/all-null groups return null. SQL DISTINCT is rejected. - **Extension signatures:** ` sum:dec ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (decimal) -> decimal?<28,S>; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` ERROR ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Decimal precision max:** ` 28 ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: any** Dynamically typed numeric sum for any inputs. The runtime selects Int64, Double or System.Decimal; empty/all-null input returns null. Int64 overflow wraps; decimal overflow throws. Null and incompatible inputs are ignored. - **Extension signatures:** ` sum:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` sum0(x) ` **Profile: i64, fp64** Ignores null values and returns a zero matching the declared output type for empty/all-null groups. Int64 accumulation wraps on overflow; FP64 accumulation uses IEEE arithmetic. Narrow integers and FP32 are widened internally; the declarations here use native I64/FP64 value kinds. Set AggregateFunction.output_type for a correctly typed empty-group zero. SQL DISTINCT is rejected. - **Extension signatures:** ` sum0:i64, sum0:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64) -> fp64; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: dec** Uses System.Decimal rather than the upstream Decimal<38,S> accumulator. Use precision at most 28 and require every intermediate and final sum to fit Decimal<28,S>; CLR decimal overflow throws. Null input values are ignored. Empty/all-null groups return a zero matching the declared output type. Set AggregateFunction.output_type to the decimal result type. SQL DISTINCT is rejected. - **Extension signatures:** ` sum0:dec ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (decimal) -> decimal<28,S>; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` ERROR ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Decimal precision max:** ` 28 ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) **Profile: any** Dynamically typed numeric sum for any inputs. The runtime selects Int64, Double or System.Decimal; empty/all-null input returns zero. Int64 overflow wraps; decimal overflow throws. Null and incompatible inputs are ignored. - **Extension signatures:** ` sum0:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any) -> flowtide_types.u!dynamic; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Sql distinct:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/arithmetic.html) ### ` surrogate_key_int64() ` Assigns a stateful counter key per group, stable while the group exists and across checkpoint restore. Keys are operator-scoped; deleting and recreating a group can assign a new key. Empty global input also receives a key. - **Extension signatures:** ` surrogate_key_int64: ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_aggregate_generic ` - **Extension type declaration:** ` () -> i64; nullability=DECLARED_OUTPUT ` - **Aggregation phase:** ` INITIAL_TO_RESULT ` - **Deterministic:** ` false ` - **Supports filter:** ` true ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/aggregatefunctions/generic.html) ## Window functions ### ` avg(x) OVER (...) ` **Profile: fp64** Null input values are ignored; empty/all-null frames return null. Without ORDER BY, SQL uses the whole partition. With ORDER BY and no explicit frame, SQL uses ROWS UNBOUNDED PRECEDING through CURRENT ROW, including only rows through this physical row rather than all equal-order peers. Explicit ROWS bounds support preceding/following/current/unbounded endpoints. RANGE, GROUPS and dynamic frame-bound expressions are not implemented. Uses the aggregate definition as a window function. - **Extension signatures:** ` avg:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT avg(x) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) **Profile: i64** Null input values are ignored; empty/all-null frames return null. Without ORDER BY, SQL uses the whole partition. With ORDER BY and no explicit frame, SQL uses ROWS UNBOUNDED PRECEDING through CURRENT ROW, including only rows through this physical row rather than all equal-order peers. Explicit ROWS bounds support preceding/following/current/unbounded endpoints. RANGE, GROUPS and dynamic frame-bound expressions are not implemented. Uses the aggregate definition as a window function. Integer average returns a fractional Double, rather than the upstream truncated integer. Its Int64 sum wraps before division. - **Extension signatures:** ` avg:i64 ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT avg(x) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) **Profile: dec** Null input values are ignored; empty/all-null frames return null. Without ORDER BY, SQL uses the whole partition. With ORDER BY and no explicit frame, SQL uses ROWS UNBOUNDED PRECEDING through CURRENT ROW, including only rows through this physical row rather than all equal-order peers. Explicit ROWS bounds support preceding/following/current/unbounded endpoints. RANGE, GROUPS and dynamic frame-bound expressions are not implemented. Uses the aggregate definition as a window function. Decimal arithmetic uses System.Decimal at precision at most 28; CLR decimal overflow throws. Average returns a decimal with runtime-computed scale, represented by the shared opaque result type. - **Extension signatures:** ` avg:dec ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (decimal) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` ERROR ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Decimal precision max:** ` 28 ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT avg(x) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) **Profile: any** Dynamically typed numeric avg for any inputs. The runtime chooses the numeric value kind from input values. Null and incompatible inputs are ignored; empty/all-null frames return null. Explicit ROWS frames use integer literal bounds. Without ORDER BY the whole partition is used; otherwise the default frame ends at the current row. RANGE, GROUPS, FILTER and DISTINCT are unsupported. - **Extension signatures:** ` avg:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` lag(x [, offset [, default]]) OVER (...) ` Return x from a preceding row in the same partition, defaulting to offset 1. Negative offsets reverse direction and zero selects the current row. A missing target yields the provided default, evaluated on the current row, or null when omitted. Null target values are respected. SQL requires ORDER BY and rejects ROWS frames; IGNORE NULLS is not implemented. These upstream signatures apply when any explicit offset is non-null and fits Int32, and the default has the same type as x. A null offset has different native behavior, described below. - **Extension signatures:** ` lag:any, lag:any_i32, lag:any_i32_any ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, i32) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, i32, any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Default same type as value:** ` true ` - **Explicit offset must be non null:** ` true ` - **Frame types:** ` [] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT lag(x, 2, x) OVER (PARTITION BY p ORDER BY o) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` lag(x, offset [, default]) OVER (...) ` Return x from a preceding row in the same partition, defaulting to offset 1. Negative offsets reverse direction and zero selects the current row. A missing target yields the provided default, evaluated on the current row, or null when omitted. Null target values are respected. SQL requires ORDER BY and rejects ROWS frames; IGNORE NULLS is not implemented. Native offsets are Int64 and may be expressions. A null offset is treated as 1, unlike upstream. The default can have a different value kind; that overload has an opaque/dynamic result. - **Extension signatures:** ` lag:any_i64, lag:any_i64_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, i64) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, i64, any2) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Frame types:** ` [] ` - **Offset null behavior:** ` USE_ONE ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT lag(x, 2, x) OVER (PARTITION BY p ORDER BY o) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` last_value(x) IGNORE NULLS OVER (...) ` Skip null values when finding the last value in the ROWS frame. Empty/all-null frames return null. SQL requires ORDER BY; the default frame ends at CURRENT ROW. The native option key is case-sensitive NULL_TREATMENT with value IGNORE_NULLS. - **Extension signatures:** ` last_value:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Required Substrait option NULL_TREATMENT:** ` IGNORE_NULLS ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT last_value(x) IGNORE NULLS OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` last_value(x) OVER (...) ` Return the value at the last row of the ROWS frame, including null. An empty frame returns null. SQL requires ORDER BY; the default frame ends at CURRENT ROW. Use UNBOUNDED FOLLOWING explicitly for the last value in the entire partition. IGNORE NULLS uses the Flowtide option overload below. - **Extension signatures:** ` last_value:any ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (any1) -> any1; nullability=DECLARED_OUTPUT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT last_value(x) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` lead(x [, offset [, default]]) OVER (...) ` Return x from a following row in the same partition, defaulting to offset 1. Negative offsets reverse direction and zero selects the current row. A missing target yields the provided default, evaluated on the current row, or null when omitted. Null target values are respected. SQL requires ORDER BY and rejects ROWS frames; IGNORE NULLS is not implemented. These upstream signatures apply when any explicit offset is non-null and fits Int32, and the default has the same type as x. A null offset has different native behavior, described below. - **Extension signatures:** ` lead:any, lead:any_i32, lead:any_i32_any ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, i32) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, i32, any1) -> any1?; nullability=DECLARED_OUTPUT ` - **Default same type as value:** ` true ` - **Explicit offset must be non null:** ` true ` - **Frame types:** ` [] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT lead(x, 2, x) OVER (PARTITION BY p ORDER BY o) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` lead(x, offset [, default]) OVER (...) ` Return x from a following row in the same partition, defaulting to offset 1. Negative offsets reverse direction and zero selects the current row. A missing target yields the provided default, evaluated on the current row, or null when omitted. Null target values are respected. SQL requires ORDER BY and rejects ROWS frames; IGNORE NULLS is not implemented. Native offsets are Int64 and may be expressions. A null offset is treated as 1, unlike upstream. The default can have a different value kind; that overload has an opaque/dynamic result. - **Extension signatures:** ` lead:any_i64, lead:any_i64_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, i64) -> any1?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (any1, i64, any2) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Frame types:** ` [] ` - **Offset null behavior:** ` USE_ONE ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT lead(x, 2, x) OVER (PARTITION BY p ORDER BY o) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` max_by(x, y) OVER (...) ` Return x associated with the maximum y in the ROWS frame. Null y values are ignored, but the chosen x may be null. Empty frames or frames with no non-null y return null. SQL requires ORDER BY; the default frame is UNBOUNDED PRECEDING through CURRENT ROW. Do not depend on which row wins tied y. Uses the existing aggregate definition as a window function. - **Extension signatures:** ` max_by:any_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, any2) -> any1?; nullability=DECLARED_OUTPUT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT max_by(x, y) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` min_by(x, y) OVER (...) ` Return x associated with the minimum y in the ROWS frame. Null y values are ignored, but the chosen x may be null. Empty frames or frames with no non-null y return null. SQL requires ORDER BY; the default frame is UNBOUNDED PRECEDING through CURRENT ROW. Do not depend on which row wins tied y. Uses the existing aggregate definition as a window function. - **Extension signatures:** ` min_by:any_any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any1, any2) -> any1?; nullability=DECLARED_OUTPUT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT min_by(x, y) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` row_number() OVER (...) ` Numbers rows from 1 within each partition. SQL requires ORDER BY and rejects ROWS frames. Include a stable tie breaker in ORDER BY when row positions must be deterministic. Do not pass arguments. - **Extension signatures:** ` row_number: ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` () -> i64?; nullability=DECLARED_OUTPUT ` - **Frame types:** ` [] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT row_number() OVER (PARTITION BY p ORDER BY o, unique_key) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` session_window(gap_amount, gap_unit) OVER (... ORDER BY timestamp ASC) ` Return the start timestamp of the session containing each row. Exactly one ascending timestamp sort expression is required. A neighbouring gap equal to the limit remains in the session; a larger gap starts a new one. Null/non-timestamp sort values return null and do not split the run. Inserts can merge sessions and deletes can split them. The gap is a positive integer literal and a string unit literal; WEEK/DAY are fixed durations, not calendar arithmetic. Explicit frames are rejected. This binding is registered only for the bulk window operator. - **Extension signatures:** ` session_window:i64_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (i64 (constant), string (constant)) -> precision_timestamp_tz?<7>; nullability=DECLARED_OUTPUT ` - **Frame types:** ` [] ` - **Gap units:** ` [WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND] ` - **Literal arguments:** ` [0, 1] ` - **Order by count:** ` 1 ` - **Order by direction:** ` ASC ` - **Order by type:** ` precision_timestamp_tz<7> ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires bulk window operator:** ` true ` - **Requires order by:** ` true ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` - **Timestamp precision:** ` 7 ` ```sql SELECT session_window(30, 'MINUTE') OVER (PARTITION BY user_id ORDER BY event_time) FROM events ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/datetime.html) ### ` sum(x) OVER (...) ` **Profile: i64, fp64** Null input values are ignored; empty/all-null frames return null. Without ORDER BY, SQL uses the whole partition. With ORDER BY and no explicit frame, SQL uses ROWS UNBOUNDED PRECEDING through CURRENT ROW, including only rows through this physical row rather than all equal-order peers. Explicit ROWS bounds support preceding/following/current/unbounded endpoints. RANGE, GROUPS and dynamic frame-bound expressions are not implemented. Uses the aggregate definition as a window function. - **Extension signatures:** ` sum:i64, sum:fp64 ` - **Extension source:** ` extension:io.substrait:functions_arithmetic ` - **Extension type declaration:** ` (i64) -> i64?; nullability=DECLARED_OUTPUT ` - **Extension type declaration:** ` (fp64) -> fp64?; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` SILENT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT sum(x) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) **Profile: dec** Null input values are ignored; empty/all-null frames return null. Without ORDER BY, SQL uses the whole partition. With ORDER BY and no explicit frame, SQL uses ROWS UNBOUNDED PRECEDING through CURRENT ROW, including only rows through this physical row rather than all equal-order peers. Explicit ROWS bounds support preceding/following/current/unbounded endpoints. RANGE, GROUPS and dynamic frame-bound expressions are not implemented. Uses the aggregate definition as a window function. Decimal arithmetic uses System.Decimal at precision at most 28; CLR decimal overflow throws. Every intermediate and final sum must fit Decimal<28,S>. - **Extension signatures:** ` sum:dec ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (decimal) -> decimal?<28,S>; nullability=DECLARED_OUTPUT ` - **Required Substrait option overflow:** ` ERROR ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Decimal precision max:** ` 28 ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame bounds:** ` [UNBOUNDED_PRECEDING, PRECEDING, CURRENT_ROW, FOLLOWING, UNBOUNDED_FOLLOWING] ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT sum(x) OVER (PARTITION BY p ORDER BY o ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) **Profile: any** Dynamically typed numeric sum for any inputs. The runtime chooses the numeric value kind from input values. Null and incompatible inputs are ignored; empty/all-null frames return null. Explicit ROWS frames use integer literal bounds. Without ORDER BY the whole partition is used; otherwise the default frame ends at the current row. RANGE, GROUPS, FILTER and DISTINCT are unsupported. - **Extension signatures:** ` sum:any ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_arithmetic ` - **Extension type declaration:** ` (any) -> flowtide_types.u!dynamic?; nullability=DECLARED_OUTPUT ` - **Bound offsets:** ` NONNEGATIVE_INTEGER_LITERALS ` - **Default frame:** ` with_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW; without_order_by=ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ` - **Frame types:** ` [ROWS] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/arithmetic.html) ### ` surrogate_key_int64() OVER (...) ` One stateful counter key per partition, shared by all its rows. Without PARTITION BY, all rows share one key. ORDER BY is optional; SQL rejects ROWS frames. Live partitions retain their key across updates and checkpoint restore; deleting and recreating a partition can assign a new key. Allocation is operator-scoped and not deterministic across a full replay. - **Extension signatures:** ` surrogate_key_int64: ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_aggregate_generic ` - **Extension type declaration:** ` () -> i64; nullability=DECLARED_OUTPUT ` - **Deterministic:** ` false ` - **Frame types:** ` [] ` - **Plan representation:** ` CONSISTENT_PARTITION_WINDOW ` - **Requires order by:** ` false ` - **Sql distinct:** ` false ` - **Supports filter:** ` false ` ```sql SELECT surrogate_key_int64() OVER (PARTITION BY p) FROM t ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/windowfunctions/generic.html) ## Table functions ### ` hopping_window(timestamp, hop_amount, hop_unit, size_amount, size_unit) ` Emit every fixed-size window containing a timestamp, with starts spaced by the hop duration. A smaller hop than size creates overlapping windows; equal durations produce one tumbling window; a larger hop can leave gaps and emit no rows. Results are emitted from the latest matching start backwards, though a SQL result requires ORDER BY to guarantee presentation order. The number of matching windows varies by alignment and is at most ceil(size_ticks / hop_ticks). The compile-time guard rejects floor(size_ticks / hop_ticks) > 100000; a non-integral ratio just below 100001 can therefore emit 100001 rows. Duration amounts must be positive integer numeric literals; units must be string literals WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND or MICROSECOND (case-insensitive). Fractions, column/expression durations, MONTH and YEAR are rejected. Each converted duration must fit Int64 ticks. Days are fixed 24-hour durations and weeks are seven days. Window starts align to UTC ticks from 0001-01-01T00:00:00Z; a week grid therefore begins Monday UTC, not local calendar midnight. Results preserve the input timestamp offset. Boundaries are start-inclusive and end-exclusive. Null/non-timestamp input emits no rows. - **Extension signatures:** ` hopping_window:ptstz_i64_str_i64_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz<7>, i64 (constant), string (constant), i64 (constant), string (constant)) -> rows(window_start: precision_timestamp_tz<7>, window_end: precision_timestamp_tz<7>) ` - **Duration units:** ` [WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND] ` - **Fanout guard:** ` floor(size_ticks / hop_ticks) <= 100000 ` - **Literal arguments:** ` [1, 2, 3, 4] ` - **Output column count:** ` 2 ` - **Timestamp precision:** ` 7 ` ```sql SELECT o.id, window_start, window_end FROM orders o INNER JOIN hopping_window(o.order_time, 5, 'MINUTE', 10, 'MINUTE') ``` ```sql SELECT o.id, window_start FROM orders o LEFT JOIN hopping_window(o.order_time, 10, 'MINUTE', 5, 'MINUTE') ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/tablefunctions/datetime.html) ### ` tumbling_window(timestamp, size_amount, size_unit) ` Emit the single fixed-size window containing a timestamp. Duration amounts must be positive integer numeric literals; units must be string literals WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND or MICROSECOND (case-insensitive). Fractions, column/expression durations, MONTH and YEAR are rejected. Each converted duration must fit Int64 ticks. Days are fixed 24-hour durations and weeks are seven days. Window starts align to UTC ticks from 0001-01-01T00:00:00Z; a week grid therefore begins Monday UTC, not local calendar midnight. Results preserve the input timestamp offset. Boundaries are start-inclusive and end-exclusive. Null/non-timestamp input emits no rows. - **Extension signatures:** ` tumbling_window:ptstz_i64_str ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_datetime ` - **Extension type declaration:** ` (precision_timestamp_tz<7>, i64 (constant), string (constant)) -> rows(window_start: precision_timestamp_tz<7>, window_end: precision_timestamp_tz<7>) ` - **Duration units:** ` [WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND] ` - **Literal arguments:** ` [1, 2] ` - **Output column count:** ` 2 ` - **Timestamp precision:** ` 7 ` ```sql SELECT o.id, window_start, window_end FROM orders o INNER JOIN tumbling_window(o.order_time, 10, 'MINUTE') ``` ```sql SELECT window_start, COUNT(*) FROM orders o INNER JOIN tumbling_window(o.order_time, 10, 'MINUTE') GROUP BY window_start ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/tablefunctions/datetime.html) ### ` unnest(collection) ` Emit one column and one row per list element or map entry. List elements retain their original value kind, including null elements. For a map, each result is a single map/object with string fields key and value containing the original key and value; these are not separate columns. Null, empty, and non-list/non-map inputs emit no rows. SQL uses the table alias as the single output column name, or generates a name when no alias is supplied. No ordinality column is added. - **Extension signatures:** ` unnest:list, unnest:map ` - **Extension source:** ` extension:io.github.koralium.flowtide:functions_table_generic ` - **Extension type declaration:** ` (list) -> rows(value: any1) ` - **Extension type declaration:** ` (map) -> rows(value: map) ` - **Output column count:** ` 1 ` ```sql SELECT val FROM UNNEST(list(1, 2, 3)) val ``` ```sql SELECT d.id, element FROM documents d LEFT JOIN UNNEST(d.items) element ``` ```sql SELECT d.id, element FROM documents d INNER JOIN UNNEST(d.items) element ON element = 123 ``` [Detailed documentation](https://koralium.github.io/flowtide/docs/expressions/tablefunctions/generic.html) --- Source: [connectors.txt](https://koralium.github.io/flowtide/llms/connectors.txt) # Flowtide connectors and data contracts Connectors map SQL table names to sources and sinks. They are configured in C#, separately from SQL. A stream can join sources from different systems and write multiple destinations. For application setup see [building streams](https://koralium.github.io/flowtide/llms/streams.txt); for queries see [SQL](https://koralium.github.io/flowtide/llms/sql.txt). ## Registration and table discovery With dependency injection, call AddConnectors on the named stream builder. The configured IDependencyInjectionConnectorManager also exposes ServiceProvider for resolving custom services. Without dependency injection, construct a ConnectorManager and pass it to FlowtideBuilder.AddConnectorManager. Connector packages commonly expose extension methods in FlowtideDotNet.Core; add the connector's options namespace where needed. Use the actual package/API names below. Older samples may use ReadWriteFactory or older option type names. ```csharp builder.Services.AddFlowtideStream("orders") .AddConnectors(connectors => { connectors.AddCatalog("sales", catalog => catalog.AddSqlServerSource(() => sourceConnectionString)); connectors.AddCatalog("reporting", catalog => catalog.AddSqlServerSink(() => destinationConnectionString)); }); ``` AddCatalog prefixes that connector group's SQL names. A SQL Server table then looks like sales.database.schema.table. AddSqlServerAsCatalog(name, connectionStringFactory) registers both the SQL Server source and sink under one catalog. Use separate source-only/sink-only catalogs when appropriate. Sources can expose ITableProvider implementations for discovery. AddSqlTextAsPlan, AddSqlFileAsPlan, and AddSqlPlan use the registered providers. CREATE TABLE supplies explicit planner metadata when discovery is unavailable or a narrower input schema is desired. It never creates or connects a physical table. Many connectors select names using regexPattern arguments. Use a pattern that matches the intended logical SQL table name and check the connector's matching rules. Source and sink schema/key requirements still apply after a name matches. ## Available connectors The package column gives the FlowtideDotNet.Connector.* suffix unless a different package is stated. Source and sink support reflects this repository, not every historical release. | System | Package suffix | Direction and registration | Reference | | --- | --- | --- | --- | | SQL Server | SqlServer | Source and sink: AddSqlServerSource, AddSqlServerSink, AddSqlServerAsCatalog. | [SQL Server](https://koralium.github.io/flowtide/docs/connectors/sqlserver.md) | | MongoDB | MongoDB | Source and sink: AddMongoDbSource, AddMongoDbSink. | [MongoDB](https://koralium.github.io/flowtide/docs/connectors/mongodb.md) | | Delta Lake | DeltaLake | Source and sink: AddDeltaLakeSource, AddDeltaLakeSink, AddDeltaLakeCatalog. | [Delta Lake](https://koralium.github.io/flowtide/docs/connectors/deltalake.md) | | Kafka | Kafka | Source and sink: AddKafkaSource, AddKafkaSink. | [Kafka](https://koralium.github.io/flowtide/docs/connectors/kafka.md) | | Elasticsearch | ElasticSearch | Sink: AddElasticsearchSink. | [Elasticsearch](https://koralium.github.io/flowtide/docs/connectors/elasticsearch.md) | | Cosmos DB | CosmosDB | Sink: AddCosmosDbSink. | [Cosmos DB](https://koralium.github.io/flowtide/docs/connectors/cosmosdb.md) | | OpenFGA | OpenFGA | Source and sink: AddOpenFGASource, AddOpenFGASink. | [OpenFGA](https://koralium.github.io/flowtide/docs/connectors/openfga.md) | | SpiceDB/Authzed | SpiceDB | Source and sink: AddSpiceDbSource, AddSpiceDbSink. | [SpiceDB](https://koralium.github.io/flowtide/docs/connectors/spicedb.md) | | Permify | Permify | Relationship source and sink: AddPermifyRelationshipSource, AddPermifyRelationshipSink. | [Permify](https://koralium.github.io/flowtide/docs/connectors/permify.md) | | SharePoint | Sharepoint | List source and sink: AddSharepointSource, AddSharepointSink. | [SharePoint](https://koralium.github.io/flowtide/docs/connectors/sharepoint.md) | | Files | Files | Sources: AddCsvFileSource, AddXmlFileSource, AddTextLinesFileSource. Experimental. | [Files](https://koralium.github.io/flowtide/docs/connectors/files.md) | | Qdrant | Qdrant | Sink with embedding generation: AddQdrantSink. | [Qdrant](https://koralium.github.io/flowtide/docs/connectors/qdrant.md) | | StarRocks | StarRocks | Sink: AddStarRocksSink. | [StarRocks](https://koralium.github.io/flowtide/docs/connectors/starrocks.md) | | .NET options/configuration | Built into core/DI | Source: AddOptionsSource, backed by IOptionsMonitor. | [Configuration](https://koralium.github.io/flowtide/docs/connectors/configurationdata.md) | | Console / black hole | Built into core | Sinks: AddConsoleSink, AddBlackholeSink; namespace FlowtideDotNet.Core.Sinks. | [Samples](https://github.com/koralium/flowtide/tree/main/samples) | | Custom C# data | Built into core | AddCustomSource and AddCustomSink with generic object source/sink implementations. | [Custom data](https://koralium.github.io/flowtide/docs/connectors/customdata.md) | ## Important source and sink contracts - SQL Server: incremental reading uses SQL Server Change Tracking. Enable it on the database and source tables. Sources without it, including views, require explicit full-reload options; views have no delta loading. SQL names normally include database.schema.table. Sinks need an existing destination table and compatible projected columns/keys. Use the source/sink options for connection factories and reload settings. - MongoDB: reading changes requires MongoDB change streams. Default source columns are _id and _doc; use `_doc.field` to access document properties. An explicit CREATE TABLE can expose a narrower field schema. AddMongoDbSink takes FlowtideMongoDBSinkOptions including connection/database/collection and PrimaryKeys. - Delta Lake: register StorageLocation and optionally a catalog. Names beneath that catalog identify table paths. Normal reads maintain the current table state; IncludeChangeHistory exposes historical changes as inserted rows with __weight, __modificationDate, and __version. StartFromFirstVersion and OneVersionPerCheckpoint change replay behavior. Check the Delta Lake reference before interpreting history as current state. - Kafka: the logical table name selects the topic. The _key column holds the message key. Upsert JSON deserialization treats a non-null value as an upsert and a null value as a deletion. Configure key/value serializers and consumer/producer settings explicitly. Optional comparison against existing topic data can reconcile old destination keys during an initial load. - Elasticsearch: project a column named _id to identify the document; it is not included as a regular source field. The logical destination normally selects the index. FlowtideElasticsearchOptions provides settings factories, concrete index naming, mapping hooks, and initial-load callbacks. For changing stream versions, plan how to switch indices/aliases and remove old data. - Cosmos DB: output must include id and the configured container partition-key column. Configure the target container and database using FlowtideCosmosOptions. - OpenFGA: project user_type, user_id, relation, object_type, and object_id; user_relation is optional for usersets. Source tuples expose these parts separately. FlowtideDotNet.Zanzibar can turn an authorization model into a plan added through SqlPlanBuilder.AddPlanAsView, allowing permissions to join with other data. - SpiceDB/Authzed: use its documented relationship columns and options, including subject/resource type/id and relation fields. Its schema is distinct from OpenFGA's schema. - Permify: relationship projections use subject_type, subject_id, subject_relation, relation, entity_type, and entity_id. Follow the connector's required/optional field rules. - SharePoint: configure list identity and primary-key column names for writes. Read projections can use the documented fields, including _fields for dynamic properties. Prefer explicit columns where the schema is known. - Files: specify storage, schema/column selection, and initial/delta file enumeration callbacks appropriate to the file type. Reading a file is not equivalent to having a database change feed. - Qdrant: defaults require id and vector_string. IdColumnName and VectorStringColumnName can rename them. Supply an IEmbeddingGenerator or supported embedding options and optionally an IStringChunker. The connector reference describes required payload indexes and collection setup. - StarRocks: provision the target table with a primary key, then configure StarRocksSinkOptions. Execution-mode options control watermark/checkpoint write behavior. INSERT INTO ... PRIMARY KEY (...) can supply written key columns for sinks that implement declared-key support. It does not remove connector-specific identity requirements or create external constraints. Sinks that cannot honor declared keys reject them. ## Custom sources and sinks Start with the generic object APIs for custom HTTP services, business data, or in-memory sources: - GenericDataSourceAsync streams objects with IAsyncEnumerable; GenericDataSource is the synchronous variant. - Full loads return the current complete set; delta loads return changes with watermark/progress information. Include deletes when using delta ingestion, or use full reloads to discover removed rows. - Register with AddCustomSource("logical_table", factory). The generic source can provide object-schema metadata for planning. - GenericDataSink and AddCustomSink support typed output; see the custom sink sample for keys, upserts, deletes, and reading existing destination data during initialization. - Yield rows and fetch remote data in batches instead of collecting the entire input in memory. Source positions and replay behavior must be consistent with checkpoint recovery. For low-level integrations, implement the source/sink operator and factory interfaces, including schema, state, watermarks, checkpoint locking, and serialization requirements. [Consistency requirements](https://koralium.github.io/flowtide/docs/internal/dataconsistency.md) explains why these matter. ## End-to-end examples and implementation references - [CustomSinkSample](https://github.com/koralium/flowtide/tree/main/samples/CustomSinkSample): Typed input/output and reconciliation with pre-existing rows. - [SqlServerToSqlServerStream](https://github.com/koralium/flowtide/tree/main/samples/SqlServerToSqlServerStream): Catalogs, joins, persistent state, and hosting. - [MongoDbToConsoleSample](https://github.com/koralium/flowtide/tree/main/samples/MongoDbToConsoleSample): _doc field access and cross-collection joins. - [DeltaLakeSourceUsage](https://github.com/koralium/flowtide/tree/main/samples/DeltaLakeSourceUsage): Delta Lake source and console output. - [SqlServerToOpenFga](https://github.com/koralium/flowtide/tree/main/samples/SqlServerToOpenFga): Relationship projections and external SQL Server bootstrap scripts. - [OpenFgaSqlServerToMongoDb](https://github.com/koralium/flowtide/tree/main/samples/OpenFgaSqlServerToMongoDb): Materialized permissions joined with application data. - [Connector source projects](https://github.com/koralium/flowtide/tree/main/src): Actual extension-method signatures, options, schemas, and factories. - [Connector tests](https://github.com/koralium/flowtide/tree/main/tests): Connector-specific integration tests alongside SQL acceptance tests.