MeridianMERIDIAN

Binary Boolean (0/1)

representation.boolean.binary

Boolean value represented as a binary digit: "0" for false, "1" for true. Common in CSV exports, database dumps, and flag columns. Transforms to DuckDB BOOLEAN type.

Worked samples

DuckDB 1.5.5 · finetype 0.6.64

ValueAs BOOLEAN
0false
1true

Background

Origin

The Boolean data type is named after George Boole, who first defined an algebraic system of logic in the mid-19th century.[1] A bit represents a logical state with one of two possible values.[2] The two values of a bit are most commonly represented as 1 and 0.[2] Claude E. Shannon first used the word bit in his 1948 paper A Mathematical Theory of Communication.[2] Shannon credited John W. Tukey, who had contracted binary digit to bit in a 1947 Bell Labs memo.[2]

In C, comparison operators return 0 for false and 1 for true.[1] Standard C added a Boolean type, _Bool, in C99, but Boolean values in C still behave as integers.[1] The SQL:1999 standard introduced a BOOLEAN data type as an optional feature (T031).[1] When a text export holds a column of only 0 and 1, it is worth asking whether it began life as a Boolean stored as a small integer. (Meridian's view)

Use

SQL Server's bit data type is an integer data type that can take a value of 1, 0 or NULL.[3] Microsoft's documentation says the bit data type can be used to store Boolean values.[3] In SQL Server, converting to bit promotes any nonzero value to 1.[3] In MySQL, BOOL and BOOLEAN are synonyms for TINYINT(1).[4] MySQL treats the values TRUE and FALSE as merely aliases for 1 and 0.[4] SQLite does not have a separate Boolean storage class and stores Boolean values as the integers 0 (false) and 1 (true).[5] SQLite recognises the keywords TRUE and FALSE as of version 3.23.0 (2018-04-02), as alternative spellings for the integer literals 1 and 0.[5] In Python, bool is a subclass of int, and in many numeric contexts False and True behave like the integers 0 and 1.[6]

PostgreSQL's boolean input function accepts 1 for the true state and 0 for the false state, alongside true, yes, on, false, no and off.[7] The Data Package Table Schema lists 1 among the default trueValues and 0 among the default falseValues for a boolean field.[8] A column of nothing but 0 and 1 is not proof of a flag: a count, a rating or a category code can happen to hold only those two digits in a sample, so check the column's name and documentation before casting it to a boolean. (Meridian's view) Treat an empty cell as unknown rather than false, since a missing flag and a recorded 0 are different statements about the data. (Meridian's view)

Detection notes

The simplest boolean format — just 0 and 1. The model must distinguish this from single-digit integers in count/ordinal columns (handled by column-level disambiguation rules).

Use it

CLI · DuckDB
$ finetype infer -i "0" --mode column
→ representation.boolean.binary

SELECT ft_infer('0');
-- → 'representation.boolean.binary'
Cast expression
CAST({col} AS BOOLEAN)

Schema

https://meridian.online/schemas/representation.boolean.binary · Frictionless type boolean

finetype taxonomy representation.boolean.binary -o json-schema

Aliases

binary_boolbit

Type Registry