Aggregate
BigQuery
BIT_XOR
Performs a bitwise XOR operation across all values in a group. Returns a value where each bit is 1 if the number of input values with that bit set to 1 is odd.
Tipe hasil:
INT64Diperbarui: 13 Jun 2026Syntax
SQL
BIT_XOR(expression)Parameter
expressionINT64wajib
The integer column or expression to XOR together
Contoh Penggunaan
Simple XOR Aggregate
SQL
1 SELECT 2 BIT_XOR(value) as xor_result 3 FROM UNNEST([5, 3, 6]) as value; 4 -- 5 = 101 5 -- 3 = 011 6 -- 6 = 110 7 -- XOR = 000 = 0
XOR of 5, 3, and 6 produces 0.
Hasil
0
Checksum per Batch
SQL
1 SELECT 2 batch_id, 3 BIT_XOR(record_id) as checksum 4 FROM `project.dataset.batch_records` 5 GROUP BY batch_id;
Computes a simple checksum per batch for data integrity verification.
Hasil
| batch_id | checksum |
|---|---|
| B001 | 12345 |
| B002 | 67890 |
Parity Check
SQL
1 SELECT 2 partition_key, 3 BIT_XOR(data_hash) as parity 4 FROM `project.dataset.distributed_data` 5 GROUP BY partition_key;
Computes parity for distributed data verification.
Hasil
| partition_key | parity |
|---|---|
| P1 | 255 |
| P2 | 128 |
Pertanyaan Umum tentang BIT_XOR
Apa itu fungsi BIT_XOR di BigQuery?
Performs a bitwise XOR operation across all values in a group. Returns a value where each bit is 1 if the number of input values with that bit set to 1 is odd. Di BigQuery, fungsi BIT_XOR termasuk dalam kelompok fungsi yang sering digunakan untuk mengolah dan menganalisis data secara efisien.
Bagaimana cara menggunakan BIT_XOR di BigQuery?
Gunakan sintaks berikut: BIT_XOR(expression). Pastikan argumen yang dimasukkan sudah sesuai dengan tipe data yang diharapkan.
Apa nilai yang dikembalikan oleh fungsi BIT_XOR?
Fungsi BIT_XOR mengembalikan nilai bertipe INT64. 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 BIT_XOR?
Fungsi ini memiliki 1 parameter wajib. Parameter yang digunakan: expression (INT64, wajib): The integer column or expression to XOR together.
Ngulik Langsung
Latihan Langsung →Sudah paham BIT_XOR? Latih langsung di browser
Latihan interaktif, langsung di browser.