Skip to content
Search

DSL References

DSL stands for Domain Specific Language. In Flow, the DSL is a set of small functions that wrap object construction so pipelines read top-to-bottom. See the examples for usage in context.

SCHEMA

bool_schema(string $name, bool $nullable, ?Metadata $metadata) : BooleanDefinition
date_schema(string $name, bool $nullable, ?Metadata $metadata) : DateDefinition
/**
 * Create a Definition from an array representation.
 *
 * @param array<array-key, mixed> $definition
 *
 * @return Definition<mixed>
 */
definition_from_array(array $definition) : Definition
/**
 * Create a Definition from a Type.
 *
 * @param Type<mixed> $type
 *
 * @return Definition<mixed>
 */
definition_from_type(Reference|string $ref, Type $type, bool $nullable, ?Metadata $metadata) : Definition
/**
 * @template T of \UnitEnum
 *
 * @param class-string<T> $type
 *
 * @return EnumDefinition<T>
 */
enum_schema(string $name, string $type, bool $nullable, ?Metadata $metadata) : EnumDefinition
float_schema(string $name, bool $nullable, ?Metadata $metadata) : FloatDefinition
html_schema(string $name, bool $nullable, ?Metadata $metadata) : HTMLDefinition
/**
 * Alias for `integer_schema`.
 */
int_schema(string $name, bool $nullable, ?Metadata $metadata) : IntegerDefinition
json_schema(string $name, bool $nullable, ?Metadata $metadata) : JsonDefinition
/**
 * @template T
 *
 * @param ListType<list<T>>|Type<list<T>> $type
 *
 * @return ListDefinition<T>
 */
list_schema(string $name, ListType|Type $type, bool $nullable, ?Metadata $metadata) : ListDefinition
/**
 * @template TKey of array-key
 * @template TValue
 *
 * @param MapType<array<TKey, TValue>>|Type<array<TKey, TValue>> $type
 *
 * @return MapDefinition<TKey, TValue>
 */
map_schema(string $name, MapType|Type $type, bool $nullable, ?Metadata $metadata) : MapDefinition
/**
 * @param Definition<mixed> ...$definitions
 *
 * @return Schema
 */
schema(Definition $definitions) : Schema
/**
 * @param array<class-string<Type<mixed>>, int> $priorities
 */
schema_sort_by_type(array $priorities, SortOrder $order) : SortingStrategy
/**
 * @param array<class-string<Type<mixed>>, int> $priorities
 */
schema_sort_by_type_and_name(array $priorities, SortOrder $order) : SortingStrategy
/**
 * @template T
 *
 * @param StructureType<array<array-key, T>>|Type<array<array-key, T>> $type
 *
 * @return StructureDefinition<T>
 */
structure_schema(string $name, StructureType|Type $type, bool $nullable, ?Metadata $metadata) : StructureDefinition
/**
 * Alias for `string_schema`.
 */
str_schema(string $name, bool $nullable, ?Metadata $metadata) : StringDefinition
time_schema(string $name, bool $nullable, ?Metadata $metadata) : TimeDefinition
/**
 * @param Type<mixed>|UnionType<mixed, mixed> $type
 *
 * @deprecated a column holds exactly one type - use definition_from_type() instead
 *
 * @return Definition<mixed>
 */
union_schema(string $name, UnionType|Type $type, bool $nullable, ?Metadata $metadata) : Definition
uuid_schema(string $name, bool $nullable, ?Metadata $metadata) : UuidDefinition
xml_schema(string $name, bool $nullable, ?Metadata $metadata) : XMLDefinition

DATA_FRAME

/**
 * Alias for save_mode_append().
 */
append() : SaveMode
/**
 * @param array<array<mixed>>|array<mixed|string> $data
 * @param array<Partition>|Partitions $partitions
 */
array_to_row(array $data, Schema $schema, Hydrator $hydrator, Partitions|array $partitions) : Row
/**
 * @param array<array<mixed>>|array<mixed|string> $data
 */
array_to_rows(array $data, Schema $schema, Hydrator $hydrator) : Rows
/**
 * An alias for `ref`.
 */
col(string $entry) : UnresolvedReference
/**
 * Alias for data_frame() : Flow.
 */
