メインコンテンツまでスキップ
メインコンテンツまでスキップ

型変換関数

データ変換に関する一般的な問題

ClickHouseは一般的にC++プログラムと同じ振る舞いをします。

to<type>関数とcastは、いくつかのケースで異なる振る舞いをします。例えば、LowCardinalityの場合: castLowCardinality特性を削除しますが、to<type>関数は削除しません。 Nullableについても同様です。この挙動はSQL標準と互換性がなく、cast_keep_nullable設定を使うことで変更できます。

注記

より小さいデータ型(例えば、Int64からInt32へ)や互換性のないデータ型(例えば、StringからIntへ)に変換される場合は、データ損失の可能性に注意してください。結果が予期した通りであるかを慎重に確認してください。

例:

toBool

入力値をBool型の値に変換します。エラーが発生した場合は例外を投げます。

構文

引数

  • expr — 数字または文字列を返す式。 Expression

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値。
  • 型Float32/64の値。
  • 文字列 true または false(大文字小文字を区別しない)。

返される値

  • 引数の評価に基づいて true または false を返します。 Bool

クエリ:

結果:

toInt8

入力値をInt8型の値に変換します。エラーが発生した場合は例外を投げます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

サポートされていない引数:

  • NaNInfを含むFloat32/64値の文字列表現。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt8('0xc0fe');
注記

入力値がInt8の範囲内で表現できない場合、結果のオーバーフローまたはアンダーフローが発生します。 これはエラーとは見なされません。 例: SELECT toInt8(128) == -128;

返される値

  • 8ビット整数値。 Int8
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt8OrZero

toInt8と同様に、この関数は入力値をInt8型の値に変換しますが、エラーが発生した場合は 0 を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • NaNInfを含む通常のFloat32/64の文字列表現。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt8OrZero('0xc0fe');
注記

入力値がInt8の範囲内で表現できない場合、結果のオーバーフローまたはアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は8ビット整数値、それ以外の場合は0Int8
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt8OrNull

toInt8と同様に、この関数は入力値をInt8型の値に変換しますが、エラーが発生した場合は NULL を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt8OrNull('0xc0fe');
注記

入力値がInt8の範囲内で表現できない場合、結果のオーバーフローまたはアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は8ビット整数値、それ以外の場合はNULLInt8 / NULL
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt8OrDefault

toInt8と同様に、この関数は入力値をInt8型の値に変換しますが、エラーが発生した場合はデフォルト値を返します。 デフォルト値が渡されない場合は、エラーが発生した場合に 0 が返されます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression / String
  • default (オプション) — Int8型に変換が失敗した場合に返すデフォルト値。 Int8

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt8OrDefault('0xc0fe', CAST('-1', 'Int8'));
注記

入力値がInt8の範囲内で表現できない場合、結果のオーバーフローまたはアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は8ビット整数値、それ以外の場合は渡されたデフォルト値または渡されていない場合は0を返します。 Int8
注記
  • この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。
  • デフォルト値の型はキャストする型と同じである必要があります。

クエリ:

結果:

参照

toInt16

入力値をInt16型の値に変換します。エラーが発生した場合は例外を投げます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

サポートされていない引数:

  • NaNInfを含むFloat32/64の文字列表現。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt16('0xc0fe');
注記

入力値がInt16の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。 例:SELECT toInt16(32768) == -32768;

返される値

  • 16ビット整数値。 Int16
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt16OrZero

toInt16と同様に、この関数は入力値をInt16型の値に変換しますが、エラーが発生した場合は 0 を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt16OrZero('0xc0fe');
注記

入力値がInt16の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 16ビット整数値が成功した場合、それ以外の時は0Int16
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt16OrNull

toInt16と同様に、この関数は入力値をInt16型の値に変換しますが、エラーが発生した場合は NULL を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt16OrNull('0xc0fe');
注記

入力値がInt16の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 16ビット整数値が成功した場合、それ以外の場合はNULLInt16 / NULL
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt16OrDefault

toInt16と同様に、この関数は入力値をInt16型の値に変換しますが、エラーが発生した場合はデフォルト値を返します。 デフォルト値が渡されていない場合は0が返されます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression / String
  • default (オプション) — Int16型に変換が失敗した場合に返すデフォルト値。 Int16

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt16OrDefault('0xc0fe', CAST('-1', 'Int16'));
注記

入力値がInt16の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は16ビット整数値、それ以外の場合は渡されたデフォルト値または渡されていない場合は0を返します。 Int16
注記
  • この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。
  • デフォルト値のタイプはキャストする型と同じである必要があります。

クエリ:

結果:

参照

toInt32

入力値をInt32型の値に変換します。エラーが発生した場合は例外を投げます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

サポートされていない引数:

  • NaNInfを含むFloat32/64の文字列表現。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt32('0xc0fe');
注記

入力値がInt32の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとして扱われません。 例えば:SELECT toInt32(2147483648) == -2147483648;

返される値

  • 32ビット整数値。 Int32
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt32OrZero

toInt32と同様に、この関数は入力値をInt32型の値に変換しますが、エラーが発生した場合は 0 を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt32OrZero('0xc0fe');
注記

入力値がInt32の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとして扱われません。

返される値

  • 32ビット整数値が成功した場合、それ以外の場合は0Int32
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt32OrNull

toInt32と同様に、この関数は入力値をInt32型の値に変換しますが、エラーが発生した場合は NULL を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt32OrNull('0xc0fe');
注記

入力値がInt32の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は32ビット整数値、それ以外の場合はNULLInt32 / NULL
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt32OrDefault

toInt32と同様に、この関数は入力値をInt32型の値に変換しますが、エラーが発生した場合はデフォルト値を返します。 デフォルト値が渡されていない場合は0が返されます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression / String
  • default (オプション) — Int32型に変換が失敗した場合に返すデフォルト値。 Int32

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt32OrDefault('0xc0fe', CAST('-1', 'Int32'));
注記

入力値がInt32の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は32ビット整数値、それ以外の場合は渡されたデフォルト値または渡されていない場合は0を返します。 Int32
注記
  • この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。
  • デフォル卜値の型はキャストする型と同じである必要があります。

クエリ:

結果:

参照

toInt64

入力値をInt64型の値に変換します。エラーが発生した場合は例外を投げます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

サポートされていない引数:

  • NaNInfを含むFloat32/64の文字列表現。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt64('0xc0fe');
注記

入力値がInt64の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。 例えば:SELECT toInt64(9223372036854775808) == -9223372036854775808;

返される値

  • 64ビット整数値。 Int64
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt64OrZero

toInt64と同様に、この関数は入力値をInt64型の値に変換しますが、エラーが発生した場合は 0 を返します。

構文

引数

  • x — 数字の文字列表現。 String

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt64OrZero('0xc0fe');
注記

入力値がInt64の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 64ビット整数値が成功した場合、それ以外の場合は0Int64
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt64OrNull

toInt64と同様に、この関数は入力値をInt64型の値に変換しますが、エラーが発生した場合は NULL を返します。

構文

引数

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt64OrNull('0xc0fe');
注記

入力値がInt64の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 64ビット整数値が成功した場合、それ以外の場合はNULLInt64 / NULL
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt64OrDefault

toInt64と同様に、この関数は入力値をInt64型の値に変換しますが、エラーが発生した場合はデフォルト値を返します。 デフォルト値が渡されていない場合は0が返されます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression / String
  • default (オプション) — Int64型に変換が失敗した場合に返すデフォルト値。 Int64

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNInfを含む。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt64OrDefault('0xc0fe', CAST('-1', 'Int64'));
注記

入力値がInt64の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 成功した場合は64ビット整数値、それ以外の場合は渡されたデフォルト値または渡されていない場合は0を返します。 Int64
注記
  • この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。
  • デフォルト値の型はキャストする型と同じである必要があります。

クエリ:

結果:

参照

toInt128

入力値をInt128型の値に変換します。エラーが発生した場合は例外を投げます。

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 Expression

サポートされる引数:

  • 型(U)Int8/16/32/64/128/256の値またはその文字列表現。
  • 型Float32/64の値。

サポートされていない引数:

  • NaNInfを含むFloat32/64の文字列表現。
  • バイナリや16進数の値の文字列表現、例:SELECT toInt128('0xc0fe');
注記

