default_order
Definition
Sometimes users will want to ask about "best customers" or "top 10 orders last month", without telling Veezoo by what it should be sorted.
Similarly to default_date, Veezoo allows you to define a default_order
in these cases, so that users don't always need to specify it in their questions.
Example: A class kb.Order
may have a Profit
attribute, which could make sense to use as the measure of "best orders" by default.
The user can still ask "best order by revenue" and get the result using another ordering attribute.
Usage
In our example above, we will need to add the property default_order
to kb.Order
.
import: [
db.postgres.movie_db.public.ORDERS
]
kb {
class Order {
name.en: "Order"
default_order: Profit
...
number Profit {
name.en: "Profit"
sql: "${ORDERS.profit}"
}
}
}
A default_order
can also be set to a numeric attributes or measures defined in another class.
Let's say there is another class called kb.Customer
and we want to define the best customer to be also based on the order's profit.
import: [
db.postgres.movie_db.public.CUSTOMERS
]
kb {
class Customer {
name.en: "Customer"
default_order: kb.Order.Profit
...
}
}
Notice here that we need to refer to it using its fully-qualified name kb.Order.Profit
, since it is not in the same context as Customer, i.e. Profit
is not inside the class Customer
definition.
Let's say there is a measure kb.Order.Avg_Order_Value
we want to order by, we can also define the measure as the default_order
.
import: [
db.postgres.movie_db.public.CUSTOMERS
]
kb {
class Customer {
name.en: "Customer"
default_order: kb.Order.Avg_Order_Value
...
}
}