Forrest logo
back to the bq tool

bq:tldr:ddf5a

bq: Run a parameterized query.
$ bq query --use_legacy_sql=false --parameter='ts_value:TIMESTAMP:2016-12-07 08:00:00' 'SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR)'
try on your machine

This command is using the BigQuery CLI (Command Line Interface) to execute a query on a BigQuery dataset.

Here is a breakdown of the command:

  • bq: The command to invoke the BigQuery CLI.
  • query: The sub-command to specify that we want to perform a query operation.

Options:

  • --use_legacy_sql=false: This flag specifies that we want to use standard SQL syntax instead of the deprecated legacy SQL syntax.
  • --parameter='ts_value:TIMESTAMP:2016-12-07 08:00:00': This flag allows us to specify a named query parameter, ts_value, with the data type TIMESTAMP and the value 2016-12-07 08:00:00. This parameter will be used in the query.

Query:

  • 'SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR)': This is the query itself. It selects a single value: the original timestamp (@ts_value) incremented by 1 hour using the TIMESTAMP_ADD function. The result will be returned in the query output.

Overall, this command executes a query using standard SQL syntax, using a provided timestamp parameter, and returns a timestamp value that is the input timestamp (ts_value) incremented by 1 hour.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the bq tool