-
-
Notifications
You must be signed in to change notification settings - Fork 48
Milestone
Description
What happened?
Not 100% sure it's a bug, but the behaviour is quite strange in a call like ref('number')->isNotNumeric(), and down the road in: Parameter::asNumber():
public function asNumber(Row $row, FlowContext $context, int|float|null $default = null) : int|float|null
{
$result = $this->eval($row, $context);
if (\is_string($result)) {
return $default;
}
return \is_numeric($result) ? $result : $default;
}Why is it confusing? Cause string can be numeric, while this code says already that the string is not numeric and returns the default (null in this case).
How to reproduce?
data_frame()
->read(from_csv(__DIR__ . '/data/orders.csv'))
->withEntry('is_numeric', \Flow\ETL\DSL\ref('discount')->isNumeric())
->withEntry('is_string', \Flow\ETL\DSL\ref('discount')->isType(\Flow\Types\DSL\type_string()))
->select('discount', 'is_numeric', 'is_string')
->limit(10)
->collect()
->write(to_output(truncate: false))
->run();Playground snippet
Data required to reproduce bug locally
Version
Latest for sure
Relevant error output
Copy and paste any relevant error output (no backticks needed).