Documentation
¶
Overview ¶
Package foodmart provides the Foodmart data set as embedded CSV files.
The data set originated as part of the test suite of the Pentaho Mondrian OLAP engine. It contains 26 tables: 7 fact tables, such as sales_fact_1997, and 19 dimension tables, such as customer.
Tables describes the schema. Each Table can be read as CSV, or the whole data set can be loaded into a SQL database using Load.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Tables = []Table{ { Name: "account", Columns: []Column{ {Name: "account_id", Type: "INTEGER", NotNull: true}, {Name: "account_parent", Type: "INTEGER", NotNull: false}, {Name: "account_description", Type: "VARCHAR(30)", NotNull: false}, {Name: "account_type", Type: "VARCHAR(30)", NotNull: true}, {Name: "account_rollup", Type: "VARCHAR(30)", NotNull: true}, {Name: "Custom_Members", Type: "VARCHAR(255)", NotNull: false}, }, }, { Name: "category", Columns: []Column{ {Name: "category_id", Type: "VARCHAR(30)", NotNull: true}, {Name: "category_parent", Type: "VARCHAR(30)", NotNull: false}, {Name: "category_description", Type: "VARCHAR(30)", NotNull: true}, {Name: "category_rollup", Type: "VARCHAR(30)", NotNull: false}, }, }, { Name: "currency", Columns: []Column{ {Name: "currency_id", Type: "INTEGER", NotNull: true}, {Name: "date", Type: "DATE", NotNull: true}, {Name: "currency", Type: "VARCHAR(30)", NotNull: true}, {Name: "conversion_ratio", Type: "DECIMAL(10,4)", NotNull: true}, }, }, { Name: "customer", Columns: []Column{ {Name: "customer_id", Type: "INTEGER", NotNull: true}, {Name: "account_num", Type: "BIGINT", NotNull: true}, {Name: "lname", Type: "VARCHAR(30)", NotNull: true}, {Name: "fname", Type: "VARCHAR(30)", NotNull: true}, {Name: "mi", Type: "VARCHAR(30)", NotNull: false}, {Name: "address1", Type: "VARCHAR(30)", NotNull: false}, {Name: "address2", Type: "VARCHAR(30)", NotNull: false}, {Name: "address3", Type: "VARCHAR(30)", NotNull: false}, {Name: "address4", Type: "VARCHAR(30)", NotNull: false}, {Name: "city", Type: "VARCHAR(30)", NotNull: false}, {Name: "state_province", Type: "VARCHAR(30)", NotNull: false}, {Name: "postal_code", Type: "VARCHAR(30)", NotNull: true}, {Name: "country", Type: "VARCHAR(30)", NotNull: true}, {Name: "customer_region_id", Type: "INTEGER", NotNull: true}, {Name: "phone1", Type: "VARCHAR(30)", NotNull: true}, {Name: "phone2", Type: "VARCHAR(30)", NotNull: true}, {Name: "birthdate", Type: "DATE", NotNull: true}, {Name: "marital_status", Type: "VARCHAR(30)", NotNull: true}, {Name: "yearly_income", Type: "VARCHAR(30)", NotNull: true}, {Name: "gender", Type: "VARCHAR(30)", NotNull: true}, {Name: "total_children", Type: "SMALLINT", NotNull: true}, {Name: "num_children_at_home", Type: "SMALLINT", NotNull: true}, {Name: "education", Type: "VARCHAR(30)", NotNull: true}, {Name: "date_accnt_opened", Type: "DATE", NotNull: true}, {Name: "member_card", Type: "VARCHAR(30)", NotNull: false}, {Name: "occupation", Type: "VARCHAR(30)", NotNull: false}, {Name: "houseowner", Type: "VARCHAR(30)", NotNull: false}, {Name: "num_cars_owned", Type: "INTEGER", NotNull: false}, {Name: "fullname", Type: "VARCHAR(60)", NotNull: true}, }, }, { Name: "days", Columns: []Column{ {Name: "day", Type: "INTEGER", NotNull: true}, {Name: "week_day", Type: "VARCHAR(30)", NotNull: true}, }, }, { Name: "department", Columns: []Column{ {Name: "department_id", Type: "INTEGER", NotNull: true}, {Name: "department_description", Type: "VARCHAR(30)", NotNull: true}, }, }, { Name: "employee", Columns: []Column{ {Name: "employee_id", Type: "INTEGER", NotNull: true}, {Name: "full_name", Type: "VARCHAR(30)", NotNull: true}, {Name: "first_name", Type: "VARCHAR(30)", NotNull: true}, {Name: "last_name", Type: "VARCHAR(30)", NotNull: true}, {Name: "position_id", Type: "INTEGER", NotNull: false}, {Name: "position_title", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "department_id", Type: "INTEGER", NotNull: true}, {Name: "birth_date", Type: "DATE", NotNull: true}, {Name: "hire_date", Type: "TIMESTAMP", NotNull: false}, {Name: "end_date", Type: "TIMESTAMP", NotNull: false}, {Name: "salary", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "supervisor_id", Type: "INTEGER", NotNull: false}, {Name: "education_level", Type: "VARCHAR(30)", NotNull: true}, {Name: "marital_status", Type: "VARCHAR(30)", NotNull: true}, {Name: "gender", Type: "VARCHAR(30)", NotNull: true}, {Name: "management_role", Type: "VARCHAR(30)", NotNull: false}, }, }, { Name: "employee_closure", Columns: []Column{ {Name: "employee_id", Type: "INTEGER", NotNull: true}, {Name: "supervisor_id", Type: "INTEGER", NotNull: true}, {Name: "distance", Type: "INTEGER", NotNull: false}, }, }, { Name: "expense_fact", Columns: []Column{ {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "account_id", Type: "INTEGER", NotNull: true}, {Name: "exp_date", Type: "TIMESTAMP", NotNull: true}, {Name: "time_id", Type: "INTEGER", NotNull: true}, {Name: "category_id", Type: "VARCHAR(30)", NotNull: true}, {Name: "currency_id", Type: "INTEGER", NotNull: true}, {Name: "amount", Type: "DECIMAL(10,4)", NotNull: true}, }, }, { Name: "inventory_fact_1997", Columns: []Column{ {Name: "product_id", Type: "INTEGER", NotNull: true}, {Name: "time_id", Type: "INTEGER", NotNull: false}, {Name: "warehouse_id", Type: "INTEGER", NotNull: false}, {Name: "store_id", Type: "INTEGER", NotNull: false}, {Name: "units_ordered", Type: "INTEGER", NotNull: false}, {Name: "units_shipped", Type: "INTEGER", NotNull: false}, {Name: "warehouse_sales", Type: "DECIMAL(10,4)", NotNull: false}, {Name: "warehouse_cost", Type: "DECIMAL(10,4)", NotNull: false}, {Name: "supply_time", Type: "SMALLINT", NotNull: false}, {Name: "store_invoice", Type: "DECIMAL(10,4)", NotNull: false}, }, }, { Name: "inventory_fact_1998", Columns: []Column{ {Name: "product_id", Type: "INTEGER", NotNull: true}, {Name: "time_id", Type: "INTEGER", NotNull: false}, {Name: "warehouse_id", Type: "INTEGER", NotNull: false}, {Name: "store_id", Type: "INTEGER", NotNull: false}, {Name: "units_ordered", Type: "INTEGER", NotNull: false}, {Name: "units_shipped", Type: "INTEGER", NotNull: false}, {Name: "warehouse_sales", Type: "DECIMAL(10,4)", NotNull: false}, {Name: "warehouse_cost", Type: "DECIMAL(10,4)", NotNull: false}, {Name: "supply_time", Type: "SMALLINT", NotNull: false}, {Name: "store_invoice", Type: "DECIMAL(10,4)", NotNull: false}, }, }, { Name: "position", Columns: []Column{ {Name: "position_id", Type: "INTEGER", NotNull: true}, {Name: "position_title", Type: "VARCHAR(30)", NotNull: true}, {Name: "pay_type", Type: "VARCHAR(30)", NotNull: true}, {Name: "min_scale", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "max_scale", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "management_role", Type: "VARCHAR(30)", NotNull: true}, }, }, { Name: "product", Columns: []Column{ {Name: "product_class_id", Type: "INTEGER", NotNull: true}, {Name: "product_id", Type: "INTEGER", NotNull: true}, {Name: "brand_name", Type: "VARCHAR(60)", NotNull: false}, {Name: "product_name", Type: "VARCHAR(60)", NotNull: true}, {Name: "SKU", Type: "BIGINT", NotNull: true}, {Name: "SRP", Type: "DECIMAL(10,4)", NotNull: false}, {Name: "gross_weight", Type: "DOUBLE", NotNull: false}, {Name: "net_weight", Type: "DOUBLE", NotNull: false}, {Name: "recyclable_package", Type: "BOOLEAN", NotNull: false}, {Name: "low_fat", Type: "BOOLEAN", NotNull: false}, {Name: "units_per_case", Type: "SMALLINT", NotNull: false}, {Name: "cases_per_pallet", Type: "SMALLINT", NotNull: false}, {Name: "shelf_width", Type: "DOUBLE", NotNull: false}, {Name: "shelf_height", Type: "DOUBLE", NotNull: false}, {Name: "shelf_depth", Type: "DOUBLE", NotNull: false}, }, }, { Name: "product_class", Columns: []Column{ {Name: "product_class_id", Type: "INTEGER", NotNull: true}, {Name: "product_subcategory", Type: "VARCHAR(30)", NotNull: false}, {Name: "product_category", Type: "VARCHAR(30)", NotNull: false}, {Name: "product_department", Type: "VARCHAR(30)", NotNull: false}, {Name: "product_family", Type: "VARCHAR(30)", NotNull: false}, }, }, { Name: "promotion", Columns: []Column{ {Name: "promotion_id", Type: "INTEGER", NotNull: true}, {Name: "promotion_district_id", Type: "INTEGER", NotNull: false}, {Name: "promotion_name", Type: "VARCHAR(30)", NotNull: false}, {Name: "media_type", Type: "VARCHAR(30)", NotNull: false}, {Name: "cost", Type: "DECIMAL(10,4)", NotNull: false}, {Name: "start_date", Type: "TIMESTAMP", NotNull: false}, {Name: "end_date", Type: "TIMESTAMP", NotNull: false}, }, }, { Name: "region", Columns: []Column{ {Name: "region_id", Type: "INTEGER", NotNull: true}, {Name: "sales_city", Type: "VARCHAR(30)", NotNull: false}, {Name: "sales_state_province", Type: "VARCHAR(30)", NotNull: false}, {Name: "sales_district", Type: "VARCHAR(30)", NotNull: false}, {Name: "sales_region", Type: "VARCHAR(30)", NotNull: false}, {Name: "sales_country", Type: "VARCHAR(30)", NotNull: false}, {Name: "sales_district_id", Type: "INTEGER", NotNull: false}, }, }, { Name: "reserve_employee", Columns: []Column{ {Name: "employee_id", Type: "INTEGER", NotNull: true}, {Name: "full_name", Type: "VARCHAR(30)", NotNull: true}, {Name: "first_name", Type: "VARCHAR(30)", NotNull: true}, {Name: "last_name", Type: "VARCHAR(30)", NotNull: true}, {Name: "position_id", Type: "INTEGER", NotNull: false}, {Name: "position_title", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "department_id", Type: "INTEGER", NotNull: true}, {Name: "birth_date", Type: "TIMESTAMP", NotNull: true}, {Name: "hire_date", Type: "TIMESTAMP", NotNull: false}, {Name: "end_date", Type: "TIMESTAMP", NotNull: false}, {Name: "salary", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "supervisor_id", Type: "INTEGER", NotNull: false}, {Name: "education_level", Type: "VARCHAR(30)", NotNull: true}, {Name: "marital_status", Type: "VARCHAR(30)", NotNull: true}, {Name: "gender", Type: "VARCHAR(30)", NotNull: true}, }, }, { Name: "salary", Columns: []Column{ {Name: "pay_date", Type: "TIMESTAMP", NotNull: true}, {Name: "employee_id", Type: "INTEGER", NotNull: true}, {Name: "department_id", Type: "INTEGER", NotNull: true}, {Name: "currency_id", Type: "INTEGER", NotNull: true}, {Name: "salary_paid", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "overtime_paid", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "vacation_accrued", Type: "DOUBLE", NotNull: true}, {Name: "vacation_used", Type: "DOUBLE", NotNull: true}, }, }, { Name: "sales_fact_1997", Columns: []Column{ {Name: "product_id", Type: "INTEGER", NotNull: true}, {Name: "time_id", Type: "INTEGER", NotNull: true}, {Name: "customer_id", Type: "INTEGER", NotNull: true}, {Name: "promotion_id", Type: "INTEGER", NotNull: true}, {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "store_sales", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "store_cost", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "unit_sales", Type: "DECIMAL(10,4)", NotNull: true}, }, }, { Name: "sales_fact_1998", Columns: []Column{ {Name: "product_id", Type: "INTEGER", NotNull: true}, {Name: "time_id", Type: "INTEGER", NotNull: true}, {Name: "customer_id", Type: "INTEGER", NotNull: true}, {Name: "promotion_id", Type: "INTEGER", NotNull: true}, {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "store_sales", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "store_cost", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "unit_sales", Type: "DECIMAL(10,4)", NotNull: true}, }, }, { Name: "sales_fact_dec_1998", Columns: []Column{ {Name: "product_id", Type: "INTEGER", NotNull: true}, {Name: "time_id", Type: "INTEGER", NotNull: true}, {Name: "customer_id", Type: "INTEGER", NotNull: true}, {Name: "promotion_id", Type: "INTEGER", NotNull: true}, {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "store_sales", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "store_cost", Type: "DECIMAL(10,4)", NotNull: true}, {Name: "unit_sales", Type: "DECIMAL(10,4)", NotNull: true}, }, }, { Name: "store", Columns: []Column{ {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "store_type", Type: "VARCHAR(30)", NotNull: false}, {Name: "region_id", Type: "INTEGER", NotNull: false}, {Name: "store_name", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_number", Type: "INTEGER", NotNull: false}, {Name: "store_street_address", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_city", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_state", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_postal_code", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_country", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_manager", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_phone", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_fax", Type: "VARCHAR(30)", NotNull: false}, {Name: "first_opened_date", Type: "TIMESTAMP", NotNull: false}, {Name: "last_remodel_date", Type: "TIMESTAMP", NotNull: false}, {Name: "store_sqft", Type: "INTEGER", NotNull: false}, {Name: "grocery_sqft", Type: "INTEGER", NotNull: false}, {Name: "frozen_sqft", Type: "INTEGER", NotNull: false}, {Name: "meat_sqft", Type: "INTEGER", NotNull: false}, {Name: "coffee_bar", Type: "BOOLEAN", NotNull: false}, {Name: "video_store", Type: "BOOLEAN", NotNull: false}, {Name: "salad_bar", Type: "BOOLEAN", NotNull: false}, {Name: "prepared_food", Type: "BOOLEAN", NotNull: false}, {Name: "florist", Type: "BOOLEAN", NotNull: false}, }, }, { Name: "store_ragged", Columns: []Column{ {Name: "store_id", Type: "INTEGER", NotNull: true}, {Name: "store_type", Type: "VARCHAR(30)", NotNull: false}, {Name: "region_id", Type: "INTEGER", NotNull: false}, {Name: "store_name", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_number", Type: "INTEGER", NotNull: false}, {Name: "store_street_address", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_city", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_state", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_postal_code", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_country", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_manager", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_phone", Type: "VARCHAR(30)", NotNull: false}, {Name: "store_fax", Type: "VARCHAR(30)", NotNull: false}, {Name: "first_opened_date", Type: "TIMESTAMP", NotNull: false}, {Name: "last_remodel_date", Type: "TIMESTAMP", NotNull: false}, {Name: "store_sqft", Type: "INTEGER", NotNull: false}, {Name: "grocery_sqft", Type: "INTEGER", NotNull: false}, {Name: "frozen_sqft", Type: "INTEGER", NotNull: false}, {Name: "meat_sqft", Type: "INTEGER", NotNull: false}, {Name: "coffee_bar", Type: "BOOLEAN", NotNull: false}, {Name: "video_store", Type: "BOOLEAN", NotNull: false}, {Name: "salad_bar", Type: "BOOLEAN", NotNull: false}, {Name: "prepared_food", Type: "BOOLEAN", NotNull: false}, {Name: "florist", Type: "BOOLEAN", NotNull: false}, }, }, { Name: "time_by_day", Columns: []Column{ {Name: "time_id", Type: "INTEGER", NotNull: true}, {Name: "the_date", Type: "TIMESTAMP", NotNull: false}, {Name: "the_day", Type: "VARCHAR(30)", NotNull: false}, {Name: "the_month", Type: "VARCHAR(30)", NotNull: false}, {Name: "the_year", Type: "SMALLINT", NotNull: false}, {Name: "day_of_month", Type: "SMALLINT", NotNull: false}, {Name: "week_of_year", Type: "INTEGER", NotNull: false}, {Name: "month_of_year", Type: "SMALLINT", NotNull: false}, {Name: "quarter", Type: "VARCHAR(30)", NotNull: false}, {Name: "fiscal_period", Type: "VARCHAR(30)", NotNull: false}, }, }, { Name: "warehouse", Columns: []Column{ {Name: "warehouse_id", Type: "INTEGER", NotNull: true}, {Name: "warehouse_class_id", Type: "INTEGER", NotNull: false}, {Name: "stores_id", Type: "INTEGER", NotNull: false}, {Name: "warehouse_name", Type: "VARCHAR(60)", NotNull: false}, {Name: "wa_address1", Type: "VARCHAR(30)", NotNull: false}, {Name: "wa_address2", Type: "VARCHAR(30)", NotNull: false}, {Name: "wa_address3", Type: "VARCHAR(30)", NotNull: false}, {Name: "wa_address4", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_city", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_state_province", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_postal_code", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_country", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_owner_name", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_phone", Type: "VARCHAR(30)", NotNull: false}, {Name: "warehouse_fax", Type: "VARCHAR(30)", NotNull: false}, }, }, { Name: "warehouse_class", Columns: []Column{ {Name: "warehouse_class_id", Type: "INTEGER", NotNull: true}, {Name: "description", Type: "VARCHAR(30)", NotNull: false}, }, }, }
Tables describes every table in the data set, in alphabetical order.
Functions ¶
func Load ¶
Load creates every Foodmart table in db and inserts all rows.
This package has no driver of its own; the caller supplies the database. For example, using a SQLite driver:
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
return err
}
if err := foodmart.Load(ctx, db); err != nil {
return err
}
The statements use "?" parameter markers and standard double-quoted identifiers; see Table.InsertSQL. Everything runs in a single transaction, so a failure leaves db unchanged.
func TableNames ¶
func TableNames() []string
TableNames returns the names of all tables, in alphabetical order.
Types ¶
type Column ¶
type Column struct {
// Name is the column name, as it appears in the CSV header row.
Name string
// Type is the SQL type, for example "VARCHAR(30)" or "DECIMAL(10,4)".
Type string
// NotNull is whether the column is declared NOT NULL.
NotNull bool
}
Column is a column of a Table.
type Table ¶
type Table struct {
// Name is the table name, and also the base name of its CSV file.
Name string
// Columns are the table's columns, in CSV column order.
Columns []Column
}
Table is a table in the Foodmart data set.
The zero value is not useful; obtain tables from Tables or Find.
func (Table) ColumnNames ¶
ColumnNames returns the table's column names, in CSV column order.
func (Table) CreateSQL ¶
CreateSQL returns a CREATE TABLE statement for the table, with identifiers quoted using the SQL standard double-quote.
func (Table) InsertSQL ¶
InsertSQL returns an INSERT statement for the table, with one positional parameter marker per column.
The marker is "?", which suits SQLite, MySQL and DuckDB. For a database that numbers its parameters, such as PostgreSQL, build the statement from Table.ColumnNames instead.
func (Table) Open ¶
Open returns the table's CSV file, including its header row. The caller must close it.
func (Table) ReadAll ¶
ReadAll returns every data row of the table. The header row is not included. Empty fields represent SQL NULL.
The larger fact tables have over 100,000 rows; to avoid holding them all in memory, use Table.Open and Table.Reader instead.