Views in Spice are virtual tables defined by SQL queries. They help simplify complex queries and promote reuse across different applications by encapsulating query logic in a single, reusable entity.
To define a view in the spicepod.yaml configuration file, specify the views section. Each view definition must include a name and a sql field.
The following example demonstrates how to define a view named rankings that lists the top five products based on the total count of orders:
name: The view's identifier, used for referencing in queries.sql: The SQL query defining the view, supporting joins, subqueries, and aggregations.acceleration: Views can be locally accelerated.