You can see the digits in the column, so why refuse to count them? Conversions are always written out. Nothing here converts a column on your behalf, because a column that quietly changes what it holds is the hardest kind of mistake to find later.
messy then add [word] as to_text([n]) then add [digits] as characters([word])
Every conversion begins to_, and nothing else does: to_number, to_text, to_date. Ask for the characters in a number without converting it first and you are told which conversion you wanted:
Error:
!
illegal: `characters` counts the characters in text, and this is a number. Convert it first with `to_text(...)`
|
2 | then add [size] as characters([n])
| ^
try: collect(messy >> add(size = characters(col.n)))except GodError as refusal:print(refusal)
illegal: `characters` counts the characters in text, and this is a number. Convert it first with `to_text(...)`
|
2 | then add [size] as characters([n])
| ^
16.1 The three conversions
to_text, to_number and to_date are the whole set. Each one says what it makes rather than what it takes, so there is nothing to remember about direction.
There were four of these, and the fourth was a mistake of the kind that hides. to_whole turned a number into a whole one, which sounds like a conversion and is not: this grammar has one kind of number, so to_whole converted nothing. It was a rounding wearing a conversion’s name, and because the name said nothing about direction, no reader could tell whether -5.5 came back as -5 or as -6. It is two words now, round_below and round_above, and they are in the chapter on adding a column, where the arithmetic lives.
A conversion that cannot be made is the one answer this grammar does not own. to_number("abc") goes to the engine underneath, and engines disagree: one stops with an error, another hands back a missing value. It is one of the few places where the answer depends on where the pipeline ran, and the honest sentence is exactly that one.
16.2 Between two ends
between is not a conversion, and it is here because it is the other word you reach for when a column has just become a number. It asks whether a value falls in a range.