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 datetime_schema(string $name, bool $nullable, ?Metadata $metadata) : DateTimeDefinition 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_element_schema(string $name, bool $nullable, ?Metadata $metadata) : HTMLElementDefinition html_schema(string $name, bool $nullable, ?Metadata $metadata) : HTMLDefinition infer_schema() : SchemaInferenceBuilder integer_schema(string $name, bool $nullable, ?Metadata $metadata) : IntegerDefinition /**
* 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 null_schema(string $name, ?Metadata $metadata) : NullDefinition /**
* @param Definition<mixed> ...$definitions
*
* @return Schema
*/
schema(Definition $definitions) : Schema schema_sort_by_metadata(string $key, SortOrder $order) : SortingStrategy schema_sort_by_name(SortOrder $order) : SortingStrategy /**
* @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 string_schema(string $name, bool $nullable, ?Metadata $metadata) : StringDefinition /**
* @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 time_zone_schema(string $name, bool $nullable, ?Metadata $metadata) : TimeZoneDefinition /**
* @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_element_schema(string $name, bool $nullable, ?Metadata $metadata) : XMLElementDefinition 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 config() : Config config_builder() : ConfigBuilder current_row() : FrameBound data_frame(Config|ConfigBuilder|null $config) : Flow /**
* Alias for data_frame() : Flow.
*/
df(Config|ConfigBuilder|null $config) : Flow /**
* Alias for save_mode_exception_if_exists().
*/
exception_if_exists() : SaveMode execution_context(?Config $config) : FlowContext external_sort() : ExternalSortBuilder filesystem_cache(Path|string|null $cache_dir, Filesystem $filesystem, Serializer $serializer) : FilesystemCache flow_context(?Config $config) : FlowContext following(int $offset) : FrameBound generate_random_int(int $start, int $end, RandomValueGenerator $generator) : int generate_random_string(int $length, RandomValueGenerator $generator) : string hash_group_by() : HashGroupByBuilder hash_join() : HashJoinBuilder hash_repartition() : HashRepartitionBuilder /**
* Alias for save_mode_ignore().
*/
ignore() : SaveMode ignore_error_handler() : IgnoreError /**
* @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 memory_sort() : MemorySortBuilder /**
* Alias for save_mode_overwrite().
*/
overwrite() : SaveMode preceding(int $offset) : FrameBound 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 rows(Schema $schema, Row $row) : Rows row_number() : RowNumber save_mode_append() : SaveMode save_mode_exception_if_exists() : SaveMode save_mode_ignore() : SaveMode save_mode_overwrite() : SaveMode skip_rows_handler() : SkipRows throw_error_handler() : ThrowError unbounded_following() : FrameBound unbounded_preceding() : FrameBound window() : Window 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 from_all(Extractor $extractors) : ChainExtractor /**
* @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_data_frame(DataFrame $data_frame) : DataFrameExtractor from_memory(Memory $memory) : MemoryExtractor from_path_partitions(Path|string $path, Filesystem $filesystem) : PathPartitionsExtractor from_rows(Rows $rows) : RowsExtractor from_sequence_date_period(string $entry_name, DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end, int $options) : SequenceExtractor from_sequence_date_period_recurrences(string $entry_name, DateTimeInterface $start, DateInterval $interval, int $recurrences, 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
add_row_index(string $column, StartFrom $startFrom) : AddRowIndex /**
* @param int<1, max> $size
*/
batch_size(int $size) : BatchSize drop(Reference|string $entries) : Drop limit(?int $limit) : Limit /**
* @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 rename_style(StringStyles $style) : RenameCaseEntryStrategy select(Reference|string $entries) : Select AGGREGATING_FUNCTION
average(Reference|string $ref, int $scale, Rounding $rounding) : Average collect(Reference|string $ref) : Collect collect_unique(Reference|string $ref) : CollectUnique count(?Reference $function) : Count first(Reference|string $ref) : First last(Reference|string $ref) : Last max(Reference|string $ref) : Max min(Reference|string $ref) : Min string_agg(Reference|string $ref, string $separator, ?SortOrder $sort) : StringAggregate sum(Reference|string $ref, ScalarFunction|bool $exact) : Sum SCALAR_FUNCTION
all(ScalarFunction $functions) : All any(ScalarFunction $values) : Any /**
* @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 array_get(ScalarFunction $ref, string $path) : ArrayGet /**
* @param array<array-key, mixed>|ScalarFunction $keys
*/
array_get_collection(ScalarFunction $ref, ScalarFunction|array $keys) : ArrayGetCollection array_get_collection_first(ScalarFunction $ref, string $keys) : ArrayGetCollection array_keys_style_convert(ScalarFunction $ref, StringStyles|string $style) : ArrayKeysStyleConvert array_key_rename(ScalarFunction $ref, string $path, string $newName) : ArrayKeyRename /**
* @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 capitalize(ScalarFunction|string $value) : Capitalize /**
* @param \Flow\Types\Type<mixed>|string $type
*/
cast(?mixed $value, Type|string $type) : Cast coalesce(ScalarFunction $values) : Coalesce /**
* @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 date_time_format(ScalarFunction $ref, string $format) : DateTimeFormat /**
* An alias for `ref`.
*/
entry(string $entry) : UnresolvedReference enum_name(?mixed $value) : EnumName enum_value(?mixed $value) : EnumValue exists(ScalarFunction $ref) : Exists greatest(?mixed $values) : Greatest hash(?mixed $value, Algorithm $algorithm) : Hash least(?mixed $values) : Least list_ref(string $entry) : ListFunctions lit(?mixed $value) : Literal lower(ScalarFunction|string $value) : ToLower /**
* @param array<MatchCondition> $cases
*/
match_cases(array $cases, ?mixed $default) : MatchCases match_condition(?mixed $condition, ?mixed $then) : MatchCondition not(ScalarFunction $value) : Not now(DateTimeZone|ScalarFunction $time_zone) : Now number_format(ScalarFunction|int|float $value, ScalarFunction|int $decimals, ScalarFunction|string $decimal_separator, ScalarFunction|string $thousands_separator) : NumberFormat optional(ScalarFunction $function) : Optional ref(string $entry) : UnresolvedReference refs(Reference|string $entries) : References 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 size(?mixed $value) : Size 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 /**
* Alias for `array_get_collection_first`.
*/
structure_get_collection_first(ScalarFunction $ref, string $keys) : ArrayGetCollection structure_ref(string $entry) : StructureFunctions 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 ulid(ScalarFunction|string|null $value) : Ulid upper(ScalarFunction|string $value) : ToUpper uuid_v4() : Uuid uuid_v7(ScalarFunction|DateTimeInterface $value) : Uuid when(?mixed $condition, ?mixed $then, ?mixed $else) : When WINDOW_FUNCTION
COMPARISON
compare_all(Comparison $comparison, Comparison $comparisons) : All compare_any(Comparison $comparison, Comparison $comparisons) : Any equal(Reference|string $left, Reference|string $right) : Equal identical(Reference|string $left, Reference|string $right) : Identical HELPER
analyze() : Analyze clock(string $time_zone) : ClockInterface constraint_sorted_by(Reference|string $column, Reference|string $columns) : SortedByConstraint constraint_unique(string $reference, string $references) : UniqueConstraint date_interval_to_microseconds(DateInterval $interval) : int date_interval_to_milliseconds(DateInterval $interval) : int date_interval_to_seconds(DateInterval $interval) : int delay_exponential(Duration $base, int $multiplier, ?Duration $max_delay) : Exponential delay_fixed(Duration $delay) : Fixed /**
* @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 delay_linear(Duration $delay, Duration $increment) : Linear /**
* 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 duration_microseconds(int $microseconds) : Duration duration_milliseconds(int $milliseconds) : Duration duration_minutes(int $minutes) : Duration duration_seconds(int $seconds) : Duration /**
* Declares the pivot columns a groupBy()->pivot() produces, so the plan can name them before a row flows.
*/
pivot_values(string|int $values) : DeclaredPivotValues retry_any_throwable(int $limit) : AnyThrowable /**
* @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 schema_evolving_validator() : EvolvingValidator /**
* @return Schema
*/
schema_from_json(string $schema) : Schema /**
* @param array<string, array<bool|float|int|string>|bool|float|int|string> $metadata
*/
schema_metadata(array $metadata) : Metadata schema_selective_validator() : SelectiveValidator schema_strict_validator() : StrictValidator /**
* @param Schema $schema
*/
schema_to_ascii(Schema $schema, ?SchemaFormatter $formatter) : string /**
* @param Schema $schema
*/
schema_to_json(Schema $schema, bool $pretty) : 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 serialize_to_string(Serializer $serializer, Rows $rows) : string telemetry_options(bool $trace_loading, bool $trace_transformations, bool $trace_cache, bool $collect_metrics) : TelemetryOptions unserialize_from_string(Serializer $serializer, string $payload) : Rows with_entry(string $name, ScalarFunction $function) : WithEntry LOADER
partition_by(Reference|string $entry, Reference|string $entries) : Partitioning /**
* 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_memory(Memory $memory) : MemoryLoader 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 to_transformation(Transformer|Transformation $transformer, Loader $loader) : TransformerLoader write_with_retries(Loader $loader, RetryStrategy $retry_strategy, DelayFactory $delay_factory, Sleep $sleep) : RetryLoader