@intentius/chant-lexicon-sql 0.124.45 → 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,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `OtelTables`: the tables the OpenTelemetry Collector's `clickhouse` exporter writes, declared here so the exporter can run with `create_schema: false`.
|
|
3
|
+
*
|
|
4
|
+
* The DDL follows the exporter's own create statements at
|
|
5
|
+
* opentelemetry-collector-contrib v0.130.0, the otel lexicon's
|
|
6
|
+
* `COLLECTOR_PIN`, column for column:
|
|
7
|
+
*
|
|
8
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/logs_table.sql`
|
|
9
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/traces_table.sql`
|
|
10
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/traces_id_ts_lookup_table.sql`
|
|
11
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/traces_id_ts_lookup_mv.sql`
|
|
12
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/metrics_gauge_table.sql`,
|
|
13
|
+
* `metrics_sum_table.sql`, `metrics_summary_table.sql`,
|
|
14
|
+
* `metrics_histogram_table.sql` and `metrics_exp_histogram_table.sql`
|
|
15
|
+
*
|
|
16
|
+
* The table names default to the exporter's (`exporter/clickhouseexporter/config.go`,
|
|
17
|
+
* `createDefaultConfig`): `otel_logs`, `otel_traces` and `otel_metrics_<type>`.
|
|
18
|
+
* The exponential histogram table is `otel_metrics_exponential_histogram`:
|
|
19
|
+
* `defaultExpHistogramSuffix` in config.go is `_exponential_histogram`, though
|
|
20
|
+
* the README's option list says `otel_metrics_exp_histogram`. The code decides.
|
|
21
|
+
*
|
|
22
|
+
* With `create_schema: true` the exporter's traces exporter also creates a
|
|
23
|
+
* trace-id lookup table, `<traces>_trace_id_ts`, and a materialized view,
|
|
24
|
+
* `<traces>_trace_id_ts_mv`, that fills it from the traces table
|
|
25
|
+
* (`createTraceTables` in `exporter_traces.go`). The README's trace query
|
|
26
|
+
* reads the lookup table to bound a trace's time range. Both are declared
|
|
27
|
+
* here unless `traceIdLookup` is false.
|
|
28
|
+
*
|
|
29
|
+
* What differs from the exporter's DDL, none of it a column:
|
|
30
|
+
*
|
|
31
|
+
* - The engine is `MergeTree`, the exporter's default `table_engine`. A
|
|
32
|
+
* replicated setup declares its own tables.
|
|
33
|
+
* - `IF NOT EXISTS` and `ON CLUSTER` are left out; the sql lexicon plans the
|
|
34
|
+
* tables instead.
|
|
35
|
+
* - The metrics templates put `TTL` before `PARTITION BY`; here it follows
|
|
36
|
+
* `ORDER BY`, as in the logs and traces templates. ClickHouse reads the
|
|
37
|
+
* clauses the same in either order.
|
|
38
|
+
* - The exporter's JSON tables (`logs_json_table.sql`, `traces_json_table.sql`)
|
|
39
|
+
* are used only behind the `clickhouse.json` feature gate (alpha, off by
|
|
40
|
+
* default, `factory.go`) and are not declared.
|
|
41
|
+
*
|
|
42
|
+
* The database is not declared. Unqualified, the tables are created in the
|
|
43
|
+
* server's `default` database, which is the exporter's default `database`.
|
|
44
|
+
*/
|
|
45
|
+
import { type ClickHouseTable, type ClickHouseView } from "../clickhouse/entities.js";
|
|
46
|
+
/** The table names the exporter writes, by its config key. Each defaults to the exporter's. */
|
|
47
|
+
export interface OtelTableNames {
|
|
48
|
+
/** `logs_table_name` (default `otel_logs`). */
|
|
49
|
+
logs?: string;
|
|
50
|
+
/** `traces_table_name` (default `otel_traces`). */
|
|
51
|
+
traces?: string;
|
|
52
|
+
/** `metrics_tables.gauge.name` (default `otel_metrics_gauge`). */
|
|
53
|
+
gauge?: string;
|
|
54
|
+
/** `metrics_tables.sum.name` (default `otel_metrics_sum`). */
|
|
55
|
+
sum?: string;
|
|
56
|
+
/** `metrics_tables.summary.name` (default `otel_metrics_summary`). */
|
|
57
|
+
summary?: string;
|
|
58
|
+
/** `metrics_tables.histogram.name` (default `otel_metrics_histogram`). */
|
|
59
|
+
histogram?: string;
|
|
60
|
+
/** `metrics_tables.exponential_histogram.name` (default `otel_metrics_exponential_histogram`). */
|
|
61
|
+
exponentialHistogram?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface OtelTablesProps {
|
|
64
|
+
/** The database the tables are created in, the exporter's `database`. Unset, the names are unqualified and land in `default`. */
|
|
65
|
+
database?: string;
|
|
66
|
+
/**
|
|
67
|
+
* How long rows are kept, as the exporter's `ttl` takes it: a Go duration
|
|
68
|
+
* such as `72h` or `30m`. Rendered the way the exporter renders it
|
|
69
|
+
* (`GenerateTTLExpr` in `internal/clickhouse.go`): whole days as
|
|
70
|
+
* `toIntervalDay`, else hours, minutes or seconds. Unset or zero, no TTL.
|
|
71
|
+
*/
|
|
72
|
+
ttl?: string;
|
|
73
|
+
/** Table names other than the exporter's defaults, as set on the exporter. */
|
|
74
|
+
tables?: OtelTableNames;
|
|
75
|
+
/** Declare the trace-id lookup table and its materialized view (default true). */
|
|
76
|
+
traceIdLookup?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export type OtelTablesMembers = {
|
|
79
|
+
logs: ClickHouseTable;
|
|
80
|
+
traces: ClickHouseTable;
|
|
81
|
+
/** `<traces>_trace_id_ts`, absent when `traceIdLookup` is false. */
|
|
82
|
+
traceIdTs?: ClickHouseTable;
|
|
83
|
+
/** `<traces>_trace_id_ts_mv`, absent when `traceIdLookup` is false. */
|
|
84
|
+
traceIdTsView?: ClickHouseView;
|
|
85
|
+
metricsGauge: ClickHouseTable;
|
|
86
|
+
metricsSum: ClickHouseTable;
|
|
87
|
+
metricsSummary: ClickHouseTable;
|
|
88
|
+
metricsHistogram: ClickHouseTable;
|
|
89
|
+
metricsExponentialHistogram: ClickHouseTable;
|
|
90
|
+
};
|
|
91
|
+
/** The exporter's default table names at v0.130.0 (`createDefaultConfig` in `config.go`). */
|
|
92
|
+
export declare const OTEL_EXPORTER_DEFAULT_TABLES: Readonly<Required<OtelTableNames>>;
|
|
93
|
+
/**
|
|
94
|
+
* The TTL clause the exporter writes for `ttl` over `timeField`, or "" for none
|
|
95
|
+
* (`GenerateTTLExpr` in `internal/clickhouse.go` at v0.130.0).
|
|
96
|
+
*/
|
|
97
|
+
export declare function otelTtlClause(ttl: string | undefined, timeField: string): string;
|
|
98
|
+
/** The logs, traces and metrics tables the OpenTelemetry Collector's clickhouse exporter writes, as it creates them at v0.130.0. */
|
|
99
|
+
export declare const OtelTables: import("@intentius/chant").CompositeDefinition<OtelTablesProps, OtelTablesMembers>;
|
|
100
|
+
//# sourceMappingURL=otel-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel-tables.d.ts","sourceRoot":"","sources":["../../src/composites/otel-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEhG,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,iIAAiI;IACjI,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;IACxB,oEAAoE;IACpE,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,uEAAuE;IACvE,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,eAAe,CAAC;IAC9B,UAAU,EAAE,eAAe,CAAC;IAC5B,cAAc,EAAE,eAAe,CAAC;IAChC,gBAAgB,EAAE,eAAe,CAAC;IAClC,2BAA2B,EAAE,eAAe,CAAC;CAC9C,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAQ1E,CAAC;AAgBH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAQhF;AA+ED,oIAAoI;AACpI,eAAO,MAAM,UAAU,oFA6HP,CAAC"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `OtelTables`: the tables the OpenTelemetry Collector's `clickhouse` exporter writes, declared here so the exporter can run with `create_schema: false`.
|
|
3
|
+
*
|
|
4
|
+
* The DDL follows the exporter's own create statements at
|
|
5
|
+
* opentelemetry-collector-contrib v0.130.0, the otel lexicon's
|
|
6
|
+
* `COLLECTOR_PIN`, column for column:
|
|
7
|
+
*
|
|
8
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/logs_table.sql`
|
|
9
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/traces_table.sql`
|
|
10
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/traces_id_ts_lookup_table.sql`
|
|
11
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/traces_id_ts_lookup_mv.sql`
|
|
12
|
+
* - `exporter/clickhouseexporter/internal/sqltemplates/metrics_gauge_table.sql`,
|
|
13
|
+
* `metrics_sum_table.sql`, `metrics_summary_table.sql`,
|
|
14
|
+
* `metrics_histogram_table.sql` and `metrics_exp_histogram_table.sql`
|
|
15
|
+
*
|
|
16
|
+
* The table names default to the exporter's (`exporter/clickhouseexporter/config.go`,
|
|
17
|
+
* `createDefaultConfig`): `otel_logs`, `otel_traces` and `otel_metrics_<type>`.
|
|
18
|
+
* The exponential histogram table is `otel_metrics_exponential_histogram`:
|
|
19
|
+
* `defaultExpHistogramSuffix` in config.go is `_exponential_histogram`, though
|
|
20
|
+
* the README's option list says `otel_metrics_exp_histogram`. The code decides.
|
|
21
|
+
*
|
|
22
|
+
* With `create_schema: true` the exporter's traces exporter also creates a
|
|
23
|
+
* trace-id lookup table, `<traces>_trace_id_ts`, and a materialized view,
|
|
24
|
+
* `<traces>_trace_id_ts_mv`, that fills it from the traces table
|
|
25
|
+
* (`createTraceTables` in `exporter_traces.go`). The README's trace query
|
|
26
|
+
* reads the lookup table to bound a trace's time range. Both are declared
|
|
27
|
+
* here unless `traceIdLookup` is false.
|
|
28
|
+
*
|
|
29
|
+
* What differs from the exporter's DDL, none of it a column:
|
|
30
|
+
*
|
|
31
|
+
* - The engine is `MergeTree`, the exporter's default `table_engine`. A
|
|
32
|
+
* replicated setup declares its own tables.
|
|
33
|
+
* - `IF NOT EXISTS` and `ON CLUSTER` are left out; the sql lexicon plans the
|
|
34
|
+
* tables instead.
|
|
35
|
+
* - The metrics templates put `TTL` before `PARTITION BY`; here it follows
|
|
36
|
+
* `ORDER BY`, as in the logs and traces templates. ClickHouse reads the
|
|
37
|
+
* clauses the same in either order.
|
|
38
|
+
* - The exporter's JSON tables (`logs_json_table.sql`, `traces_json_table.sql`)
|
|
39
|
+
* are used only behind the `clickhouse.json` feature gate (alpha, off by
|
|
40
|
+
* default, `factory.go`) and are not declared.
|
|
41
|
+
*
|
|
42
|
+
* The database is not declared. Unqualified, the tables are created in the
|
|
43
|
+
* server's `default` database, which is the exporter's default `database`.
|
|
44
|
+
*/
|
|
45
|
+
import { Composite } from "@intentius/chant/composite";
|
|
46
|
+
import { table, view } from "../clickhouse/entities.js";
|
|
47
|
+
/** The exporter's default table names at v0.130.0 (`createDefaultConfig` in `config.go`). */
|
|
48
|
+
export const OTEL_EXPORTER_DEFAULT_TABLES = Object.freeze({
|
|
49
|
+
logs: "otel_logs",
|
|
50
|
+
traces: "otel_traces",
|
|
51
|
+
gauge: "otel_metrics_gauge",
|
|
52
|
+
sum: "otel_metrics_sum",
|
|
53
|
+
summary: "otel_metrics_summary",
|
|
54
|
+
histogram: "otel_metrics_histogram",
|
|
55
|
+
exponentialHistogram: "otel_metrics_exponential_histogram",
|
|
56
|
+
});
|
|
57
|
+
const GO_UNITS_S = { ns: 1e-9, us: 1e-6, "µs": 1e-6, "μs": 1e-6, ms: 1e-3, s: 1, m: 60, h: 3600 };
|
|
58
|
+
/** A Go duration in whole seconds, or an error naming the value. Go's `time.ParseDuration` has no day unit. */
|
|
59
|
+
function goDurationSeconds(d) {
|
|
60
|
+
const text = d.trim();
|
|
61
|
+
if (/^0$/.test(text))
|
|
62
|
+
return 0;
|
|
63
|
+
if (!/^((\d+(\.\d*)?|\.\d+)(ns|us|µs|μs|ms|s|m|h))+$/.test(text)) {
|
|
64
|
+
throw new Error(`OtelTables: ttl ${JSON.stringify(d)} is not a Go duration such as 72h or 30m`);
|
|
65
|
+
}
|
|
66
|
+
let total = 0;
|
|
67
|
+
for (const part of text.matchAll(/(\d+(?:\.\d*)?|\.\d+)(ns|us|µs|μs|ms|s|m|h)/g))
|
|
68
|
+
total += Number(part[1]) * GO_UNITS_S[part[2]];
|
|
69
|
+
return Math.floor(total);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The TTL clause the exporter writes for `ttl` over `timeField`, or "" for none
|
|
73
|
+
* (`GenerateTTLExpr` in `internal/clickhouse.go` at v0.130.0).
|
|
74
|
+
*/
|
|
75
|
+
export function otelTtlClause(ttl, timeField) {
|
|
76
|
+
if (ttl === undefined)
|
|
77
|
+
return "";
|
|
78
|
+
const s = goDurationSeconds(ttl);
|
|
79
|
+
if (s <= 0)
|
|
80
|
+
return "";
|
|
81
|
+
if (s % 86400 === 0)
|
|
82
|
+
return `TTL ${timeField} + toIntervalDay(${s / 86400})`;
|
|
83
|
+
if (s % 3600 === 0)
|
|
84
|
+
return `TTL ${timeField} + toIntervalHour(${s / 3600})`;
|
|
85
|
+
if (s % 60 === 0)
|
|
86
|
+
return `TTL ${timeField} + toIntervalMinute(${s / 60})`;
|
|
87
|
+
return `TTL ${timeField} + toIntervalSecond(${s})`;
|
|
88
|
+
}
|
|
89
|
+
// The column lists of the exporter's create statements, as written there.
|
|
90
|
+
const METRIC_HEAD = `
|
|
91
|
+
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
92
|
+
ResourceSchemaUrl String CODEC(ZSTD(1)),
|
|
93
|
+
ScopeName String CODEC(ZSTD(1)),
|
|
94
|
+
ScopeVersion String CODEC(ZSTD(1)),
|
|
95
|
+
ScopeAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
96
|
+
ScopeDroppedAttrCount UInt32 CODEC(ZSTD(1)),
|
|
97
|
+
ScopeSchemaUrl String CODEC(ZSTD(1)),
|
|
98
|
+
ServiceName LowCardinality(String) CODEC(ZSTD(1)),
|
|
99
|
+
MetricName String CODEC(ZSTD(1)),
|
|
100
|
+
MetricDescription String CODEC(ZSTD(1)),
|
|
101
|
+
MetricUnit String CODEC(ZSTD(1)),
|
|
102
|
+
Attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
103
|
+
StartTimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)),
|
|
104
|
+
TimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)),`;
|
|
105
|
+
const EXEMPLARS = `
|
|
106
|
+
Exemplars Nested (
|
|
107
|
+
FilteredAttributes Map(LowCardinality(String), String),
|
|
108
|
+
TimeUnix DateTime64(9),
|
|
109
|
+
Value Float64,
|
|
110
|
+
SpanId String,
|
|
111
|
+
TraceId String
|
|
112
|
+
) CODEC(ZSTD(1)),`;
|
|
113
|
+
const METRIC_INDEXES = `
|
|
114
|
+
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
115
|
+
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
116
|
+
INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
117
|
+
INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
118
|
+
INDEX idx_attr_key mapKeys(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
119
|
+
INDEX idx_attr_value mapValues(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1`;
|
|
120
|
+
/** The columns each metric table adds between the shared head and the indexes. */
|
|
121
|
+
const METRIC_BODIES = {
|
|
122
|
+
gauge: `
|
|
123
|
+
Value Float64 CODEC(ZSTD(1)),
|
|
124
|
+
Flags UInt32 CODEC(ZSTD(1)),${EXEMPLARS}`,
|
|
125
|
+
sum: `
|
|
126
|
+
Value Float64 CODEC(ZSTD(1)),
|
|
127
|
+
Flags UInt32 CODEC(ZSTD(1)),${EXEMPLARS}
|
|
128
|
+
AggregationTemporality Int32 CODEC(ZSTD(1)),
|
|
129
|
+
IsMonotonic Boolean CODEC(Delta, ZSTD(1)),`,
|
|
130
|
+
summary: `
|
|
131
|
+
Count UInt64 CODEC(Delta, ZSTD(1)),
|
|
132
|
+
Sum Float64 CODEC(ZSTD(1)),
|
|
133
|
+
ValueAtQuantiles Nested (
|
|
134
|
+
Quantile Float64,
|
|
135
|
+
Value Float64
|
|
136
|
+
) CODEC(ZSTD(1)),
|
|
137
|
+
Flags UInt32 CODEC(ZSTD(1)),`,
|
|
138
|
+
histogram: `
|
|
139
|
+
Count UInt64 CODEC(Delta, ZSTD(1)),
|
|
140
|
+
Sum Float64 CODEC(ZSTD(1)),
|
|
141
|
+
BucketCounts Array(UInt64) CODEC(ZSTD(1)),
|
|
142
|
+
ExplicitBounds Array(Float64) CODEC(ZSTD(1)),${EXEMPLARS}
|
|
143
|
+
Flags UInt32 CODEC(ZSTD(1)),
|
|
144
|
+
Min Float64 CODEC(ZSTD(1)),
|
|
145
|
+
Max Float64 CODEC(ZSTD(1)),
|
|
146
|
+
AggregationTemporality Int32 CODEC(ZSTD(1)),`,
|
|
147
|
+
exponentialHistogram: `
|
|
148
|
+
Count UInt64 CODEC(Delta, ZSTD(1)),
|
|
149
|
+
Sum Float64 CODEC(ZSTD(1)),
|
|
150
|
+
Scale Int32 CODEC(ZSTD(1)),
|
|
151
|
+
ZeroCount UInt64 CODEC(ZSTD(1)),
|
|
152
|
+
PositiveOffset Int32 CODEC(ZSTD(1)),
|
|
153
|
+
PositiveBucketCounts Array(UInt64) CODEC(ZSTD(1)),
|
|
154
|
+
NegativeOffset Int32 CODEC(ZSTD(1)),
|
|
155
|
+
NegativeBucketCounts Array(UInt64) CODEC(ZSTD(1)),${EXEMPLARS}
|
|
156
|
+
Flags UInt32 CODEC(ZSTD(1)),
|
|
157
|
+
Min Float64 CODEC(ZSTD(1)),
|
|
158
|
+
Max Float64 CODEC(ZSTD(1)),
|
|
159
|
+
AggregationTemporality Int32 CODEC(ZSTD(1)),`,
|
|
160
|
+
};
|
|
161
|
+
/** The logs, traces and metrics tables the OpenTelemetry Collector's clickhouse exporter writes, as it creates them at v0.130.0. */
|
|
162
|
+
export const OtelTables = Composite((props) => {
|
|
163
|
+
const names = { ...OTEL_EXPORTER_DEFAULT_TABLES, ...props.tables };
|
|
164
|
+
const q = (name) => (props.database ? `${props.database}.${name}` : name);
|
|
165
|
+
const ttl = (field) => otelTtlClause(props.ttl, field);
|
|
166
|
+
const logs = table `
|
|
167
|
+
CREATE TABLE ${q(names.logs)} (
|
|
168
|
+
Timestamp DateTime64(9) CODEC(Delta(8), ZSTD(1)),
|
|
169
|
+
TimestampTime DateTime DEFAULT toDateTime(Timestamp),
|
|
170
|
+
TraceId String CODEC(ZSTD(1)),
|
|
171
|
+
SpanId String CODEC(ZSTD(1)),
|
|
172
|
+
TraceFlags UInt8,
|
|
173
|
+
SeverityText LowCardinality(String) CODEC(ZSTD(1)),
|
|
174
|
+
SeverityNumber UInt8,
|
|
175
|
+
ServiceName LowCardinality(String) CODEC(ZSTD(1)),
|
|
176
|
+
Body String CODEC(ZSTD(1)),
|
|
177
|
+
ResourceSchemaUrl LowCardinality(String) CODEC(ZSTD(1)),
|
|
178
|
+
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
179
|
+
ScopeSchemaUrl LowCardinality(String) CODEC(ZSTD(1)),
|
|
180
|
+
ScopeName String CODEC(ZSTD(1)),
|
|
181
|
+
ScopeVersion LowCardinality(String) CODEC(ZSTD(1)),
|
|
182
|
+
ScopeAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
183
|
+
LogAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
184
|
+
INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1,
|
|
185
|
+
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
186
|
+
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
187
|
+
INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
188
|
+
INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
189
|
+
INDEX idx_log_attr_key mapKeys(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
190
|
+
INDEX idx_log_attr_value mapValues(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
191
|
+
INDEX idx_body Body TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 8
|
|
192
|
+
)
|
|
193
|
+
ENGINE = MergeTree
|
|
194
|
+
PARTITION BY toDate(TimestampTime)
|
|
195
|
+
PRIMARY KEY (ServiceName, TimestampTime)
|
|
196
|
+
ORDER BY (ServiceName, TimestampTime, Timestamp)
|
|
197
|
+
${ttl("TimestampTime")}
|
|
198
|
+
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1`;
|
|
199
|
+
const traces = table `
|
|
200
|
+
CREATE TABLE ${q(names.traces)} (
|
|
201
|
+
Timestamp DateTime64(9) CODEC(Delta, ZSTD(1)),
|
|
202
|
+
TraceId String CODEC(ZSTD(1)),
|
|
203
|
+
SpanId String CODEC(ZSTD(1)),
|
|
204
|
+
ParentSpanId String CODEC(ZSTD(1)),
|
|
205
|
+
TraceState String CODEC(ZSTD(1)),
|
|
206
|
+
SpanName LowCardinality(String) CODEC(ZSTD(1)),
|
|
207
|
+
SpanKind LowCardinality(String) CODEC(ZSTD(1)),
|
|
208
|
+
ServiceName LowCardinality(String) CODEC(ZSTD(1)),
|
|
209
|
+
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
210
|
+
ScopeName String CODEC(ZSTD(1)),
|
|
211
|
+
ScopeVersion String CODEC(ZSTD(1)),
|
|
212
|
+
SpanAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)),
|
|
213
|
+
Duration UInt64 CODEC(ZSTD(1)),
|
|
214
|
+
StatusCode LowCardinality(String) CODEC(ZSTD(1)),
|
|
215
|
+
StatusMessage String CODEC(ZSTD(1)),
|
|
216
|
+
Events Nested (
|
|
217
|
+
Timestamp DateTime64(9),
|
|
218
|
+
Name LowCardinality(String),
|
|
219
|
+
Attributes Map(LowCardinality(String), String)
|
|
220
|
+
) CODEC(ZSTD(1)),
|
|
221
|
+
Links Nested (
|
|
222
|
+
TraceId String,
|
|
223
|
+
SpanId String,
|
|
224
|
+
TraceState String,
|
|
225
|
+
Attributes Map(LowCardinality(String), String)
|
|
226
|
+
) CODEC(ZSTD(1)),
|
|
227
|
+
INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1,
|
|
228
|
+
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
229
|
+
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
230
|
+
INDEX idx_span_attr_key mapKeys(SpanAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
231
|
+
INDEX idx_span_attr_value mapValues(SpanAttributes) TYPE bloom_filter(0.01) GRANULARITY 1,
|
|
232
|
+
INDEX idx_duration Duration TYPE minmax GRANULARITY 1
|
|
233
|
+
)
|
|
234
|
+
ENGINE = MergeTree
|
|
235
|
+
PARTITION BY toDate(Timestamp)
|
|
236
|
+
ORDER BY (ServiceName, SpanName, toDateTime(Timestamp))
|
|
237
|
+
${ttl("toDateTime(Timestamp)")}
|
|
238
|
+
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1`;
|
|
239
|
+
const metric = (name, body) => table `
|
|
240
|
+
CREATE TABLE ${q(name)} (${METRIC_HEAD}${body}${METRIC_INDEXES}
|
|
241
|
+
)
|
|
242
|
+
ENGINE = MergeTree
|
|
243
|
+
PARTITION BY toDate(TimeUnix)
|
|
244
|
+
ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix))
|
|
245
|
+
${ttl("toDateTime(TimeUnix)")}
|
|
246
|
+
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1`;
|
|
247
|
+
const members = {
|
|
248
|
+
logs,
|
|
249
|
+
traces,
|
|
250
|
+
metricsGauge: metric(names.gauge, METRIC_BODIES.gauge),
|
|
251
|
+
metricsSum: metric(names.sum, METRIC_BODIES.sum),
|
|
252
|
+
metricsSummary: metric(names.summary, METRIC_BODIES.summary),
|
|
253
|
+
metricsHistogram: metric(names.histogram, METRIC_BODIES.histogram),
|
|
254
|
+
metricsExponentialHistogram: metric(names.exponentialHistogram, METRIC_BODIES.exponentialHistogram),
|
|
255
|
+
};
|
|
256
|
+
if (props.traceIdLookup !== false) {
|
|
257
|
+
const traceIdTs = table `
|
|
258
|
+
CREATE TABLE ${q(`${names.traces}_trace_id_ts`)} (
|
|
259
|
+
TraceId String CODEC(ZSTD(1)),
|
|
260
|
+
Start DateTime CODEC(Delta, ZSTD(1)),
|
|
261
|
+
End DateTime CODEC(Delta, ZSTD(1)),
|
|
262
|
+
INDEX idx_trace_id TraceId TYPE bloom_filter(0.01) GRANULARITY 1
|
|
263
|
+
)
|
|
264
|
+
ENGINE = MergeTree
|
|
265
|
+
PARTITION BY toDate(Start)
|
|
266
|
+
ORDER BY (TraceId, Start)
|
|
267
|
+
${ttl("toDateTime(Start)")}
|
|
268
|
+
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1`;
|
|
269
|
+
const traceIdTsView = view `
|
|
270
|
+
CREATE MATERIALIZED VIEW ${q(`${names.traces}_trace_id_ts_mv`)} TO ${traceIdTs} AS
|
|
271
|
+
SELECT
|
|
272
|
+
TraceId,
|
|
273
|
+
min(Timestamp) AS Start,
|
|
274
|
+
max(Timestamp) AS End
|
|
275
|
+
FROM ${traces}
|
|
276
|
+
WHERE TraceId != ''
|
|
277
|
+
GROUP BY TraceId`;
|
|
278
|
+
members.traceIdTs = traceIdTs;
|
|
279
|
+
members.traceIdTsView = traceIdTsView;
|
|
280
|
+
}
|
|
281
|
+
return members;
|
|
282
|
+
}, "OtelTables");
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `StreamIngest`: the usual ClickHouse ingestion chain, a stream table, a materialized view reading it and a MergeTree target.
|
|
3
|
+
*
|
|
4
|
+
* The stream table (Kafka, S3Queue, AzureQueue, RabbitMQ, NATS or FileLog)
|
|
5
|
+
* stores no rows: it is the consumer. The materialized view pulls each batch
|
|
6
|
+
* through it with `TO` and writes the target, which is an ordinary MergeTree
|
|
7
|
+
* table that can be queried, altered and backfilled on its own. Every column
|
|
8
|
+
* the view's select list writes has to be one the target declares (SQLCH110).
|
|
9
|
+
*
|
|
10
|
+
* The stream engine usually carries credentials. Name a named collection as
|
|
11
|
+
* its first argument (`Kafka(kafka_creds)`, `S3Queue(lake_creds)`) and keep
|
|
12
|
+
* the broker, bucket and keys in the collection on the server: chant never
|
|
13
|
+
* declares or reads one (#4395), and SQLCH128 fails a build that writes a
|
|
14
|
+
* password in the engine's arguments.
|
|
15
|
+
*
|
|
16
|
+
* A change to the stream table is planned as SQLCH225, not as a rebuild: the
|
|
17
|
+
* view is detached, the table replaced and the view attached again. A
|
|
18
|
+
* different `kafka_group_name` or S3Queue `keeper_path` loses the table's
|
|
19
|
+
* position, and the plan says so (#4396).
|
|
20
|
+
*/
|
|
21
|
+
import { type ClickHouseTable, type ClickHouseView } from "../clickhouse/entities.js";
|
|
22
|
+
import type { ClickHouseMemberName } from "../core/typed.js";
|
|
23
|
+
import type { Instance, TypedComposite } from "./typed.js";
|
|
24
|
+
export interface StreamIngestProps {
|
|
25
|
+
/** The target table's name. The stream table is `<name>_stream` and the view `<name>_mv`. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** The target's columns, as SQL: `ts DateTime, user_id UInt64, kind LowCardinality(String)`. */
|
|
28
|
+
columns: string;
|
|
29
|
+
/**
|
|
30
|
+
* The stream table's engine, with a named collection as its first argument
|
|
31
|
+
* rather than inline credentials: `Kafka(kafka_creds)`, `S3Queue(lake_creds)`.
|
|
32
|
+
*/
|
|
33
|
+
engine: string;
|
|
34
|
+
/**
|
|
35
|
+
* The engine's settings, the body of a `SETTINGS` clause:
|
|
36
|
+
* `kafka_topic_list = 'events', kafka_group_name = 'ingest', kafka_format = 'JSONEachRow'`.
|
|
37
|
+
* Settings the named collection already holds are left out.
|
|
38
|
+
*/
|
|
39
|
+
settings?: string;
|
|
40
|
+
/** The stream table's columns when they differ from the target's: the message as it arrives. Default: `columns`. */
|
|
41
|
+
streamColumns?: string;
|
|
42
|
+
/** The view's select list over the stream table, each item aliased to a target column. Default: `*`. */
|
|
43
|
+
select?: string;
|
|
44
|
+
/** The target's sort key (a column list or an expression). */
|
|
45
|
+
orderBy: string;
|
|
46
|
+
/** The target's engine (default `MergeTree`). */
|
|
47
|
+
targetEngine?: string;
|
|
48
|
+
/** The target's partition key. Left out by default. */
|
|
49
|
+
partitionBy?: string;
|
|
50
|
+
}
|
|
51
|
+
/** `Target`, `Stream` and `View` are the members' names, when the call's props give them (chant#3787). */
|
|
52
|
+
export type StreamIngestMembers<Target extends string = string, Stream extends string = string, View extends string = string> = {
|
|
53
|
+
target: ClickHouseTable<Target>;
|
|
54
|
+
stream: ClickHouseTable<Stream>;
|
|
55
|
+
view: ClickHouseView<View>;
|
|
56
|
+
};
|
|
57
|
+
type StreamIngestCall = <const N extends string>(props: StreamIngestProps & {
|
|
58
|
+
name: N;
|
|
59
|
+
}) => Instance<StreamIngestMembers<ClickHouseMemberName<N>, ClickHouseMemberName<N, "_stream">, ClickHouseMemberName<N, "_mv">>>;
|
|
60
|
+
/** A stream table, the materialized view that reads it, and the MergeTree target the view writes. */
|
|
61
|
+
export declare const StreamIngest: TypedComposite<StreamIngestProps, StreamIngestMembers<string, string, string>, StreamIngestCall>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=stream-ingest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-ingest.d.ts","sourceRoot":"","sources":["../../src/composites/stream-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAChC,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb,gGAAgG;IAChG,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oHAAoH;IACpH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wGAAwG;IACxG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,0GAA0G;AAC1G,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;IAC9H,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,KAAK,gBAAgB,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAC7C,KAAK,EAAE,iBAAiB,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,KACnC,QAAQ,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAEhI,qGAAqG;AACrG,eAAO,MAAM,YAAY,kGAeP,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `StreamIngest`: the usual ClickHouse ingestion chain, a stream table, a materialized view reading it and a MergeTree target.
|
|
3
|
+
*
|
|
4
|
+
* The stream table (Kafka, S3Queue, AzureQueue, RabbitMQ, NATS or FileLog)
|
|
5
|
+
* stores no rows: it is the consumer. The materialized view pulls each batch
|
|
6
|
+
* through it with `TO` and writes the target, which is an ordinary MergeTree
|
|
7
|
+
* table that can be queried, altered and backfilled on its own. Every column
|
|
8
|
+
* the view's select list writes has to be one the target declares (SQLCH110).
|
|
9
|
+
*
|
|
10
|
+
* The stream engine usually carries credentials. Name a named collection as
|
|
11
|
+
* its first argument (`Kafka(kafka_creds)`, `S3Queue(lake_creds)`) and keep
|
|
12
|
+
* the broker, bucket and keys in the collection on the server: chant never
|
|
13
|
+
* declares or reads one (#4395), and SQLCH128 fails a build that writes a
|
|
14
|
+
* password in the engine's arguments.
|
|
15
|
+
*
|
|
16
|
+
* A change to the stream table is planned as SQLCH225, not as a rebuild: the
|
|
17
|
+
* view is detached, the table replaced and the view attached again. A
|
|
18
|
+
* different `kafka_group_name` or S3Queue `keeper_path` loses the table's
|
|
19
|
+
* position, and the plan says so (#4396).
|
|
20
|
+
*/
|
|
21
|
+
import { Composite } from "@intentius/chant/composite";
|
|
22
|
+
import { table, view } from "../clickhouse/entities.js";
|
|
23
|
+
/** A stream table, the materialized view that reads it, and the MergeTree target the view writes. */
|
|
24
|
+
export const StreamIngest = Composite((props) => {
|
|
25
|
+
const target = table `
|
|
26
|
+
CREATE TABLE ${props.name} (${props.columns})
|
|
27
|
+
ENGINE = ${props.targetEngine ?? "MergeTree"}
|
|
28
|
+
${props.partitionBy ? `PARTITION BY ${props.partitionBy}` : ""}
|
|
29
|
+
ORDER BY ${props.orderBy}`;
|
|
30
|
+
const stream = table `
|
|
31
|
+
CREATE TABLE ${`${props.name}_stream`} (${props.streamColumns ?? props.columns})
|
|
32
|
+
ENGINE = ${props.engine}
|
|
33
|
+
${props.settings ? `SETTINGS ${props.settings}` : ""}`;
|
|
34
|
+
const ingest = view `
|
|
35
|
+
CREATE MATERIALIZED VIEW ${`${props.name}_mv`} TO ${target} AS
|
|
36
|
+
SELECT ${props.select ?? "*"}
|
|
37
|
+
FROM ${stream}`;
|
|
38
|
+
return { target, stream, view: ingest };
|
|
39
|
+
}, "StreamIngest");
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{ "command": "CREATE HANDLER", "kind": "HTTP handler", "status": "refused", "reason": "an HTTP handler is server-level configuration, not a schema object" },
|
|
9
9
|
{ "command": "CREATE INDEX", "kind": "index", "status": "declared", "entity": "ClickHouse::Table", "note": "an index is part of its table: SHOW CREATE TABLE prints it, and the table's declaration holds it" },
|
|
10
10
|
{ "command": "CREATE MASKING POLICY", "kind": "masking policy", "status": "refused", "reason": "masking policies are available only in ClickHouse Cloud, not on the pinned server" },
|
|
11
|
-
{ "command": "CREATE NAMED COLLECTION", "kind": "named collection", "status": "
|
|
11
|
+
{ "command": "CREATE NAMED COLLECTION", "kind": "named collection", "status": "referenced", "reason": "a named collection holds credentials (a password, a secret key), which are the environment's: chant never declares one or reads its values. An engine, a table function or a dictionary SOURCE names it, a plan checks that it exists, and import lists the server's as prerequisites" },
|
|
12
12
|
{ "command": "CREATE QUOTA", "kind": "quota", "status": "declared", "entity": "ClickHouse::Quota", "note": "import reads only the access objects a build declares" },
|
|
13
13
|
{ "command": "CREATE RESOURCE", "kind": "workload resource", "status": "refused", "reason": "a resource is server-level scheduling (a disk's reads or writes), configured with the server, not a schema object" },
|
|
14
14
|
{ "command": "CREATE ROLE", "kind": "role", "status": "declared", "entity": "ClickHouse::Role", "note": "import reads only the access objects a build declares" },
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{ "command": "CREATE DOMAIN", "kind": "domain", "status": "declared", "entity": "Postgres::Domain" },
|
|
11
11
|
{ "command": "CREATE EVENT TRIGGER", "kind": "event trigger", "status": "declared", "entity": "Postgres::EventTrigger", "note": "the database's, not a schema's; creating one takes a superuser" },
|
|
12
12
|
{ "command": "CREATE EXTENSION", "kind": "extension", "status": "declared", "entity": "Postgres::Extension" },
|
|
13
|
-
{ "command": "CREATE FOREIGN DATA WRAPPER", "kind": "foreign data wrapper", "status": "
|
|
13
|
+
{ "command": "CREATE FOREIGN DATA WRAPPER", "kind": "foreign data wrapper", "status": "declared", "entity": "Postgres::ForeignDataWrapper", "note": "the database's, not a schema's; creating one takes a superuser; one an extension installs comes with the extension; an option that holds a credential is refused" },
|
|
14
14
|
{ "command": "CREATE FOREIGN TABLE", "kind": "foreign table", "status": "refused", "reason": "no tag declares a foreign table yet" },
|
|
15
15
|
{ "command": "CREATE FUNCTION", "kind": "function", "status": "declared", "entity": "Postgres::Function" },
|
|
16
16
|
{ "command": "CREATE FUNCTION", "form": "RETURN or BEGIN ATOMIC body", "match": "\\b(?:RETURN|BEGIN\\s+ATOMIC)\\b", "kind": "routine with a SQL-standard body", "status": "refused", "reason": "the server stores a SQL-standard body parsed and prints it back rewritten, so a declaration cannot be compared with it; declare the routine with a string body (AS $$ ... $$)" },
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
{ "command": "CREATE INDEX", "kind": "index", "status": "declared", "entity": "Postgres::Index" },
|
|
19
19
|
{ "command": "CREATE LANGUAGE", "kind": "procedural language", "status": "refused", "reason": "no tag declares a procedural language; an extension installs one, and the extension is declared instead" },
|
|
20
20
|
{ "command": "CREATE MATERIALIZED VIEW", "kind": "materialized view", "status": "declared", "entity": "Postgres::MaterializedView" },
|
|
21
|
-
{ "command": "CREATE OPERATOR", "kind": "operator", "status": "
|
|
21
|
+
{ "command": "CREATE OPERATOR", "kind": "operator", "status": "declared", "entity": "Postgres::Operator", "note": "identified by its name and operand types; a change is a drop and a create" },
|
|
22
22
|
{ "command": "CREATE OPERATOR CLASS", "kind": "operator class", "status": "refused", "reason": "no tag declares an operator class yet" },
|
|
23
23
|
{ "command": "CREATE OPERATOR FAMILY", "kind": "operator family", "status": "refused", "reason": "no tag declares an operator family yet" },
|
|
24
24
|
{ "command": "CREATE POLICY", "kind": "policy", "status": "declared", "entity": "Postgres::Policy", "note": "read where the profile manages access (sql.profiles.<env>.access)" },
|
|
25
25
|
{ "command": "CREATE PROCEDURE", "kind": "procedure", "status": "declared", "entity": "Postgres::Procedure" },
|
|
26
|
-
{ "command": "CREATE PUBLICATION", "kind": "publication", "status": "
|
|
26
|
+
{ "command": "CREATE PUBLICATION", "kind": "publication", "status": "declared", "entity": "Postgres::Publication", "note": "the database's, not a schema's; a table of it may carry a column list and row filter from 15" },
|
|
27
27
|
{ "command": "CREATE ROLE", "kind": "role", "status": "declared", "entity": "Postgres::Role", "note": "import reads only the roles a build declares, since a role is the cluster's" },
|
|
28
28
|
{ "command": "CREATE RULE", "kind": "rule", "status": "refused", "reason": "no tag declares a rewrite rule; a view's own rule is the view's" },
|
|
29
29
|
{ "command": "CREATE SCHEMA", "kind": "schema", "status": "declared", "entity": "Postgres::Schema" },
|
|
30
30
|
{ "command": "CREATE SEQUENCE", "kind": "sequence", "status": "declared", "entity": "Postgres::Sequence" },
|
|
31
|
-
{ "command": "CREATE SERVER", "kind": "foreign server", "status": "
|
|
32
|
-
{ "command": "CREATE STATISTICS", "kind": "extended statistics", "status": "
|
|
33
|
-
{ "command": "CREATE SUBSCRIPTION", "kind": "subscription", "status": "refused", "reason": "
|
|
31
|
+
{ "command": "CREATE SERVER", "kind": "foreign server", "status": "declared", "entity": "Postgres::ForeignServer", "note": "the database's, not a schema's; its user mappings are refused, so credentials stay out of the declaration" },
|
|
32
|
+
{ "command": "CREATE STATISTICS", "kind": "extended statistics", "status": "declared", "entity": "Postgres::Statistics" },
|
|
33
|
+
{ "command": "CREATE SUBSCRIPTION", "kind": "subscription", "status": "refused", "reason": "a subscription's connection string carries a credential, and creating one opens a replication slot on the publisher, outside this database; the environment makes it" },
|
|
34
34
|
{ "command": "CREATE TABLE", "kind": "table", "status": "declared", "entity": "Postgres::Table" },
|
|
35
35
|
{ "command": "CREATE TABLE AS", "kind": "table from a query", "status": "declared", "entity": "Postgres::Table", "note": "the server keeps no query, so the table it made reads as a CREATE TABLE" },
|
|
36
36
|
{ "command": "CREATE TABLESPACE", "kind": "tablespace", "status": "out-of-scope", "reason": "a tablespace is the cluster's, a directory on the server; a table's TABLESPACE clause is kept" },
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
{ "command": "CREATE TYPE", "form": "AS RANGE", "match": "\\bAS\\s+RANGE\\b", "kind": "range type", "status": "declared", "entity": "Postgres::RangeType", "note": "its multirange type comes with it (MULTIRANGE_TYPE_NAME)" },
|
|
46
46
|
{ "command": "CREATE TYPE", "form": "INPUT, OUTPUT, or a shell type", "kind": "base type", "status": "refused", "reason": "no tag declares a base type; its input and output functions are C code an extension installs" },
|
|
47
47
|
{ "command": "CREATE USER", "kind": "user", "status": "declared", "entity": "Postgres::Role", "note": "an alias of CREATE ROLE ... LOGIN" },
|
|
48
|
-
{ "command": "CREATE USER MAPPING", "kind": "user mapping", "status": "refused", "reason": "
|
|
48
|
+
{ "command": "CREATE USER MAPPING", "kind": "user mapping", "status": "refused", "reason": "a user mapping carries the remote user and password, which the environment supplies and a declaration never holds" },
|
|
49
49
|
{ "command": "CREATE VIEW", "kind": "view", "status": "declared", "entity": "Postgres::View" }
|
|
50
50
|
]
|
|
51
51
|
}
|
package/dist/coverage.d.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Which kinds of object each dialect declares (#3911): every `CREATE` command
|
|
5
5
|
* a pinned server has (`./coverage/<dialect>-commands.json`, written by
|
|
6
6
|
* `scripts/sql-create-commands.ts` from the server's own sources) has a row
|
|
7
|
-
* in `./coverage/<dialect>.json` marking it declared, refused
|
|
8
|
-
* or out of scope. A
|
|
7
|
+
* in `./coverage/<dialect>.json` marking it declared, referenced, refused
|
|
8
|
+
* with a reason, or out of scope. A referenced kind (a ClickHouse named
|
|
9
|
+
* collection, #4395) is never declared: a declaration names one, a plan
|
|
10
|
+
* checks it exists, and import lists the server's as prerequisites. A command with several forms that differ in what chant can
|
|
9
11
|
* hold (`CREATE TYPE ... AS ENUM` and `CREATE TYPE ... AS RANGE`) has a row
|
|
10
12
|
* per form. Import refuses an object of a refused kind by that row's `kind`
|
|
11
13
|
* (`./core/undeclarable.ts`), and the docs page is rendered from the rows
|
|
@@ -21,8 +23,15 @@
|
|
|
21
23
|
* that, per section, from the generated tables.
|
|
22
24
|
*/
|
|
23
25
|
import type { SqlDialect } from "./dialects.js";
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* `declared`: a tag holds it. `referenced`: the environment's, never declared
|
|
28
|
+
* and its values never read; a declaration names it, a plan checks it exists,
|
|
29
|
+
* and import lists the server's as prerequisites (#4395). `refused`: import
|
|
30
|
+
* names it and stops. `out-of-scope`: the environment's, never imported.
|
|
31
|
+
*/
|
|
32
|
+
export type KindStatus = "declared" | "referenced" | "refused" | "out-of-scope";
|
|
33
|
+
/** Every status a coverage row may have. */
|
|
34
|
+
export declare const KIND_STATUSES: readonly KindStatus[];
|
|
26
35
|
/** One row of a dialect's coverage table: a `CREATE` command, or one form of it. */
|
|
27
36
|
export interface KindRow {
|
|
28
37
|
/** The command as the server's reference names it: `CREATE TYPE`. */
|
|
@@ -40,7 +49,7 @@ export interface KindRow {
|
|
|
40
49
|
status: KindStatus;
|
|
41
50
|
/** The entity type that declares it, when declared. */
|
|
42
51
|
entity?: string;
|
|
43
|
-
/** Why it is refused or out of scope. */
|
|
52
|
+
/** Why it is referenced, refused or out of scope. */
|
|
44
53
|
reason?: string;
|
|
45
54
|
/** Anything else a reader should know. */
|
|
46
55
|
note?: string;
|
|
@@ -58,7 +67,8 @@ export declare function kindRow(dialect: SqlDialect, kind: string): KindRow;
|
|
|
58
67
|
* What is wrong with a dialect's coverage table, against its pinned servers'
|
|
59
68
|
* commands: a command a pinned server has and no row covers, a row for a
|
|
60
69
|
* command no pinned server has, a kind named twice, a declared row with no
|
|
61
|
-
* entity, a refused or out-of-scope row with no reason. Empty
|
|
70
|
+
* entity, a referenced, refused or out-of-scope row with no reason. Empty
|
|
71
|
+
* when complete.
|
|
62
72
|
*/
|
|
63
73
|
export declare function kindCoverageProblems(dialect: SqlDialect, opts?: {
|
|
64
74
|
pins?: ReadonlyArray<{
|
package/dist/coverage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAQ7C;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,cAAc,CAAC;AAEhF,4CAA4C;AAC5C,eAAO,MAAM,aAAa,EAAE,SAAS,UAAU,EAA0D,CAAC;AAE1G,oFAAoF;AACpF,MAAM,WAAW,OAAO;IACtB,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qCAAqC;AACrC,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,OAAO,EAAE,CAGhE,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAG/G,CAAC;AAEF,2HAA2H;AAC3H,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;CAAO,GAAG,MAAM,EAAE,CAmBpL;AAiBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAcnF;AAED,sHAAsH;AACtH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,EAAE,CAQnE;AAID,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED,wBAAgB,OAAO,IAAI,cAAc,CAyBxC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAYjH"}
|