入力値がInt128の範囲内で表現できない場合、オーバーフローやアンダーフローが発生します。 これはエラーとは見なされません。

返される値

  • 128ビット整数値。 Int128
注記

この関数はゼロに向かう丸めを使用しており、数字の小数部分を切り捨てます。

クエリ:

結果:

参照

toInt128OrZero

Like toInt128, this function converts an input value to a value of type Int128 but returns 0 in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 / 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt128OrZero('0xc0fe');
注記

If the input value cannot be represented within the bounds of Int128, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば128ビット整数値、そうでなければ0Int128
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toInt128OrNull

Like toInt128, this function converts an input value to a value of type Int128 but returns NULL in case of an error.

構文

引数

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt128OrNull('0xc0fe');
注記

If the input value cannot be represented within the bounds of Int128, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば128ビット整数値、そうでなければNULLInt128 / NULL
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toInt128OrDefault

Like toInt128, this function converts an input value to a value of type Int128 but returns the default value in case of an error. If no default value is passed then 0 is returned in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 / 文字列
  • default (オプション) — Int128型へのパースが失敗した場合に返されるデフォルト値。 Int128

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値。
  • Float32/64の値。
  • (U)Int8/16/32/128/256の文字列表現。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt128OrDefault('0xc0fe', CAST('-1', 'Int128'));
注記

If the input value cannot be represented within the bounds of Int128, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば128ビット整数値、そうでなければ渡されたデフォルト値が返されるか、そうでなければ0が返される。 Int128
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

クエリ:

結果:

関連項目

toInt256

Converts an input value to a value of type Int256. Throws an exception in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値または文字列表現。
  • Float32/64の型の値。

サポートされていない引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt256('0xc0fe');
注記

If the input value cannot be represented within the bounds of Int256, the result over or under flows. This is not considered an error.

戻り値

  • 256ビット整数値。 Int256
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toInt256OrZero

Like toInt256, this function converts an input value to a value of type Int256 but returns 0 in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt256OrZero('0xc0fe');
注記

If the input value cannot be represented within the bounds of Int256, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば256ビット整数値、そうでなければ0Int256
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toInt256OrNull

Like toInt256, this function converts an input value to a value of type Int256 but returns NULL in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt256OrNull('0xc0fe');
注記

If the input value cannot be represented within the bounds of Int256, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば256ビット整数値、そうでなければNULLInt256 / NULL
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toInt256OrDefault

Like toInt256, this function converts an input value to a value of type Int256 but returns the default value in case of an error. If no default value is passed then 0 is returned in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 / 文字列
  • default (オプション) — Int256型へのパースが失敗した場合に返されるデフォルト値。 Int256

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値。
  • Float32/64の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toInt256OrDefault('0xc0fe', CAST('-1', 'Int256'));
注記

If the input value cannot be represented within the bounds of Int256, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば256ビット整数値、そうでなければ渡されたデフォルト値が返されるか、そうでなければ0が返される。 Int256
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

クエリ:

結果:

関連項目

toUInt8

Converts an input value to a value of type UInt8. Throws an exception in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値または文字列表現。
  • Float32/64の型の値。

