boolean
Definition
A boolean
is used whenever you have a column or SQL expression that returns True
or False
(i.e., yes or no).
Usage
Assume our order table contains a column indicating whether an order was returned ('yes') or not ('no'). To configure this column as a boolean attribute, we use the following VKL definition:
import: [
db.postgres.movie_db.public.ORDERS
]
kb {
class Order {
...
boolean Returned {
name.en: "Returned"
sql: "${ORDERS.returned} = 'yes'"
}
}
}
For boolean
, the sql
property can be any kind of SQL boolean expression.
The name of a boolean attribute refers to the case where the SQL expression evaluates to True
. That is, asking about "Returned Orders" will show the orders whose Returned
boolean is True
.
Naming the Negated Case
Veezoo allows optionally providing a name and synonyms for the case when the boolean is False
.
For instance, assume we are using Veezoo on a flight dataset indicating for each flight the origin and destination country. We would like to model whether a flight is domestic using a boolean
. If a flight is not domestic, it is international. We can instruct Veezoo to treat "international" as a synonym for "not domestic" using the negated
property as follows:
import: [
db.postgres.flights_db.public.FLIGHTS
]
kb {
class Flight {
...
boolean is_Domestic {
name.en: "Domestic"
sql: "${FLIGHTS.from_country} = ${FLIGHTS.to_country}"
negated: {
name.en: "International"
}
}
}
}
We can define additional synonyms for "international" by adding synonym
properties inside the negated
object.