GET map function
GET map function with 2 arguments
The following is an example of a GET map function used to read records from a table (-READMODE read_table). The table to retrieve the data from is the teachers table (-TABLE teachers), in the staff dataset (-DATASET staff).
The adapter is using the service account private key credentials file (-CREDENTIALSFILE /tmp/creds/key.json) for authentication.
The adapter logging is enabled at the verbose level (-TV), and since the adapter trace file was not specified, the default log file (m4bigquery.mtr) is created automatically in the map directory.
GET("BIGQUERY","-CREDENTIALSFILE /tmp/creds/key.json -READMODE read_table -DATASET staff -TABLE teachers -TV")
GET map function with 3 arguments (lookup operation)
The following is an example of a GET map function used to look up records using a parameterized SELECT query statement (-WRITEMODE execute_parameterized_query). The statement used is specified in the -QUERY 'SELECT id,name,dob FROM staff.teachers WHERE name=@name AND dob >= @min_dob LIMIT 1' command. The order of the parameters and their respective data types are specified in the -PARAMETERS 'name:STRING min_dob:DATE' command.
The values to set for the parameters are provided in the third argument of the GET map function. In this example, the fixed parameter values are specified (john|1980-01-01). This will result in the adapter returning a record for a teacher named John born in 1980 or later. Even if there are more than one teacher records that meet this criteria, only one will be returned because of the (-LIMIT 1) clause included in the statement.
In a more realistic scenario, the statement parameter values would be constructed from the incoming data values on the input link, instead of being hard-coded.
The adapter is using the service account private key credentials file (-CREDENTIALSFILE /tmp/creds/key.json) for authentication.
The adapter logging is enabled at the verbose level (-TV), and the log messages are written to the specified log file (/tmp/bq.adapter.log).
GET("BIGQUERY","-CREDENTIALSFILE /tmp/creds/key.json -WRITEMODE execute_parameterized_query -QUERY 'SELECT id,name,dob FROM staff.teachers WHERE name=@name AND dob >= @min_dob LIMIT 1' -PARAMETERS 'name:STRING min_dob:DATE' -TV /tmp/bq.adapter.log", "john|1980-01-01")