/** * Iceberg type and partition-transform parsing and legality. * * Ported from the arceus repo (`lib/iceberg/iceberg-type.ts`, * `lib/iceberg/iceberg-partition-transform.ts`). arceus models types as * constructed objects and *throws* on the first problem because it is a CDK * construct; FDD instead parses the *string* type found in a JSON file and * returns structured results so the validator can collect every violation. * * Supports Iceberg primitives, the parameterized `decimal(p,s)` and `fixed[L]`, * and the nested v2 forms `struct`, `list`, and * `map` (recursively). Partition and sort transforms only apply to * primitive source types, so they are rejected on nested-typed columns. */ /** Iceberg type kinds: primitives, parameterized, and nested (v2). */ export declare enum IcebergTypeKind { BOOLEAN = "boolean", INT = "int", LONG = "long", FLOAT = "float", DOUBLE = "double", DATE = "date", TIME = "time", TIMESTAMP = "timestamp", TIMESTAMPTZ = "timestamptz", STRING = "string", UUID = "uuid", BINARY = "binary", DECIMAL = "decimal", FIXED = "fixed", STRUCT = "struct", LIST = "list", MAP = "map" } /** A named field of a `struct` type, in declared order. */ export interface IcebergStructField { /** Field name as written in the type string (original case preserved). */ readonly name: string; /** Field type. */ readonly type: IcebergType; } /** A parsed Iceberg type. */ export interface IcebergType { /** Discriminator. */ readonly kind: IcebergTypeKind; /** Decimal precision (set when `kind === DECIMAL`). */ readonly decimalPrecision?: number; /** Decimal scale (set when `kind === DECIMAL`). */ readonly decimalScale?: number; /** Fixed byte length (set when `kind === FIXED`). */ readonly fixedLength?: number; /** Ordered fields (set when `kind === STRUCT`). */ readonly structFields?: readonly IcebergStructField[]; /** Element type (set when `kind === LIST`). */ readonly elementType?: IcebergType; /** Map key type (set when `kind === MAP`). */ readonly keyType?: IcebergType; /** Map value type (set when `kind === MAP`). */ readonly valueType?: IcebergType; } /** * Why a type string failed to parse. `MALFORMED` is a broken nested string * (unbalanced brackets, empty struct, bad field, invalid inner type); * `DUPLICATE_FIELD` is two fields sharing a name in one struct; `UNKNOWN` is a * plain unrecognized scalar type (not an attempted nested form). */ export type IcebergTypeErrorCode = 'MALFORMED' | 'DUPLICATE_FIELD' | 'UNKNOWN'; /** A structured Iceberg type parse result. */ export type IcebergTypeParse = { readonly ok: true; readonly type: IcebergType; } | { readonly ok: false; readonly code: IcebergTypeErrorCode; readonly message: string; }; /** * Parse an Iceberg type string into a structured type, or explain why it is * invalid. Handles primitives, `decimal(p,s)`, `fixed[L]`, and the nested v2 * forms `struct`, `list`, and `map`, * recursively. Type keywords match case-insensitively; struct field names keep * their original case. * * @param typeStr Type string from a column definition. * @returns A structured parse result. */ export declare function analyzeIcebergType(typeStr: string): IcebergTypeParse; /** * Parse an Iceberg type string into a structured type. Thin wrapper over * `analyzeIcebergType` for callers that only need the type or null. * * @param typeStr Type string from a column definition. * @returns The parsed type, or null if it is not a valid Iceberg type. */ export declare function parseIcebergType(typeStr: string): IcebergType | null; /** Whether the string is a valid Iceberg column type. */ export declare function isValidIcebergType(typeStr: string): boolean; /** Whether a parsed Iceberg type is a nested type (`struct`, `list`, or `map`). */ export declare function isNestedIcebergType(type: IcebergType): boolean; /** Iceberg partition-transform kinds. */ export declare enum IcebergTransformKind { IDENTITY = "identity", YEAR = "year", MONTH = "month", DAY = "day", HOUR = "hour", VOID = "void", BUCKET = "bucket", TRUNCATE = "truncate" } /** A parsed Iceberg partition transform. */ export interface IcebergTransform { /** Discriminator. */ readonly kind: IcebergTransformKind; /** Parameter for `bucket[N]` / `truncate[W]` (positive integer). */ readonly param?: number; } /** * Parse an Iceberg transform string. Matching is case-insensitive. * * @param transformStr Transform string from a partition definition. * @returns The parsed transform, or null if it is not a valid transform. */ export declare function parseIcebergTransform(transformStr: string): IcebergTransform | null; /** * Whether a transform is legal on a given source-column type. Mirrors arceus's * `IcebergPartitionTransform.validateSourceType`. * * @param transform Parsed transform. * @param sourceType Parsed source-column type. * @returns True when the transform may be applied to that type. */ export declare function transformLegalOnType(transform: IcebergTransform, sourceType: IcebergType): boolean;