BigQuery Missing Dataset Error While Creating User-Defined Function

794 views Asked by At

I'm trying to create simple user-defined function in BigQuery using sql query like this:

CREATE OR REPLACE FUNCTION
  distance_traveled_between_time(id STRING,
    starttime TIMESTAMP,
    endtime TIMESTAMP)
RETURNS FLOAT64 AS (
  (
    SELECT SUM(fueltanklevel) FROM `eva-boa-inf2.evaboa.gpsapi`
  )
)

Note: this is not the real function, it's just dummy function that return float value

I think, this is a valid SQL statement, but I have this error:

Routine name "distance_traveled_between_time" missing dataset while no default dataset is set in the request.

And I don't know what to fix at this point. Anyone knows?

1

There are 1 answers

0
Pentium10 On BEST ANSWER

Add the dataset to the name of the routine:

CREATE OR REPLACE FUNCTION
   dataset.distance_traveled_between_time

look here-^