df(Config|ConfigBuilder|null $config) : Flow
filesystem_cache(Path|string|null $cache_dir, Filesystem $filesystem, Serializer $serializer) : FilesystemCache
/**
 * Alias for save_mode_ignore().
 */
ignore() : SaveMode
/**
 * @param array<string|Type<mixed>>|Type<mixed> $type
 * @param mixed $value
 */
is_type(Type|array $type, ?mixed $value) : bool
/**
 * @param array<Comparison|string>|Comparison $comparisons
 */
join_on(Comparison|array $comparisons, string $join_prefix) : Expression
print_rows(Rows $rows, int|bool $truncate, ?Formatter $formatter) : string
random_string(ScalarFunction|int $length, RandomValueGenerator $generator) : RandomString
/**
 * @param array<array-key, mixed> $values
 */
row(array $values) : Row

EXTRACTOR

/**
 * @param null|int<1, max> $min_size
 */
batched_by(Extractor $extractor, Reference|string $column, ?int $min_size) : BatchByExtractor
/**
 * @param int<1, max> $size
 */
batches(Extractor $extractor, int $size) : BatchExtractor
files(Path|string $directory, Filesystem $filesystem) : FilesExtractor
/**
 * @param iterable<array<mixed>> $array
 * @param null|Schema $schema - @deprecated use withSchema() method instead
 * @param null|Path $spillRoot - where a non-array $array is spilled while it is described; null resolves to
 *                          $filesystem->getSystemTmpDir() and only on that path
 */
from_array(iterable $array, ?Schema $schema, Filesystem $filesystem, ?Path $spillRoot) : ArrayExtractor
/**
 * @param string $id - cache id from which data will be extracted
 * @param null|Extractor $fallback_extractor - extractor that will be used when cache is empty - @deprecated use withFallbackExtractor() method instead
 * @param bool $clear - clear cache after extraction - @deprecated use withClearOnFinish() method instead
 */
from_cache(string $id, ?Extractor $fallback_extractor, bool $clear, ?Cache $cache) : CacheExtractor
from_sequence_date_period(string $entry_name, DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end, int $options) : SequenceExtractor
from_sequence_number(string $entry_name, string|int|float $start, string|int|float $end, int|float $step) : SequenceExtractor
/**
 * @param Type<mixed> ...$types partition column name => type, passed as named arguments
 */
partition_types(Type $types) : PartitionTypes

TRANSFORMER

/**
 * @param array<int, string> $columns
 */
mask_columns(array $columns, string $mask) : MaskColumns
/**
 * @param array<array-key, string> $renames Map of old_name => new_name
 */
rename_map(array $renames) : RenameMapEntryStrategy
/**
 * @param array<string>|string $search
 * @param array<string>|string $replace
 */
rename_replace(array|string $search, array|string $replace) : RenameReplaceEntryStrategy

AGGREGATING_FUNCTION

average(Reference|string $ref, int $scale, Rounding $rounding) : Average
string_agg(Reference|string $ref, string $separator, ?SortOrder $sort) : StringAggregate
sum(Reference|string $ref, ScalarFunction|bool $exact) : Sum

SCALAR_FUNCTION

/**
 * @param array<array-key, mixed>|ScalarFunction $ref
 */
array_exists(ScalarFunction|array $ref, ScalarFunction|string $path) : ArrayPathExists
/**
 * Expands each value into entry, if there are more than one value, multiple rows will be created.
 * Array keys are ignored, only values are used to create new rows.
 * Nested in another function (structure(), concat(), ...) it still gives one row per element. Several
 * expands in one expression are zipped to the longest list; a shorter one gives null, so its element
 * type becomes nullable. It is refused inside another array_expand() and in filter(), until(),
 * duplicateRow(), aggregate(), over() and onEach().
 *
 * Before:
 *   +--+-------------------+
 *   |id|              array|
 *   +--+-------------------+
 *   | 1|{"a":1,"b":2,"c":3}|
 *   +--+-------------------+
 *
 * After:
 *   +--+--------+
 *   |id|expanded|
 *   +--+--------+
 *   | 1|       1|
 *   | 1|       2|
 *   | 1|       3|
 *   +--+--------+
 */
array_expand(ScalarFunction $function, ArrayExpand $expand) : ArrayExpand
/**
 * @param array<array-key, mixed>|ScalarFunction $keys
 */
