共用方式為


assert_true函式

適用於:勾選為「是」Databricks SQL 勾選為「是」Databricks Runtime

如果 expr 不是 true,則傳回錯誤。

語法

assert_true(condition [, message])

論點

  • conditionBOOLEAN 表達式。
  • message:具有訊息的選擇性 STRING 表達式。 預設值為 '<condition>' is not true!

退貨

如果未傳回任何錯誤,則為不具類型的 NULL

適用於:打勾為「是」 Databricks SQL 打勾為「是」 Databricks Runtime 14.2 及更新版本

傳回的錯誤條件為 USER_RAISED_EXCEPTION ,且 SQLSTATEP0001

如需處理錯誤條件的詳細資訊,請參閱 處理錯誤狀況

範例

> SELECT assert_true(0 < 1);
 NULL

> SELECT assert_true(0 > 1);
 [USER_RAISED_EXCEPTION] '0 > 1' is not true! SQLSTATE: P0001

> SELECT assert_true(1 = 2, 'One is not two!');
 [USER_RAISED_EXCEPTION] One is not two! SQLSTATE: P0001