Skip to main content

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 doesn't need to be set to a numeric attribute that is inside the same class though.

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.

Currently, we only support default_order by a numeric attribute.