Create and load
A warehouse, a table with the right types, COPY INTO from Parquet files, and a table created straight from files with CTAS.
A Fabric warehouse is a SQL database you write with T-SQL: tables, views, procedures, inserts and updates, stored as Delta tables in OneLake. This course uses Microsoft's public Wide World Importers sample files, so you only need a workspace.
Create the warehouse
In your workspace choose New item > Warehouse and name it Sales. It opens with an explorer on the left and a New SQL query button. Every query in this course runs there.
A table straight from files
The fastest way to a loaded table is CREATE TABLE AS SELECT (CTAS) over the files with OPENROWSET. Fabric reads the Parquet files and creates a table with matching columns and types:
CREATE TABLE dbo.dimension_city AS
SELECT *
FROM OPENROWSET(BULK 'https://fabrictutorialdata.dfs.core.windows.net/sampledata/WideWorldImportersDW/parquet/full/dimension_city/*.parquet');Do the same for the facts, with fact_sale in both places in the path and the table name. Then check what arrived:
SELECT COUNT_BIG(*) AS Rows FROM dbo.fact_sale;
SELECT TOP 10 * FROM dbo.dimension_city;A table you define, loaded with COPY INTO
CTAS is good for a first load. For a table you reload every night, define it yourself so the types stay fixed, then load it with COPY INTO, the statement Microsoft recommends for new ingestion code:
CREATE TABLE dbo.fact_sale_daily
(
SaleKey bigint,
CityKey int,
InvoiceDateKey datetime2(6),
Quantity int,
TotalExcludingTax numeric(18,2),
Profit numeric(18,2)
);TRUNCATE TABLE dbo.fact_sale_daily;
COPY INTO dbo.fact_sale_daily
FROM 'https://<your account>.dfs.core.windows.net/<container>/sales/*.parquet'
WITH ( FILE_TYPE = 'PARQUET' );TRUNCATE empties the table and COPY INTO reads every matching file in one statement. It also reads CSV with FILE_TYPE = 'CSV' and options such as FIRSTROW = 2 to skip a header. For files in your own storage, add a CREDENTIAL or give the warehouse access to the account.
Keys are notes, not rules
You can declare a primary key, but only as NONCLUSTERED and NOT ENFORCED:
ALTER TABLE dbo.dimension_city
ADD CONSTRAINT PK_dimension_city PRIMARY KEY NONCLUSTERED (CityKey) NOT ENFORCED;The warehouse does not stop a duplicate CityKey. The constraint tells the engine and tools what the key is; keeping it unique is the load's job.