Flow PHP

functions.php

Functions

telemetry_options()

telemetry_options([bool $trace_loading = false ][, bool $trace_transformations = false ][, bool $trace_cache = false ][, bool $collect_metrics = false ]) : TelemetryOptions
Parameters
$trace_loading : bool = false
$trace_transformations : bool = false
$trace_cache : bool = false
$collect_metrics : bool = false
Return values
TelemetryOptions

from_array()

from_array(iterable<string|int, array<string|int, mixed>> $array[, null|Schema $schema = null ][, Filesystem $filesystem = new NativeLocalFilesystem() ][, null|Path $spillRoot = null ]) : ArrayExtractor
Parameters
$array : iterable<string|int, array<string|int, mixed>>
$schema : null|Schema = null
  • @deprecated use withSchema() method instead
$filesystem : Filesystem = new NativeLocalFilesystem()
$spillRoot : null|Path = null
  • where a non-array $array is spilled while it is described; null resolves to $filesystem->getSystemTmpDir() and only on that path
Return values
ArrayExtractor

from_cache()

from_cache(string $id[, null|Extractor $fallback_extractor = null ][, bool $clear = false ][, Cache|null $cache = null ]) : CacheExtractor
Parameters
$id : string
  • cache id from which data will be extracted
$fallback_extractor : null|Extractor = null
  • extractor that will be used when cache is empty - @deprecated use withFallbackExtractor() method instead
$clear : bool = false
  • clear cache after extraction - @deprecated use withClearOnFinish() method instead
$cache : Cache|null = null
Return values
CacheExtractor

files()

files(string|Path $directory[, Filesystem $filesystem = new NativeLocalFilesystem() ]) : FilesExtractor
Parameters
$directory : string|Path
$filesystem : Filesystem = new NativeLocalFilesystem()
Return values
FilesExtractor

filesystem_cache()

filesystem_cache([Path|string|null $cache_dir = null ][, Filesystem $filesystem = new NativeLocalFilesystem() ][, Serializer $serializer = new FloeSerializer() ]) : FilesystemCache
Parameters
$cache_dir : Path|string|null = null
$filesystem : Filesystem = new NativeLocalFilesystem()
$serializer : Serializer = new FloeSerializer()
Return values
FilesystemCache

from_sequence_date_period()

from_sequence_date_period(string $entry_name, DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end[, int $options = 0 ]) : SequenceExtractor
Parameters
$entry_name : string
$start : DateTimeInterface
$interval : DateInterval
$end : DateTimeInterface
$options : int = 0
Return values
SequenceExtractor

from_sequence_date_period_recurrences()

from_sequence_date_period_recurrences(string $entry_name, DateTimeInterface $start, DateInterval $interval, int $recurrences[, int $options = 0 ]) : SequenceExtractor
Parameters
$entry_name : string
$start : DateTimeInterface
$interval : DateInterval
$recurrences : int
$options : int = 0
Return values
SequenceExtractor

from_sequence_number()

from_sequence_number(string $entry_name, string|int|float $start, string|int|float $end[, int|float $step = 1 ]) : SequenceExtractor
Parameters
$entry_name : string
$start : string|int|float
$end : string|int|float
$step : int|float = 1
Return values
SequenceExtractor

to_array()

Convert rows to an array and store them in passed array variable.

to_array(array<string|int, mixed> &$array) : ArrayLoader
Parameters
$array : array<string|int, mixed>
Tags
param-out

array<array> $array

Return values
ArrayLoader

to_stream()

to_stream(string $uri[, int|bool $truncate = 20 ][, Output $output = Output::rows ][, string $mode = 'w' ][, Formatter $formatter = new AsciiTableFormatter() ][, SchemaFormatter $schemaFormatter = new ASCIISchemaFormatter() ]) : StreamLoader
Parameters
$uri : string
$truncate : int|bool = 20
$output : Output = Output::rows
$mode : string = 'w'
$formatter : Formatter = new AsciiTableFormatter()
$schemaFormatter : SchemaFormatter = new ASCIISchemaFormatter()
Return values
StreamLoader

row()

row(array<string|int, mixed> $values) : Row
Parameters
$values : array<string|int, mixed>
Return values
Row

structure()

