Boolean
Generates a true or false value for each row, with a set percentage of true values.
Use it for flags, such as whether an account is active, an order was refunded or a customer opted in.
Most real flags are not evenly split, so set percentageTrue to the expected rate, such as 3 for a
refund flag.
A text column can contain labels such as Y and N instead of true and false. See
Labels for a text column.
The value of each row is independent of every other field. For a flag that depends on another column
in the same row, such as an order total above a limit, use a Calculated field.
Sub-field: value
Every JSON block on this page is a single field object, one entry in a table's fields array.
See Building a Request for the full request structure.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
falseLabel |
string? |
none | Text written for false in a text column. Set together with trueLabel. See Labels for a text column. |
map |
object |
required | Maps the value sub-field to a destination column. See Building a Request and Column types. |
nullPercentageMax |
number |
0 |
Upper bound (0-100) of the percentage of rows that should be null. See nullPercentageMin. |
nullPercentageMin |
number |
0 |
Lower bound (0-100) of the percentage of rows that should be null. The rate is fixed once for the whole field from this range, not recalculated per row. Set equal to nullPercentageMax for an exact rate. |
percentageTrue |
number |
50 |
The chance (0-100) that a row's value is true. Each row is evaluated separately against this percentage. 100 always produces true, and 0 always produces false. A value outside 0 to 100 is rejected. |
seed |
integer |
random | Per-field seed, overriding the request's own seed for this field only. |
trueLabel |
string? |
none | Text written for true in a text column, such as Y or Active. Set together with falseLabel. See Labels for a text column. |
unique |
boolean |
false |
Whether every generated value must differ from the others. A boolean has two values, so a unique field can produce at most two rows, or one when percentageTrue is 0 or 100. A request for more is rejected before any data is generated, stating how many are available. |
Column types
The value written depends on the type of the mapped column:
| Column type | Written as |
|---|---|
Boolean |
true and false |
Byte, Short, Integer, Long, Decimal, Float, Double |
1 and 0 |
VarChar, Char, Clob |
True and False, or the labels where they are set |
A field mapped to any other column type is rejected.
Labels for a text column
Many schemas store a flag as text, such as Y and N, Yes and No, or Active and Inactive.
trueLabel and falseLabel set the text written for each value:
- Both must be set, neither can be empty, and they must be different.
- They apply only to a text column:
VarChar,CharorClob. A field with labels mapped to any other column type is rejected. percentageTruesets how oftentrueLabelis written, in the same way as fortrue.- A
Calculatedfield that reads the column reads the label text.
Examples
Each example below is a single field object, one entry in a table's fields array within a full
request, not a complete request on its own. See Building a Request for how it fits
into a full DatasetRequest.
Even split
{
"type": "Boolean",
"map": { "value": { "column": "is_active", "dataType": "Boolean" } }
}
Sample output:
| is_active |
|---|
| true |
| true |
| true |
| false |
| false |
| false |
| false |
| true |
A flag true on about 10% of rows
{
"type": "Boolean",
"percentageTrue": 10,
"seed": 2,
"map": { "value": { "column": "is_flagged", "dataType": "Boolean" } }
}
Sample output:
| is_flagged |
|---|
| false |
| false |
| false |
| false |
| false |
| false |
| false |
| false |
| false |
| true |
Each row is evaluated separately, so the proportion of true values in a table is close to
percentageTrue but not exact. The difference gets smaller as the number of rows grows. At 0 and
100, every row has the same value.
Setting seed returns the same values on every run. It does not make the proportion exact.
Y and N in a text column
{
"type": "Boolean",
"percentageTrue": 80,
"trueLabel": "Y",
"falseLabel": "N",
"seed": 2,
"map": { "value": { "column": "is_subscribed", "dataType": "Char" } }
}
Sample output:
| is_subscribed |
|---|
| Y |
| Y |
| Y |
| N |
| Y |
| Y |
| N |
| Y |
1 and 0 in a numeric column
{
"type": "Boolean",
"percentageTrue": 30,
"seed": 5,
"map": { "value": { "column": "has_discount", "dataType": "Integer" } }
}
Sample output:
| has_discount |
|---|
| 0 |
| 1 |
| 1 |
| 0 |
| 0 |
| 0 |
| 1 |
| 0 |