이 튜토리얼 단계에서는 Fabric HorizonDB SQL 편집기를 사용하여 horizon_sample 스키마를 생성하고 PostgreSQL SQL로 소규모 Contoso 주문 데이터셋을 로드합니다.
Important
Fabric HorizonDB는 공개 프리뷰 단계입니다. 기능, 한계, 동작 방식은 일반 제공 전에 변경될 수 있습니다. 자세한 내용은 Microsoft Fabric 미리보기 기능을 참조하세요.
Prerequisites
- HorizonDB 데이터베이스 생성을 완료합니다.
-
contoso-orders-db항목을 열어보세요. - 현재 미리보기에서 PostgreSQL에 연결할 수 있는 유일한 ID인 데이터베이스 생성자로 로그인하세요.
SQL 편집기 열기
contoso-orders-db에 대한 운영 데이터베이스 쿼리 환경을 엽니다.새 SQL 쿼리를 만듭니다.
쿼리가 SQL 분석 엔드포인트가 아닌 PostgreSQL 엔드포인트를 대상으로 하는지 확인하세요.
Run:
SELECT current_database() AS database_name, current_user AS signed_in_user, clock_timestamp() AS connected_at;결과가 항목의 연결 세부 정보에 표시된 데이터베이스
postgres, 그리고 생성자의 유효 신원을 식별하는지 확인하십시오.
스키마와 테이블 생성
다음 스크립트를 실행합니다.
CREATE SCHEMA IF NOT EXISTS horizon_sample;
CREATE TABLE IF NOT EXISTS horizon_sample.customers (
customer_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
customer_name text NOT NULL UNIQUE,
segment text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS horizon_sample.orders (
order_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
order_reference text NOT NULL UNIQUE,
customer_id bigint NOT NULL
REFERENCES horizon_sample.customers (customer_id),
order_date date NOT NULL DEFAULT current_date,
status text NOT NULL
CHECK (status IN ('open', 'processing', 'completed', 'cancelled')),
total numeric(12, 2) NOT NULL
CHECK (total >= 0),
created_at timestamptz NOT NULL DEFAULT now()
);
테이블들은 PostgreSQL 식별 열, 제약 조건, 타임스탬프 유형을 사용합니다. 기본 키는 나중에 수행하는 미러링 자격 검사도 지원합니다.
샘플 행을 불러오세요
이 재실행 가능한 로드를 실행하세요:
INSERT INTO horizon_sample.customers (customer_name, segment)
VALUES
('Contoso Retail', 'Enterprise'),
('Fabrikam Stores', 'Commercial'),
('Adventure Works', 'Enterprise')
ON CONFLICT (customer_name) DO UPDATE
SET segment = EXCLUDED.segment;
INSERT INTO horizon_sample.orders (
order_reference,
customer_id,
order_date,
status,
total
)
SELECT
source.order_reference,
customer.customer_id,
source.order_date,
source.status,
source.total
FROM (
VALUES
('ORD-1001', 'Contoso Retail', current_date, 'open', 1250.00::numeric),
('ORD-1002', 'Fabrikam Stores', current_date - 1, 'processing', 425.50::numeric),
('ORD-1003', 'Adventure Works', current_date - 2, 'completed', 980.25::numeric)
) AS source (
order_reference,
customer_name,
order_date,
status,
total
)
JOIN horizon_sample.customers AS customer
ON customer.customer_name = source.customer_name
ON CONFLICT (order_reference) DO UPDATE
SET
customer_id = EXCLUDED.customer_id,
order_date = EXCLUDED.order_date,
status = EXCLUDED.status,
total = EXCLUDED.total;
ON CONFLICT 안정적인 고객 이름과 주문 참조에 대해 로드를 멱등하게 만듭니다. 다시 실행하면 샘플 행이 중복 생성 대신 업데이트됩니다.
데이터 유효성 검사
Run:
SELECT
order_row.order_reference,
customer.customer_name,
customer.segment,
order_row.order_date,
order_row.status,
order_row.total
FROM horizon_sample.orders AS order_row
JOIN horizon_sample.customers AS customer
ON customer.customer_id = order_row.customer_id
ORDER BY order_row.order_reference;
결과에는 세 개의 행이 포함되어 있습니다:
| Order | Customer | 세그먼트 | 상태 | 총계 |
|---|---|---|---|---|
ORD-1001 |
콘토소 리테일 | Enterprise | 열다 | 1250.00 |
ORD-1002 |
Fabrikam 매장 | 상업용 | 가공 | 425.50 |
ORD-1003 |
어드벤처 웍스 | Enterprise | 완료됨 | 980.25 |
집계를 검증하세요:
SELECT
count(*) AS order_count,
sum(total) AS order_total,
min(order_date) AS earliest_order_date,
max(order_date) AS latest_order_date
FROM horizon_sample.orders;
기대 order_count 값은 3, 그리고 기대 order_total 값은 2655.75이다.
객체 탐색기 새로 고침
- 데이터베이스 개체 탐색기를 새로 고칩니다.
- 스키마 컬렉션을 확장하세요.
-
horizon_sample를 확장합니다. - 테이블 컬렉션을 확장하세요.
-
customers를 선택한 후 열과 기본 키를 검사합니다. -
orders를 선택한 후 해당 열, 기본 키, 외래 키, 고유 제약 조건, 검사 제약 조건을 검사합니다.
탐색기가 새로고침되지 않으면 PostgreSQL 메타데이터를 통해 테이블을 확인하십시오:
SELECT
table_schema,
table_name,
table_type
FROM information_schema.tables
WHERE table_schema = 'horizon_sample'
ORDER BY table_name;
튜토리얼 후반부에서는 Copy 작업을 사용하여 적격한 Fabric 소스에서 별도로 경계가 지정된 고객 신호 결과를 로드합니다. 이 단계에서 운영 중인 고객 및 주문 행을 변경하지 않아 PostgreSQL과 미러링된 분석 결과를 비교할 수 있도록 하세요.
로드 문제 해결
| 증상 | 해결책 |
|---|---|
permission denied for schema |
데이터베이스 생성자로 연결되어 있고, 고객 소유 스키마에서 객체를 생성하고 있는지 확인하세요. |
relation does not exist |
생성 스크립트를 실행하고, 현재 데이터베이스를 확인한 후 horizon_sample로 테이블을 한정하세요. |
| 고유 제약 조건 위반 | 충돌 규칙을 변경하기 전에 기존 고객 이름과 주문 참조를 검토하세요. |
| 외래 키 제약 조건 위반이 발생합니다 | 주문 전에 고객을 불러오고 고객 조인을 확인하세요. |
| 개체 탐색기가 최신 상태가 아닙니다 | 필요하면 DDL을 커밋하고, 탐색기를 새로 고침한 뒤 information_schema로 확인하십시오. |