String
BigQuery
SAFE_CONVERT_BYTES_TO_STRING
Safely converts a BYTES value to a STRING, replacing any invalid UTF-8 characters with the Unicode replacement character instead of raising an error.
Tipe hasil:
STRINGDiperbarui: 13 Jun 2026Syntax
SQL
SAFE_CONVERT_BYTES_TO_STRING(bytes_value)Parameter
bytes_valueBYTESwajib
The BYTES value to convert.
Contoh Penggunaan
Safe Conversion
SQL
1 SELECT 2 SAFE_CONVERT_BYTES_TO_STRING(b'Hello World') as safe_string;
Convert valid bytes to a string.
Hasil
Hello World
Handle Invalid UTF-8
SQL
1 SELECT 2 SAFE_CONVERT_BYTES_TO_STRING(b'Hello\xff\xfeWorld') as with_invalid;
Invalid characters are replaced with the Unicode replacement character.
Hasil
Hello��World
Compare with CAST
SQL
1 -- CAST will error on invalid UTF-8 2 -- SELECT CAST(b'Hello\xff' AS STRING); -- Error! 3 4 -- SAFE_CONVERT does not error 5 SELECT SAFE_CONVERT_BYTES_TO_STRING(b'Hello\xff') as safe_result;
SAFE_CONVERT is more tolerant than CAST for invalid byte sequences.
Pertanyaan Umum tentang SAFE_CONVERT_BYTES_TO_STRING
Apa itu fungsi SAFE_CONVERT_BYTES_TO_STRING di BigQuery?
Safely converts a BYTES value to a STRING, replacing any invalid UTF-8 characters with the Unicode replacement character instead of raising an error. Di BigQuery, fungsi SAFE_CONVERT_BYTES_TO_STRING termasuk dalam kelompok fungsi yang sering digunakan untuk mengolah dan menganalisis data secara efisien.
Bagaimana cara menggunakan SAFE_CONVERT_BYTES_TO_STRING di BigQuery?
Gunakan sintaks berikut: SAFE_CONVERT_BYTES_TO_STRING(bytes_value). Pastikan argumen yang dimasukkan sudah sesuai dengan tipe data yang diharapkan.
Apa nilai yang dikembalikan oleh fungsi SAFE_CONVERT_BYTES_TO_STRING?
Fungsi SAFE_CONVERT_BYTES_TO_STRING mengembalikan nilai bertipe STRING. Pastikan tipe data hasil sudah sesuai dengan kebutuhan query atau formula kamu. Jika input mengandung nilai NULL, perilaku fungsi dapat berbeda — selalu periksa dokumentasi untuk memastikan hasilnya sesuai ekspektasi.
Apa saja parameter fungsi SAFE_CONVERT_BYTES_TO_STRING?
Fungsi ini memiliki 1 parameter wajib. Parameter yang digunakan: bytes_value (BYTES, wajib): The BYTES value to convert..
Ngulik Langsung
Latihan Langsung →Sudah paham SAFE_CONVERT_BYTES_TO_STRING? Latih langsung di browser
Latihan interaktif, langsung di browser.