Builds a structure from scalar functions: one element per key, in key order.

structure(array<string|int, ScalarFunction$elements) : Structure

An element is nullable when its function is; the structure itself never is.

Parameters
$elements : array<string|int, ScalarFunction>
Return values
Structure

mask_columns()

mask_columns([array<int, string> $columns = [] ][, string $mask = '******' ]) : MaskColumns
Parameters
$columns : array<int, string> = []
$mask : string = '******'
Return values
MaskColumns

when()

when(mixed $condition, mixed $then[, mixed $else = null ]) : When
Parameters
$condition : mixed
$then : mixed
$else : mixed = null
Return values
When

cast()

cast(mixed $value, Type<string|int, mixed>|string $type) : Cast
Parameters
$value : mixed
$type : Type<string|int, mixed>|string
Return values
Cast

call()

Calls a user-defined function with the given parameters.

call(ScalarFunction $callable, Type<string|int, mixed> $return_type[, array<string|int, mixed> $parameters = [] ]) : CallUserFunc
Parameters
$callable : ScalarFunction
$return_type : Type<string|int, mixed>
$parameters : array<string|int, mixed> = []
Return values
CallUserFunc

array_unpack()

Unpacks each element of an array into a new entry, using the array key as the entry name.

array_unpack(array<string|int, mixed>|ScalarFunction $array, Schema $schema) : ArrayUnpack

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| +--+-----+-----+-----+-----+-----+

Parameters
$array : array<string|int, mixed>|ScalarFunction
$schema : Schema
Return values
ArrayUnpack

array_expand()

Expands each value into entry, if there are more than one value, multiple rows will be created.

array_expand(ScalarFunction $function[, ArrayExpand $expand = ArrayExpand::VALUES ]) : ArrayExpand

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| +--+--------+

Parameters
$function : ScalarFunction
$expand : ArrayExpand = ArrayExpand::VALUES
Return values
ArrayExpand

array_to_row()

array_to_row(array<string|int, array<string|int, mixed>>|array<string|int, mixed|string> $data, Schema $schema[, Hydrator $hydrator = new AdaptiveRowHydrator() ][, array<string|int, Partition>|Partitions $partitions = [] ]) : Row
Parameters
$data : array<string|int, array<string|int, mixed>>|array<string|int, mixed|string>
$schema : Schema
$hydrator : Hydrator = new AdaptiveRowHydrator()
$partitions : array<string|int, Partition>|Partitions = []
Return values
Row

schema_to_json()

schema_to_json(Schema $schema[, bool $pretty = false ]) : string
Parameters
$schema : Schema
$pretty : bool = false
Return values
string

schema_from_json()

schema_from_json(string $schema) : Schema
Parameters
$schema : string
Return values
Schema

schema_metadata()

schema_metadata([array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $metadata = [] ]) : Metadata
Parameters
$metadata : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
Return values
Metadata

map_schema()

