@intentius/chant-lexicon-sql 0.124.46 → 0.124.49
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/statements.d.ts +29 -0
- package/dist/clickhouse/plan/statements.d.ts.map +1 -0
- package/dist/clickhouse/plan/statements.js +334 -0
- 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 +44 -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 +2 -2
- package/dist/codegen/registry.d.ts.map +1 -1
- package/dist/codegen/registry.js +10 -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/core/statement-class.d.ts +55 -0
- package/dist/core/statement-class.d.ts.map +1 -0
- package/dist/core/statement-class.js +43 -0
- package/dist/coverage/clickhouse.json +1 -1
- package/dist/coverage/postgres.json +12 -12
- 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 +689 -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.d.ts.map +1 -1
- package/dist/files/postgres.js +35 -3
- 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 +7 -6
- 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/postgres-names.d.ts.map +1 -1
- package/dist/lint/post-synth/postgres-names.js +3 -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 +21 -0
- package/dist/manifest.json +1 -1
- package/dist/mcp/postgres.js +1 -1
- package/dist/meta.json +50 -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-classify.d.ts +23 -0
- package/dist/migration-classify.d.ts.map +1 -0
- package/dist/migration-classify.js +44 -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 +11 -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/PostgresForeignTable.md +9 -0
- package/dist/okf/types/PostgresOperator.md +9 -0
- package/dist/okf/types/PostgresOperatorClass.md +9 -0
- package/dist/okf/types/PostgresOperatorFamily.md +9 -0
- package/dist/okf/types/PostgresPublication.md +9 -0
- package/dist/okf/types/PostgresStatistics.md +9 -0
- package/dist/okf/types/PostgresTextSearchConfiguration.md +9 -0
- package/dist/okf/types/PostgresTextSearchDictionary.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 +49 -2
- package/dist/postgres/access/acl.js +1 -1
- package/dist/postgres/access/import.js +1 -1
- package/dist/postgres/apply/apply.js +13 -1
- package/dist/postgres/apply/statements.d.ts.map +1 -1
- package/dist/postgres/apply/statements.js +243 -4
- 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 +229 -2
- package/dist/postgres/entities.d.ts.map +1 -1
- package/dist/postgres/entities.js +326 -5
- package/dist/postgres/entity-types.d.ts +10 -0
- package/dist/postgres/entity-types.d.ts.map +1 -1
- package/dist/postgres/entity-types.js +10 -0
- package/dist/postgres/import/generator.d.ts.map +1 -1
- package/dist/postgres/import/generator.js +65 -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 +20 -0
- package/dist/postgres/live/catalog-kinds.d.ts.map +1 -1
- package/dist/postgres/live/catalog-kinds.js +452 -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 +12 -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 +45 -13
- 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/replication.d.ts +42 -0
- package/dist/postgres/migrate/replication.d.ts.map +1 -1
- package/dist/postgres/migrate/replication.js +53 -0
- 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 +144 -1
- package/dist/postgres/parser.d.ts.map +1 -1
- package/dist/postgres/parser.js +370 -4
- package/dist/postgres/plan/deep.d.ts.map +1 -1
- package/dist/postgres/plan/deep.js +43 -4
- package/dist/postgres/plan/diff.d.ts.map +1 -1
- package/dist/postgres/plan/diff.js +154 -1
- package/dist/postgres/plan/normalize.d.ts +28 -2
- package/dist/postgres/plan/normalize.d.ts.map +1 -1
- package/dist/postgres/plan/normalize.js +260 -1
- package/dist/postgres/plan/rules.d.ts +4 -0
- package/dist/postgres/plan/rules.d.ts.map +1 -1
- package/dist/postgres/plan/rules.js +6 -2
- package/dist/postgres/plan/schema.js +1 -1
- package/dist/postgres/plan/statements.d.ts +26 -0
- package/dist/postgres/plan/statements.d.ts.map +1 -0
- package/dist/postgres/plan/statements.js +364 -0
- 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 +4 -2
- package/dist/postgres/testing/roundtrip-schema.d.ts.map +1 -1
- package/dist/postgres/testing/roundtrip-schema.js +24 -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-names.ts +2 -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 +10 -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/statements.test.ts +61 -0
- package/src/clickhouse/plan/statements.ts +306 -0
- 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 +44 -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 +2 -2
- package/src/codegen/registry.ts +10 -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/statement-class.ts +88 -0
- package/src/core/undeclarable.test.ts +6 -5
- package/src/coverage/clickhouse.json +1 -1
- package/src/coverage/postgres.json +12 -12
- 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 +742 -0
- package/src/files/clickhouse.ts +8 -1
- package/src/files/common.ts +14 -1
- package/src/files/postgres.ts +34 -3
- package/src/generated/clickhouse.ts +3 -0
- package/src/generated/lexicon-sql.json +50 -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/postgres-checks.test.ts +8 -1
- package/src/lint/post-synth/postgres-names.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 +20 -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-classify.test.ts +150 -0
- package/src/migration-classify.ts +45 -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/op/watch-pipeline.test.ts +8 -1
- package/src/plugin.ts +51 -2
- package/src/postgres/access/acl.ts +1 -1
- package/src/postgres/access/import.ts +1 -1
- package/src/postgres/apply/apply.ts +14 -1
- package/src/postgres/apply/statements.ts +225 -4
- package/src/postgres/constraint-names.ts +71 -0
- package/src/postgres/database-kinds.test.ts +865 -0
- package/src/postgres/entities.ts +541 -5
- package/src/postgres/entity-types.ts +10 -0
- package/src/postgres/import/generator.ts +54 -2
- package/src/postgres/import/live-export.ts +1 -0
- package/src/postgres/live/catalog-kinds.ts +494 -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 +13 -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 +56 -15
- 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/replication.ts +66 -0
- package/src/postgres/migrate/steps.ts +157 -12
- package/src/postgres/migrate/subscriber.e2e.test.ts +141 -0
- package/src/postgres/migrate/subscriber.test.ts +59 -0
- package/src/postgres/parser.ts +455 -4
- package/src/postgres/plan/deep.ts +42 -4
- package/src/postgres/plan/diff.ts +137 -1
- package/src/postgres/plan/normalize.ts +277 -1
- package/src/postgres/plan/rules.ts +32 -4
- package/src/postgres/plan/schema.ts +1 -1
- package/src/postgres/plan/statements.test.ts +78 -0
- package/src/postgres/plan/statements.ts +299 -0
- package/src/postgres/secret-options.ts +10 -0
- package/src/postgres/testing/roundtrip-schema.ts +24 -1
- package/src/postgres.ts +33 -0
- package/src/serializer.ts +13 -2
- package/src/skills/chant-sql-postgres-migration.md +4 -3
- package/src/skills/chant-sql-postgres.md +11 -1
- package/src/skills/chant-sql.md +2 -1
- package/src/sql-files.test.ts +33 -0
- 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 +10 -0
- package/src/workspace-kinds.test.ts +11 -0
- package/workspace-kinds.json +100 -2
|
@@ -236,6 +236,9 @@ export function renderClickHouseModule(catalog) {
|
|
|
236
236
|
`/** The table functions (\`system.table_functions\`): \`numbers\`, \`remote\`, \`s3\`. */`,
|
|
237
237
|
`export const TABLE_FUNCTIONS: readonly string[] = ${JSON.stringify(catalog.tableFunctions)};`,
|
|
238
238
|
"",
|
|
239
|
+
`/** The input and output formats (\`system.formats\`): \`Parquet\`, \`JSONEachRow\`. */`,
|
|
240
|
+
`export const FORMATS: readonly string[] = ${JSON.stringify(catalog.formats.map((f) => f.name))};`,
|
|
241
|
+
"",
|
|
239
242
|
`export const SKIP_INDEX_TYPES: Readonly<Record<SkipIndexType, SkipIndexSpec>> = {`,
|
|
240
243
|
...indexLines,
|
|
241
244
|
"};",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage-page.d.ts","sourceRoot":"","sources":["../../src/codegen/coverage-page.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"coverage-page.d.ts","sourceRoot":"","sources":["../../src/codegen/coverage-page.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6BH,wBAAgB,kBAAkB,IAAI,MAAM,CA6C3C"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { KIND_COVERAGE, PINNED_COMMANDS } from "../coverage.js";
|
|
7
7
|
const cell = (s) => s.replace(/\|/g, "\\|").replace(/[{}<>]/g, (c) => `\\${c}`);
|
|
8
|
-
const STATUS = { declared: "declared", refused: "refused", "out-of-scope": "out of scope" };
|
|
8
|
+
const STATUS = { declared: "declared", referenced: "referenced", refused: "refused", "out-of-scope": "out of scope" };
|
|
9
9
|
function table(dialect) {
|
|
10
10
|
const rows = [...KIND_COVERAGE[dialect]].sort((a, b) => (a.command < b.command ? -1 : a.command > b.command ? 1 : 0));
|
|
11
11
|
return [
|
|
@@ -21,7 +21,8 @@ function table(dialect) {
|
|
|
21
21
|
function counts(dialect) {
|
|
22
22
|
const rows = KIND_COVERAGE[dialect];
|
|
23
23
|
const n = (s) => rows.filter((r) => r.status === s).length;
|
|
24
|
-
|
|
24
|
+
const referenced = n("referenced") > 0 ? `, ${n("referenced")} referenced` : "";
|
|
25
|
+
return `${n("declared")} declared${referenced}, ${n("refused")} refused, ${n("out-of-scope")} out of scope`;
|
|
25
26
|
}
|
|
26
27
|
export function renderCoveragePage() {
|
|
27
28
|
const pg = PINNED_COMMANDS.postgres.map((p) => p.version).join(", ");
|
|
@@ -29,7 +30,7 @@ export function renderCoveragePage() {
|
|
|
29
30
|
return `---
|
|
30
31
|
title: "Object Coverage"
|
|
31
32
|
label: "Object Coverage"
|
|
32
|
-
description: "Every kind of object each pinned Postgres and ClickHouse server can create, marked declared, refused with a reason, or out of scope, and what import does with each"
|
|
33
|
+
description: "Every kind of object each pinned Postgres and ClickHouse server can create, marked declared, referenced, refused with a reason, or out of scope, and what import does with each"
|
|
33
34
|
diataxis: reference
|
|
34
35
|
order: 3
|
|
35
36
|
---
|
|
@@ -39,6 +40,7 @@ order: 3
|
|
|
39
40
|
Each row is a \`CREATE\` command a pinned server has, or one form of a command where chant treats the forms apart (\`CREATE TYPE ... AS ENUM\` is declared, \`CREATE TYPE ... AS RANGE\` is not). The commands come from the servers' own sources at each pinned version (\`scripts/sql-create-commands.ts\`), and a test fails when a pinned server has a command with no row here, so a new server release cannot add a kind nobody looked at.
|
|
40
41
|
|
|
41
42
|
- **declared**: a tag declares it, and import writes it as that declaration.
|
|
43
|
+
- **referenced**: the environment's, and never declared: a declaration names one, and chant never reads its values. A ClickHouse named collection is one ([#4395](https://github.com/INTENTIUS/chant/issues/4395)): \`ENGINE = S3(lake_creds, format = 'Parquet')\` names \`lake_creds\`, the build records the name, and \`chant sql plan\` fails when the server has no collection of that name. \`chant import --from <env>\` lists the server's SQL-defined collections as prerequisites and imports the rest. See [Named collections](../clickhouse-ddl/#named-collections).
|
|
42
44
|
- **refused**: no declaration holds it yet. \`chant import --from <env>\` fails when the server has one, naming every such object (kind, schema, name) at once, and \`chant import schema.sql\` fails on the statement. Nothing is left out without a word.
|
|
43
45
|
- **out of scope**: the environment's, not a schema's: import never reads it.
|
|
44
46
|
|
package/dist/codegen/docs.js
CHANGED
|
@@ -120,7 +120,7 @@ Postgres:
|
|
|
120
120
|
- [Getting Started with Postgres](./postgres-getting-started/): declare a
|
|
121
121
|
schema, apply it to a local server, add a column and an index, and see a
|
|
122
122
|
rename refused.
|
|
123
|
-
- [Declaring Postgres Objects](./postgres-ddl/): the
|
|
123
|
+
- [Declaring Postgres Objects](./postgres-ddl/): the tags for every schema-level kind,
|
|
124
124
|
constraints, \`nextval(\${seq})\`, \`COMMENT ON\` and \`literal()\`.
|
|
125
125
|
- [Importing a Postgres Server](./postgres-importing/): canonical text from
|
|
126
126
|
the catalog's printers, and the objects that belong to someone else.
|
|
@@ -60,14 +60,14 @@ A column rename or a type change across kinds is never DDL: it is a step naming
|
|
|
60
60
|
|
|
61
61
|
## Which major
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Three rules change class across the supported majors: a STORED generated column's expression (SQLPG212) is a rewrite from 17 and expand and contract before it, a table's access method (SQLPG226) is a rewrite from 15 and expand and contract before it, and an operator's commutator, negator, HASHES and MERGES (SQLPG304) are altered in place from 17 and dropped and created before it.
|
|
64
64
|
|
|
65
65
|
- \`chant sql diff\` classifies for the major the builds recorded (\`postgresMajor\` in the build output): the newer build's, else the older build's, else \`sql.postgresMajor\`, else 18. A diff between two revisions does not depend on today's config.
|
|
66
66
|
- \`chant sql plan\` classifies for the major the server runs (\`server_version_num\`), since the server is what takes the locks. When the build targets another major, the plan says so in a hint.
|
|
67
67
|
|
|
68
68
|
## Identity and renames
|
|
69
69
|
|
|
70
|
-
An object is identified by its export name between two builds, and by its schema-qualified name against a server, which has no export names. Tables, views, materialized views, sequences and indexes share one namespace per schema, types and domains another, and schemas and extensions are matched by name. Functions, procedures and aggregates share a namespace of their own and are told apart by their input parameter types, so an overload is another object; composite and range types share the types' namespace, collations have one of their own,
|
|
70
|
+
An object is identified by its export name between two builds, and by its schema-qualified name against a server, which has no export names. Tables, foreign tables, views, materialized views, sequences and indexes share one namespace per schema, types and domains another, and schemas and extensions are matched by name. Functions, procedures and aggregates share a namespace of their own and are told apart by their input parameter types, so an overload is another object; composite and range types share the types' namespace, collations have one of their own, extended statistics another, an operator by its symbol and operand types, an operator class and an operator family each by its name and index method, text search configurations one namespace and dictionaries another, a cast by its two types and an event trigger, a foreign data wrapper, a foreign server and a publication by their names in the database; a trigger is matched by its name on its table.
|
|
71
71
|
|
|
72
72
|
A rename is declared where it happens. Before a CREATE, \`-- previously: <old name>\` says the object had another name; on a column's line, it says the column did:
|
|
73
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/codegen/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/codegen/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoDH,wBAAgB,aAAa,IAAI,MAAM,CAKtC"}
|
package/dist/codegen/registry.js
CHANGED
|
@@ -37,6 +37,16 @@ const KINDS = {
|
|
|
37
37
|
PostgresCollation: POSTGRES_ENTITY_TYPES.collation,
|
|
38
38
|
PostgresCast: POSTGRES_ENTITY_TYPES.cast,
|
|
39
39
|
PostgresEventTrigger: POSTGRES_ENTITY_TYPES.eventTrigger,
|
|
40
|
+
PostgresOperator: POSTGRES_ENTITY_TYPES.operator,
|
|
41
|
+
PostgresOperatorClass: POSTGRES_ENTITY_TYPES.operatorClass,
|
|
42
|
+
PostgresOperatorFamily: POSTGRES_ENTITY_TYPES.operatorFamily,
|
|
43
|
+
PostgresForeignTable: POSTGRES_ENTITY_TYPES.foreignTable,
|
|
44
|
+
PostgresTextSearchConfiguration: POSTGRES_ENTITY_TYPES.textSearchConfiguration,
|
|
45
|
+
PostgresTextSearchDictionary: POSTGRES_ENTITY_TYPES.textSearchDictionary,
|
|
46
|
+
PostgresStatistics: POSTGRES_ENTITY_TYPES.statistics,
|
|
47
|
+
PostgresForeignDataWrapper: POSTGRES_ENTITY_TYPES.foreignDataWrapper,
|
|
48
|
+
PostgresForeignServer: POSTGRES_ENTITY_TYPES.foreignServer,
|
|
49
|
+
PostgresPublication: POSTGRES_ENTITY_TYPES.publication,
|
|
40
50
|
PostgresExtension: POSTGRES_ENTITY_TYPES.extension,
|
|
41
51
|
PostgresFunction: POSTGRES_ENTITY_TYPES.function,
|
|
42
52
|
PostgresProcedure: POSTGRES_ENTITY_TYPES.procedure,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/composites/catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/composites/catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,cAAc,EA+mB5C,CAAC"}
|
|
@@ -210,6 +210,41 @@ export const compositeCatalog = [
|
|
|
210
210
|
}
|
|
211
211
|
]
|
|
212
212
|
},
|
|
213
|
+
{
|
|
214
|
+
"name": "OtelTables",
|
|
215
|
+
"lexicon": "sql",
|
|
216
|
+
"description": "The logs, traces and metrics tables the OpenTelemetry Collector's clickhouse exporter writes, as it creates them at v0.130.0.",
|
|
217
|
+
"bundles": [
|
|
218
|
+
"ClickHouseTable",
|
|
219
|
+
"ClickHouseView"
|
|
220
|
+
],
|
|
221
|
+
"params": [
|
|
222
|
+
{
|
|
223
|
+
"name": "database",
|
|
224
|
+
"type": "string",
|
|
225
|
+
"required": false,
|
|
226
|
+
"description": "The database the tables are created in, the exporter's `database`."
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "ttl",
|
|
230
|
+
"type": "string",
|
|
231
|
+
"required": false,
|
|
232
|
+
"description": "How long rows are kept, as the exporter's `ttl` takes it: a Go duration such as `72h` or `30m`."
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"name": "tables",
|
|
236
|
+
"type": "OtelTableNames",
|
|
237
|
+
"required": false,
|
|
238
|
+
"description": "Table names other than the exporter's defaults, as set on the exporter."
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "traceIdLookup",
|
|
242
|
+
"type": "boolean",
|
|
243
|
+
"required": false,
|
|
244
|
+
"description": "Declare the trace-id lookup table and its materialized view (default true)."
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
},
|
|
213
248
|
{
|
|
214
249
|
"name": "RefreshedView",
|
|
215
250
|
"lexicon": "sql",
|
|
@@ -468,6 +503,71 @@ export const compositeCatalog = [
|
|
|
468
503
|
}
|
|
469
504
|
]
|
|
470
505
|
},
|
|
506
|
+
{
|
|
507
|
+
"name": "StreamIngest",
|
|
508
|
+
"lexicon": "sql",
|
|
509
|
+
"description": "A stream table, the materialized view that reads it, and the MergeTree target the view writes.",
|
|
510
|
+
"bundles": [
|
|
511
|
+
"ClickHouseTable",
|
|
512
|
+
"ClickHouseView"
|
|
513
|
+
],
|
|
514
|
+
"params": [
|
|
515
|
+
{
|
|
516
|
+
"name": "name",
|
|
517
|
+
"type": "string",
|
|
518
|
+
"required": true,
|
|
519
|
+
"description": "The target table's name."
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"name": "columns",
|
|
523
|
+
"type": "string",
|
|
524
|
+
"required": true,
|
|
525
|
+
"description": "The target's columns, as SQL: `ts DateTime, user_id UInt64, kind LowCardinality(String)`."
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"name": "engine",
|
|
529
|
+
"type": "string",
|
|
530
|
+
"required": true,
|
|
531
|
+
"description": "The stream table's engine, with a named collection as its first argument rather than inline credentials: `Kafka(kafka_creds)`, `S3Queue(lake_creds)`."
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"name": "settings",
|
|
535
|
+
"type": "string",
|
|
536
|
+
"required": false,
|
|
537
|
+
"description": "The engine's settings, the body of a `SETTINGS` clause: `kafka_topic_list = 'events', kafka_group_name = 'ingest', kafka_format = 'JSONEachRow'`."
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"name": "streamColumns",
|
|
541
|
+
"type": "string",
|
|
542
|
+
"required": false,
|
|
543
|
+
"description": "The stream table's columns when they differ from the target's: the message as it arrives."
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
"name": "select",
|
|
547
|
+
"type": "string",
|
|
548
|
+
"required": false,
|
|
549
|
+
"description": "The view's select list over the stream table, each item aliased to a target column."
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"name": "orderBy",
|
|
553
|
+
"type": "string",
|
|
554
|
+
"required": true,
|
|
555
|
+
"description": "The target's sort key (a column list or an expression)."
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
"name": "targetEngine",
|
|
559
|
+
"type": "string",
|
|
560
|
+
"required": false,
|
|
561
|
+
"description": "The target's engine (default `MergeTree`)."
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"name": "partitionBy",
|
|
565
|
+
"type": "string",
|
|
566
|
+
"required": false,
|
|
567
|
+
"description": "The target's partition key."
|
|
568
|
+
}
|
|
569
|
+
]
|
|
570
|
+
},
|
|
471
571
|
{
|
|
472
572
|
"name": "TenantTable",
|
|
473
573
|
"lexicon": "sql",
|
|
@@ -4,4 +4,6 @@ export { EventsTable, type EventsTableProps, type EventsTableMembers } from "./e
|
|
|
4
4
|
export { RollupView, type RollupViewProps, type RollupViewMembers } from "./rollup-view.js";
|
|
5
5
|
export { CdcMirror, type CdcMirrorProps, type CdcMirrorMembers } from "./cdc-mirror.js";
|
|
6
6
|
export { ShardedTable, type ShardedTableProps, type ShardedTableMembers } from "./sharded-table.js";
|
|
7
|
+
export { OtelTables, OTEL_EXPORTER_DEFAULT_TABLES, otelTtlClause, type OtelTablesProps, type OtelTablesMembers, type OtelTableNames } from "./otel-tables.js";
|
|
8
|
+
export { StreamIngest, type StreamIngestProps, type StreamIngestMembers } from "./stream-ingest.js";
|
|
7
9
|
//# sourceMappingURL=clickhouse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickhouse.d.ts","sourceRoot":"","sources":["../../src/composites/clickhouse.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"clickhouse.d.ts","sourceRoot":"","sources":["../../src/composites/clickhouse.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,4BAA4B,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3J,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -4,3 +4,5 @@ export { EventsTable } from "./events-table.js";
|
|
|
4
4
|
export { RollupView } from "./rollup-view.js";
|
|
5
5
|
export { CdcMirror } from "./cdc-mirror.js";
|
|
6
6
|
export { ShardedTable } from "./sharded-table.js";
|
|
7
|
+
export { OtelTables, OTEL_EXPORTER_DEFAULT_TABLES, otelTtlClause } from "./otel-tables.js";
|
|
8
|
+
export { StreamIngest } from "./stream-ingest.js";
|
|
@@ -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");
|