SQL#
Supernova는 DuckDB 1.4-LTS를 기반으로 한 읽기 전용 SQL 방언을 지원합니다. 레이크 테이블은 titan.<schema>.<table> 또는 <schema>.<table>로 참조합니다. 두 형식 모두 조직 레이크 안에서 확인됩니다.
with ranked as (
select
customer,
amount,
row_number() over (partition by customer order by created_at desc) as recency
from titan.stripe.charges
where status = 'succeeded' and not _deleted
)
select * exclude (recency)
from ranked
qualify recency = 1이름과 범위#
titan은 물리적 레이크 ID가 아닌 카탈로그 별칭입니다. 쿼리 텍스트에 물리적 ID를 쓸 수 없습니다. 단일 부분으로 된 관계 이름은 범위 안의 CTE와 별칭으로만 확인됩니다.
공백을 포함하거나 키워드와 충돌하는 식별자는 큰따옴표로 감쌉니다. 문자열 리터럴은 작은따옴표를 사용합니다.
지원되는 쿼리 구조#
핵심 기능에는 CTE, 내부 및 외부 조인, using, 윈도 함수, qualify, union all, union all by name, distinct, order by, limit, offset이 있습니다. 별표 수정자를 사용하면 열이 많은 소스 테이블을 편리하게 다룰 수 있습니다.
select * exclude (metadata, _synced_at)
replace (lower(email) as email)
from titan.hubspot.contacts
where not _deleted목록 인덱스는 1부터 시작합니다. JSON은 키, 인덱스, JSON 경로와 함께 ->, ->>를 지원합니다. 고차 목록 함수는 x -> expression과 lambda x: expression 형식을 받습니다.
유용한 내장 함수로는 date_trunc, strftime, strptime, date_diff, epoch_ms, split_part, regexp_extract, regexp_replace, string_agg, json_extract, unnest, generate_series, list_aggregate가 있습니다.
형 변환과 null#
cast(value as type)는 변환에 실패하면 오류를 냅니다. try_cast(value as type)는 해당 행에 null을 반환합니다. is not distinct from은 null에 안전한 동등 비교를 제공합니다.
select try_cast(property_annual_revenue as decimal(18, 2)) as annual_revenue
from titan.hubspot.companies거부되는 SQL 문#
쿼리는 레이크 상태를 변경할 수 없습니다. insert, update, delete, merge, drop, alter, truncate, attach, copy, install, load, 트랜잭션 문, 매크로 이외의 create 문은 거부된 구문을 명시하는 기능 오류를 반환합니다.
이 방언은 저장 프로시저, 공간 타입, 외부 카탈로그, 파일 자동 검색도 허용하지 않습니다. 수집에는 소스를, 영구적인 파생 테이블에는 모델을, 대상에 쓰는 작업에는 전송을 사용하세요.