map_schema(string $name, MapType|Type $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : MapDefinition<TKey, TValue>
Parameters
$name : string
$type : MapType|Type
$nullable : bool = false
$metadata : Metadata|null = null
Tags
template
Return values
MapDefinition<TKey, TValue>

list_schema()

list_schema(string $name, ListType<string|int, array<int, T>>|Type<string|int, array<int, T>> $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : ListDefinition<string|int, T>
Parameters
$name : string
$type : ListType<string|int, array<int, T>>|Type<string|int, array<int, T>>
$nullable : bool = false
$metadata : Metadata|null = null
Tags
template
Return values
ListDefinition<string|int, T>

enum_schema()

enum_schema(string $name, T> $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : EnumDefinition<string|int, T>
Parameters
$name : string
$type : T>
$nullable : bool = false
$metadata : Metadata|null = null
Tags
template
Return values
EnumDefinition<string|int, T>

structure_schema()

structure_schema(string $name, StructureType<string|int, array<string|int, T>>|Type<string|int, array<string|int, T>> $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : StructureDefinition<string|int, T>
Parameters
$name : string
$type : StructureType<string|int, array<string|int, T>>|Type<string|int, array<string|int, T>>
$nullable : bool = false
$metadata : Metadata|null = null
Tags
template
Return values
StructureDefinition<string|int, T>

union_schema()

a column holds exactly one type - use definition_from_type() instead

union_schema(string $name, Type<string|int, mixed>|UnionType<mixed, mixed> $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition<string|int, mixed>
Parameters
$name : string
$type : Type<string|int, mixed>|UnionType<mixed, mixed>
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition<string|int, mixed>

definition_from_array()

Create a Definition from an array representation.

definition_from_array(array<string|int, mixed> $definition) : Definition<string|int, mixed>
Parameters
$definition : array<string|int, mixed>
Return values
Definition<string|int, mixed>

definition_from_type()

Create a Definition from a Type.

definition_from_type(string|Reference $ref, Type<string|int, mixed> $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition<string|int, mixed>
Parameters
$ref : string|Reference
$type : Type<string|int, mixed>
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition<string|int, mixed>

pivot_values()

Declares the pivot columns a groupBy()->pivot() produces, so the plan can name them before a row flows.

pivot_values(int|string ...$values) : DeclaredPivotValues
Parameters
$values : int|string
Return values
DeclaredPivotValues

discover_pivot_values()

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 = 10000 ]) : DiscoveredPivotValues
Parameters
$maxValues : int = 10000
Return values
DiscoveredPivotValues

partition_types()

partition_types(Type<string|int, mixed> ...$types) : PartitionTypes
Parameters
$types : Type<string|int, mixed>

partition column name => type, passed as named arguments

Return values
PartitionTypes

print_rows()

print_rows(Rows $rows[, int|bool $truncate = false ][, Formatter|null $formatter = null ]) : string
Parameters
$rows : Rows
$truncate : int|bool = false
$formatter : Formatter|null = null
Return values
string

is_type()

is_type(array<string|int, string|Type<string|int, mixed>>|Type<string|int, mixed> $type, mixed $value) : bool
Parameters
$type : array<string|int, string|Type<string|int, mixed>>|Type<string|int, mixed>
$value : mixed
Return values
bool

date_interval_to_milliseconds()

date_interval_to_milliseconds(DateInterval $interval) : int
Parameters
$interval : DateInterval
Return values
int

date_interval_to_seconds()

date_interval_to_seconds(DateInterval $interval) : int
Parameters
$interval : DateInterval
Return values
int

date_interval_to_microseconds()

date_interval_to_microseconds(DateInterval $interval) : int
Parameters
$interval : DateInterval
Return values
int

retry_on_exception_types()

retry_on_exception_types(array<string|int, Throwable>$exception_types, int $limit) : OnExceptionTypes
Parameters
$exception_types : array<string|int, Throwable>>
$limit : int
Return values
OnExceptionTypes

retry_any_throwable_except()

retry_any_throwable_except(array<string|int, Throwable>$exception_types, int $limit) : AnyThrowableExcept
Parameters
$exception_types : array<string|int, Throwable>>
$limit : int
Return values
AnyThrowableExcept

delay_jitter()

delay_jitter(DelayFactory $delay, float $jitter_factor) : Jitter
Parameters
$delay : DelayFactory
$jitter_factor : float

a value between 0 and 1 representing the maximum percentage of jitter to apply

Return values
Jitter

duration_milliseconds()

duration_milliseconds(int $milliseconds) : Duration
Parameters
$milliseconds : int
Return values
Duration

duration_microseconds()

duration_microseconds(int $microseconds) : Duration
Parameters
$microseconds : int
Return values
Duration

write_with_retries()

write_with_retries(Loader $loader[, RetryStrategy $retry_strategy = new AnyThrowableExcept([InvalidLogicException::class], 3) ][, DelayFactory $delay_factory = new FixedMilliseconds(200) ][, Sleep $sleep = new SystemSleep() ]) : RetryLoader
Parameters
$loader : Loader
$retry_strategy : RetryStrategy = new AnyThrowableExcept([InvalidLogicException::class], 3)
$delay_factory : DelayFactory = new FixedMilliseconds(200)
$sleep : Sleep = new SystemSleep()
Return values
RetryLoader

clock()

clock([string $time_zone = 'UTC' ]) : ClockInterface
Parameters
$time_zone : string = 'UTC'
Return values
ClockInterface
On this page

Search results