次の方法で共有


assert_true 関数

適用対象:check marked yes Databricks SQL check marked yes Databricks Runtime

expr が true ではない場合、エラーを返します。

構文

assert_true(condition [, message])

引数

  • condition: BOOLEAN 式。
  • message: メッセージを含む省略可能な STRING 式。 既定では、 '<condition>' is not true!です。

返品

エラーが返されない場合は、型指定されていない NULL

適用対象:check marked yes Databricks SQL check marked yes 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