본문 바로가기
WIKI 기술 지식 베이스

데이터 카탈로그 익스포트

원문 보기 위키 갱신

데이터 카탈로그 익스포트 (Data Catalogs Export)

Data Catalog Export의 핵심은 Spark, AWS Athena, Presto 같은 쿼리 엔진을 lakeFS와 연동하는 거예요.

Data Catalog(Hive Metastore, AWS Glue 등)는 Spark, Trino, Athena 같은 서비스를 위한 메타데이터를 저장해요. 테이블의 위치, 컬럼 정보, 파티션 같은 메타데이터가 여기에 담기죠.

Data Catalog Export를 쓰면 lakeFS의 버저닝 능력을 외부 데이터 웨어하우스와 쿼리 엔진에서 그대로 활용해, 브랜치와 커밋으로 테이블에 접근할 수 있어요.

출처: 문서

본문

Data Catalog Export란

이 가이드를 끝까지 읽으면 Athena, Trino, 그 밖의 카탈로그 의존 도구에서 lakeFS 데이터를 직접 쿼리할 수 있게 돼요:

USE main;
USE my_branch; -- any branch
USE v101; -- or tag

SELECT * FROM users
INNER JOIN events
ON users.id = events.user_id; -- SQL stays the same, branch or tag exist as schema

동작 방식

오늘날 잘 알려진 몇 가지 포맷은 lakeFS 안에 있는 기존 테이블을 "네이티브" 오브젝트 스토어 표현으로 내보낼 수 있게 해 줘요. 이 방식은 데이터를 lakeFS 밖으로 복사하지 않아도 돼요.

이건 메타데이터 표현이고, 훅(hooks)을 통해 자동으로 적용할 수 있어요.

테이블 선언 (Table Declaration)

lakeFS 저장소를 만든 뒤, 저장소의 _lakefs_tables/TABLE.yaml 경로에 테이블 기술자(table descriptor) 객체로 테이블을 설정해요. 참고: Glue 익스포터는 현재 type: hive 테이블만 내보낼 수 있어요. 더 많은 타입이 추가될 예정이에요.

Hive 테이블

Hive 메타데이터 서버의 테이블은 본질적으로 같은 접두사를 공유하는 객체들의 모음일 뿐이고, 오브젝트 스토어에는 테이블 메타데이터가 저장되지 않아요. 그래서 접두사(prefix), 파티션(partitions), 스키마(schema)를 직접 설정해야 해요.

name: animals
type: hive
path: path/to/animals/
partition_columns: ['year']
schema:
  type: struct
  fields:
    - name: year
      type: integer
      nullable: false
      metadata: {}
    - name: page
      type: string
      nullable: false
      metadata: {}
    - name: site
      type: string
      nullable: true
      metadata:
        comment: a comment about this column

팁

Hive가 인식하는 유용한 타입으로는 integer, long, short, string, double, float, date, timestamp가 있어요.

카탈로그 익스포터 (Catalog Exporters)

익스포터는 Lua 연동을 통해 접근하는 코드 패키지예요. 각 익스포터는 lakefs/catalogexport 패키지 네임스페이스 아래의 Lua 함수로 노출돼요. 훅에서 이 함수를 호출해 lakeFS 테이블을 여러 카탈로그에 연결해요.

현재 지원되는 익스포터

익스포터 설명 비고
Symlink exporter Hive의 SymlinkTextInputFormat을 사용해 테이블 메타데이터를 기록해요
AWS Glue Catalog (+ Athena) exporter Hive 포맷으로 Glue에 테이블을 만들고, 위치를 symlink 파일로 업데이트해요(Symlink Exporter 재사용) Iceberg 테이블이라면 Glue Catalog Federation 연동 문서를 참고하세요
Delta Lake table exporter lakeFS의 Delta Lake 테이블을 외부 스토리지로 내보내요
Unity Catalog exporter Unity Catalog에 Delta Lake 테이블을 등록하는 용도예요. Delta Lake exporter와 함께 동작해요. Delta Lake exporter가 lakeFS에서 Delta 테이블을 내보내면, 그 결과를 Unity Catalog exporter에 전달해 Unity Catalog에 등록해요 단계별 연동 가이드는 Unity Catalog Exporter 문서를 참고하세요. 현재 AWS S3 스토리지만 지원돼요

익스포터 실행하기

익스포터는 Lua 훅으로 실행하도록 설계돼 있어요.

events와 branches로 actions 트리거를 설정해요. 물론 필요하면 Lua 스크립트에 커스텀 필터링 로직을 추가할 수도 있고요. 익스포트될 때의 기본 테이블 이름은 ${repository_id}_${_lakefs_tables/TABLE.md(name field)}_${ref_name}_${short_commit}이에요.

export_table 브랜치에서 post-commit 이벤트가 발생할 때 실행되는 action 예시예요:

name: Glue Table Exporter
description: export my table to glue
on:
  post-commit:
    branches: ["export_table"]
hooks:
  - id: my_exporter
    type: lua
    properties:
      # exporter script location
      script_path: "scripts/my_export_script.lua"
      args:
        # table descriptor
        table_source: '_lakefs_tables/my_table.yaml'

Actions는 원하는 동작을 맞춤 설정으로 확장할 수 있어요. 예를 들어 브랜치 이름이 테이블 이름의 일부가 되므로, 브랜치 이름을 검증하는 액션을 만들 수 있죠:

# _lakefs_actions/validate_branch_name.yaml
name: validate-lower-case-branches
on:
  pre-create-branch:
hooks:
  - id: check_branch_id
    type: lua
    properties:
      script: |
        regexp = require("regexp")
        if not regexp.match("^[a-z0-9\\_\\-]+$", action.branch_id) then
          error("branches must be lower case, invalid branch ID: " .. action.branch_id)
        end

흐름 (Flow)

다음 다이어그램은 lakeFS Action이 트리거되어 익스포터를 호출하는 lua 훅이 실행될 때 무슨 일이 일어나는지 보여 줘요.

sequenceDiagram
    note over Lua Hook: lakeFS Action trigger. <br> Pass Context for the export.
    Lua Hook->>Exporter: export request
    note over Table Registry: _lakefs_tables/TABLE.yaml
    Exporter->>Table Registry: Get table descriptor
    Table Registry->>Exporter: Parse table structure
    Exporter->>Object Store: materialize an exported table
    Exporter->>Catalog: register object store location
    Query Engine-->Catalog: Query
    Query Engine-->Object Store: Query

더 알아보기 (Learn more)

공식 문서: lakeFS Data Catalogs Export 가이드