array_get_collection(ScalarFunction $ref, ScalarFunction|array $keys) : ArrayGetCollection
/**
 * @param array<array-key, mixed>|ScalarFunction $left
 * @param array<array-key, mixed>|ScalarFunction $right
 */
array_merge(ScalarFunction|array $left, ScalarFunction|array $right) : ArrayMerge
/**
 * @param array<array-key, mixed>|ScalarFunction $array
 */
array_merge_collection(ScalarFunction|array $array) : ArrayMergeCollection
/**
 * @param array<array-key, mixed>|ScalarFunction $function
 */
array_reverse(ScalarFunction|array $function, bool $preserveKeys) : ArrayReverse
array_sort(ScalarFunction $function, ?Sort $sort_function, ScalarFunction|int|null $flags, ScalarFunction|bool $recursive) : ArraySort
/**
 * Unpacks each element of an array into a new entry, using the array key as the entry name.
 *
 * Before:
 * +--+-------------------+
 * |id|              array|
 * +--+-------------------+
 * | 1|{"a":1,"b":2,"c":3}|
 * | 2|{"d":4,"e":5,"f":6}|
 * +--+-------------------+
 *
 * After:
 * +--+-----+-----+-----+-----+-----+
 * |id|arr.b|arr.c|arr.d|arr.e|arr.f|
 * +--+-----+-----+-----+-----+-----+
 * | 1|    2|    3|     |     |     |
 * | 2|     |     |    4|    5|    6|
 * +--+-----+-----+-----+-----+-----+
 *
 * @param array<array-key, mixed>|ScalarFunction $array
 */
array_unpack(ScalarFunction|array $array, Schema $schema) : ArrayUnpack
between(?mixed $value, ?mixed $lower_bound, ?mixed $upper_bound, ScalarFunction|Boundary $boundary) : Between
/**
 * Calls a user-defined function with the given parameters.
 *
 * @param Type<mixed> $return_type
 * @param array<mixed> $parameters
 */
call(ScalarFunction $callable, Type $return_type, array $parameters) : CallUserFunc
/**
 * @param \Flow\Types\Type<mixed>|string $type
 */
cast(?mixed $value, Type|string $type) : Cast
/**
 * @param array<array-key, mixed>|ScalarFunction $keys
 * @param array<array-key, mixed>|ScalarFunction $values
 */
combine(ScalarFunction|array $keys, ScalarFunction|array $values) : Combine
/**
 * Concat all values. If you want to concatenate values with separator use concat_ws function.
 */
concat(ScalarFunction|string $functions) : Concat
/**
 * Concat all values with separator.
 */
concat_ws(ScalarFunction|string $separator, ScalarFunction|string $functions) : ConcatWithSeparator
/**
 * An alias for `ref`.
 */
entry(string $entry) : UnresolvedReference
hash(?mixed $value, Algorithm $algorithm) : Hash
/**
 * @param array<MatchCondition> $cases
 */
match_cases(array $cases, ?mixed $default) : MatchCases
now(DateTimeZone|ScalarFunction $time_zone) : Now
number_format(ScalarFunction|int|float $value, ScalarFunction|int $decimals, ScalarFunction|string $decimal_separator, ScalarFunction|string $thousands_separator) : NumberFormat
regex(ScalarFunction|string $pattern, ScalarFunction|string $subject, int $flags, ScalarFunction|int $offset) : Regex
regex_all(ScalarFunction|string $pattern, ScalarFunction|string $subject, int $flags, ScalarFunction|int $offset) : RegexAll
regex_match(ScalarFunction|string $pattern, ScalarFunction|string $subject, ScalarFunction|int $flags, ScalarFunction|int $offset) : RegexMatch
regex_match_all(ScalarFunction|string $pattern, ScalarFunction|string $subject, ScalarFunction|int $flags, ScalarFunction|int $offset) : RegexMatchAll
regex_replace(ScalarFunction|string $pattern, ScalarFunction|string $replacement, ScalarFunction|string $subject, ScalarFunction|int|null $limit) : RegexReplace
round(ScalarFunction|int|float $value, ScalarFunction|int $precision, ScalarFunction|int $mode) : Round
sanitize(ScalarFunction|string $value, ScalarFunction|string $placeholder, ScalarFunction|int|null $skipCharacters) : Sanitize
split(ScalarFunction|string $value, ScalarFunction|string $separator, ScalarFunction|int $limit) : Split
sprintf(ScalarFunction|string $format, ScalarFunction|string|int|float|null $args) : Sprintf
/**
 * Builds a structure from scalar functions: one element per key, in key order.
 * An element is nullable when its function is; the structure itself never is.
 *
 * @param array<array-key, ScalarFunction> $elements
 */