サポートされていない引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt8('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt8, overflow or underflow of the result occurs. This is not considered an error. For example: SELECT toUInt8(256) == 0;.

戻り値

  • 8ビット符号なし整数値。 UInt8
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt8OrZero

Like toUInt8, this function converts an input value to a value of type UInt8 but returns 0 in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • 通常のFloat32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt8OrZero('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt8, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば8ビット符号なし整数値、そうでなければ0UInt8
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt8OrNull

Like toUInt8, this function converts an input value to a value of type UInt8 but returns NULL in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt8OrNull('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt8, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば8ビット符号なし整数値、そうでなければNULLUInt8 / NULL
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt8OrDefault

Like toUInt8, this function converts an input value to a value of type UInt8 but returns the default value in case of an error. If no default value is passed then 0 is returned in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 / 文字列
  • default (オプション) — UInt8型へのパースが失敗した場合に返されるデフォルト値。 UInt8

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値または文字列表現。
  • Float32/64の型の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt8OrDefault('0xc0fe', CAST('0', 'UInt8'));
注記

If the input value cannot be represented within the bounds of UInt8, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば8ビット符号なし整数値、そうでなければ渡されたデフォルト値が返されるか、そうでなければ0が返される。 UInt8
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

クエリ:

結果:

関連項目

toUInt16

Converts an input value to a value of type UInt16. Throws an exception in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値または文字列表現。
  • Float32/64の型の値。

サポートされていない引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt16('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt16, overflow or underflow of the result occurs. This is not considered an error. For example: SELECT toUInt16(65536) == 0;.

戻り値

  • 16ビット符号なし整数値。 UInt16
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt16OrZero

Like toUInt16, this function converts an input value to a value of type UInt16 but returns 0 in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt16OrZero('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt16, overflow or underflow of the result occurs. This is not considered as an error.

戻り値

  • 成功すれば16ビット符号なし整数値、そうでなければ0UInt16
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt16OrNull

Like toUInt16, this function converts an input value to a value of type UInt16 but returns NULL in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt16OrNull('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt16, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば16ビット符号なし整数値、そうでなければNULLUInt16 / NULL
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt16OrDefault

Like toUInt16, this function converts an input value to a value of type UInt16 but returns the default value in case of an error. If no default value is passed then 0 is returned in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。 / 文字列
  • default (オプション) — UInt16型へのパースが失敗した場合に返されるデフォルト値。 UInt16

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値または文字列表現。
  • Float32/64の型の値。

デフォルト値が返される引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt16OrDefault('0xc0fe', CAST('0', 'UInt16'));
注記

If the input value cannot be represented within the bounds of UInt16, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば16ビット符号なし整数値、そうでなければ渡されたデフォルト値が返されるか、そうでなければ0が返される。 UInt16
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

クエリ:

結果:

関連項目

toUInt32

Converts an input value to a value of type UInt32. Throws an exception in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。

サポートされる引数:

  • (U)Int8/16/32/64/128/256の値または文字列表現。
  • Float32/64の型の値。

サポートされていない引数:

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt32('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt32, the result over or under flows. This is not considered an error. For example: SELECT toUInt32(4294967296) == 0;

戻り値

  • 32ビット符号なし整数値。 UInt32
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt32OrZero

Like toUInt32, this function converts an input value to a value of type UInt32 but returns 0 in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(0を返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt32OrZero('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt32, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば32ビット符号なし整数値、そうでなければ0UInt32
注記

The function uses rounding towards zero , meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt32OrNull

Like toUInt32, this function converts an input value to a value of type UInt32 but returns NULL in case of an error.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • (U)Int8/16/32/128/256の文字列表現。

サポートされていない引数(\Nを返す):

  • Float32/64の値の文字列表現、NaNおよびInfを含む。
  • バイナリおよび16進数の値の文字列表現、例えば SELECT toUInt32OrNull('0xc0fe');
注記

If the input value cannot be represented within the bounds of UInt32, overflow or underflow of the result occurs. This is not considered an error.

戻り値

  • 成功すれば32ビット符号なし整数値、そうでなければNULLUInt32 / NULL
注記

The function uses rounding towards zero , meaning it truncates fractional digits of numbers.

クエリ:

結果:

関連項目

toUInt32OrDefault

Like toUInt32, this function converts an input value to a value of type UInt32 but returns the default value in case of an error.
If no default value is passed then 0 is returned in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression / String.
  • default (optional) — The default value to return if parsing to type UInt32 is unsuccessful. UInt32.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values of type Float32/64.

Arguments for which the default value is returned:

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt32OrDefault('0xc0fe', CAST('0', 'UInt32'));.
注記

If the input value cannot be represented within the bounds of UInt32, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 32-bit unsigned integer value if successful, otherwise returns the default value if passed or 0 if not. UInt32.
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

Example

Query:

Result:

See also

toUInt64

Converts an input value to a value of type UInt64. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values of type Float32/64.

Unsupported types:

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt64('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt64, the result over or under flows.
This is not considered an error.
For example: SELECT toUInt64(18446744073709551616) == 0;

Returned value

  • 64-bit unsigned integer value. UInt64.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt64OrZero

Like toUInt64, this function converts an input value to a value of type UInt64 but returns 0 in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256.

Unsupported arguments (return 0):

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt64OrZero('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt64, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 64-bit unsigned integer value if successful, otherwise 0. UInt64.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt64OrNull

Like toUInt64, this function converts an input value to a value of type UInt64 but returns NULL in case of an error.

Syntax

Arguments

Supported arguments:

  • String representations of (U)Int8/16/32/128/256.

Unsupported arguments (return \N)

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt64OrNull('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt64, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 64-bit unsigned integer value if successful, otherwise NULL. UInt64 / NULL.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt64OrDefault

Like toUInt64, this function converts an input value to a value of type UInt64 but returns the default value in case of an error.
If no default value is passed then 0 is returned in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression / String.
  • default (optional) — The default value to return if parsing to type UInt64 is unsuccessful. UInt64.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values of type Float32/64.

Arguments for which the default value is returned:

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt64OrDefault('0xc0fe', CAST('0', 'UInt64'));.
注記

If the input value cannot be represented within the bounds of UInt64, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 64-bit unsigned integer value if successful, otherwise returns the default value if passed or 0 if not. UInt64.
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

Example

Query:

Result:

See also

toUInt128

Converts an input value to a value of type UInt128. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt128('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt128, the result over or under flows.
This is not considered an error.

Returned value

  • 128-bit unsigned integer value. UInt128.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt128OrZero

Like toUInt128, this function converts an input value to a value of type UInt128 but returns 0 in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression / String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256.

Unsupported arguments (return 0):

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt128OrZero('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt128, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 128-bit unsigned integer value if successful, otherwise 0. UInt128.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt128OrNull

Like toUInt128, this function converts an input value to a value of type UInt128 but returns NULL in case of an error.

Syntax

Arguments

Supported arguments:

  • String representations of (U)Int8/16/32/128/256.

Unsupported arguments (return \N)

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt128OrNull('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt128, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 128-bit unsigned integer value if successful, otherwise NULL. UInt128 / NULL.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt128OrDefault

Like toUInt128, this function converts an input value to a value of type UInt128 but returns the default value in case of an error.
If no default value is passed then 0 is returned in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression / String.
  • default (optional) — The default value to return if parsing to type UInt128 is unsuccessful. UInt128.

Supported arguments:

  • (U)Int8/16/32/64/128/256.
  • Float32/64.
  • String representations of (U)Int8/16/32/128/256.

Arguments for which the default value is returned:

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt128OrDefault('0xc0fe', CAST('0', 'UInt128'));.
注記

If the input value cannot be represented within the bounds of UInt128, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 128-bit unsigned integer value if successful, otherwise returns the default value if passed or 0 if not. UInt128.
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

Example

Query:

Result:

See also

toUInt256

Converts an input value to a value of type UInt256. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt256('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt256, the result over or under flows.
This is not considered an error.

Returned value

  • 256-bit unsigned integer value. Int256.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt256OrZero

Like toUInt256, this function converts an input value to a value of type UInt256 but returns 0 in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256.

Unsupported arguments (return 0):

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt256OrZero('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt256, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 256-bit unsigned integer value if successful, otherwise 0. UInt256.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt256OrNull

Like toUInt256, this function converts an input value to a value of type UInt256 but returns NULL in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256.

Unsupported arguments (return \N)

  • String representations of Float32/64 values, including NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt256OrNull('0xc0fe');.
注記

If the input value cannot be represented within the bounds of UInt256, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 256-bit unsigned integer value if successful, otherwise NULL. UInt256 / NULL.
注記

The function uses rounding towards zero, meaning it truncates fractional digits of numbers.

Example

Query:

Result:

See also

toUInt256OrDefault

Like toUInt256, this function converts an input value to a value of type UInt256 but returns the default value in case of an error.
If no default value is passed then 0 is returned in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression / String.
  • default (optional) — The default value to return if parsing to type UInt256 is unsuccessful. UInt256.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values of type Float32/64.

Arguments for which the default value is returned:

  • String representations of Float32/64 values, including NaN and Inf
  • String representations of binary and hexadecimal values, e.g. SELECT toUInt256OrDefault('0xc0fe', CAST('0', 'UInt256'));
注記

If the input value cannot be represented within the bounds of UInt256, overflow or underflow of the result occurs.
This is not considered an error.

Returned value

  • 256-bit unsigned integer value if successful, otherwise returns the default value if passed or 0 if not. UInt256.
注記
  • The function uses rounding towards zero, meaning it truncates fractional digits of numbers.
  • The default value type should be the same as the cast type.

Example

Query:

Result:

See also

toFloat32

Converts an input value to a value of type Float32. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.

Supported arguments:

  • Values of type (U)Int8/16/32/64/128/256.
  • String representations of (U)Int8/16/32/128/256.
  • Values of type Float32/64, including NaN and Inf.
  • String representations of Float32/64, including NaN and Inf (case-insensitive).

Unsupported arguments:

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat32('0xc0fe');.

Returned value

  • 32-bit floating point value. Float32.

Example

Query:

Result:

See also

toFloat32OrZero

Like toFloat32, this function converts an input value to a value of type Float32 but returns 0 in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256, Float32/64.

Unsupported arguments (return 0):

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat32OrZero('0xc0fe');.

Returned value

  • 32-bit Float value if successful, otherwise 0. Float32.

Example

Query:

Result:

See also

toFloat32OrNull

Like toFloat32, this function converts an input value to a value of type Float32 but returns NULL in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256, Float32/64.

Unsupported arguments (return \N):

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat32OrNull('0xc0fe');.

Returned value

  • 32-bit Float value if successful, otherwise \N. Float32.

Example

Query:

Result:

See also

toFloat32OrDefault

Like toFloat32, this function converts an input value to a value of type Float32 but returns the default value in case of an error.
If no default value is passed then 0 is returned in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression / String.
  • default (optional) — The default value to return if parsing to type Float32 is unsuccessful. Float32.

Supported arguments:

  • Values of type (U)Int8/16/32/64/128/256.
  • String representations of (U)Int8/16/32/128/256.
  • Values of type Float32/64, including NaN and Inf.
  • String representations of Float32/64, including NaN and Inf (case-insensitive).

Arguments for which the default value is returned:

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat32OrDefault('0xc0fe', CAST('0', 'Float32'));.

Returned value

  • 32-bit Float value if successful, otherwise returns the default value if passed or 0 if not. Float32.

Example

Query:

Result:

See also

toFloat64

Converts an input value to a value of type Float64. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.

Supported arguments:

  • Values of type (U)Int8/16/32/64/128/256.
  • String representations of (U)Int8/16/32/128/256.
  • Values of type Float32/64, including NaN and Inf.
  • String representations of type Float32/64, including NaN and Inf (case-insensitive).

Unsupported arguments:

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat64('0xc0fe');.

Returned value

  • 64-bit floating point value. Float64.

Example

Query:

Result:

See also

toFloat64OrZero

Like toFloat64, this function converts an input value to a value of type Float64 but returns 0 in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256, Float32/64.

Unsupported arguments (return 0):

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat64OrZero('0xc0fe');.

Returned value

  • 64-bit Float value if successful, otherwise 0. Float64.

Example

Query:

Result:

See also

toFloat64OrNull

Like toFloat64, this function converts an input value to a value of type Float64 but returns NULL in case of an error.

Syntax

Arguments

  • x — A String representation of a number. String.

Supported arguments:

  • String representations of (U)Int8/16/32/128/256, Float32/64.

Unsupported arguments (return \N):

  • String representations of binary and hexadecimal values, e.g. SELECT toFloat64OrNull('0xc0fe');.

Returned value

  • 64-bit Float value if successful, otherwise \N. Float64.

Example

Query:

Result:

See also

引数

  • expr — 数字または数字の文字列表現を返す式。 / 文字列
  • default (オプション) — Float64型へのパースが失敗した場合に返すデフォルト値。 Float64

サポートされる引数:

  • (U)Int8/16/32/64/128/256型の値。
  • (U)Int8/16/32/128/256の文字列表現。
  • Float32/64型の値、NaNおよびInfを含む。
  • Float32/64の文字列表現、NaNおよびInfを含む(ケース非感知)。

デフォルト値が返される引数:

  • 2進数および16進数の文字列表現、例: SELECT toFloat64OrDefault('0xc0fe', CAST('0', 'Float64'));

返される値

  • 成功した場合は64ビットのFloat値、失敗した場合は渡されたデフォルト値または渡されなかった場合は0が返されます。 Float64

クエリ:

結果:

その他の情報

toBFloat16

Converts an input value to a value of type BFloat16. Throws an exception in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。

サポートされる引数:

  • (U)Int8/16/32/64/128/256型の値。
  • (U)Int8/16/32/128/256の文字列表現。
  • Float32/64型の値、NaNおよびInfを含む。
  • Float32/64の文字列表現、NaNおよびInfを含む(ケース非感知)。

返される値

  • 16ビットのブレインフロート値。 BFloat16

その他の情報

toBFloat16OrZero

Converts a String input value to a value of type BFloat16. If the string does not represent a floating point value, the function returns zero.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • 数値の文字列表現。

サポートされていない引数(0を返す):

  • 2進数および16進数の文字列表現。
  • 数値。

返される値

  • 16ビットのブレインフロート値、さもなくば0BFloat16
注記

関数は文字列表現から変換する際に精度の静かな損失を許可します。

その他の情報

toBFloat16OrNull

Converts a String input value to a value of type BFloat16 but if the string does not represent a floating point value, the function returns NULL.

構文

引数

  • x — 数字の文字列表現。 文字列

サポートされる引数:

  • 数値の文字列表現。

サポートされていない引数(NULLを返す):

  • 2進数および16進数の文字列表現。
  • 数値。

返される値

  • 16ビットのブレインフロート値、さもなくばNULL (\N)。 BFloat16
注記

関数は文字列表現から変換する際に精度の静かな損失を許可します。

その他の情報

toDate

Converts the argument to Date data type.

If the argument is DateTime or DateTime64, it truncates it and leaves the date component of the DateTime:

If the argument is a String, it is parsed as Date or DateTime. If it was parsed as DateTime, the date component is being used:

If the argument is a number and looks like a UNIX timestamp (is greater than 65535), it is interpreted as a DateTime, then truncated to Date in the current timezone. The timezone argument can be specified as a second argument of the function. The truncation to Date depends on the timezone:

The example above demonstrates how the same UNIX timestamp can be interpreted as different dates in different time zones.

If the argument is a number and it is smaller than 65536, it is interpreted as the number of days since 1970-01-01 (the first UNIX day) and converted to Date. It corresponds to the internal numeric representation of the Date data type. Example:

This conversion does not depend on timezones.

If the argument does not fit in the range of the Date type, it results in an implementation-defined behavior, that can saturate to the maximum supported date or overflow:

The function toDate can be also written in alternative forms:

toDateOrZero

The same as toDate but returns lower boundary of Date if an invalid argument is received. Only String argument is supported.

クエリ:

結果:

toDateOrNull

The same as toDate but returns NULL if an invalid argument is received. Only String argument is supported.

クエリ:

結果:

toDateOrDefault

Like toDate but if unsuccessful, returns a default value which is either the second argument (if specified), or otherwise the lower boundary of Date.

構文

クエリ:

結果:

toDateTime

Converts an input value to DateTime.

構文

引数

注記

expr が数値の場合、それはUnixエポックの始まりからの秒数として解釈されます(Unixタイムスタンプとして)。 expr文字列 の場合、Unixタイムスタンプまたは日付/日時の文字列として解釈される場合があります。 したがって、短い数値の文字列表現(最大4桁)のパースはあいまいさのために明示的に無効化されています。例えば、文字列'1999'は年(不完全な日付/日時の文字列表現)またはUnixタイムスタンプの両方として解釈されます。長い数値の文字列は許可されます。

返される値

クエリ:

結果:

toDateTimeOrZero

The same as toDateTime but returns lower boundary of DateTime if an invalid argument is received. Only String argument is supported.

クエリ:

結果:

toDateTimeOrNull

The same as toDateTime but returns NULL if an invalid argument is received. Only String argument is supported.

クエリ:

結果:

toDateTimeOrDefault

Like toDateTime but if unsuccessful, returns a default value which is either the third argument (if specified), or otherwise the lower boundary of DateTime.

構文

クエリ:

結果:

toDate32

Converts the argument to the Date32 data type. If the value is outside the range, toDate32 returns the border values supported by Date32. If the argument has Date type, it's borders are taken into account.

構文

引数

返される値

  • カレンダー日。 タイプ Date32

  1. 値が範囲内である場合:
  1. 値が範囲外である場合:
  1. Date引数を使用:

toDate32OrZero

The same as toDate32 but returns the min value of Date32 if an invalid argument is received.

クエリ:

結果:

toDate32OrNull

The same as toDate32 but returns NULL if an invalid argument is received.

クエリ:

結果:

toDate32OrDefault

Converts the argument to the Date32 data type. If the value is outside the range, toDate32OrDefault returns the lower border value supported by Date32. If the argument has Date type, it's borders are taken into account. Returns default value if an invalid argument is received.

クエリ:

結果:

toDateTime64

Converts an input value to a value of type DateTime64.

構文

引数

  • expr — 値。 文字列UInt32浮動小数点またはDateTime
  • scale - ティックサイズ(精度):10-precision秒。 有効な範囲: [ 0 : 9 ]。
  • timezone (オプション) - 指定されたdatetime64オブジェクトのタイムゾーン。

返される値

  • サブ秒精度を持つカレンダー日と時間帯。 DateTime64

  1. 値が範囲内である場合:
  1. 精度付きの小数として:

小数点なしの値はUnixタイムスタンプ(秒単位)のものとして扱われます:

  1. timezoneを使用:

toDateTime64OrZero

Like toDateTime64, this function converts an input value to a value of type DateTime64 but returns the min value of DateTime64 if an invalid argument is received.

構文

引数

  • expr — 値。 文字列UInt32浮動小数点またはDateTime
  • scale - ティックサイズ(精度):10-precision秒。 有効な範囲: [ 0 : 9 ]。
  • timezone (オプション) - 指定されたDateTime64オブジェクトのタイムゾーン。

返される値

  • サブ秒精度を持つカレンダー日と時間帯、さもなくばDateTime64の最小値:1970-01-01 01:00:00.000DateTime64

クエリ:

結果:

その他の情報

toDateTime64OrNull

Like toDateTime64, this function converts an input value to a value of type DateTime64 but returns NULL if an invalid argument is received.

構文

引数

  • expr — 値。 文字列UInt32浮動小数点またはDateTime
  • scale - ティックサイズ(精度):10-precision秒。 有効な範囲: [ 0 : 9 ]。
  • timezone (オプション) - 指定されたDateTime64オブジェクトのタイムゾーン。

返される値

  • サブ秒精度を持つカレンダー日と時間帯、さもなくばNULLDateTime64/NULL

クエリ:

結果:

その他の情報

toDateTime64OrDefault

Like toDateTime64, this function converts an input value to a value of type DateTime64, but returns either the default value of DateTime64 or the provided default if an invalid argument is received.

構文

引数

  • expr — 値。 文字列UInt32浮動小数点またはDateTime
  • scale - ティックサイズ(精度):10-precision秒。 有効な範囲: [ 0 : 9 ]。
  • timezone (オプション) - 指定されたDateTime64オブジェクトのタイムゾーン。
  • default (オプション) - 無効な引数が渡された場合に返すデフォルト値。 DateTime64

返される値

  • サブ秒精度を持つカレンダー日と時間帯、さもなくばDateTime64の最小値または提供されたdefault値が返されます。 DateTime64

クエリ:

結果:

その他の情報

toDecimal32

Converts an input value to a value of type Decimal(9, S) with scale of S. Throws an exception in case of an error.

構文

引数

  • expr — 数字または数字の文字列表現を返す式。
  • S — 数値の小数部が持つことができる桁数を指定するスケールパラメータ、0から9の間。 UInt8

サポートされる引数:

  • (U)Int8/16/32/64/128/256型の値または文字列表現。
  • Float32/64型の値または文字列表現。

サポートされていない引数:

  • Float32/64型の値 NaN および Inf の文字列表現(ケース非感知)。
  • 2進数および16進数の文字列表現、例: SELECT toDecimal32('0xc0fe', 1);
注記

オーバーフローが発生する可能性があります。もしexprの値がDecimal32の境界を超えると: ( -1 * 10^(9 - S), 1 * 10^(9 - S) )。 小数部に過剰な桁が含まれている場合は切り捨てられます(四捨五入ではない)。 整数部に過剰な桁が含まれていると、例外が発生します。

危険

変換は余分な桁を削除し、Float32/Float64入力での操作が予期せぬ方法で行われる可能性があります。演算は浮動小数点命令を使用して行われるためです。 たとえば、toDecimal32(1.15, 2)1.14に等しいです。これは1.15 * 100が浮動小数点で114.99に等しいからです。 文字列入力を使用することで元の整数型を使用して演算が行われるようにできます:toDecimal32('1.15', 2) = 1.15

返される値

クエリ:

結果:

その他の情報

toDecimal32OrZero

Like toDecimal32, this function converts an input value to a value of type Decimal(9, S) but returns 0 in case of an error.

構文

引数

  • expr — 数字の文字列表現。 文字列
  • S — 数値の小数部が持つことができる桁数を指定するスケールパラメータ、0から9の間。 UInt8

サポートされる引数:

  • (U)Int8/16/32/64/128/256型の値または文字列表現。
  • Float32/64型の値または文字列表現。

サポートされていない引数:

  • Float32/64型の値のNaNおよびInfの文字列表現。
  • 2進数および16進数の文字列表現、例: SELECT toDecimal32OrZero('0xc0fe', 1);
注記

オーバーフローが発生する可能性があります。もしexprの値がDecimal32の境界を超えると: ( -1 * 10^(9 - S), 1 * 10^(9 - S) )。 小数部に過剰な桁が含まれている場合は切り捨てられます(四捨五入ではない)。 整数部に過剰な桁が含まれているとエラーが発生します。

返される値

  • 成功した場合は型 Decimal(9, S)の値、それ以外の場合は0S 小数桁数の値。 Decimal32(S)

クエリ:

結果:

その他の情報

toDecimal32OrNull

Like toDecimal32, this function converts an input value to a value of type Nullable(Decimal(9, S)) but returns 0 in case of an error.

構文

引数

  • expr — 数字の文字列表現。 文字列
  • S — 数値の小数部が持つことができる桁数を指定するスケールパラメータ、0から9の間。 UInt8

サポートされる引数:

  • (U)Int8/16/32/64/128/256型の値または文字列表現。
  • Float32/64型の値または文字列表現。

サポートされていない引数:

  • Float32/64型の値 NaN および Inf の文字列表現。
  • 2進数および16進数の文字列表現、例: SELECT toDecimal32OrNull('0xc0fe', 1);
注記

オーバーフローが発生する可能性があります。もしexprの値がDecimal32の境界を超えると: ( -1 * 10^(9 - S), 1 * 10^(9 - S) )。 小数部に過剰な桁が含まれている場合は切り捨てられます(四捨五入ではない)。 整数部に過剰な桁が含まれているとエラーが発生します。

返される値

  • 成功した場合は型 Nullable(Decimal(9, S))の値、それ以外の場合は同じ型の値NULLDecimal32(S)

クエリ:

結果:

その他の情報

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 9, specifying how many digits the fractional part of a number can have. UInt8.
  • default (optional) — The default value to return if parsing to type Decimal32(S) is unsuccessful. Decimal32(S).

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal32OrDefault('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal32: ( -1 * 10^(9 - S), 1 * 10^(9 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal32OrDefault(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal32OrDefault('1.15', 2) = 1.15

Returned value

  • Value of type Decimal(9, S) if successful, otherwise returns the default value if passed or 0 if not. Decimal32(S).

Examples

Query:

Result:

See also

toDecimal64

Converts an input value to a value of type Decimal(18, S) with scale of S. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.
  • S — Scale parameter between 0 and 18, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values or string representations of type Float32/64.

Unsupported arguments:

  • Values or string representations of Float32/64 values NaN and Inf (case-insensitive).
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal64('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal64: ( -1 * 10^(18 - S), 1 * 10^(18 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an exception.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal64(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal64('1.15', 2) = 1.15

Returned value

Example

Query:

Result:

See also

toDecimal64OrZero

Like toDecimal64, this function converts an input value to a value of type Decimal(18, S) but returns 0 in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 18, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal64OrZero('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal64: ( -1 * 10^(18 - S), 1 * 10^(18 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

Returned value

  • Value of type Decimal(18, S) if successful, otherwise 0 with S decimal places. Decimal64(S).

Example

Query:

Result:

See also

toDecimal64OrNull

Like toDecimal64, this function converts an input value to a value of type Nullable(Decimal(18, S)) but returns 0 in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 18, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal64OrNull('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal64: ( -1 * 10^(18 - S), 1 * 10^(18 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

Returned value

  • Value of type Nullable(Decimal(18, S)) if successful, otherwise value NULL of the same type. Decimal64(S).

Examples

Query:

Result:

See also

toDecimal64OrDefault

Like toDecimal64, this function converts an input value to a value of type Decimal(18, S) but returns the default value in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 18, specifying how many digits the fractional part of a number can have. UInt8.
  • default (optional) — The default value to return if parsing to type Decimal64(S) is unsuccessful. Decimal64(S).

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal64OrDefault('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal64: ( -1 * 10^(18 - S), 1 * 10^(18 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal64OrDefault(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal64OrDefault('1.15', 2) = 1.15

Returned value

  • Value of type Decimal(18, S) if successful, otherwise returns the default value if passed or 0 if not. Decimal64(S).

Examples

Query:

Result:

See also

toDecimal128

Converts an input value to a value of type Decimal(38, S) with scale of S. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.
  • S — Scale parameter between 0 and 38, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values or string representations of type Float32/64.

Unsupported arguments:

  • Values or string representations of Float32/64 values NaN and Inf (case-insensitive).
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal128('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal128: ( -1 * 10^(38 - S), 1 * 10^(38 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an exception.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal128(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal128('1.15', 2) = 1.15

Returned value

Example

Query:

Result:

See also

toDecimal128OrZero

Like toDecimal128, this function converts an input value to a value of type Decimal(38, S) but returns 0 in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 38, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal128OrZero('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal128: ( -1 * 10^(38 - S), 1 * 10^(38 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

Returned value

  • Value of type Decimal(38, S) if successful, otherwise 0 with S decimal places. Decimal128(S).

Example

Query:

Result:

See also

toDecimal128OrNull

Like toDecimal128, this function converts an input value to a value of type Nullable(Decimal(38, S)) but returns 0 in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 38, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal128OrNull('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal128: ( -1 * 10^(38 - S), 1 * 10^(38 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

Returned value

  • Value of type Nullable(Decimal(38, S)) if successful, otherwise value NULL of the same type. Decimal128(S).

Examples

Query:

Result:

See also

toDecimal128OrDefault

Like toDecimal128, this function converts an input value to a value of type Decimal(38, S) but returns the default value in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 38, specifying how many digits the fractional part of a number can have. UInt8.
  • default (optional) — The default value to return if parsing to type Decimal128(S) is unsuccessful. Decimal128(S).

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal128OrDefault('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal128: ( -1 * 10^(38 - S), 1 * 10^(38 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal128OrDefault(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal128OrDefault('1.15', 2) = 1.15

Returned value

  • Value of type Decimal(38, S) if successful, otherwise returns the default value if passed or 0 if not. Decimal128(S).

Examples

Query:

Result:

See also

toDecimal256

Converts an input value to a value of type Decimal(76, S) with scale of S. Throws an exception in case of an error.

Syntax

Arguments

  • expr — Expression returning a number or a string representation of a number. Expression.
  • S — Scale parameter between 0 and 76, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • Values or string representations of type (U)Int8/16/32/64/128/256.
  • Values or string representations of type Float32/64.

Unsupported arguments:

  • Values or string representations of Float32/64 values NaN and Inf (case-insensitive).
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal256('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal256: ( -1 * 10^(76 - S), 1 * 10^(76 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an exception.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal256(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal256('1.15', 2) = 1.15

Returned value

Example

Query:

Result:

See also

toDecimal256OrZero

Like toDecimal256, this function converts an input value to a value of type Decimal(76, S) but returns 0 in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 76, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal256OrZero('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal256: ( -1 * 10^(76 - S), 1 * 10^(76 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

Returned value

  • Value of type Decimal(76, S) if successful, otherwise 0 with S decimal places. Decimal256(S).

Example

Query:

Result:

See also

toDecimal256OrNull

Like toDecimal256, this function converts an input value to a value of type Nullable(Decimal(76, S)) but returns 0 in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 76, specifying how many digits the fractional part of a number can have. UInt8.

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal256OrNull('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal256: ( -1 * 10^(76 - S), 1 * 10^(76 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

Returned value

  • Value of type Nullable(Decimal(76, S)) if successful, otherwise value NULL of the same type. Decimal256(S).

Examples

Query:

Result:

See also

toDecimal256OrDefault

Like toDecimal256, this function converts an input value to a value of type Decimal(76, S) but returns the default value in case of an error.

Syntax

Arguments

  • expr — A String representation of a number. String.
  • S — Scale parameter between 0 and 76, specifying how many digits the fractional part of a number can have. UInt8.
  • default (optional) — The default value to return if parsing to type Decimal256(S) is unsuccessful. Decimal256(S).

Supported arguments:

  • String representations of type (U)Int8/16/32/64/128/256.
  • String representations of type Float32/64.

Unsupported arguments:

  • String representations of Float32/64 values NaN and Inf.
  • String representations of binary and hexadecimal values, e.g. SELECT toDecimal256OrDefault('0xc0fe', 1);.
注記

An overflow can occur if the value of expr exceeds the bounds of Decimal256: ( -1 * 10^(76 - S), 1 * 10^(76 - S) ). Excessive digits in a fraction are discarded (not rounded). Excessive digits in the integer part will lead to an error.

危険

Conversions drop extra digits and could operate in an unexpected way when working with Float32/Float64 inputs as the operations are performed using floating point instructions. For example: toDecimal256OrDefault(1.15, 2) is equal to 1.14 because 1.15 * 100 in floating point is 114.99. You can use a String input so the operations use the underlying integer type: toDecimal256OrDefault('1.15', 2) = 1.15

Returned value

  • Value of type Decimal(76, S) if successful, otherwise returns the default value if passed or 0 if not. Decimal256(S).

Examples

Query:

Result:

See also

toString

Functions for converting between numbers, strings (but not fixed strings), dates, and dates with times. All these functions accept one argument.

When converting to or from a string, the value is formatted or parsed using the same rules as for the TabSeparated format (and almost all other text formats). If the string can't be parsed, an exception is thrown and the request is canceled.

When converting dates to numbers or vice versa, the date corresponds to the number of days since the beginning of the Unix epoch. When converting dates with times to numbers or vice versa, the date with time corresponds to the number of seconds since the beginning of the Unix epoch.

The date and date-with-time formats for the toDate/toDateTime functions are defined as follows:

As an exception, if converting from UInt32, Int32, UInt64, or Int64 numeric types to Date, and if the number is greater than or equal to 65536, the number is interpreted as a Unix timestamp (and not as the number of days) and is rounded to the date. This allows support for the common occurrence of writing toDate(unix_timestamp), which otherwise would be an error and would require writing the more cumbersome toDate(toDateTime(unix_timestamp)).

Conversion between a date and a date with time is performed the natural way: by adding a null time or dropping the time.

Conversion between numeric types uses the same rules as assignments between different numeric types in C++.

Additionally, the toString function of the DateTime argument can take a second String argument containing the name of the time zone. Example: Asia/Yekaterinburg In this case, the time is formatted according to the specified time zone.

Example

Query:

Result:

Also see the toUnixTimestamp function.

toFixedString

引数の String 型を FixedString(N) 型(固定長 N の文字列)に変換します。文字列のバイト数が N より少ない場合は、右側にヌルバイトが追加されます。文字列のバイト数が N より多い場合は、例外がスローされます。

構文

引数

  • s — 固定文字列に変換する文字列。 String
  • N — 長さ N。 UInt8

戻り値

クエリ:

結果:

toStringCutToZero

String または FixedString 引数を受け取ります。最初に見つかったゼロバイトで内容が切り捨てられた文字列を返します。

構文

クエリ:

結果:

クエリ:

結果:

toDecimalString

数値を文字列に変換し、小数点以下の桁数はユーザーが指定します。

構文

引数

  • number — 文字列として表現される値。 Int, UIntFloatDecimal
  • scale — 小数点以下の桁数。 UInt8
    • Decimal および Int, UInt 型の最大スケールは 77 です(Decimal の有効数字の最大数です)。
    • Float の最大スケールは 60 です。

戻り値

  • 指定された小数点以下の桁数を持つ String として表現された入力値。 リクエストされたスケールが元の数のスケールより小さい場合、数は一般的な算術に従って切り捨てられます。

クエリ:

結果:

reinterpretAsUInt8

入力値を UInt8 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • UInt8 として再解釈された値 xUInt8

クエリ:

結果:

reinterpretAsUInt16

入力値を UInt16 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • UInt16 として再解釈された値 xUInt16

クエリ:

結果:

reinterpretAsUInt32

入力値を UInt32 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • UInt32 として再解釈された値 xUInt32

クエリ:

結果:

reinterpretAsUInt64

入力値を UInt64 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • UInt64 として再解釈された値 xUInt64

クエリ:

結果:

reinterpretAsUInt128

入力値を UInt128 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • UInt128 として再解釈された値 xUInt128

クエリ:

結果:

reinterpretAsUInt256

入力値を UInt256 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • UInt256 として再解釈された値 xUInt256

クエリ:

結果:

reinterpretAsInt8

入力値を Int8 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Int8 として再解釈された値 xInt8

クエリ:

結果:

reinterpretAsInt16

入力値を Int16 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Int16 として再解釈された値 xInt16

クエリ:

結果:

reinterpretAsInt32

入力値を Int32 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Int32 として再解釈された値 xInt32

クエリ:

結果:

reinterpretAsInt64

入力値を Int64 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Int64 として再解釈された値 xInt64

クエリ:

結果:

reinterpretAsInt128

入力値を Int128 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Int128 として再解釈された値 xInt128

クエリ:

結果:

reinterpretAsInt256

入力値を Int256 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Int256 として再解釈された値 xInt256

クエリ:

結果:

reinterpretAsFloat32

入力値を Float32 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Float32 として再解釈された値 xFloat32

クエリ:

結果:

reinterpretAsFloat64

入力値を Float64 型の値として扱うことでバイトの再解釈を行います。 CAST とは異なり、この関数は元の値を保持しようとはしません - 対象の型が入力型を表現できない場合、出力は意味を成しません。

構文

引数

戻り値

  • Float64 として再解釈された値 xFloat64

クエリ:

結果:

reinterpretAsDate

文字列、固定文字列、または数値の値を受け取り、バイトをホスト順序(リトルエンディアン)で数値として解釈します。Unixエポックの開始からの日数として解釈された日付を返します。

構文

引数

戻り値

実装の詳細

注記

提供された文字列が十分に長くない場合、関数は必要な数のヌルバイトでパディングされた文字列として機能します。文字列が必要以上に長い場合、余分なバイトは無視されます。

クエリ:

結果:

reinterpretAsDateTime

これらの関数は文字列を受け取り、文字列の最初に配置されたバイトをホスト順序(リトルエンディアン)で数値として解釈します。Unixエポックの開始からの秒数として解釈された日時を返します。

構文

引数

戻り値

実装の詳細

注記

提供された文字列が十分に長くない場合、関数は必要な数のヌルバイトでパディングされた文字列として機能します。文字列が必要以上に長い場合、余分なバイトは無視されます。

クエリ:

結果:

reinterpretAsString

この関数は数値、日付、または日時を受け取り、ホスト順序(リトルエンディアン)で対応する値を表すバイトを含む文字列を返します。末尾のヌルバイトはドロップされます。例えば、UInt32 タイプの値 255 は 1 バイトの長さの文字列です。

構文

引数

戻り値

  • x を表すバイトを含む文字列。 String

クエリ:

結果:

reinterpretAsFixedString

この関数は数値、日付、または日時を受け取り、ホスト順序(リトルエンディアン)で対応する値を表すバイトを含む FixedString を返します。末尾のヌルバイトはドロップされます。例えば、UInt32 タイプの値 255 は 1 バイトの長さの FixedString です。

構文

引数

戻り値

  • x を表すバイトを含む FixedString。 FixedString

クエリ:

結果:

reinterpretAsUUID

注記

ここにリストされた UUID 関数に加えて、専用の UUID 関数のドキュメント があります。

16 バイトの文字列を受け取り、8 バイトの半分をリトルエンディアンのバイト順で解釈することによって UUID を返します。文字列が十分に長くない場合、関数は必要な数のヌルバイトでパディングされた文字列として機能します。文字列が 16 バイトより長い場合、末尾の余分なバイトは無視されます。

構文

引数

  • fixed_string — ビッグエンディアンバイト文字列。 FixedString

戻り値

  • UUID 型の値。 UUID

文字列から UUID への変換。

クエリ:

結果:

文字列から UUID への往復変換。

クエリ:

結果:

reinterpret

ソースのメモリ内バイトシーケンスを x 値に使用し、宛先型として再解釈します。

構文

引数

  • x — 任意の型。
  • type — 目的の型。 String

戻り値

  • 目的の型の値。

クエリ:

結果:

CAST

入力値を指定されたデータ型に変換します。 reinterpret 関数とは異なり、CAST は新しいデータ型を使用して同じ値を提示しようとします。変換ができない場合は、例外がスローされます。いくつかの構文のバリアントがサポートされています。

構文

引数

  • x — 変換する値。任意の型で構いません。
  • T — 目的のデータ型の名前。 String
  • t — 目的のデータ型。

戻り値

  • 変換された値。
注記

入力値が対象型の範囲に収まらない場合、結果がオーバーフローします。たとえば、CAST(-1, 'UInt8')255 を返します。

クエリ:

結果:

クエリ:

結果:

FixedString (N) への型変換は、String または FixedString 型の引数に対してのみ機能します。

Nullable への型変換とその逆もサポートされています。

クエリ:

結果:

クエリ:

結果:

参照

accurateCast(x, T)

xT データ型に変換します。

cast との違いは、accurateCast は型 T の範囲に収まらない場合、数値型のオーバーフローを許可しません。たとえば、accurateCast(-1, 'UInt8') は例外をスローします。

クエリ:

結果:

クエリ:

結果:

accurateCastOrNull(x, T)

入力値 x を指定されたデータ型 T に変換します。常に Nullable 型を返し、キャスト値が対象型に表現できない場合は NULL を返します。

構文

引数

  • x — 入力値。
  • T — 戻り値のデータ型の名前。

戻り値

  • 指定されたデータ型 T に変換された値。

クエリ:

結果:

クエリ:

結果:

accurateCastOrDefault(x, T[, default_value])

入力値 x を指定されたデータ型 T に変換します。キャストした値がターゲット型に表現できない場合、指定した場合はデフォルト型の値または default_value を返します。

文法

引数

  • x — 入力値。
  • T — 返されるデータ型の名前。
  • default_value — 返されるデータ型のデフォルト値。

返される値

  • 指定されたデータ型 T に変換された値。

クエリ:

結果:

クエリ:

結果:

toIntervalYear

n 年の間隔をデータ型 IntervalYear で返します。

文法

引数

  • n — 年数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalQuarter

n 四半期の間隔をデータ型 IntervalQuarter で返します。

文法

引数

  • n — 四半期の数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalMonth

n ヶ月の間隔をデータ型 IntervalMonth で返します。

文法

引数

  • n — ヶ月数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalWeek

n 週間の間隔をデータ型 IntervalWeek で返します。

文法

引数

  • n — 週間数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalDay

n 日の間隔をデータ型 IntervalDay で返します。

文法

引数

  • n — 日数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalHour

n 時間の間隔をデータ型 IntervalHour で返します。

文法

引数

  • n — 時間数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalMinute

n 分の間隔をデータ型 IntervalMinute で返します。

文法

引数

  • n — 分数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalSecond

n 秒の間隔をデータ型 IntervalSecond で返します。

文法

引数

  • n — 秒数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalMillisecond

n ミリ秒の間隔をデータ型 IntervalMillisecond で返します。

文法

引数

  • n — ミリ秒数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalMicrosecond

n マイクロ秒の間隔をデータ型 IntervalMicrosecond で返します。

文法

引数

  • n — マイクロ秒数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

toIntervalNanosecond

n ナノ秒の間隔をデータ型 IntervalNanosecond で返します。

文法

引数

  • n — ナノ秒数。整数またはそれに対応する文字列、及び浮動小数点数。(U)Int*/Float*/String

返される値

クエリ:

結果:

parseDateTime

文字列DateTime に変換します。この際、MySQL のフォーマット文字列 に従います。

この関数は、関数 formatDateTime の反対の操作です。

文法

引数

  • str — パースする文字列
  • format — フォーマット文字列。省略可能。指定しない場合は %Y-%m-%d %H:%i:%s
  • timezoneタイムゾーン。省略可能。

返される値

入力文字列から解析された DateTime 値。

サポートされているフォーマット指定子

formatDateTime にリストされたすべてのフォーマット指定子をサポートしていますが、次は除きます:

  • %Q: 四半期 (1-4)

エイリアス: TO_TIMESTAMP.

parseDateTimeOrZero

parseDateTime と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付を返します。

parseDateTimeOrNull

parseDateTime と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

エイリアス: str_to_date.

parseDateTimeInJodaSyntax

parseDateTime と似ていますが、フォーマット文字列は MySQL 構文ではなく Joda の形式です。

この関数は、関数 formatDateTimeInJodaSyntax の反対の操作です。

文法

引数

  • str — パースする文字列
  • format — フォーマット文字列。省略可能。指定しない場合は yyyy-MM-dd HH:mm:ss
  • timezoneタイムゾーン。省略可能。

返される値

入力文字列から取得された DateTime 値を返します。

サポートされているフォーマット指定子

formatDateTimeInJoda にリストされているすべてのフォーマット指定子をサポートしていますが、次は除きます:

  • S: 秒の分数
  • z: タイムゾーン
  • Z: タイムゾーンのオフセット/id

parseDateTimeInJodaSyntaxOrZero

parseDateTimeInJodaSyntax と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付を返します。

parseDateTimeInJodaSyntaxOrNull

parseDateTimeInJodaSyntax と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTime64

文字列DateTime64 に変換します。この際、MySQL のフォーマット文字列 に従います。

文法

引数

  • str — パースする文字列。
  • format — フォーマット文字列。省略可能。指定しない場合は %Y-%m-%d %H:%i:%s.%f
  • timezoneタイムゾーン。省略可能。

返される値

入力文字列から取得された DateTime64 値を返します。 返される値の精度は6です。

parseDateTime64OrZero

parseDateTime64 と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付を返します。

parseDateTime64OrNull

parseDateTime64 と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTime64InJodaSyntax

文字列DateTime64 に変換します。この際、Joda のフォーマット文字列 に従います。

文法

引数

  • str — パースする文字列。
  • format — フォーマット文字列。省略可能。指定しない場合は yyyy-MM-dd HH:mm:ss
  • timezoneタイムゾーン。省略可能。

返される値

入力文字列から取得された DateTime64 値を返します。 返される値の精度はフォーマット文字列内の S プレースホルダーの数に等しいですが、最大で6に制限されます。

parseDateTime64InJodaSyntaxOrZero

parseDateTime64InJodaSyntax と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付を返します。

parseDateTime64InJodaSyntaxOrNull

parseDateTime64InJodaSyntax と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTimeBestEffort

parseDateTime32BestEffort

文字列 で表現された日付と時刻を DateTime データ型に変換します。

この関数は、ISO 8601RFC 1123 - 5.2.14 RFC-822 日付および時刻の仕様、ClickHouse のおよびその他のいくつかの日付と時刻の形式を解析します。

文法

引数

  • time_string — 変換する日付と時刻を含む文字列。文字列
  • time_zone — タイムゾーン。この関数は time_string を指定されたタイムゾーンに従って解析します。文字列

サポートされている非標準形式

  • 9..10 桁の unix timestamp を含む文字列。
  • 日付と時刻のコンポーネントを持つ文字列: YYYYMMDDhhmmssDD/MM/YYYY hh:mm:ssDD-MM-YY hh:mmYYYY-MM-DD hh:mm:ss など。
  • 時間コンポーネントを持たない日付を含む文字列: YYYYYYYYMMYYYY*MMDD/MM/YYYYDD-MM-YY など。
  • 日と時きを含む文字列: DDDD hhDD hh:mm。この場合、MM01 に置き換えられます。
  • 日付と時刻の他にタイムゾーンのオフセット情報を含む文字列: YYYY-MM-DD hh:mm:ss ±h:mm など。例えば、2020-12-12 17:36:00 -5:00 です。
  • syslog タイムスタンプ: Mmm dd hh:mm:ss。例えば、Jun 9 14:20:32 です。

セパレータを持つすべての形式の場合、関数は月の名前をその完全な名前または月名の最初の3文字で表したもので解析します。例: 24/DEC/1824-Dec-1801-September-2018。 年が指定されていない場合は、現在の年と同じとみなされます。結果の DateTime が将来(現在の瞬間の 1 秒後でも)にあたる場合には、現在の年が前の年に置き換えられます。

返される値

  • time_stringDateTime データ型に変換されます。

クエリ:

結果:

クエリ:

結果:

クエリ:

結果:

クエリ:

結果:

クエリ:

結果:

クエリ:

結果:

参照

parseDateTimeBestEffortUS

この関数は、ISO 日付形式、例: YYYY-MM-DD hh:mm:ss の場合、及び月と日コンポーネントが明確に区別できるその他の日付形式、例: YYYYMMDDhhmmssYYYY-MMDD hh、または YYYY-MM-DD hh:mm:ss ±h:mm の場合は、parseDateTimeBestEffort と同様に動作します。月と日コンポーネントが明確に区別できない場合、例: MM/DD/YYYYMM-DD-YYYY、または MM-DD-YY の場合は、 DD/MM/YYYYDD-MM-YYYY、または DD-MM-YY の代わりに米国日付形式を優先します。ただし例外として、月の値が12より大きく31以下の場合は、この関数は parseDateTimeBestEffort の動作に従います。例: 15/08/20202020-08-15 として解析されます。

parseDateTimeBestEffortOrNull

parseDateTime32BestEffortOrNull

parseDateTimeBestEffort と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTimeBestEffortOrZero

parseDateTime32BestEffortOrZero

parseDateTimeBestEffort と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付またはゼロ日付時刻を返します。

parseDateTimeBestEffortUSOrNull

parseDateTimeBestEffortUS 関数と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTimeBestEffortUSOrZero

parseDateTimeBestEffortUS 関数と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付 (1970-01-01) またはゼロ日付と時刻 (1970-01-01 00:00:00) を返します。

parseDateTime64BestEffort

parseDateTimeBestEffort 関数と同様ですが、ミリ秒とマイクロ秒を解析し、DateTime データ型を返します。

文法

引数

  • time_string — 変換する日付または日付と時刻を含む文字列。文字列
  • precision — 精度。ミリ秒には 3、マイクロ秒には 6 を指定します。デフォルトは 3。省略可能。UInt8
  • time_zoneタイムゾーン。関数は time_string を指定されたタイムゾーンに従って解析します。省略可能。文字列

返される値

  • time_stringDateTime データ型に変換されます。

クエリ:

結果:

parseDateTime64BestEffortUS

parseDateTime64BestEffort と同様ですが、この関数は揺らぎがある場合は米国の日付形式 (MM/DD/YYYY など) を優先します。

parseDateTime64BestEffortOrNull

parseDateTime64BestEffort と同様ですが、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTime64BestEffortOrZero

parseDateTime64BestEffort と同様ですが、処理できない日付形式に遭遇した場合はゼロ日付またはゼロ日付時刻を返します。

parseDateTime64BestEffortUSOrNull

parseDateTime64BestEffort と同様ですが、この関数は揺らぎがある場合は米国の日付形式 (MM/DD/YYYY など) を優先し、処理できない日付形式に遭遇した場合は NULL を返します。

parseDateTime64BestEffortUSOrZero

parseDateTime64BestEffort と同様ですが、この関数は揺らぎがある場合は米国の日付形式 (MM/DD/YYYY など) を優先し、処理できない日付形式に遭遇した場合はゼロ日付またはゼロ日付時刻を返します。

toLowCardinality

入力パラメータを同じデータ型の LowCardinality バージョンに変換します。

LowCardinality データ型からデータを変換するには、CAST 関数を使用します。例えば、CAST(x as String)

文法

引数

  • expr — 結果として取得される 、およびサポートされているデータ型の1つ。

返される値

クエリ:

結果:

toUnixTimestamp64Second

DateTime64 を固定秒精度の Int64 値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

出力値は UTC のタイムスタンプであり、DateTime64 のタイムゾーンではありません。

文法

引数

  • value — 任意の精度の DateTime64 値。DateTime64

返される値

  • valueInt64 データ型に変換されます。Int64

クエリ:

結果:

toUnixTimestamp64Milli

DateTime64 を固定ミリ秒精度の Int64 値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

出力値は UTC のタイムスタンプであり、DateTime64 のタイムゾーンではありません。

文法

引数

  • value — 任意の精度の DateTime64 値。DateTime64

返される値

  • valueInt64 データ型に変換されます。Int64

クエリ:

結果:

toUnixTimestamp64Micro

DateTime64 を固定マイクロ秒精度の Int64 値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

出力値は UTC のタイムスタンプであり、DateTime64 のタイムゾーンではありません。

文法

引数

  • value — 任意の精度の DateTime64 値。DateTime64

返される値

  • valueInt64 データ型に変換されます。Int64

クエリ:

結果:

toUnixTimestamp64Nano

DateTime64 を固定ナノ秒精度の Int64 値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

出力値は UTC のタイムスタンプであり、DateTime64 のタイムゾーンではありません。

文法

引数

  • value — 任意の精度の DateTime64 値。DateTime64

返される値

  • valueInt64 データ型に変換されます。Int64

クエリ:

結果:

fromUnixTimestamp64Second

Int64を固定の秒精度とオプションのタイムゾーンを持つDateTime64値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

入力値は、指定された(または暗黙の)タイムゾーンではなく、UTCタイムスタンプとして扱われることに注意してください。

構文

引数

  • value — 任意の精度の値。Int64
  • timezone — (オプション)結果のタイムゾーン名。String

返される値

  • 精度0のDateTime64に変換されたvalueDateTime64

クエリ:

結果:

fromUnixTimestamp64Milli

Int64を固定のミリ秒精度とオプションのタイムゾーンを持つDateTime64値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

入力値は、指定された(または暗黙の)タイムゾーンではなく、UTCタイムスタンプとして扱われることに注意してください。

構文

引数

  • value — 任意の精度の値。Int64
  • timezone — (オプション)結果のタイムゾーン名。String

返される値

  • 精度3のDateTime64に変換されたvalueDateTime64

クエリ:

結果:

fromUnixTimestamp64Micro

Int64を固定のマイクロ秒精度とオプションのタイムゾーンを持つDateTime64値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

入力値は、指定された(または暗黙の)タイムゾーンではなく、UTCタイムスタンプとして扱われることに注意してください。

構文

引数

  • value — 任意の精度の値。Int64
  • timezone — (オプション)結果のタイムゾーン名。String

返される値

  • 精度6のDateTime64に変換されたvalueDateTime64

クエリ:

結果:

fromUnixTimestamp64Nano

Int64を固定のナノ秒精度とオプションのタイムゾーンを持つDateTime64値に変換します。入力値は、その精度に応じて適切にスケーリングされます。

注記

入力値は、指定された(または暗黙の)タイムゾーンではなく、UTCタイムスタンプとして扱われることに注意してください。

構文

引数

  • value — 任意の精度の値。Int64
  • timezone — (オプション)結果のタイムゾーン名。String

返される値

  • 精度9のDateTime64に変換されたvalueDateTime64

クエリ:

結果:

formatRow

任意の式を指定された形式の文字列に変換します。

構文

引数

  • format — テキスト形式。たとえば、CSVTSV
  • x,y, ... — 式。

返される値

  • 形式化された文字列。(テキスト形式の場合、通常は改行文字で終了します)。

クエリ:

結果:

: フォーマットに接頭辞/接尾辞が含まれている場合、各行に書き込まれます。

クエリ:

結果:

注: この関数では、行ベースの形式のみがサポートされています。

formatRowNoNewline

任意の式を指定された形式の文字列に変換します。formatRowとは異なり、この関数は最後の\nをトリムします(もしあれば)。

構文

引数

  • format — テキスト形式。たとえば、CSVTSV
  • x,y, ... — 式。

返される値

  • 形式化された文字列。

クエリ:

結果: