import type { ColumnDefaultValue, SQLExpression } from './model.js'; /** Legacy spelling of an expression default: `'fn:now()'` ≡ `{ expression: 'now()' }`. */ export declare const LEGACY_EXPRESSION_PREFIX = "fn:"; export type ParsedColumnDefault = { kind: 'expression'; sql: string; } | { kind: 'literal'; value: string | number | boolean; }; /** * Classifies a column default. `{ expression }` and a legacy `'fn:'` string * are SQL expressions, trimmed with their comments kept (an empty `# ` comment * at the end is trimmed like whitespace); every other value is a literal. * Canonical definitions, which snapshots and plugin hooks see, always use the * `fn:` spelling, so read defaults through this function rather than * inspecting the raw value. */ export declare function parseColumnDefault(value: ColumnDefaultValue): ParsedColumnDefault; /** * Snapshot form of a default: an expression in either spelling becomes the * trimmed `fn:` string (`{ expression: ' now() ' }` and `'fn: now()'` both give * `'fn:now()'`), so switching spellings plans nothing. Literals are unchanged. */ export declare function canonicalizeColumnDefault(value: ColumnDefaultValue): string | number | boolean; /** * SQL for a column default, whatever its `defaultKind`. An expression is its * SQL without comments: chkit renders it on the column's line, where a `--` * comment would swallow the `,`, COMMENT, CODEC or `;` that follows (#234). A * string is a quoted literal with quotes and backslashes escaped; numbers and * booleans render as written. */ export declare function renderDefault(value: ColumnDefaultValue): string; export declare function isSQLExpression(value: unknown): value is SQLExpression; /** Whether a quoted string literal is a valid value of `type`, whatever its Nullable or LowCardinality wrappers. */ export declare function columnTypeAcceptsStringLiteral(type: string): boolean; /** * Whether ClickHouse accepts any quoted string as a default of the rendered * column type `type` and stores NULL when the text does not parse: a Nullable * number, decimal, date, time, UUID or IP address. SimpleAggregateFunction * defers to its value type, as ClickHouse does. */ export declare function storesUnparsableLiteralAsNull(type: string): boolean; /** * storesUnparsableLiteralAsNull for an EPHEMERAL default, which ClickHouse * reads but never stores, so it skips the checks for stored column types. * LowCardinality around a Nullable number, date, time, UUID or IP address * then reads NULL too, where a DEFAULT column of that type is refused; a type * that LowCardinality rejects (decimals, DateTime64, Time64) still fails. * Verified on ClickHouse 26.3 (#234). */ export declare function readsUnparsableEphemeralLiteralAsNull(type: string): boolean; /** Text that starts with a function call, e.g. `now()` or `toDate(ts) + 1`. */ export declare function startsWithFunctionCall(value: string): boolean; /** * Trims an expression. ClickHouse reads `#` as a comment only before a space * or `!`, so trimming the space of an empty `# ` comment at the end would * leave a bare `#`, a syntax error. That comment is trimmed with the * whitespace instead. */ export declare function trimExpression(sql: string): string; //# sourceMappingURL=column-default.d.ts.map