dimanche 26 juillet 2020

Conditional evaluation bigquery UDF

I'm passing some values to UDF and checking to see if they are between a range, I pass that range as well. My two parameters: P5->1 , P10->2 . I'm applying this function on a column of integer. I'm getting an odd outcome from this snippet below:

(INPUT > P5 && INPUT <= P10)

INPUT: 117

P5: 1

P10:2

RETURNED: TRUE (ALL ABOVE VALUES WERE CONFIRMED BY OUTPUTTING THEM DIRECTLY)

So instead I attempted with the parameters:

(INPUT > 1 && INPUT <= 2)

INPUT: 117

RETURNED: FALSE

FULL CODE:

CREATE TEMP FUNCTION label2(INPUT INT64, P5 INT64, P10 INT64)
RETURNS STRING
LANGUAGE js
"""
if (INPUT > P5 && INPUT <= P10){
return 'B1'
}else{
return false
}
""";
SELECT A.COLUMN , LABEL2(A.COLUMN,1,2)
FROM ... AS A 

AS

Aucun commentaire:

Enregistrer un commentaire