ADR-018 — SQL native AI UDF
| 항목 | 값 |
|---|---|
| Status | Proposed (2026-05-25 — #1005 design step, P3) |
| Related Epic | #1005 |
| Related ADR | ADR-014 (MLOps Governance — ModelGrant) |
한 줄 결정: Trino UDF
ai_query(prompt, column)/ai_classify(text, labels)/ai_embed(text)신설. backend 는 GenD LlmProxyService 재호출 +ModelGrant(ADR-014) ABAC 통과.
결정
- UDF impl: Trino plugin (Java) 가 GenD API
POST /api/v1/ai/udf/{op}호출. row 단위 batch (≤100 rows). - Cost guard: row count × prompt token estimate > limit 시 query 자체 reject (SQLGuard 통합).
- Cache:
ai_embed결과는 (text_hash → embedding) 캐시 (Redis).ai_classify도 (text_hash + labels_hash → result). - ABAC: Trino session.user → GenD JWT →
ModelGrant.VIEW검증. 모델별 access 제한. - Audit:
UdfCallLog— 호출 row 수 + tokens used + cost.
비목표
- Streaming UDF (Trino 미지원). UDF 내부 다단 chain 별도.