@intentius/chant-lexicon-sql 0.124.46 → 0.124.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/change-set.d.ts +1 -1
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -1
- package/dist/clickhouse/apply/statements.d.ts +9 -0
- package/dist/clickhouse/apply/statements.d.ts.map +1 -1
- package/dist/clickhouse/apply/statements.js +24 -0
- package/dist/clickhouse/import/live-export.d.ts +7 -3
- package/dist/clickhouse/import/live-export.d.ts.map +1 -1
- package/dist/clickhouse/import/live-export.js +21 -5
- package/dist/clickhouse/live/named-collections.d.ts +27 -0
- package/dist/clickhouse/live/named-collections.d.ts.map +1 -0
- package/dist/clickhouse/live/named-collections.js +53 -0
- package/dist/clickhouse/live/undeclarable.d.ts +15 -3
- package/dist/clickhouse/live/undeclarable.d.ts.map +1 -1
- package/dist/clickhouse/live/undeclarable.js +18 -4
- package/dist/clickhouse/named-collections.d.ts +83 -0
- package/dist/clickhouse/named-collections.d.ts.map +1 -0
- package/dist/clickhouse/named-collections.js +203 -0
- package/dist/clickhouse/parser.d.ts.map +1 -1
- package/dist/clickhouse/parser.js +1 -1
- package/dist/clickhouse/plan/commands.d.ts +2 -1
- package/dist/clickhouse/plan/commands.d.ts.map +1 -1
- package/dist/clickhouse/plan/commands.js +17 -2
- package/dist/clickhouse/plan/diff.d.ts +15 -0
- package/dist/clickhouse/plan/diff.d.ts.map +1 -1
- package/dist/clickhouse/plan/diff.js +43 -1
- package/dist/clickhouse/plan/disruption.d.ts.map +1 -1
- package/dist/clickhouse/plan/disruption.js +5 -0
- package/dist/clickhouse/plan/rebuild-handoff.d.ts.map +1 -1
- package/dist/clickhouse/plan/rebuild-handoff.js +4 -0
- package/dist/clickhouse/plan/report.d.ts.map +1 -1
- package/dist/clickhouse/plan/report.js +6 -1
- package/dist/clickhouse/plan/rules.d.ts +5 -1
- package/dist/clickhouse/plan/rules.d.ts.map +1 -1
- package/dist/clickhouse/plan/rules.js +7 -3
- package/dist/clickhouse/plan/stream.d.ts +40 -0
- package/dist/clickhouse/plan/stream.d.ts.map +1 -0
- package/dist/clickhouse/plan/stream.js +107 -0
- package/dist/clickhouse/rebuild/observe.d.ts +3 -1
- package/dist/clickhouse/rebuild/observe.d.ts.map +1 -1
- package/dist/clickhouse/rebuild/observe.js +14 -1
- package/dist/clickhouse/review-catalog.d.ts +213 -0
- package/dist/clickhouse/review-catalog.d.ts.map +1 -0
- package/dist/clickhouse/review-catalog.js +330 -0
- package/dist/codegen/classifier-page.d.ts.map +1 -1
- package/dist/codegen/classifier-page.js +21 -4
- package/dist/codegen/clickhouse-module.d.ts.map +1 -1
- package/dist/codegen/clickhouse-module.js +3 -0
- package/dist/codegen/coverage-page.d.ts.map +1 -1
- package/dist/codegen/coverage-page.js +5 -3
- package/dist/codegen/docs.js +1 -1
- package/dist/codegen/postgres-classifier-page.js +1 -1
- package/dist/codegen/registry.d.ts.map +1 -1
- package/dist/codegen/registry.js +5 -0
- package/dist/composites/catalog.d.ts.map +1 -1
- package/dist/composites/catalog.js +100 -0
- package/dist/composites/clickhouse.d.ts +2 -0
- package/dist/composites/clickhouse.d.ts.map +1 -1
- package/dist/composites/clickhouse.js +2 -0
- package/dist/composites/otel-tables.d.ts +100 -0
- package/dist/composites/otel-tables.d.ts.map +1 -0
- package/dist/composites/otel-tables.js +282 -0
- package/dist/composites/stream-ingest.d.ts +63 -0
- package/dist/composites/stream-ingest.d.ts.map +1 -0
- package/dist/composites/stream-ingest.js +39 -0
- package/dist/coverage/clickhouse.json +1 -1
- package/dist/coverage/postgres.json +7 -7
- package/dist/coverage.d.ts +16 -6
- package/dist/coverage.d.ts.map +1 -1
- package/dist/coverage.js +10 -5
- package/dist/drizzle-command.d.ts +17 -0
- package/dist/drizzle-command.d.ts.map +1 -0
- package/dist/drizzle-command.js +91 -0
- package/dist/drizzle.d.ts +70 -0
- package/dist/drizzle.d.ts.map +1 -0
- package/dist/drizzle.js +684 -0
- package/dist/files/clickhouse.d.ts.map +1 -1
- package/dist/files/clickhouse.js +8 -1
- package/dist/files/common.d.ts +13 -0
- package/dist/files/common.d.ts.map +1 -1
- package/dist/files/common.js +5 -0
- package/dist/files/postgres.js +12 -2
- package/dist/generated/clickhouse.d.ts +2 -0
- package/dist/generated/clickhouse.d.ts.map +1 -1
- package/dist/generated/clickhouse.js +2 -0
- package/dist/import-parser.d.ts +21 -1
- package/dist/import-parser.d.ts.map +1 -1
- package/dist/import-parser.js +79 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/integrity.json +6 -5
- package/dist/lint/post-synth/audit-entries.d.ts.map +1 -1
- package/dist/lint/post-synth/audit-entries.js +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/index.js +2 -0
- package/dist/lint/post-synth/sqlch128.d.ts +18 -0
- package/dist/lint/post-synth/sqlch128.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch128.js +222 -0
- package/dist/lint/rules/postgres-templates.js +2 -2
- package/dist/lsp/postgres-template.d.ts.map +1 -1
- package/dist/lsp/postgres-template.js +11 -0
- package/dist/manifest.json +1 -1
- package/dist/mcp/postgres.js +1 -1
- package/dist/meta.json +25 -0
- package/dist/migrate/from-postgres/detect.d.ts +4 -0
- package/dist/migrate/from-postgres/detect.d.ts.map +1 -0
- package/dist/migrate/from-postgres/detect.js +7 -0
- package/dist/migrate/from-postgres/emit.d.ts +26 -0
- package/dist/migrate/from-postgres/emit.d.ts.map +1 -0
- package/dist/migrate/from-postgres/emit.js +86 -0
- package/dist/migrate/from-postgres/index.d.ts +51 -0
- package/dist/migrate/from-postgres/index.d.ts.map +1 -0
- package/dist/migrate/from-postgres/index.js +115 -0
- package/dist/migrate/from-postgres/translate.d.ts +73 -0
- package/dist/migrate/from-postgres/translate.d.ts.map +1 -0
- package/dist/migrate/from-postgres/translate.js +261 -0
- package/dist/migrate/from-postgres/types.d.ts +51 -0
- package/dist/migrate/from-postgres/types.d.ts.map +1 -0
- package/dist/migrate/from-postgres/types.js +211 -0
- package/dist/migration-replay.d.ts +73 -0
- package/dist/migration-replay.d.ts.map +1 -0
- package/dist/migration-replay.js +294 -0
- package/dist/okf/index.md +6 -0
- package/dist/okf/rules/SQLCH128.md +11 -0
- package/dist/okf/types/PostgresForeignDataWrapper.md +9 -0
- package/dist/okf/types/PostgresForeignServer.md +9 -0
- package/dist/okf/types/PostgresOperator.md +9 -0
- package/dist/okf/types/PostgresPublication.md +9 -0
- package/dist/okf/types/PostgresStatistics.md +9 -0
- package/dist/op/activities/postgres-migration.d.ts.map +1 -1
- package/dist/op/activities/postgres-migration.js +4 -0
- package/dist/op/activity-contracts.d.ts +20 -0
- package/dist/op/activity-contracts.d.ts.map +1 -1
- package/dist/op/activity-contracts.js +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +36 -2
- package/dist/postgres/apply/apply.js +8 -1
- package/dist/postgres/apply/statements.d.ts.map +1 -1
- package/dist/postgres/apply/statements.js +87 -2
- package/dist/postgres/constraint-names.d.ts +30 -0
- package/dist/postgres/constraint-names.d.ts.map +1 -0
- package/dist/postgres/constraint-names.js +72 -0
- package/dist/postgres/entities.d.ts +110 -1
- package/dist/postgres/entities.d.ts.map +1 -1
- package/dist/postgres/entities.js +146 -0
- package/dist/postgres/entity-types.d.ts +5 -0
- package/dist/postgres/entity-types.d.ts.map +1 -1
- package/dist/postgres/entity-types.js +5 -0
- package/dist/postgres/import/generator.d.ts.map +1 -1
- package/dist/postgres/import/generator.js +50 -2
- package/dist/postgres/import/live-export.d.ts.map +1 -1
- package/dist/postgres/import/live-export.js +2 -0
- package/dist/postgres/live/catalog-kinds.d.ts +14 -0
- package/dist/postgres/live/catalog-kinds.d.ts.map +1 -1
- package/dist/postgres/live/catalog-kinds.js +206 -0
- package/dist/postgres/live/catalog.d.ts +2 -0
- package/dist/postgres/live/catalog.d.ts.map +1 -1
- package/dist/postgres/live/catalog.js +3 -1
- package/dist/postgres/live/describe-resources.d.ts.map +1 -1
- package/dist/postgres/live/describe-resources.js +10 -2
- package/dist/postgres/migrate/backfill.d.ts +2 -0
- package/dist/postgres/migrate/backfill.d.ts.map +1 -1
- package/dist/postgres/migrate/backfill.js +7 -1
- package/dist/postgres/migrate/carry.d.ts +45 -1
- package/dist/postgres/migrate/carry.d.ts.map +1 -1
- package/dist/postgres/migrate/carry.js +72 -8
- package/dist/postgres/migrate/observe.d.ts +28 -4
- package/dist/postgres/migrate/observe.d.ts.map +1 -1
- package/dist/postgres/migrate/observe.js +41 -12
- package/dist/postgres/migrate/op.d.ts +26 -1
- package/dist/postgres/migrate/op.d.ts.map +1 -1
- package/dist/postgres/migrate/op.js +3 -1
- package/dist/postgres/migrate/steps.d.ts +35 -2
- package/dist/postgres/migrate/steps.d.ts.map +1 -1
- package/dist/postgres/migrate/steps.js +158 -12
- package/dist/postgres/parser.d.ts +72 -1
- package/dist/postgres/parser.d.ts.map +1 -1
- package/dist/postgres/parser.js +194 -2
- package/dist/postgres/plan/deep.d.ts.map +1 -1
- package/dist/postgres/plan/deep.js +29 -1
- package/dist/postgres/plan/diff.d.ts.map +1 -1
- package/dist/postgres/plan/diff.js +39 -1
- package/dist/postgres/plan/normalize.d.ts +17 -2
- package/dist/postgres/plan/normalize.d.ts.map +1 -1
- package/dist/postgres/plan/normalize.js +109 -1
- package/dist/postgres/plan/rules.d.ts +1 -0
- package/dist/postgres/plan/rules.d.ts.map +1 -1
- package/dist/postgres/plan/rules.js +3 -2
- package/dist/postgres/plan/schema.js +1 -1
- package/dist/postgres/secret-options.d.ts +10 -0
- package/dist/postgres/secret-options.d.ts.map +1 -0
- package/dist/postgres/secret-options.js +9 -0
- package/dist/postgres/testing/roundtrip-schema.d.ts +3 -2
- package/dist/postgres/testing/roundtrip-schema.d.ts.map +1 -1
- package/dist/postgres/testing/roundtrip-schema.js +13 -1
- package/dist/postgres.d.ts +1 -1
- package/dist/postgres.d.ts.map +1 -1
- package/dist/postgres.js +1 -1
- package/dist/rules/audit-entries.ts +1 -0
- package/dist/rules/postgres-templates.ts +2 -2
- package/dist/rules/sqlch128.ts +230 -0
- package/dist/serializer.d.ts +5 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +13 -2
- package/dist/sql-types-command.d.ts +13 -0
- package/dist/sql-types-command.d.ts.map +1 -1
- package/dist/sql-types-command.js +31 -16
- package/dist/sql-types.d.ts +22 -0
- package/dist/sql-types.d.ts.map +1 -1
- package/dist/sql-types.js +10 -6
- package/dist/sqlserver/lexer.d.ts +37 -0
- package/dist/sqlserver/lexer.d.ts.map +1 -0
- package/dist/sqlserver/lexer.js +254 -0
- package/dist/sqlserver/parse.d.ts +185 -0
- package/dist/sqlserver/parse.d.ts.map +1 -0
- package/dist/sqlserver/parse.js +767 -0
- package/dist/sqlserver/translate.d.ts +34 -0
- package/dist/sqlserver/translate.d.ts.map +1 -0
- package/dist/sqlserver/translate.js +495 -0
- package/dist/sqlserver/types.d.ts +44 -0
- package/dist/sqlserver/types.d.ts.map +1 -0
- package/dist/sqlserver/types.js +133 -0
- package/dist/sqlserver/validate.d.ts +31 -0
- package/dist/sqlserver/validate.d.ts.map +1 -0
- package/dist/sqlserver/validate.js +67 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +5 -0
- package/package.json +2 -2
- package/src/change-set.ts +2 -1
- package/src/clickhouse/apply/statements.ts +25 -0
- package/src/clickhouse/import/live-export.ts +20 -5
- package/src/clickhouse/live/named-collections.e2e.test.ts +88 -0
- package/src/clickhouse/live/named-collections.ts +61 -0
- package/src/clickhouse/live/undeclarable.e2e.test.ts +5 -3
- package/src/clickhouse/live/undeclarable.ts +20 -4
- package/src/clickhouse/named-collections.test.ts +187 -0
- package/src/clickhouse/named-collections.ts +224 -0
- package/src/clickhouse/parser.ts +2 -1
- package/src/clickhouse/plan/commands.ts +17 -2
- package/src/clickhouse/plan/diff.ts +57 -1
- package/src/clickhouse/plan/disruption.ts +5 -0
- package/src/clickhouse/plan/rebuild-handoff.ts +3 -0
- package/src/clickhouse/plan/report.ts +6 -1
- package/src/clickhouse/plan/rules.ts +14 -4
- package/src/clickhouse/plan/stream-s3queue.e2e.test.ts +148 -0
- package/src/clickhouse/plan/stream.test.ts +237 -0
- package/src/clickhouse/plan/stream.ts +111 -0
- package/src/clickhouse/rebuild/observe.ts +15 -1
- package/src/clickhouse/review-catalog.test.ts +181 -0
- package/src/clickhouse/review-catalog.ts +489 -0
- package/src/codegen/classifier-page.ts +21 -4
- package/src/codegen/clickhouse-module.ts +3 -0
- package/src/codegen/coverage-page.ts +5 -3
- package/src/codegen/docs.ts +1 -1
- package/src/codegen/postgres-classifier-page.ts +1 -1
- package/src/codegen/registry.ts +5 -0
- package/src/composites/catalog.test.ts +6 -1
- package/src/composites/catalog.ts +100 -0
- package/src/composites/clickhouse.ts +2 -0
- package/src/composites/composites.test.ts +1 -1
- package/src/composites/otel-tables.test.ts +118 -0
- package/src/composites/otel-tables.ts +339 -0
- package/src/composites/stream-ingest.test.ts +114 -0
- package/src/composites/stream-ingest.ts +82 -0
- package/src/core/undeclarable.test.ts +6 -5
- package/src/coverage/clickhouse.json +1 -1
- package/src/coverage/postgres.json +7 -7
- package/src/coverage.test.ts +27 -2
- package/src/coverage.ts +18 -7
- package/src/drizzle-command.ts +94 -0
- package/src/drizzle-kit.e2e.test.ts +89 -0
- package/src/drizzle-types.e2e.test.ts +67 -0
- package/src/drizzle.test.ts +358 -0
- package/src/drizzle.ts +737 -0
- package/src/files/clickhouse.ts +8 -1
- package/src/files/common.ts +14 -1
- package/src/files/postgres.ts +12 -2
- package/src/generated/clickhouse.ts +3 -0
- package/src/generated/lexicon-sql.json +25 -0
- package/src/import-parser.sqlserver.test.ts +92 -0
- package/src/import-parser.ts +79 -5
- package/src/index.ts +1 -1
- package/src/lint/post-synth/audit-entries.ts +1 -0
- package/src/lint/post-synth/index.ts +2 -0
- package/src/lint/post-synth/sqlch128.test.ts +107 -0
- package/src/lint/post-synth/sqlch128.ts +230 -0
- package/src/lint/rules/postgres-templates.ts +2 -2
- package/src/lsp/postgres-template.ts +11 -0
- package/src/mcp/postgres.ts +1 -1
- package/src/migrate/from-postgres/cli.test.ts +165 -0
- package/src/migrate/from-postgres/detect.ts +7 -0
- package/src/migrate/from-postgres/emit.ts +96 -0
- package/src/migrate/from-postgres/example.test.ts +205 -0
- package/src/migrate/from-postgres/index.ts +122 -0
- package/src/migrate/from-postgres/translate.test.ts +242 -0
- package/src/migrate/from-postgres/translate.ts +359 -0
- package/src/migrate/from-postgres/types.test.ts +116 -0
- package/src/migrate/from-postgres/types.ts +236 -0
- package/src/migrate/from-postgres/validate.e2e.test.ts +44 -0
- package/src/migrate/from-postgres/workspace.e2e.test.ts +114 -0
- package/src/migration-replay.e2e.test.ts +155 -0
- package/src/migration-replay.test.ts +173 -0
- package/src/migration-replay.ts +289 -0
- package/src/op/__snapshots__/watch-pipeline.test.ts.snap +2 -2
- package/src/op/activities/postgres-migration.ts +4 -0
- package/src/op/activity-contracts.ts +2 -0
- package/src/plugin.ts +37 -2
- package/src/postgres/apply/apply.ts +9 -1
- package/src/postgres/apply/statements.ts +74 -1
- package/src/postgres/constraint-names.ts +71 -0
- package/src/postgres/database-kinds.test.ts +384 -0
- package/src/postgres/entities.ts +266 -1
- package/src/postgres/entity-types.ts +5 -0
- package/src/postgres/import/generator.ts +42 -2
- package/src/postgres/import/live-export.ts +1 -0
- package/src/postgres/live/catalog-kinds.ts +223 -0
- package/src/postgres/live/catalog.ts +6 -1
- package/src/postgres/live/database-kinds.e2e.test.ts +164 -0
- package/src/postgres/live/describe-resources.ts +11 -2
- package/src/postgres/live/undeclarable.e2e.test.ts +13 -6
- package/src/postgres/migrate/backfill.ts +13 -1
- package/src/postgres/migrate/carry.ts +103 -8
- package/src/postgres/migrate/followups.e2e.test.ts +218 -0
- package/src/postgres/migrate/followups.test.ts +199 -0
- package/src/postgres/migrate/kinds.e2e.test.ts +5 -5
- package/src/postgres/migrate/observe.ts +53 -14
- package/src/postgres/migrate/op.ts +28 -1
- package/src/postgres/migrate/partition.e2e.test.ts +129 -0
- package/src/postgres/migrate/partition.test.ts +206 -0
- package/src/postgres/migrate/steps.ts +157 -12
- package/src/postgres/parser.ts +234 -2
- package/src/postgres/plan/deep.ts +28 -1
- package/src/postgres/plan/diff.ts +36 -1
- package/src/postgres/plan/normalize.ts +122 -1
- package/src/postgres/plan/rules.ts +10 -3
- package/src/postgres/plan/schema.ts +1 -1
- package/src/postgres/secret-options.ts +10 -0
- package/src/postgres/testing/roundtrip-schema.ts +13 -1
- package/src/postgres.ts +16 -0
- package/src/serializer.ts +13 -2
- package/src/skills/chant-sql-postgres-migration.md +3 -3
- package/src/skills/chant-sql-postgres.md +6 -1
- package/src/skills/chant-sql.md +2 -1
- package/src/sql-types-command.ts +38 -16
- package/src/sql-types.ts +11 -6
- package/src/sqlserver/fixture.test.ts +186 -0
- package/src/sqlserver/import-cli.test.ts +61 -0
- package/src/sqlserver/lexer.ts +260 -0
- package/src/sqlserver/parse.ts +865 -0
- package/src/sqlserver/translate.test.ts +396 -0
- package/src/sqlserver/translate.ts +558 -0
- package/src/sqlserver/types.test.ts +102 -0
- package/src/sqlserver/types.ts +154 -0
- package/src/sqlserver/validate.e2e.test.ts +32 -0
- package/src/sqlserver/validate.test.ts +49 -0
- package/src/sqlserver/validate.ts +76 -0
- package/src/validate.ts +5 -0
- package/src/workspace-kinds.test.ts +11 -0
- package/workspace-kinds.json +100 -2
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream engines (#4396): Kafka, S3Queue, AzureQueue, RabbitMQ, NATS and
|
|
3
|
+
* FileLog. A table on one of them stores no rows. It is a consumer: the
|
|
4
|
+
* materialized views that read it pull messages (or files) through it into a
|
|
5
|
+
* target, and the position it has reached lives outside the table, in the
|
|
6
|
+
* broker's committed offsets or in Keeper.
|
|
7
|
+
*
|
|
8
|
+
* What follows from that, and what this file holds:
|
|
9
|
+
*
|
|
10
|
+
* - There is no ALTER for the engine's arguments, and nothing to copy to a
|
|
11
|
+
* new table, so a change is neither `metadata` nor a `rebuild`: the table is
|
|
12
|
+
* replaced, with the views that read it detached around the replacement
|
|
13
|
+
* (SQLCH225, `./rules.ts`).
|
|
14
|
+
* - A replacement can lose the table's position. The two changes that do
|
|
15
|
+
* are found here and reported on the change as a note.
|
|
16
|
+
*/
|
|
17
|
+
/** The stream engines, as `system.tables.engine` names them. */
|
|
18
|
+
export const STREAM_ENGINES = new Set(["Kafka", "S3Queue", "AzureQueue", "RabbitMQ", "NATS", "FileLog"]);
|
|
19
|
+
/** Whether an engine name is a stream engine. */
|
|
20
|
+
export const isStreamEngine = (engine) => engine !== undefined && STREAM_ENGINES.has(engine);
|
|
21
|
+
/** Whether a canonical table is on a stream engine. */
|
|
22
|
+
export const isStreamTable = (o) => o.kind === "table" && isStreamEngine(o.engineName);
|
|
23
|
+
/** The arguments inside an engine's parentheses, split at top-level commas, string quotes removed. Empty when it has none. */
|
|
24
|
+
export function streamEngineArguments(engine) {
|
|
25
|
+
const open = engine?.indexOf("(") ?? -1;
|
|
26
|
+
if (engine === undefined || open < 0 || !engine.endsWith(")"))
|
|
27
|
+
return [];
|
|
28
|
+
const inner = engine.slice(open + 1, -1);
|
|
29
|
+
const out = [];
|
|
30
|
+
let depth = 0;
|
|
31
|
+
let quote;
|
|
32
|
+
let cur = "";
|
|
33
|
+
for (let i = 0; i < inner.length; i++) {
|
|
34
|
+
const ch = inner[i];
|
|
35
|
+
if (quote) {
|
|
36
|
+
cur += ch;
|
|
37
|
+
if (ch === "\\")
|
|
38
|
+
cur += inner[++i] ?? "";
|
|
39
|
+
else if (ch === quote)
|
|
40
|
+
quote = undefined;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (ch === "'" || ch === '"' || ch === "`")
|
|
44
|
+
quote = ch;
|
|
45
|
+
if (ch === "(" || ch === "[")
|
|
46
|
+
depth++;
|
|
47
|
+
if (ch === ")" || ch === "]")
|
|
48
|
+
depth--;
|
|
49
|
+
if (ch === "," && depth === 0) {
|
|
50
|
+
out.push(cur.trim());
|
|
51
|
+
cur = "";
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
cur += ch;
|
|
55
|
+
}
|
|
56
|
+
if (cur.trim())
|
|
57
|
+
out.push(cur.trim());
|
|
58
|
+
return out.map((a) => (/^'.*'$/.test(a) ? a.slice(1, -1) : a));
|
|
59
|
+
}
|
|
60
|
+
/** Kafka's positional arguments, in the order the engine takes them. */
|
|
61
|
+
const KAFKA_POSITIONAL = ["kafka_broker_list", "kafka_topic_list", "kafka_group_name", "kafka_format"];
|
|
62
|
+
/** A Kafka setting, from SETTINGS or from the engine's positional arguments. */
|
|
63
|
+
function kafkaSetting(o, name) {
|
|
64
|
+
const at = KAFKA_POSITIONAL.indexOf(name);
|
|
65
|
+
return o.settings[name] ?? (at >= 0 ? streamEngineArguments(o.engine)[at] : undefined);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What a replacement would lose, in a sentence each (#4396):
|
|
69
|
+
*
|
|
70
|
+
* - a different `kafka_group_name` is a different consumer group: it starts
|
|
71
|
+
* from the group's committed offsets, or from the topic's start when the
|
|
72
|
+
* group has none (`auto.offset.reset`);
|
|
73
|
+
* - a different S3Queue `keeper_path` is a different place for the table's
|
|
74
|
+
* record of processed files, so every file already seen is processed again.
|
|
75
|
+
*
|
|
76
|
+
* Neither is a refusal: a new group or path is sometimes the point.
|
|
77
|
+
*/
|
|
78
|
+
export function positionWarnings(before, after) {
|
|
79
|
+
const out = [];
|
|
80
|
+
if (before.engineName === "Kafka" && after.engineName === "Kafka") {
|
|
81
|
+
const b = kafkaSetting(before, "kafka_group_name");
|
|
82
|
+
const a = kafkaSetting(after, "kafka_group_name");
|
|
83
|
+
if (b !== a) {
|
|
84
|
+
out.push(`kafka_group_name changes from ${b ?? "none"} to ${a ?? "none"}: the new group starts from its own committed offsets, or from the start of the topic when it has none, ` +
|
|
85
|
+
"so messages already consumed may be read again or skipped");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (before.engineName === "S3Queue" && after.engineName === "S3Queue") {
|
|
89
|
+
const b = before.settings.keeper_path;
|
|
90
|
+
const a = after.settings.keeper_path;
|
|
91
|
+
if (b !== a) {
|
|
92
|
+
out.push(`keeper_path changes from ${b ?? "none"} to ${a ?? "none"}: the new path holds no record of processed files, so every file already seen is processed again`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/** Whether a materialized view reads from the table: its SELECT names the table, qualified or, in the table's own database, bare. */
|
|
98
|
+
export function readsTable(view, table) {
|
|
99
|
+
if (view.kind !== "materializedView" || view.select === undefined)
|
|
100
|
+
return false;
|
|
101
|
+
const escaped = table.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
102
|
+
const sameDatabase = view.database === table.database;
|
|
103
|
+
const database = table.database?.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
104
|
+
// The canonical SELECT drops the view's own database from a name, so a bare name is a table in the view's database.
|
|
105
|
+
const names = [...(sameDatabase ? [escaped] : []), ...(database ? [`${database}\\s*\\.\\s*${escaped}`] : [])];
|
|
106
|
+
return names.some((n) => new RegExp(`(?:^|[^\\w.])${n}(?![\\w.])`).test(view.select));
|
|
107
|
+
}
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
*
|
|
28
28
|
* Anything else is refused with a {@link RebuildRefusal}: a database that is
|
|
29
29
|
* neither Atomic nor Replicated, a table that is not there, a change that is
|
|
30
|
-
* not a rebuild, a working object chant did not make
|
|
30
|
+
* not a rebuild, a working object chant did not make, a table on a stream
|
|
31
|
+
* engine (Kafka, S3Queue, AzureQueue, RabbitMQ, NATS, FileLog), which holds no
|
|
32
|
+
* rows to copy and is replaced by the applier instead (#4396).
|
|
31
33
|
*
|
|
32
34
|
* A Replicated database (#3249) is Atomic on every replica, with its DDL run
|
|
33
35
|
* on each through Keeper, so the same EXCHANGE swaps the table everywhere.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../../src/clickhouse/rebuild/observe.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../../src/clickhouse/rebuild/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAMxD,OAAO,EAAE,KAAK,EAAwC,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEvG,gFAAgF;AAChF,MAAM,MAAM,SAAS,GACjB;IACE;;;;;;;;;;;;;;OAcG;IACH,IAAI,EAAE,mBAAmB,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACD;IACE;;;;;OAKG;IACH,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAEN,iGAAiG;AACjG,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE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,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc,CAO9F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,GAAG,YAAY,EAAE,CAS9F;AAED,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOrE;AAgBD,4EAA4E;AAC5E,wBAAsB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAGtG;AAED,2HAA2H;AAC3H,wBAAsB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGzI;AA4BD,+DAA+D;AAC/D,wBAAsB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6EzJ;AAoCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASvG;AAED,eAAO,MAAM,iBAAiB,GAAI,GAAG,kBAAkB,EAAE,WAAW,SAAS,KAAG,MAAmF,CAAC;AAEpK,mEAAmE;AACnE,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
*
|
|
28
28
|
* Anything else is refused with a {@link RebuildRefusal}: a database that is
|
|
29
29
|
* neither Atomic nor Replicated, a table that is not there, a change that is
|
|
30
|
-
* not a rebuild, a working object chant did not make
|
|
30
|
+
* not a rebuild, a working object chant did not make, a table on a stream
|
|
31
|
+
* engine (Kafka, S3Queue, AzureQueue, RabbitMQ, NATS, FileLog), which holds no
|
|
32
|
+
* rows to copy and is replaced by the applier instead (#4396).
|
|
31
33
|
*
|
|
32
34
|
* A Replicated database (#3249) is Atomic on every replica, with its DDL run
|
|
33
35
|
* on each through Keeper, so the same EXCHANGE swaps the table everywhere.
|
|
@@ -44,6 +46,7 @@ import { dropFormattingOnly } from "../plan/server-format.js";
|
|
|
44
46
|
import { CLASSIFIER_RULES } from "../plan/rules.js";
|
|
45
47
|
import { CLICKHOUSE_ENTITY_TYPES } from "../entities.js";
|
|
46
48
|
import { carriesMarker, readTrailerPairs, REBUILD_TRAILER_KEY, stripMarkerFromStatement } from "../ownership.js";
|
|
49
|
+
import { isStreamEngine } from "../plan/stream.js";
|
|
47
50
|
import { ident, isRebuild, qualifiedIdent, sqlString } from "../apply/statements.js";
|
|
48
51
|
/** A refusal: the rebuild cannot start, or cannot go on, for a reason a person has to act on. */
|
|
49
52
|
export class RebuildRefusal extends Error {
|
|
@@ -140,10 +143,18 @@ function ownWorkingObject(o, names, role, marker) {
|
|
|
140
143
|
}
|
|
141
144
|
return o;
|
|
142
145
|
}
|
|
146
|
+
/** The refusal for a stream-engine table, naming the engine and where its change goes instead (#4396). */
|
|
147
|
+
function streamRefusal(key, engine, side) {
|
|
148
|
+
return new RebuildRefusal(`${key} is ${side === "declared" ? "declared on" : "on the server as"} the ${engine} engine, a stream engine: it stores no rows, so there is nothing to backfill, and a direct SELECT from it either fails ` +
|
|
149
|
+
`or consumes messages. A change to it is SQLCH225 (replace a stream table), which the applier makes in place: it detaches the materialized views that read the table, drops and creates it, and attaches the views again ` +
|
|
150
|
+
`(ApplyOp with target "clickhouse").`);
|
|
151
|
+
}
|
|
143
152
|
/** Observe the rebuild of the declared table on the server. */
|
|
144
153
|
export async function observeRebuild(target, declared, marker) {
|
|
145
154
|
const database = declared.canonical.database ?? target.defaultDatabase;
|
|
146
155
|
const names = rebuildNames(database, declared.canonical.name);
|
|
156
|
+
if (isStreamEngine(declared.canonical.engineName))
|
|
157
|
+
throw streamRefusal(names.key, declared.canonical.engineName, "declared");
|
|
147
158
|
const [db] = await clickhouseQuery(target.endpoint, `SELECT engine FROM system.databases WHERE name = ${sqlString(database)}`);
|
|
148
159
|
if (!db)
|
|
149
160
|
throw new RebuildRefusal(`database ${database} is not on the server, so there is no ${names.key} to rebuild; the applier creates it`);
|
|
@@ -160,6 +171,8 @@ export async function observeRebuild(target, declared, marker) {
|
|
|
160
171
|
// Between EXCHANGE and the end of the swap, the table's own name holds the
|
|
161
172
|
// new table, still carrying role=new, and the new table's name holds the
|
|
162
173
|
// old table until it is renamed; the swap step finishes that.
|
|
174
|
+
if (isStreamEngine(liveRow.engine))
|
|
175
|
+
throw streamRefusal(names.key, liveRow.engine, "live");
|
|
163
176
|
const exchanged = liveRow.pairs?.get(REBUILD_TRAILER_KEY) === names.key && liveRow.pairs.get("role") === "new";
|
|
164
177
|
const newTable = exchanged ? undefined : ownWorkingObject(objects.get(names.newName), names, "new", marker);
|
|
165
178
|
const exchangedOld = exchanged ? objects.get(names.newName) : undefined;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The needs-review catalog: the judgment calls that turn a table from another
|
|
3
|
+
* database into a ClickHouse table, each as a finding with the evidence it
|
|
4
|
+
* used. A source reader (`chant import` of SQL Server, #4398; `chant migrate`
|
|
5
|
+
* of Postgres, #4399) does the mechanical work, a type map and a rename,
|
|
6
|
+
* and asks this module for everything that is a decision.
|
|
7
|
+
*
|
|
8
|
+
* Nothing here knows a source dialect. A reader describes its table in the
|
|
9
|
+
* neutral facts below (a candidate sort key, a column's nullability, a
|
|
10
|
+
* constraint) and gets back the ClickHouse choice, a finding to report, and
|
|
11
|
+
* for a constraint the comment lines to keep in the DDL. The rules are the
|
|
12
|
+
* same whichever database the table came from.
|
|
13
|
+
*
|
|
14
|
+
* ## API
|
|
15
|
+
*
|
|
16
|
+
* - {@link sortKeyReview}: `ORDER BY` from the candidates the source offers,
|
|
17
|
+
* in the priority `explicit-order`, `clustering-key`, `primary-key`,
|
|
18
|
+
* `unique-key`, then `tuple()`. Returns `orderBy`, the `settings` the key
|
|
19
|
+
* needs (`allow_nullable_key` when a key column is `Nullable`), and a
|
|
20
|
+
* finding that names the chosen candidate and the others it passed over.
|
|
21
|
+
* - {@link engineReview}: `MergeTree` for an append-only table;
|
|
22
|
+
* `ReplacingMergeTree(_version, _deleted)` for a CDC mirror, with the two
|
|
23
|
+
* columns it adds in `extraColumns`. `cdcColumns` names them otherwise
|
|
24
|
+
* (the Postgres pair uses the `CdcMirror` composite's `_is_deleted`).
|
|
25
|
+
* - {@link nullableReview}: a column's final type. A `NOT NULL` column keeps
|
|
26
|
+
* its type with no finding. A nullable column becomes `Nullable(T)` with a
|
|
27
|
+
* finding; when it has a default the finding says the default could
|
|
28
|
+
* replace `Nullable`.
|
|
29
|
+
* - {@link lowCardinalityReview}: a finding for a `String` column whose name
|
|
30
|
+
* and declared length suggest few distinct values. It never changes the
|
|
31
|
+
* type; offline, the name and the type are all there is to read.
|
|
32
|
+
* - {@link constraintReview}: foreign keys, checks, unique and exclusion
|
|
33
|
+
* constraints, which ClickHouse does not enforce. Returns `comments` (SQL `--` lines to
|
|
34
|
+
* put before the `CREATE`) and one finding per constraint.
|
|
35
|
+
* - {@link REVIEW_RULES}: every rule id with its summary and the ClickHouse
|
|
36
|
+
* documentation it rests on, for report metadata.
|
|
37
|
+
* - {@link findingText}: a finding as one line (object, message, evidence,
|
|
38
|
+
* suggestion), the form a SARIF `message` takes.
|
|
39
|
+
*
|
|
40
|
+
* A finding's `severity` is `warning` for a decision the author must confirm
|
|
41
|
+
* and `info` for a note that changes nothing. The caller maps findings to its
|
|
42
|
+
* own diagnostic type; `at` carries the source line and column when the
|
|
43
|
+
* reader knows them.
|
|
44
|
+
*
|
|
45
|
+
* Every ClickHouse type and engine this module writes is checked against the
|
|
46
|
+
* pinned catalog (`src/generated/clickhouse.ts`, ClickHouse 26.8) in
|
|
47
|
+
* `review-catalog.test.ts`, so a pin move that drops one fails there.
|
|
48
|
+
*
|
|
49
|
+
* Sources: the MergeTree sorting key and `allow_nullable_key`
|
|
50
|
+
* (https://clickhouse.com/docs/engines/table-engines/mergetree-family/mergetree),
|
|
51
|
+
* `ReplacingMergeTree(ver, is_deleted)`
|
|
52
|
+
* (https://clickhouse.com/docs/engines/table-engines/mergetree-family/replacingmergetree),
|
|
53
|
+
* `Nullable` (https://clickhouse.com/docs/sql-reference/data-types/nullable),
|
|
54
|
+
* `LowCardinality`
|
|
55
|
+
* (https://clickhouse.com/docs/sql-reference/data-types/lowcardinality).
|
|
56
|
+
*/
|
|
57
|
+
export type ReviewSeverity = "warning" | "info";
|
|
58
|
+
export type ReviewRuleId = "SQLRV001" | "SQLRV002" | "SQLRV003" | "SQLRV004" | "SQLRV005" | "SQLRV006" | "SQLRV007" | "SQLRV008" | "SQLRV009" | "SQLRV010" | "SQLRV011" | "SQLRV012";
|
|
59
|
+
export interface ReviewRule {
|
|
60
|
+
id: ReviewRuleId;
|
|
61
|
+
name: string;
|
|
62
|
+
summary: string;
|
|
63
|
+
docs: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The rules. SQLRV001 to SQLRV005 are the shared ones; the rest are raised by
|
|
67
|
+
* a source reader for what only its dialect has, and live here so a report
|
|
68
|
+
* lists one catalog.
|
|
69
|
+
*/
|
|
70
|
+
export declare const REVIEW_RULES: Readonly<Record<ReviewRuleId, ReviewRule>>;
|
|
71
|
+
export interface SourcePosition {
|
|
72
|
+
/** 1-based. */
|
|
73
|
+
line: number;
|
|
74
|
+
/** 1-based. */
|
|
75
|
+
column: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ReviewFinding {
|
|
78
|
+
ruleId: ReviewRuleId;
|
|
79
|
+
severity: ReviewSeverity;
|
|
80
|
+
/** The table or view the finding is about, as the source names it. */
|
|
81
|
+
object: string;
|
|
82
|
+
/** The column, when the finding is about one. */
|
|
83
|
+
column?: string;
|
|
84
|
+
message: string;
|
|
85
|
+
/** What the decision was read from: each entry is a fact in the source. */
|
|
86
|
+
evidence: readonly string[];
|
|
87
|
+
suggestion?: string;
|
|
88
|
+
at?: SourcePosition;
|
|
89
|
+
}
|
|
90
|
+
/** A finding as one line. */
|
|
91
|
+
export declare function findingText(f: ReviewFinding): string;
|
|
92
|
+
/**
|
|
93
|
+
* Where a candidate sort key came from, strongest first. `explicit-order` is
|
|
94
|
+
* an ordering the author declared for storage (a columnstore `ORDER`),
|
|
95
|
+
* `clustering-key` the key the source stores rows in (a clustered index),
|
|
96
|
+
* then the primary key and the first unique key.
|
|
97
|
+
*/
|
|
98
|
+
export type SortKeyKind = "explicit-order" | "clustering-key" | "primary-key" | "unique-key";
|
|
99
|
+
export interface SortKeyCandidate {
|
|
100
|
+
kind: SortKeyKind;
|
|
101
|
+
/** The index or constraint name, for the evidence. */
|
|
102
|
+
name?: string;
|
|
103
|
+
columns: readonly string[];
|
|
104
|
+
/** Columns the source sorts descending; ClickHouse's `ORDER BY` drops the direction. */
|
|
105
|
+
descending?: readonly string[];
|
|
106
|
+
/** The fact this candidate was read from, e.g. `CREATE CLUSTERED INDEX CX_t`. */
|
|
107
|
+
source: string;
|
|
108
|
+
}
|
|
109
|
+
export interface SortKeyInput {
|
|
110
|
+
object: string;
|
|
111
|
+
candidates: readonly SortKeyCandidate[];
|
|
112
|
+
/** Each column's ClickHouse type, by name; `Nullable(...)` marks a nullable key column. */
|
|
113
|
+
columnTypes: Readonly<Record<string, string>>;
|
|
114
|
+
at?: SourcePosition;
|
|
115
|
+
}
|
|
116
|
+
export interface SortKeyResult {
|
|
117
|
+
orderBy: string[];
|
|
118
|
+
/** MergeTree settings the key needs. */
|
|
119
|
+
settings: Record<string, string>;
|
|
120
|
+
finding: ReviewFinding;
|
|
121
|
+
}
|
|
122
|
+
export declare function sortKeyReview(input: SortKeyInput): SortKeyResult;
|
|
123
|
+
export interface EngineInput {
|
|
124
|
+
object: string;
|
|
125
|
+
/**
|
|
126
|
+
* `append` for a table that is loaded and queried, `cdc` for a mirror of a
|
|
127
|
+
* table that changes in place (#4399): rows arrive as new versions and a
|
|
128
|
+
* delete arrives as a marker row.
|
|
129
|
+
*/
|
|
130
|
+
mode: "append" | "cdc";
|
|
131
|
+
/** Facts about the source table that bear on the choice, as plain sentences. */
|
|
132
|
+
facts?: readonly string[];
|
|
133
|
+
/** The columns the source enforces unique, when it does. */
|
|
134
|
+
uniqueKey?: readonly string[];
|
|
135
|
+
/**
|
|
136
|
+
* For `cdc`, the names of the version and deleted columns, when the pipeline
|
|
137
|
+
* or the `CdcMirror` composite names them other than `_version` and
|
|
138
|
+
* `_deleted`. The names are the caller's; the catalog only writes them.
|
|
139
|
+
*/
|
|
140
|
+
cdcColumns?: {
|
|
141
|
+
version: string;
|
|
142
|
+
deleted: string;
|
|
143
|
+
};
|
|
144
|
+
at?: SourcePosition;
|
|
145
|
+
}
|
|
146
|
+
export interface EngineResult {
|
|
147
|
+
/** The text after `ENGINE =`. */
|
|
148
|
+
engine: string;
|
|
149
|
+
/** Columns the engine needs and the source does not have. */
|
|
150
|
+
extraColumns: Array<{
|
|
151
|
+
name: string;
|
|
152
|
+
type: string;
|
|
153
|
+
}>;
|
|
154
|
+
finding: ReviewFinding;
|
|
155
|
+
}
|
|
156
|
+
export declare const CDC_VERSION_COLUMN: {
|
|
157
|
+
readonly name: "_version";
|
|
158
|
+
readonly type: "UInt64";
|
|
159
|
+
};
|
|
160
|
+
export declare const CDC_DELETED_COLUMN: {
|
|
161
|
+
readonly name: "_deleted";
|
|
162
|
+
readonly type: "UInt8";
|
|
163
|
+
};
|
|
164
|
+
export declare function engineReview(input: EngineInput): EngineResult;
|
|
165
|
+
export interface NullableInput {
|
|
166
|
+
object: string;
|
|
167
|
+
column: string;
|
|
168
|
+
/** The column's ClickHouse type before `Nullable`. */
|
|
169
|
+
type: string;
|
|
170
|
+
sourceNullable: boolean;
|
|
171
|
+
/** The default as the ClickHouse expression it became, or the source text when it did not translate. */
|
|
172
|
+
defaultExpr?: string;
|
|
173
|
+
at?: SourcePosition;
|
|
174
|
+
}
|
|
175
|
+
export interface NullableResult {
|
|
176
|
+
type: string;
|
|
177
|
+
finding?: ReviewFinding;
|
|
178
|
+
}
|
|
179
|
+
export declare function nullableReview(input: NullableInput): NullableResult;
|
|
180
|
+
export interface LowCardinalityInput {
|
|
181
|
+
object: string;
|
|
182
|
+
column: string;
|
|
183
|
+
/** The ClickHouse type as emitted. Only `String` and `Nullable(String)` are candidates. */
|
|
184
|
+
type: string;
|
|
185
|
+
/** The source's declared maximum length, when it has one. */
|
|
186
|
+
maxLength?: number;
|
|
187
|
+
at?: SourcePosition;
|
|
188
|
+
}
|
|
189
|
+
/** The longest declared length that still counts as supporting evidence. */
|
|
190
|
+
export declare const LOW_CARDINALITY_MAX_LENGTH = 50;
|
|
191
|
+
export declare function lowCardinalityReview(input: LowCardinalityInput): ReviewFinding | undefined;
|
|
192
|
+
export interface ConstraintFact {
|
|
193
|
+
kind: "foreign-key" | "check" | "unique" | "exclusion";
|
|
194
|
+
name?: string;
|
|
195
|
+
columns?: readonly string[];
|
|
196
|
+
references?: {
|
|
197
|
+
table: string;
|
|
198
|
+
columns: readonly string[];
|
|
199
|
+
};
|
|
200
|
+
/** A check's expression, or an exclusion's `USING method (element WITH operator, ...)`, as the source wrote it. */
|
|
201
|
+
expression?: string;
|
|
202
|
+
at?: SourcePosition;
|
|
203
|
+
}
|
|
204
|
+
export interface ConstraintResult {
|
|
205
|
+
/** `-- ` lines to put before the `CREATE`; never contain a line break. */
|
|
206
|
+
comments: string[];
|
|
207
|
+
findings: ReviewFinding[];
|
|
208
|
+
}
|
|
209
|
+
export declare function constraintReview(input: {
|
|
210
|
+
object: string;
|
|
211
|
+
constraints: readonly ConstraintFact[];
|
|
212
|
+
}): ConstraintResult;
|
|
213
|
+
//# sourceMappingURL=review-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-catal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