structure(array $elements) : Structure
/**
 * Alias for `array_get`.
 */
structure_get(ScalarFunction $ref, string $path) : ArrayGet
/**
 * Alias for `array_get_collection`.
 *
 * @param array<array-key, mixed>|ScalarFunction $keys
 */
structure_get_collection(ScalarFunction $ref, ScalarFunction|array $keys) : ArrayGetCollection
to_date(?mixed $ref, ScalarFunction|string $format, ScalarFunction|DateTimeZone $timeZone) : ToDate
to_date_time(?mixed $ref, ScalarFunction|string $format, ScalarFunction|DateTimeZone $timeZone) : ToDateTime
to_timezone(ScalarFunction|DateTimeInterface $value, ScalarFunction|DateTimeZone|string $timeZone) : ToTimeZone
when(?mixed $condition, ?mixed $then, ?mixed $else) : When

WINDOW_FUNCTION

COMPARISON

equal(Reference|string $left, Reference|string $right) : Equal
identical(Reference|string $left, Reference|string $right) : Identical

HELPER

/**
 * @param float $jitter_factor a value between 0 and 1 representing the maximum percentage of jitter to apply
 */
delay_jitter(DelayFactory $delay, float $jitter_factor) : Jitter
/**
 * Reads the pivot column once at build time and turns what it finds into declared values. Refuses a
 * source that cannot be read twice.
 */
discover_pivot_values(int $maxValues) : DiscoveredPivotValues
/**
 * Declares the pivot columns a groupBy()->pivot() produces, so the plan can name them before a row flows.
 */
pivot_values(string|int $values) : DeclaredPivotValues
/**
 * @param array<class-string<\Throwable>> $exception_types
 */
retry_any_throwable_except(array $exception_types, int $limit) : AnyThrowableExcept
/**
 * @param array<class-string<\Throwable>> $exception_types
 */
retry_on_exception_types(array $exception_types, int $limit) : OnExceptionTypes
/**
 * @param array<string, array<bool|float|int|string>|bool|float|int|string> $metadata
 */
schema_metadata(array $metadata) : Metadata
/**
 * @param Schema $schema
 */
schema_to_ascii(Schema $schema, ?SchemaFormatter $formatter) : string
/**
 * @param Schema $schema
 */
schema_to_php(Schema $schema, ValueFormatter $valueFormatter, TypeFormatter $typeFormatter) : string
/**
 * @param Schema $expected
 * @param Schema $given
 */
schema_validate(Schema $expected, Schema $given, SchemaValidator $validator) : ValidationContext
telemetry_options(bool $trace_loading, bool $trace_transformations, bool $trace_cache, bool $collect_metrics) : TelemetryOptions

LOADER

/**
 * Convert rows to an array and store them in passed array variable.
 *
 * @param array<array-key, mixed> $array
 *
 * @param-out array<array<mixed>> $array
 */
to_array(array $array) : ArrayLoader
to_branch(ScalarFunction $condition, Loader $loader, ?Transformation $transformation) : BranchingLoader
to_output(int|bool $truncate, Output $output, Formatter $formatter, SchemaFormatter $schemaFormatter) : StreamLoader
to_stderr(int|bool $truncate, Output $output, Formatter $formatter, SchemaFormatter $schemaFormatter) : StreamLoader
to_stdout(int|bool $truncate, Output $output, Formatter $formatter, SchemaFormatter $schemaFormatter) : StreamLoader
to_stream(string $uri, int|bool $truncate, Output $output, string $mode, Formatter $formatter, SchemaFormatter $schemaFormatter) : StreamLoader
write_with_retries(Loader $loader, RetryStrategy $retry_strategy, DelayFactory $delay_factory, Sleep $sleep) : RetryLoader
Contributors

Built in the open.

Join us on GitHub
scroll back to top