Displaying error message in BigQuery

  • date 29th May, 2021 |
  • by Prwatech |
  • 0 Comments

Prerequisites

GCP account

You may face various error codes and error messages when working with BigQuery, including HTTP error codes, job errors, and Google Cloud Console error messages. You can give your own error messages.

Open Cloud Console

Open Menu > Bigquery

Click 3 dots on project Click Create Dataset

Give Dataset ID.

Click Create Dataset.

Click 3 dots in dataset. Click Open

Click on Create table

Select  Source as empty table.

Give Table name.

Click create

Click 3 dots in table. Click Open

Click on Compose new query.

Paste the Query in query editor. Click run

CREATE OR REPLACE TABLE business.customer AS

SELECT

     123 AS cust_id,

‘Evan’ AS name;

SELECE * FROM business.customer;

Paste the below query in query editor.

DELETE FROM business.customer WHERE true;

Click run.

It will remove 1 row.

Paste the below code in query editor.

SELECT

COUNT(*) AS row_count

FROM business.customer

HAVING

     IF(row_count > 0,true,

ERROR(FORMAT(‘Error : row_count must be positive but it is %t ‘,row_count)

)

);

Click run.

It will display error message.

Quick Support

image image