Mark P Neyer
Mark P Neyer

Reputation: 1009

How to specify BeamSQL UDF for Numeric Types

I'm trying to add a User Defined Function (UDF) to a SqlTransform in a Beam pipeline, and the SQL parser doesn't seem to understand the function's type. The error i get is:

No match found for function signature IF(<BOOLEAN>, <NUMERIC>, <NUMERIC>)

I've tried defining this for a bunch of different types (Double, Float, Long, Integer), but don't see how i can write this generically in a way that Beam will understand.

Is there some way to give type hints to the UDF, to to write one that handles arbitrary numeric types?

Upvotes: 0

Views: 153

Answers (2)

Mark P Neyer
Mark P Neyer

Reputation: 1009

I ended up finding out the problem was with my code registering the UDF. The error message you get from not registering the UDF appears to be identical to the message you'd get if you wrote one with incompatible types. Just using 'Double' seemed to work fine.

Upvotes: 0

Alex Chermenin
Alex Chermenin

Reputation: 858

Seems, you should use BigDecimal.

Here is a similar question: What is the equivalent Data type for Numeric in apache.beam.sdk.schemas.Schema.FieldType

Upvotes: 0

Related Questions