From c2514c54f565994169f751c2d4022a8125a0e40b Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Fri, 26 Sep 2025 15:39:54 -0400 Subject: [PATCH 01/11] Add Archetype search attributes for CHASM Visibility --- .../versioned/v10/index_template_v7.json | 159 ++++++++++++++++++ .../visibility/versioned/v10/upgrade.sh | 99 +++++++++++ schema/mysql/v8/version.go | 2 +- schema/mysql/v8/visibility/schema.sql | 56 ++++++ .../v1.10/add_archetype_search_attributes.sql | 55 ++++++ .../visibility/versioned/v1.10/manifest.json | 8 + schema/postgresql/v12/version.go | 2 +- schema/postgresql/v12/visibility/schema.sql | 36 ++++ .../v1.10/add_archetype_search_attributes.sql | 36 ++++ .../visibility/versioned/v1.10/manifest.json | 8 + schema/sqlite/v3/visibility/schema.sql | 99 +++++++++-- 11 files changed, 542 insertions(+), 18 deletions(-) create mode 100644 schema/elasticsearch/visibility/versioned/v10/index_template_v7.json create mode 100755 schema/elasticsearch/visibility/versioned/v10/upgrade.sh create mode 100644 schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql create mode 100644 schema/mysql/v8/visibility/versioned/v1.10/manifest.json create mode 100644 schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql create mode 100644 schema/postgresql/v12/visibility/versioned/v1.10/manifest.json diff --git a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json new file mode 100644 index 00000000000..6c7e3db4f7a --- /dev/null +++ b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json @@ -0,0 +1,159 @@ +{ + "order": 0, + "index_patterns": ["temporal_visibility_v1*"], + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "0", + "auto_expand_replicas": "0-2", + "search.idle.after": "365d", + "sort.field": ["CloseTime", "StartTime", "RunId"], + "sort.order": ["desc", "desc", "desc"], + "sort.missing": ["_first", "_first", "_first"] + } + }, + "mappings": { + "dynamic": "false", + "properties": { + "NamespaceId": { + "type": "keyword" + }, + "TemporalNamespaceDivision": { + "type": "keyword" + }, + "WorkflowId": { + "type": "keyword" + }, + "RunId": { + "type": "keyword" + }, + "WorkflowType": { + "type": "keyword" + }, + "StartTime": { + "type": "date_nanos" + }, + "ExecutionTime": { + "type": "date_nanos" + }, + "CloseTime": { + "type": "date_nanos" + }, + "ExecutionDuration": { + "type": "long" + }, + "ExecutionStatus": { + "type": "keyword" + }, + "TaskQueue": { + "type": "keyword" + }, + "TemporalChangeVersion": { + "type": "keyword" + }, + "BatcherNamespace": { + "type": "keyword" + }, + "BatcherUser": { + "type": "keyword" + }, + "BinaryChecksums": { + "type": "keyword" + }, + "HistoryLength": { + "type": "long" + }, + "StateTransitionCount": { + "type": "long" + }, + "TemporalScheduledStartTime": { + "type": "date_nanos" + }, + "TemporalScheduledById": { + "type": "keyword" + }, + "TemporalSchedulePaused": { + "type": "boolean" + }, + "HistorySizeBytes": { + "type": "long" + }, + "BuildIds": { + "type": "keyword" + }, + "ParentWorkflowId": { + "type": "keyword" + }, + "ParentRunId": { + "type": "keyword" + }, + "RootWorkflowId": { + "type": "keyword" + }, + "RootRunId": { + "type": "keyword" + }, + "TemporalPauseInfo": { + "type": "keyword" + }, + "TemporalWorkerDeploymentVersion": { + "type": "keyword" + }, + "TemporalWorkflowVersioningBehavior": { + "type": "keyword" + }, + "TemporalWorkerDeployment": { + "type": "keyword" + }, + "TemporalBool01": { + "type": "boolean" + }, + "TemporalBool02": { + "type": "boolean" + }, + "TemporalDatetime01": { + "type": "date_nanos" + }, + "TemporalDatetime02": { + "type": "date_nanos" + }, + "TemporalDouble01": { + "type": "double" + }, + "TemporalDouble02": { + "type": "double" + }, + "TemporalInt01": { + "type": "int" + }, + "TemporalInt02": { + "type": "int" + }, + "TemporalKeyword01": { + "type": "keyword" + }, + "TemporalKeyword02": { + "type": "keyword" + }, + "TemporalKeyword03": { + "type": "keyword" + }, + "TemporalKeyword04": { + "type": "keyword" + }, + "TemporalText01": { + "type": "text" + }, + "TemporalText02": { + "type": "text" + }, + "TemporalKeywordList01": { + "type": "keyword" + }, + "TemporalKeywordList02": { + "type": "keyword" + } + } + }, + "aliases": {} +} diff --git a/schema/elasticsearch/visibility/versioned/v10/upgrade.sh b/schema/elasticsearch/visibility/versioned/v10/upgrade.sh new file mode 100755 index 00000000000..7dcff163668 --- /dev/null +++ b/schema/elasticsearch/visibility/versioned/v10/upgrade.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +# Prerequisites: +# - jq +# - curl + +# Input parameters. +: "${ES_SCHEME:=http}" +: "${ES_SERVER:=127.0.0.1}" +: "${ES_PORT:=9200}" +: "${ES_USER:=}" +: "${ES_PWD:=}" +: "${ES_VERSION:=v7}" +: "${ES_VIS_INDEX_V1:=temporal_visibility_v1_dev}" +: "${AUTO_CONFIRM:=}" +: "${SLICES_COUNT:=auto}" + +es_endpoint="${ES_SCHEME}://${ES_SERVER}:${ES_PORT}" + +echo "=== Step 0. Sanity check if Elasticsearch index is accessible ===" + +if ! curl --silent --fail --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/${ES_VIS_INDEX_V1}/_stats/docs" --write-out "\n"; then + echo "Elasticsearch index ${ES_VIS_INDEX_V1} is not accessible at ${es_endpoint}." + exit 1 +fi + +echo "=== Step 1. Add new builtin search attributes ===" + +new_mapping=' +{ + "properties": { + "TemporalBool01": { + "type": "boolean" + }, + "TemporalBool02": { + "type": "boolean" + }, + "TemporalDatetime01": { + "type": "date_nanos" + }, + "TemporalDatetime02": { + "type": "date_nanos" + }, + "TemporalDouble01": { + "type": "double" + }, + "TemporalDouble02": { + "type": "double" + }, + "TemporalInt01": { + "type": "int" + }, + "TemporalInt02": { + "type": "int" + }, + "TemporalKeyword01": { + "type": "keyword" + }, + "TemporalKeyword02": { + "type": "keyword" + }, + "TemporalKeyword03": { + "type": "keyword" + }, + "TemporalKeyword04": { + "type": "keyword" + }, + "TemporalText01": { + "type": "text" + }, + "TemporalText02": { + "type": "text" + }, + "TemporalKeywordList01": { + "type": "keyword" + }, + "TemporalKeywordList02": { + "type": "keyword" + } + } +} +' + +if [ -z "${AUTO_CONFIRM}" ]; then + read -p "Add new builtin search attributes to the index ${ES_VIS_INDEX_V1}? (N/y)" -n 1 -r + echo +else + REPLY="y" +fi +if [ "${REPLY}" = "y" ]; then + curl --silent --fail --user "${ES_USER}":"${ES_PWD}" -X PUT "${es_endpoint}/${ES_VIS_INDEX_V1}/_mapping" -H "Content-Type: application/json" --data-binary "$new_mapping" | jq + # Wait for mapping changes to go through. + until curl --silent --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/_cluster/health/${ES_VIS_INDEX_V1}" | jq --exit-status '.status=="green" | .'; do + echo "Waiting for Elasticsearch index ${ES_VIS_INDEX_V1} become green." + sleep 1 + done +fi diff --git a/schema/mysql/v8/version.go b/schema/mysql/v8/version.go index d9af4aa90e8..2661c0e4a69 100644 --- a/schema/mysql/v8/version.go +++ b/schema/mysql/v8/version.go @@ -6,4 +6,4 @@ package v8 const Version = "1.18" // VisibilityVersion is the MySQL visibility database release version -const VisibilityVersion = "1.9" +const VisibilityVersion = "1.10" diff --git a/schema/mysql/v8/visibility/schema.sql b/schema/mysql/v8/visibility/schema.sql index 7cb6aa0897c..fcbb97725d9 100644 --- a/schema/mysql/v8/visibility/schema.sql +++ b/schema/mysql/v8/visibility/schema.sql @@ -166,3 +166,59 @@ CREATE FULLTEXT INDEX by_text_03 ON custom_search_attributes (Text03); CREATE INDEX by_keyword_list_01 ON custom_search_attributes (namespace_id, (CAST(KeywordList01 AS CHAR(255) ARRAY))); CREATE INDEX by_keyword_list_02 ON custom_search_attributes (namespace_id, (CAST(KeywordList02 AS CHAR(255) ARRAY))); CREATE INDEX by_keyword_list_03 ON custom_search_attributes (namespace_id, (CAST(KeywordList03 AS CHAR(255) ARRAY))); + +CREATE TABLE archetype_search_attributes ( + namespace_id CHAR(64) NOT NULL, + run_id CHAR(64) NOT NULL, + _version BIGINT NOT NULL DEFAULT 0, + search_attributes JSON NULL, + + -- Pre-allocated Archetype search attributes + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool01"), + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool02"), + TemporalDatetime01 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + TemporalDatetime02 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble01"), + TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble02"), + TemporalInt01 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt01"), + TemporalInt02 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt02"), + TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword01"), + TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword02"), + TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword03"), + TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword04"), + TemporalText01 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText01") STORED, + TemporalText02 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText02") STORED, + TemporalKeywordList01 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList01"), + TemporalKeywordList02 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList02"), + + PRIMARY KEY (namespace_id, run_id) +); + +CREATE INDEX by_temporal_bool_01 ON archetype_search_attributes (namespace_id, TemporalBool01); +CREATE INDEX by_temporal_bool_02 ON archetype_search_attributes (namespace_id, TemporalBool02); +CREATE INDEX by_temporal_datetime_01 ON archetype_search_attributes (namespace_id, TemporalDatetime01); +CREATE INDEX by_temporal_datetime_02 ON archetype_search_attributes (namespace_id, TemporalDatetime02); +CREATE INDEX by_temporal_double_01 ON archetype_search_attributes (namespace_id, TemporalDouble01); +CREATE INDEX by_temporal_double_02 ON archetype_search_attributes (namespace_id, TemporalDouble02); +CREATE INDEX by_temporal_int_01 ON archetype_search_attributes (namespace_id, TemporalInt01); +CREATE INDEX by_temporal_int_02 ON archetype_search_attributes (namespace_id, TemporalInt02); +CREATE INDEX by_temporal_keyword_01 ON archetype_search_attributes (namespace_id, TemporalKeyword01); +CREATE INDEX by_temporal_keyword_02 ON archetype_search_attributes (namespace_id, TemporalKeyword02); +CREATE INDEX by_temporal_keyword_03 ON archetype_search_attributes (namespace_id, TemporalKeyword03); +CREATE INDEX by_temporal_keyword_04 ON archetype_search_attributes (namespace_id, TemporalKeyword04); +CREATE FULLTEXT INDEX by_temporal_text_01 ON archetype_search_attributes (TemporalText01); +CREATE FULLTEXT INDEX by_temporal_text_02 ON archetype_search_attributes (TemporalText02); +CREATE INDEX by_temporal_keyword_list_01 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList01 AS CHAR(255) ARRAY))); +CREATE INDEX by_temporal_keyword_list_02 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList02 AS CHAR(255) ARRAY))); diff --git a/schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql b/schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql new file mode 100644 index 00000000000..49589433f3a --- /dev/null +++ b/schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql @@ -0,0 +1,55 @@ +CREATE TABLE archetype_search_attributes ( + namespace_id CHAR(64) NOT NULL, + run_id CHAR(64) NOT NULL, + _version BIGINT NOT NULL DEFAULT 0, + search_attributes JSON NULL, + + -- Pre-allocated Archetype search attributes + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool01"), + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool02"), + TemporalDatetime01 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + TemporalDatetime02 DATETIME(6) GENERATED ALWAYS AS ( + CONVERT_TZ( + REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), + SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z', '+00:00'), -6, 6), + '+00:00' + ) + ), + TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble01"), + TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble02"), + TemporalInt01 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt01"), + TemporalInt02 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt02"), + TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword01"), + TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword02"), + TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword03"), + TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword04"), + TemporalText01 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText01") STORED, + TemporalText02 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText02") STORED, + TemporalKeywordList01 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList01"), + TemporalKeywordList02 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList02"), + + PRIMARY KEY (namespace_id, run_id) +); + +CREATE INDEX by_temporal_bool_01 ON archetype_search_attributes (namespace_id, TemporalBool01); +CREATE INDEX by_temporal_bool_02 ON archetype_search_attributes (namespace_id, TemporalBool02); +CREATE INDEX by_temporal_datetime_01 ON archetype_search_attributes (namespace_id, TemporalDatetime01); +CREATE INDEX by_temporal_datetime_02 ON archetype_search_attributes (namespace_id, TemporalDatetime02); +CREATE INDEX by_temporal_double_01 ON archetype_search_attributes (namespace_id, TemporalDouble01); +CREATE INDEX by_temporal_double_02 ON archetype_search_attributes (namespace_id, TemporalDouble02); +CREATE INDEX by_temporal_int_01 ON archetype_search_attributes (namespace_id, TemporalInt01); +CREATE INDEX by_temporal_int_02 ON archetype_search_attributes (namespace_id, TemporalInt02); +CREATE INDEX by_temporal_keyword_01 ON archetype_search_attributes (namespace_id, TemporalKeyword01); +CREATE INDEX by_temporal_keyword_02 ON archetype_search_attributes (namespace_id, TemporalKeyword02); +CREATE INDEX by_temporal_keyword_03 ON archetype_search_attributes (namespace_id, TemporalKeyword03); +CREATE INDEX by_temporal_keyword_04 ON archetype_search_attributes (namespace_id, TemporalKeyword04); +CREATE FULLTEXT INDEX by_temporal_text_01 ON archetype_search_attributes (TemporalText01); +CREATE FULLTEXT INDEX by_temporal_text_02 ON archetype_search_attributes (TemporalText02); +CREATE INDEX by_temporal_keyword_list_01 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList01 AS CHAR(255) ARRAY))); +CREATE INDEX by_temporal_keyword_list_02 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList02 AS CHAR(255) ARRAY))); diff --git a/schema/mysql/v8/visibility/versioned/v1.10/manifest.json b/schema/mysql/v8/visibility/versioned/v1.10/manifest.json new file mode 100644 index 00000000000..289576a6016 --- /dev/null +++ b/schema/mysql/v8/visibility/versioned/v1.10/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.10", + "MinCompatibleVersion": "0.1", + "Description": "add archetype search attributes table and indices", + "SchemaUpdateCqlFiles": [ + "add_archetype_search_attributes.sql" + ] +} diff --git a/schema/postgresql/v12/version.go b/schema/postgresql/v12/version.go index 4dcdd8fdcd5..741e05bfb96 100644 --- a/schema/postgresql/v12/version.go +++ b/schema/postgresql/v12/version.go @@ -8,4 +8,4 @@ const Version = "1.18" // VisibilityVersion is the Postgres visibility database release version // Temporal supports both MySQL and Postgres officially, so upgrade should be performed for both MySQL and Postgres -const VisibilityVersion = "1.9" +const VisibilityVersion = "1.10" diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index 166b1c056d6..28fec4f2f99 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -79,6 +79,24 @@ CREATE TABLE executions_visibility ( KeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList02') STORED, KeywordList03 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList03') STORED, + -- Pre-allocated Archetype search attributes + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, + TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, + TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, + TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, + TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, + TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, + TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, + TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, + TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, + TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, + TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, + TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, + TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, + TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, + TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, + PRIMARY KEY (namespace_id, run_id) ); @@ -140,3 +158,21 @@ CREATE INDEX by_text_03 ON executions_visibility USING GIN (namespace_id CREATE INDEX by_keyword_list_01 ON executions_visibility USING GIN (namespace_id, KeywordList01 jsonb_path_ops); CREATE INDEX by_keyword_list_02 ON executions_visibility USING GIN (namespace_id, KeywordList02 jsonb_path_ops); CREATE INDEX by_keyword_list_03 ON executions_visibility USING GIN (namespace_id, KeywordList03 jsonb_path_ops); + +-- Indexes for the pre-allocated Archetype search attributes +CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_bool_02 ON executions_visibility (namespace_id, TemporalBool02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_datetime_01 ON executions_visibility (namespace_id, TemporalDatetime01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_datetime_02 ON executions_visibility (namespace_id, TemporalDatetime02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_double_01 ON executions_visibility (namespace_id, TemporalDouble01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_double_02 ON executions_visibility (namespace_id, TemporalDouble02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_int_01 ON executions_visibility (namespace_id, TemporalInt01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_int_02 ON executions_visibility (namespace_id, TemporalInt02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_01 ON executions_visibility (namespace_id, TemporalKeyword01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_02 ON executions_visibility (namespace_id, TemporalKeyword02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_03 ON executions_visibility (namespace_id, TemporalKeyword03, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_04 ON executions_visibility (namespace_id, TemporalKeyword04, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_text_01 ON executions_visibility USING GIN (namespace_id, TemporalText01); +CREATE INDEX by_temporal_text_02 ON executions_visibility USING GIN (namespace_id, TemporalText02); +CREATE INDEX by_temporal_keyword_list_01 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList01 jsonb_path_ops); +CREATE INDEX by_temporal_keyword_list_02 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList02 jsonb_path_ops); \ No newline at end of file diff --git a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql new file mode 100644 index 00000000000..5b34b2a38c7 --- /dev/null +++ b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql @@ -0,0 +1,36 @@ +-- Pre-allocated archetype search attributes +ALTER TABLE executions_visibility + ADD COLUMN TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, + ADD COLUMN TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, + ADD COLUMN TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, + ADD COLUMN TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, + ADD COLUMN TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, + ADD COLUMN TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, + ADD COLUMN TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, + ADD COLUMN TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, + ADD COLUMN TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, + ADD COLUMN TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, + ADD COLUMN TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, + ADD COLUMN TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, + ADD COLUMN TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, + ADD COLUMN TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, + ADD COLUMN TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, + ADD COLUMN TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, + +-- Indexes for the pre-allocated Archetype search attributes +CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_bool_02 ON executions_visibility (namespace_id, TemporalBool02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_datetime_01 ON executions_visibility (namespace_id, TemporalDatetime01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_datetime_02 ON executions_visibility (namespace_id, TemporalDatetime02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_double_01 ON executions_visibility (namespace_id, TemporalDouble01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_double_02 ON executions_visibility (namespace_id, TemporalDouble02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_int_01 ON executions_visibility (namespace_id, TemporalInt01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_int_02 ON executions_visibility (namespace_id, TemporalInt02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_01 ON executions_visibility (namespace_id, TemporalKeyword01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_02 ON executions_visibility (namespace_id, TemporalKeyword02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_03 ON executions_visibility (namespace_id, TemporalKeyword03, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_04 ON executions_visibility (namespace_id, TemporalKeyword04, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_text_01 ON executions_visibility USING GIN (namespace_id, TemporalText01); +CREATE INDEX by_temporal_text_02 ON executions_visibility USING GIN (namespace_id, TemporalText02); +CREATE INDEX by_temporal_keyword_list_01 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList01 jsonb_path_ops); +CREATE INDEX by_temporal_keyword_list_02 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList02 jsonb_path_ops); diff --git a/schema/postgresql/v12/visibility/versioned/v1.10/manifest.json b/schema/postgresql/v12/visibility/versioned/v1.10/manifest.json new file mode 100644 index 00000000000..e2a407dc71a --- /dev/null +++ b/schema/postgresql/v12/visibility/versioned/v1.10/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "1.10", + "MinCompatibleVersion": "0.1", + "Description": "add archetype search attributes columns and indices", + "SchemaUpdateCqlFiles": [ + "add_archetype_search_attributes.sql" + ] +} diff --git a/schema/sqlite/v3/visibility/schema.sql b/schema/sqlite/v3/visibility/schema.sql index ff48c35ff6b..2ee74fef35f 100644 --- a/schema/sqlite/v3/visibility/schema.sql +++ b/schema/sqlite/v3/visibility/schema.sql @@ -65,6 +65,24 @@ CREATE TABLE executions_visibility ( KeywordList02 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.KeywordList02")) STORED, KeywordList03 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.KeywordList03")) STORED, + -- Pre-allocated archetype search attributes + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalBool01")), + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalBool02")), + TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (STRFTIME('%Y-%m-%d %H:%M:%f+00:00', JSON_EXTRACT(search_attributes, "$.TemporalDatetime01"))), + TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (STRFTIME('%Y-%m-%d %H:%M:%f+00:00', JSON_EXTRACT(search_attributes, "$.TemporalDatetime02"))), + TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalDouble01")), + TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalDouble02")), + TemporalInt01 BIGINT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalInt01")), + TemporalInt02 BIGINT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalInt02")), + TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword01")), + TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword02")), + TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword03")), + TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword04")), + TemporalText01 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalText01")) STORED, + TemporalText02 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalText02")) STORED, + TemporalKeywordList01 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeywordList01")) STORED, + TemporalKeywordList02 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeywordList02")) STORED, + PRIMARY KEY (namespace_id, run_id) ); @@ -118,11 +136,26 @@ CREATE INDEX by_keyword_08 ON executions_visibility (namespace_id, Keyword08, CREATE INDEX by_keyword_09 ON executions_visibility (namespace_id, Keyword09, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); CREATE INDEX by_keyword_10 ON executions_visibility (namespace_id, Keyword10, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +-- Indexes for the pre-allocated Archetype search attributes +CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_bool_02 ON executions_visibility (namespace_id, TemporalBool02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_datetime_01 ON executions_visibility (namespace_id, TemporalDatetime01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_datetime_02 ON executions_visibility (namespace_id, TemporalDatetime02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_double_01 ON executions_visibility (namespace_id, TemporalDouble01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_double_02 ON executions_visibility (namespace_id, TemporalDouble02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_int_01 ON executions_visibility (namespace_id, TemporalInt01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_int_02 ON executions_visibility (namespace_id, TemporalInt02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_01 ON executions_visibility (namespace_id, TemporalKeyword01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_02 ON executions_visibility (namespace_id, TemporalKeyword02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_03 ON executions_visibility (namespace_id, TemporalKeyword03, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); +CREATE INDEX by_temporal_keyword_04 ON executions_visibility (namespace_id, TemporalKeyword04, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); CREATE VIRTUAL TABLE executions_visibility_fts_text USING fts5 ( Text01, Text02, Text03, + TemporalText01, + TemporalText02, content='executions_visibility', tokenize="unicode61 remove_diacritics 2" ); @@ -140,6 +173,8 @@ CREATE VIRTUAL TABLE executions_visibility_fts_keyword_list USING fts5 ( KeywordList01, KeywordList02, KeywordList03, + TemporalKeywordList01, + TemporalKeywordList02, content='executions_visibility', tokenize="unicode61 remove_diacritics 0 categories 'C* L* M* N* P* S* Z*' separators '♡'" ); @@ -151,12 +186,16 @@ BEGIN rowid, Text01, Text02, - Text03 + Text03, + TemporalText01, + TemporalText02 ) VALUES ( NEW.rowid, NEW.Text01, NEW.Text02, - NEW.Text03 + NEW.Text03, + NEW.TemporalText01, + NEW.TemporalText02 ); -- insert into fts_keyword_list table INSERT INTO executions_visibility_fts_keyword_list ( @@ -167,7 +206,9 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03 + KeywordList03, + TemporalKeywordList01, + TemporalKeywordList02 ) VALUES ( NEW.rowid, NEW.TemporalChangeVersion, @@ -176,7 +217,9 @@ BEGIN NEW.TemporalPauseInfo, NEW.KeywordList01, NEW.KeywordList02, - NEW.KeywordList03 + NEW.KeywordList03, + NEW.TemporalKeywordList01, + NEW.TemporalKeywordList02 ); END; @@ -188,13 +231,17 @@ BEGIN rowid, Text01, Text02, - Text03 + Text03, + TemporalText01, + TemporalText02 ) VALUES ( 'delete', OLD.rowid, OLD.Text01, OLD.Text02, - OLD.Text03 + OLD.Text03, + OLD.TemporalText01, + OLD.TemporalText02 ); -- delete from fts_keyword_list table INSERT INTO executions_visibility_fts_keyword_list ( @@ -206,7 +253,9 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03 + KeywordList03, + TemporalKeywordList01, + TemporalKeywordList02 ) VALUES ( 'delete', OLD.rowid, @@ -216,7 +265,9 @@ BEGIN OLD.TemporalPauseInfo, OLD.KeywordList01, OLD.KeywordList02, - OLD.KeywordList03 + OLD.KeywordList03, + OLD.TemporalKeywordList01, + OLD.TemporalKeywordList02 ); END; @@ -228,24 +279,32 @@ BEGIN rowid, Text01, Text02, - Text03 + Text03, + TemporalText01, + TemporalText02 ) VALUES ( 'delete', OLD.rowid, OLD.Text01, OLD.Text02, - OLD.Text03 + OLD.Text03, + OLD.TemporalText01, + OLD.TemporalText02 ); INSERT INTO executions_visibility_fts_text ( rowid, Text01, Text02, - Text03 + Text03, + TemporalText01, + TemporalText02 ) VALUES ( NEW.rowid, NEW.Text01, NEW.Text02, - NEW.Text03 + NEW.Text03, + NEW.TemporalText01, + NEW.TemporalText02 ); -- update fts_keyword_list table INSERT INTO executions_visibility_fts_keyword_list ( @@ -257,7 +316,9 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03 + KeywordList03, + TemporalKeywordList01, + TemporalKeywordList02 ) VALUES ( 'delete', OLD.rowid, @@ -267,7 +328,9 @@ BEGIN OLD.TemporalPauseInfo, OLD.KeywordList01, OLD.KeywordList02, - OLD.KeywordList03 + OLD.KeywordList03, + OLD.TemporalKeywordList01, + OLD.TemporalKeywordList02 ); INSERT INTO executions_visibility_fts_keyword_list ( rowid, @@ -277,7 +340,9 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03 + KeywordList03, + TemporalKeywordList01, + TemporalKeywordList02 ) VALUES ( NEW.rowid, NEW.TemporalChangeVersion, @@ -286,6 +351,8 @@ BEGIN NEW.TemporalPauseInfo, NEW.KeywordList01, NEW.KeywordList02, - NEW.KeywordList03 + NEW.KeywordList03, + NEW.TemporalKeywordList01, + NEW.TemporalKeywordList02 ); END; From bbe2c13e5dfe271ac453952d728b40d5cf9da5ec Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Fri, 26 Sep 2025 16:21:25 -0400 Subject: [PATCH 02/11] Update minor formatting --- schema/postgresql/v12/visibility/schema.sql | 16 +++++----- .../v1.10/add_archetype_search_attributes.sql | 32 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index 28fec4f2f99..552764e8d1d 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -80,22 +80,22 @@ CREATE TABLE executions_visibility ( KeywordList03 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList03') STORED, -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, - TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, - TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, - TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, - TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, + TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, + TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, + TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, + TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, - TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, - TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, + TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, + TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, PRIMARY KEY (namespace_id, run_id) ); diff --git a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql index 5b34b2a38c7..0d69d4919dc 100644 --- a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql +++ b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql @@ -1,21 +1,21 @@ -- Pre-allocated archetype search attributes ALTER TABLE executions_visibility - ADD COLUMN TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, - ADD COLUMN TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, - ADD COLUMN TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, - ADD COLUMN TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, - ADD COLUMN TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, - ADD COLUMN TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, - ADD COLUMN TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, - ADD COLUMN TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, - ADD COLUMN TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, - ADD COLUMN TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, - ADD COLUMN TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, - ADD COLUMN TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, - ADD COLUMN TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, - ADD COLUMN TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, - ADD COLUMN TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, - ADD COLUMN TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, + ADD COLUMN TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, + ADD COLUMN TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, + ADD COLUMN TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, + ADD COLUMN TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, + ADD COLUMN TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, + ADD COLUMN TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, + ADD COLUMN TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, + ADD COLUMN TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, + ADD COLUMN TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, + ADD COLUMN TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, + ADD COLUMN TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, + ADD COLUMN TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, + ADD COLUMN TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, + ADD COLUMN TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, + ADD COLUMN TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, + ADD COLUMN TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, -- Indexes for the pre-allocated Archetype search attributes CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); From c30f78db25d9b8fd91a105c2b12d5ba19b71a9e6 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 29 Sep 2025 16:54:19 -0400 Subject: [PATCH 03/11] Add archetype search attributes to Cluster Metadata --- api/persistence/v1/cluster_metadata.pb.go | 16 ++++++++--- chasm/registrable_component.go | 7 +++++ common/searchattribute/defs.go | 27 ++++++++++++++++++- common/searchattribute/manager.go | 12 ++++++++- common/searchattribute/name_type_map.go | 22 ++++++++++++--- .../api/persistence/v1/cluster_metadata.proto | 1 + 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/api/persistence/v1/cluster_metadata.pb.go b/api/persistence/v1/cluster_metadata.pb.go index a5f5b467ba6..78ac72b8f6f 100644 --- a/api/persistence/v1/cluster_metadata.pb.go +++ b/api/persistence/v1/cluster_metadata.pb.go @@ -166,10 +166,11 @@ func (x *ClusterMetadata) GetTags() map[string]string { } type IndexSearchAttributes struct { - state protoimpl.MessageState `protogen:"open.v1"` - CustomSearchAttributes map[string]v11.IndexedValueType `protobuf:"bytes,1,rep,name=custom_search_attributes,json=customSearchAttributes,proto3" json:"custom_search_attributes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=temporal.api.enums.v1.IndexedValueType"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + CustomSearchAttributes map[string]v11.IndexedValueType `protobuf:"bytes,1,rep,name=custom_search_attributes,json=customSearchAttributes,proto3" json:"custom_search_attributes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=temporal.api.enums.v1.IndexedValueType"` + ArchetypeSearchAttributes map[string]v11.IndexedValueType `protobuf:"bytes,2,rep,name=archetype_search_attributes,json=archetypeSearchAttributes,proto3" json:"archetype_search_attributes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=temporal.api.enums.v1.IndexedValueType"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *IndexSearchAttributes) Reset() { @@ -209,6 +210,13 @@ func (x *IndexSearchAttributes) GetCustomSearchAttributes() map[string]v11.Index return nil } +func (x *IndexSearchAttributes) GetArchetypeSearchAttributes() map[string]v11.IndexedValueType { + if x != nil { + return x.ArchetypeSearchAttributes + } + return nil +} + var File_temporal_server_api_persistence_v1_cluster_metadata_proto protoreflect.FileDescriptor const file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDesc = "" + diff --git a/chasm/registrable_component.go b/chasm/registrable_component.go index 49ea0e1f630..a3ad1827be6 100644 --- a/chasm/registrable_component.go +++ b/chasm/registrable_component.go @@ -2,6 +2,8 @@ package chasm import ( "reflect" + + enumspb "go.temporal.io/api/enums/v1" ) type ( @@ -16,6 +18,11 @@ type ( } RegistrableComponentOption func(*RegistrableComponent) + + VisibilityIndexedAttribute struct { + Name string // CHASM framework will automatically add "TemporalCAT" prefix + Type enumspb.IndexedValueType + } ) func NewRegistrableComponent[C Component]( diff --git a/common/searchattribute/defs.go b/common/searchattribute/defs.go index 95f1694847a..c11fa97fc03 100644 --- a/common/searchattribute/defs.go +++ b/common/searchattribute/defs.go @@ -216,6 +216,25 @@ var ( "KeywordList02": enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, "KeywordList03": enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, } + + archetypeSearchAttributes = map[string]enumspb.IndexedValueType{ + "TemporalBool01": enumspb.INDEXED_VALUE_TYPE_BOOL, + "TemporalBool02": enumspb.INDEXED_VALUE_TYPE_BOOL, + "TemporalDatetime01": enumspb.INDEXED_VALUE_TYPE_DATETIME, + "TemporalDatetime02": enumspb.INDEXED_VALUE_TYPE_DATETIME, + "TemporalDouble01": enumspb.INDEXED_VALUE_TYPE_DOUBLE, + "TemporalDouble02": enumspb.INDEXED_VALUE_TYPE_DOUBLE, + "TemporalInt01": enumspb.INDEXED_VALUE_TYPE_INT, + "TemporalInt02": enumspb.INDEXED_VALUE_TYPE_INT, + "TemporalKeyword01": enumspb.INDEXED_VALUE_TYPE_KEYWORD, + "TemporalKeyword02": enumspb.INDEXED_VALUE_TYPE_KEYWORD, + "TemporalKeyword03": enumspb.INDEXED_VALUE_TYPE_KEYWORD, + "TemporalKeyword04": enumspb.INDEXED_VALUE_TYPE_KEYWORD, + "TemporalText01": enumspb.INDEXED_VALUE_TYPE_TEXT, + "TemporalText02": enumspb.INDEXED_VALUE_TYPE_TEXT, + "TemporalKeywordList01": enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, + "TemporalKeywordList02": enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, + } ) // IsSystem returns true if name is system search attribute @@ -260,10 +279,16 @@ func GetSqlDbColName(name string) string { func GetSqlDbIndexSearchAttributes() *persistencespb.IndexSearchAttributes { return &persistencespb.IndexSearchAttributes{ - CustomSearchAttributes: sqlDbCustomSearchAttributes, + CustomSearchAttributes: sqlDbCustomSearchAttributes, + ArchetypeSearchAttributes: archetypeSearchAttributes, } } +// GetArchetypeIndexSearchAttributes returns the predefined Archetype search attributes. +func GetArchetypeIndexSearchAttributes() map[string]enumspb.IndexedValueType { + return archetypeSearchAttributes +} + // QueryWithAnyNamespaceDivision returns a modified workflow visibility query that disables // special handling of namespace division and so matches workflows in all namespace divisions. // Normally a query that didn't explicitly mention TemporalNamespaceDivision would be limited diff --git a/common/searchattribute/manager.go b/common/searchattribute/manager.go index 82bd54a63b0..543f91a81c4 100644 --- a/common/searchattribute/manager.go +++ b/common/searchattribute/manager.go @@ -84,6 +84,7 @@ func (m *managerImpl) GetSearchAttributes( } if indexSearchAttributes, ok := saCache.searchAttributes[indexName]; ok { result.customSearchAttributes = maps.Clone(indexSearchAttributes.customSearchAttributes) + result.archetypeSearchAttributes = maps.Clone(indexSearchAttributes.archetypeSearchAttributes) } return result, nil } @@ -177,7 +178,16 @@ func (m *managerImpl) SaveSearchAttributes( if clusterMetadata.IndexSearchAttributes == nil { clusterMetadata.IndexSearchAttributes = map[string]*persistencespb.IndexSearchAttributes{indexName: nil} } - clusterMetadata.IndexSearchAttributes[indexName] = &persistencespb.IndexSearchAttributes{CustomSearchAttributes: newCustomSearchAttributes} + // Preserve any existing ArchetypeSearchAttributes while updating custom ones. + existing := clusterMetadata.IndexSearchAttributes[indexName] + var archetype map[string]enumspb.IndexedValueType + if existing != nil { + archetype = existing.GetArchetypeSearchAttributes() + } + clusterMetadata.IndexSearchAttributes[indexName] = &persistencespb.IndexSearchAttributes{ + CustomSearchAttributes: newCustomSearchAttributes, + ArchetypeSearchAttributes: archetype, + } _, err = m.clusterMetadataManager.SaveClusterMetadata(ctx, &persistence.SaveClusterMetadataRequest{ ClusterMetadata: clusterMetadata, Version: clusterMetadataResponse.Version, diff --git a/common/searchattribute/name_type_map.go b/common/searchattribute/name_type_map.go index feaa5ad4f67..833164c835f 100644 --- a/common/searchattribute/name_type_map.go +++ b/common/searchattribute/name_type_map.go @@ -11,6 +11,8 @@ type ( NameTypeMap struct { // customSearchAttributes are defined by cluster admin per cluster level and passed and stored in SearchAttributes object. customSearchAttributes map[string]enumspb.IndexedValueType + // archetypeSearchAttributes are defined during component registration, pre-allocated field name to type map is stored here. + archetypeSearchAttributes map[string]enumspb.IndexedValueType } category int32 @@ -20,13 +22,15 @@ const ( systemCategory category = 1 << iota predefinedCategory customCategory + archetypeCategory ) func buildIndexNameTypeMap(indexSearchAttributes map[string]*persistencespb.IndexSearchAttributes) map[string]NameTypeMap { indexNameTypeMap := make(map[string]NameTypeMap, len(indexSearchAttributes)) - for indexName, customSearchAttributes := range indexSearchAttributes { + for indexName, attrs := range indexSearchAttributes { indexNameTypeMap[indexName] = NameTypeMap{ - customSearchAttributes: customSearchAttributes.GetCustomSearchAttributes(), + customSearchAttributes: attrs.GetCustomSearchAttributes(), + archetypeSearchAttributes: attrs.GetArchetypeSearchAttributes(), } } return indexNameTypeMap @@ -47,8 +51,12 @@ func (m NameTypeMap) Custom() map[string]enumspb.IndexedValueType { return m.customSearchAttributes } +func (m NameTypeMap) Archetype() map[string]enumspb.IndexedValueType { + return m.archetypeSearchAttributes +} + func (m NameTypeMap) All() map[string]enumspb.IndexedValueType { - allSearchAttributes := make(map[string]enumspb.IndexedValueType, len(system)+len(m.customSearchAttributes)+len(predefined)) + allSearchAttributes := make(map[string]enumspb.IndexedValueType, len(system)+len(predefined)+len(m.customSearchAttributes)+len(m.archetypeSearchAttributes)) for saName, saType := range system { allSearchAttributes[saName] = saType } @@ -58,6 +66,9 @@ func (m NameTypeMap) All() map[string]enumspb.IndexedValueType { for saName, saType := range m.customSearchAttributes { allSearchAttributes[saName] = saType } + for saName, saType := range m.archetypeSearchAttributes { + allSearchAttributes[saName] = saType + } return allSearchAttributes } @@ -73,6 +84,11 @@ func (m NameTypeMap) getType(name string, cat category) (enumspb.IndexedValueTyp return t, nil } } + if cat|archetypeCategory == cat && len(m.archetypeSearchAttributes) != 0 { + if t, isArchetype := m.archetypeSearchAttributes[name]; isArchetype { + return t, nil + } + } if cat|predefinedCategory == cat { if t, isPredefined := predefined[name]; isPredefined { return t, nil diff --git a/proto/internal/temporal/server/api/persistence/v1/cluster_metadata.proto b/proto/internal/temporal/server/api/persistence/v1/cluster_metadata.proto index e6182b3af34..4e719f18908 100644 --- a/proto/internal/temporal/server/api/persistence/v1/cluster_metadata.proto +++ b/proto/internal/temporal/server/api/persistence/v1/cluster_metadata.proto @@ -25,4 +25,5 @@ message ClusterMetadata { message IndexSearchAttributes{ map custom_search_attributes = 1; + map archetype_search_attributes = 2; } From b41ab05ae1be8a97775873a3f2d2519e910adccc Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 29 Sep 2025 17:03:31 -0400 Subject: [PATCH 04/11] Correct double conversion type in ES schema --- .../visibility/versioned/v10/index_template_v7.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json index 6c7e3db4f7a..bc3ae9d2d94 100644 --- a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json +++ b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json @@ -118,10 +118,12 @@ "type": "date_nanos" }, "TemporalDouble01": { - "type": "double" + "type": "scaled_float", + "scaling_factor": 10000 }, "TemporalDouble02": { - "type": "double" + "type": "scaled_float", + "scaling_factor": 10000 }, "TemporalInt01": { "type": "int" From 2d196358563361733604c472c1c86ffebddb11ed Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 29 Sep 2025 17:09:00 -0400 Subject: [PATCH 05/11] Remove unused code --- chasm/registrable_component.go | 7 ------- common/searchattribute/name_type_map.go | 4 ---- 2 files changed, 11 deletions(-) diff --git a/chasm/registrable_component.go b/chasm/registrable_component.go index a3ad1827be6..49ea0e1f630 100644 --- a/chasm/registrable_component.go +++ b/chasm/registrable_component.go @@ -2,8 +2,6 @@ package chasm import ( "reflect" - - enumspb "go.temporal.io/api/enums/v1" ) type ( @@ -18,11 +16,6 @@ type ( } RegistrableComponentOption func(*RegistrableComponent) - - VisibilityIndexedAttribute struct { - Name string // CHASM framework will automatically add "TemporalCAT" prefix - Type enumspb.IndexedValueType - } ) func NewRegistrableComponent[C Component]( diff --git a/common/searchattribute/name_type_map.go b/common/searchattribute/name_type_map.go index 833164c835f..ff287b0d1cc 100644 --- a/common/searchattribute/name_type_map.go +++ b/common/searchattribute/name_type_map.go @@ -51,10 +51,6 @@ func (m NameTypeMap) Custom() map[string]enumspb.IndexedValueType { return m.customSearchAttributes } -func (m NameTypeMap) Archetype() map[string]enumspb.IndexedValueType { - return m.archetypeSearchAttributes -} - func (m NameTypeMap) All() map[string]enumspb.IndexedValueType { allSearchAttributes := make(map[string]enumspb.IndexedValueType, len(system)+len(predefined)+len(m.customSearchAttributes)+len(m.archetypeSearchAttributes)) for saName, saType := range system { From 258b9395bb2ba87062b79d926333f6c1f4261417 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 30 Sep 2025 15:40:32 -0400 Subject: [PATCH 06/11] Fix schema column generation for boolean type --- schema/postgresql/v12/visibility/schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index 552764e8d1d..f494352063a 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -80,8 +80,8 @@ CREATE TABLE executions_visibility ( KeywordList03 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList03') STORED, -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, + TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, + TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, From 8f18959c3875988138de71a77648d9c4b8655ea6 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 30 Sep 2025 15:44:10 -0400 Subject: [PATCH 07/11] Revert "Fix schema column generation for boolean type" This reverts commit 258b9395bb2ba87062b79d926333f6c1f4261417. --- schema/postgresql/v12/visibility/schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index f494352063a..552764e8d1d 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -80,8 +80,8 @@ CREATE TABLE executions_visibility ( KeywordList03 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList03') STORED, -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, - TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, From 2d0dabe4b94a5785322be9d0d2dd6a80d57a3569 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 30 Sep 2025 15:44:38 -0400 Subject: [PATCH 08/11] Revert "Correct double conversion type in ES schema" This reverts commit b41ab05ae1be8a97775873a3f2d2519e910adccc. --- .../visibility/versioned/v10/index_template_v7.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json index bc3ae9d2d94..6c7e3db4f7a 100644 --- a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json +++ b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json @@ -118,12 +118,10 @@ "type": "date_nanos" }, "TemporalDouble01": { - "type": "scaled_float", - "scaling_factor": 10000 + "type": "double" }, "TemporalDouble02": { - "type": "scaled_float", - "scaling_factor": 10000 + "type": "double" }, "TemporalInt01": { "type": "int" From 6e553e1787b8f784e4160d9714089d92b871c975 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 30 Sep 2025 15:45:47 -0400 Subject: [PATCH 09/11] Revert "Update minor formatting" This reverts commit bbe2c13e5dfe271ac453952d728b40d5cf9da5ec. --- schema/postgresql/v12/visibility/schema.sql | 16 +++++----- .../v1.10/add_archetype_search_attributes.sql | 32 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index 552764e8d1d..28fec4f2f99 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -80,22 +80,22 @@ CREATE TABLE executions_visibility ( KeywordList03 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList03') STORED, -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, + TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, + TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, - TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, - TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, - TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, - TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, + TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, + TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, + TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, + TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, - TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, - TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, + TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, + TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, PRIMARY KEY (namespace_id, run_id) ); diff --git a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql index 0d69d4919dc..5b34b2a38c7 100644 --- a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql +++ b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql @@ -1,21 +1,21 @@ -- Pre-allocated archetype search attributes ALTER TABLE executions_visibility - ADD COLUMN TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, - ADD COLUMN TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, - ADD COLUMN TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, - ADD COLUMN TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, - ADD COLUMN TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, - ADD COLUMN TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, - ADD COLUMN TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, - ADD COLUMN TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, - ADD COLUMN TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, - ADD COLUMN TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, - ADD COLUMN TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, - ADD COLUMN TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, - ADD COLUMN TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, - ADD COLUMN TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, - ADD COLUMN TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, - ADD COLUMN TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, + ADD COLUMN TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, + ADD COLUMN TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, + ADD COLUMN TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, + ADD COLUMN TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, + ADD COLUMN TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, + ADD COLUMN TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, + ADD COLUMN TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, + ADD COLUMN TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, + ADD COLUMN TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, + ADD COLUMN TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, + ADD COLUMN TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, + ADD COLUMN TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, + ADD COLUMN TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, + ADD COLUMN TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, + ADD COLUMN TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, + ADD COLUMN TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, -- Indexes for the pre-allocated Archetype search attributes CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); From cbfe53a3be60975c17369a5b14a74365cac6bb42 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 30 Sep 2025 15:46:00 -0400 Subject: [PATCH 10/11] Revert "Add Archetype search attributes for CHASM Visibility" This reverts commit c2514c54f565994169f751c2d4022a8125a0e40b. --- .../versioned/v10/index_template_v7.json | 159 ------------------ .../visibility/versioned/v10/upgrade.sh | 99 ----------- schema/mysql/v8/version.go | 2 +- schema/mysql/v8/visibility/schema.sql | 56 ------ .../v1.10/add_archetype_search_attributes.sql | 55 ------ .../visibility/versioned/v1.10/manifest.json | 8 - schema/postgresql/v12/version.go | 2 +- schema/postgresql/v12/visibility/schema.sql | 36 ---- .../v1.10/add_archetype_search_attributes.sql | 36 ---- .../visibility/versioned/v1.10/manifest.json | 8 - schema/sqlite/v3/visibility/schema.sql | 99 ++--------- 11 files changed, 18 insertions(+), 542 deletions(-) delete mode 100644 schema/elasticsearch/visibility/versioned/v10/index_template_v7.json delete mode 100755 schema/elasticsearch/visibility/versioned/v10/upgrade.sh delete mode 100644 schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql delete mode 100644 schema/mysql/v8/visibility/versioned/v1.10/manifest.json delete mode 100644 schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql delete mode 100644 schema/postgresql/v12/visibility/versioned/v1.10/manifest.json diff --git a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json b/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json deleted file mode 100644 index 6c7e3db4f7a..00000000000 --- a/schema/elasticsearch/visibility/versioned/v10/index_template_v7.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "order": 0, - "index_patterns": ["temporal_visibility_v1*"], - "settings": { - "index": { - "number_of_shards": "1", - "number_of_replicas": "0", - "auto_expand_replicas": "0-2", - "search.idle.after": "365d", - "sort.field": ["CloseTime", "StartTime", "RunId"], - "sort.order": ["desc", "desc", "desc"], - "sort.missing": ["_first", "_first", "_first"] - } - }, - "mappings": { - "dynamic": "false", - "properties": { - "NamespaceId": { - "type": "keyword" - }, - "TemporalNamespaceDivision": { - "type": "keyword" - }, - "WorkflowId": { - "type": "keyword" - }, - "RunId": { - "type": "keyword" - }, - "WorkflowType": { - "type": "keyword" - }, - "StartTime": { - "type": "date_nanos" - }, - "ExecutionTime": { - "type": "date_nanos" - }, - "CloseTime": { - "type": "date_nanos" - }, - "ExecutionDuration": { - "type": "long" - }, - "ExecutionStatus": { - "type": "keyword" - }, - "TaskQueue": { - "type": "keyword" - }, - "TemporalChangeVersion": { - "type": "keyword" - }, - "BatcherNamespace": { - "type": "keyword" - }, - "BatcherUser": { - "type": "keyword" - }, - "BinaryChecksums": { - "type": "keyword" - }, - "HistoryLength": { - "type": "long" - }, - "StateTransitionCount": { - "type": "long" - }, - "TemporalScheduledStartTime": { - "type": "date_nanos" - }, - "TemporalScheduledById": { - "type": "keyword" - }, - "TemporalSchedulePaused": { - "type": "boolean" - }, - "HistorySizeBytes": { - "type": "long" - }, - "BuildIds": { - "type": "keyword" - }, - "ParentWorkflowId": { - "type": "keyword" - }, - "ParentRunId": { - "type": "keyword" - }, - "RootWorkflowId": { - "type": "keyword" - }, - "RootRunId": { - "type": "keyword" - }, - "TemporalPauseInfo": { - "type": "keyword" - }, - "TemporalWorkerDeploymentVersion": { - "type": "keyword" - }, - "TemporalWorkflowVersioningBehavior": { - "type": "keyword" - }, - "TemporalWorkerDeployment": { - "type": "keyword" - }, - "TemporalBool01": { - "type": "boolean" - }, - "TemporalBool02": { - "type": "boolean" - }, - "TemporalDatetime01": { - "type": "date_nanos" - }, - "TemporalDatetime02": { - "type": "date_nanos" - }, - "TemporalDouble01": { - "type": "double" - }, - "TemporalDouble02": { - "type": "double" - }, - "TemporalInt01": { - "type": "int" - }, - "TemporalInt02": { - "type": "int" - }, - "TemporalKeyword01": { - "type": "keyword" - }, - "TemporalKeyword02": { - "type": "keyword" - }, - "TemporalKeyword03": { - "type": "keyword" - }, - "TemporalKeyword04": { - "type": "keyword" - }, - "TemporalText01": { - "type": "text" - }, - "TemporalText02": { - "type": "text" - }, - "TemporalKeywordList01": { - "type": "keyword" - }, - "TemporalKeywordList02": { - "type": "keyword" - } - } - }, - "aliases": {} -} diff --git a/schema/elasticsearch/visibility/versioned/v10/upgrade.sh b/schema/elasticsearch/visibility/versioned/v10/upgrade.sh deleted file mode 100755 index 7dcff163668..00000000000 --- a/schema/elasticsearch/visibility/versioned/v10/upgrade.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail - -# Prerequisites: -# - jq -# - curl - -# Input parameters. -: "${ES_SCHEME:=http}" -: "${ES_SERVER:=127.0.0.1}" -: "${ES_PORT:=9200}" -: "${ES_USER:=}" -: "${ES_PWD:=}" -: "${ES_VERSION:=v7}" -: "${ES_VIS_INDEX_V1:=temporal_visibility_v1_dev}" -: "${AUTO_CONFIRM:=}" -: "${SLICES_COUNT:=auto}" - -es_endpoint="${ES_SCHEME}://${ES_SERVER}:${ES_PORT}" - -echo "=== Step 0. Sanity check if Elasticsearch index is accessible ===" - -if ! curl --silent --fail --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/${ES_VIS_INDEX_V1}/_stats/docs" --write-out "\n"; then - echo "Elasticsearch index ${ES_VIS_INDEX_V1} is not accessible at ${es_endpoint}." - exit 1 -fi - -echo "=== Step 1. Add new builtin search attributes ===" - -new_mapping=' -{ - "properties": { - "TemporalBool01": { - "type": "boolean" - }, - "TemporalBool02": { - "type": "boolean" - }, - "TemporalDatetime01": { - "type": "date_nanos" - }, - "TemporalDatetime02": { - "type": "date_nanos" - }, - "TemporalDouble01": { - "type": "double" - }, - "TemporalDouble02": { - "type": "double" - }, - "TemporalInt01": { - "type": "int" - }, - "TemporalInt02": { - "type": "int" - }, - "TemporalKeyword01": { - "type": "keyword" - }, - "TemporalKeyword02": { - "type": "keyword" - }, - "TemporalKeyword03": { - "type": "keyword" - }, - "TemporalKeyword04": { - "type": "keyword" - }, - "TemporalText01": { - "type": "text" - }, - "TemporalText02": { - "type": "text" - }, - "TemporalKeywordList01": { - "type": "keyword" - }, - "TemporalKeywordList02": { - "type": "keyword" - } - } -} -' - -if [ -z "${AUTO_CONFIRM}" ]; then - read -p "Add new builtin search attributes to the index ${ES_VIS_INDEX_V1}? (N/y)" -n 1 -r - echo -else - REPLY="y" -fi -if [ "${REPLY}" = "y" ]; then - curl --silent --fail --user "${ES_USER}":"${ES_PWD}" -X PUT "${es_endpoint}/${ES_VIS_INDEX_V1}/_mapping" -H "Content-Type: application/json" --data-binary "$new_mapping" | jq - # Wait for mapping changes to go through. - until curl --silent --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/_cluster/health/${ES_VIS_INDEX_V1}" | jq --exit-status '.status=="green" | .'; do - echo "Waiting for Elasticsearch index ${ES_VIS_INDEX_V1} become green." - sleep 1 - done -fi diff --git a/schema/mysql/v8/version.go b/schema/mysql/v8/version.go index 2661c0e4a69..d9af4aa90e8 100644 --- a/schema/mysql/v8/version.go +++ b/schema/mysql/v8/version.go @@ -6,4 +6,4 @@ package v8 const Version = "1.18" // VisibilityVersion is the MySQL visibility database release version -const VisibilityVersion = "1.10" +const VisibilityVersion = "1.9" diff --git a/schema/mysql/v8/visibility/schema.sql b/schema/mysql/v8/visibility/schema.sql index fcbb97725d9..7cb6aa0897c 100644 --- a/schema/mysql/v8/visibility/schema.sql +++ b/schema/mysql/v8/visibility/schema.sql @@ -166,59 +166,3 @@ CREATE FULLTEXT INDEX by_text_03 ON custom_search_attributes (Text03); CREATE INDEX by_keyword_list_01 ON custom_search_attributes (namespace_id, (CAST(KeywordList01 AS CHAR(255) ARRAY))); CREATE INDEX by_keyword_list_02 ON custom_search_attributes (namespace_id, (CAST(KeywordList02 AS CHAR(255) ARRAY))); CREATE INDEX by_keyword_list_03 ON custom_search_attributes (namespace_id, (CAST(KeywordList03 AS CHAR(255) ARRAY))); - -CREATE TABLE archetype_search_attributes ( - namespace_id CHAR(64) NOT NULL, - run_id CHAR(64) NOT NULL, - _version BIGINT NOT NULL DEFAULT 0, - search_attributes JSON NULL, - - -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool01"), - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool02"), - TemporalDatetime01 DATETIME(6) GENERATED ALWAYS AS ( - CONVERT_TZ( - REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), - SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z', '+00:00'), -6, 6), - '+00:00' - ) - ), - TemporalDatetime02 DATETIME(6) GENERATED ALWAYS AS ( - CONVERT_TZ( - REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), - SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z', '+00:00'), -6, 6), - '+00:00' - ) - ), - TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble01"), - TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble02"), - TemporalInt01 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt01"), - TemporalInt02 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt02"), - TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword01"), - TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword02"), - TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword03"), - TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword04"), - TemporalText01 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText01") STORED, - TemporalText02 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText02") STORED, - TemporalKeywordList01 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList01"), - TemporalKeywordList02 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList02"), - - PRIMARY KEY (namespace_id, run_id) -); - -CREATE INDEX by_temporal_bool_01 ON archetype_search_attributes (namespace_id, TemporalBool01); -CREATE INDEX by_temporal_bool_02 ON archetype_search_attributes (namespace_id, TemporalBool02); -CREATE INDEX by_temporal_datetime_01 ON archetype_search_attributes (namespace_id, TemporalDatetime01); -CREATE INDEX by_temporal_datetime_02 ON archetype_search_attributes (namespace_id, TemporalDatetime02); -CREATE INDEX by_temporal_double_01 ON archetype_search_attributes (namespace_id, TemporalDouble01); -CREATE INDEX by_temporal_double_02 ON archetype_search_attributes (namespace_id, TemporalDouble02); -CREATE INDEX by_temporal_int_01 ON archetype_search_attributes (namespace_id, TemporalInt01); -CREATE INDEX by_temporal_int_02 ON archetype_search_attributes (namespace_id, TemporalInt02); -CREATE INDEX by_temporal_keyword_01 ON archetype_search_attributes (namespace_id, TemporalKeyword01); -CREATE INDEX by_temporal_keyword_02 ON archetype_search_attributes (namespace_id, TemporalKeyword02); -CREATE INDEX by_temporal_keyword_03 ON archetype_search_attributes (namespace_id, TemporalKeyword03); -CREATE INDEX by_temporal_keyword_04 ON archetype_search_attributes (namespace_id, TemporalKeyword04); -CREATE FULLTEXT INDEX by_temporal_text_01 ON archetype_search_attributes (TemporalText01); -CREATE FULLTEXT INDEX by_temporal_text_02 ON archetype_search_attributes (TemporalText02); -CREATE INDEX by_temporal_keyword_list_01 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList01 AS CHAR(255) ARRAY))); -CREATE INDEX by_temporal_keyword_list_02 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList02 AS CHAR(255) ARRAY))); diff --git a/schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql b/schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql deleted file mode 100644 index 49589433f3a..00000000000 --- a/schema/mysql/v8/visibility/versioned/v1.10/add_archetype_search_attributes.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE archetype_search_attributes ( - namespace_id CHAR(64) NOT NULL, - run_id CHAR(64) NOT NULL, - _version BIGINT NOT NULL DEFAULT 0, - search_attributes JSON NULL, - - -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool01"), - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->"$.TemporalBool02"), - TemporalDatetime01 DATETIME(6) GENERATED ALWAYS AS ( - CONVERT_TZ( - REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), - SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime01", 'Z', '+00:00'), -6, 6), - '+00:00' - ) - ), - TemporalDatetime02 DATETIME(6) GENERATED ALWAYS AS ( - CONVERT_TZ( - REGEXP_REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z|[+-][0-9]{2}:[0-9]{2}$', ''), - SUBSTR(REPLACE(search_attributes->>"$.TemporalDatetime02", 'Z', '+00:00'), -6, 6), - '+00:00' - ) - ), - TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble01"), - TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS (search_attributes->"$.TemporalDouble02"), - TemporalInt01 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt01"), - TemporalInt02 BIGINT GENERATED ALWAYS AS (search_attributes->"$.TemporalInt02"), - TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword01"), - TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword02"), - TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword03"), - TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>"$.TemporalKeyword04"), - TemporalText01 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText01") STORED, - TemporalText02 TEXT GENERATED ALWAYS AS (search_attributes->>"$.TemporalText02") STORED, - TemporalKeywordList01 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList01"), - TemporalKeywordList02 JSON GENERATED ALWAYS AS (search_attributes->"$.TemporalKeywordList02"), - - PRIMARY KEY (namespace_id, run_id) -); - -CREATE INDEX by_temporal_bool_01 ON archetype_search_attributes (namespace_id, TemporalBool01); -CREATE INDEX by_temporal_bool_02 ON archetype_search_attributes (namespace_id, TemporalBool02); -CREATE INDEX by_temporal_datetime_01 ON archetype_search_attributes (namespace_id, TemporalDatetime01); -CREATE INDEX by_temporal_datetime_02 ON archetype_search_attributes (namespace_id, TemporalDatetime02); -CREATE INDEX by_temporal_double_01 ON archetype_search_attributes (namespace_id, TemporalDouble01); -CREATE INDEX by_temporal_double_02 ON archetype_search_attributes (namespace_id, TemporalDouble02); -CREATE INDEX by_temporal_int_01 ON archetype_search_attributes (namespace_id, TemporalInt01); -CREATE INDEX by_temporal_int_02 ON archetype_search_attributes (namespace_id, TemporalInt02); -CREATE INDEX by_temporal_keyword_01 ON archetype_search_attributes (namespace_id, TemporalKeyword01); -CREATE INDEX by_temporal_keyword_02 ON archetype_search_attributes (namespace_id, TemporalKeyword02); -CREATE INDEX by_temporal_keyword_03 ON archetype_search_attributes (namespace_id, TemporalKeyword03); -CREATE INDEX by_temporal_keyword_04 ON archetype_search_attributes (namespace_id, TemporalKeyword04); -CREATE FULLTEXT INDEX by_temporal_text_01 ON archetype_search_attributes (TemporalText01); -CREATE FULLTEXT INDEX by_temporal_text_02 ON archetype_search_attributes (TemporalText02); -CREATE INDEX by_temporal_keyword_list_01 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList01 AS CHAR(255) ARRAY))); -CREATE INDEX by_temporal_keyword_list_02 ON archetype_search_attributes (namespace_id, (CAST(TemporalKeywordList02 AS CHAR(255) ARRAY))); diff --git a/schema/mysql/v8/visibility/versioned/v1.10/manifest.json b/schema/mysql/v8/visibility/versioned/v1.10/manifest.json deleted file mode 100644 index 289576a6016..00000000000 --- a/schema/mysql/v8/visibility/versioned/v1.10/manifest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "CurrVersion": "1.10", - "MinCompatibleVersion": "0.1", - "Description": "add archetype search attributes table and indices", - "SchemaUpdateCqlFiles": [ - "add_archetype_search_attributes.sql" - ] -} diff --git a/schema/postgresql/v12/version.go b/schema/postgresql/v12/version.go index 741e05bfb96..4dcdd8fdcd5 100644 --- a/schema/postgresql/v12/version.go +++ b/schema/postgresql/v12/version.go @@ -8,4 +8,4 @@ const Version = "1.18" // VisibilityVersion is the Postgres visibility database release version // Temporal supports both MySQL and Postgres officially, so upgrade should be performed for both MySQL and Postgres -const VisibilityVersion = "1.10" +const VisibilityVersion = "1.9" diff --git a/schema/postgresql/v12/visibility/schema.sql b/schema/postgresql/v12/visibility/schema.sql index 28fec4f2f99..166b1c056d6 100644 --- a/schema/postgresql/v12/visibility/schema.sql +++ b/schema/postgresql/v12/visibility/schema.sql @@ -79,24 +79,6 @@ CREATE TABLE executions_visibility ( KeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList02') STORED, KeywordList03 JSONB GENERATED ALWAYS AS (search_attributes->'KeywordList03') STORED, - -- Pre-allocated Archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool01') STORED, - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (search_attributes->'TemporalBool02') STORED, - TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, - TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, - TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, - TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, - TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, - TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, - TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, - TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, - TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, - TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, - TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, - TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, - TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, - TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, - PRIMARY KEY (namespace_id, run_id) ); @@ -158,21 +140,3 @@ CREATE INDEX by_text_03 ON executions_visibility USING GIN (namespace_id CREATE INDEX by_keyword_list_01 ON executions_visibility USING GIN (namespace_id, KeywordList01 jsonb_path_ops); CREATE INDEX by_keyword_list_02 ON executions_visibility USING GIN (namespace_id, KeywordList02 jsonb_path_ops); CREATE INDEX by_keyword_list_03 ON executions_visibility USING GIN (namespace_id, KeywordList03 jsonb_path_ops); - --- Indexes for the pre-allocated Archetype search attributes -CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_bool_02 ON executions_visibility (namespace_id, TemporalBool02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_datetime_01 ON executions_visibility (namespace_id, TemporalDatetime01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_datetime_02 ON executions_visibility (namespace_id, TemporalDatetime02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_double_01 ON executions_visibility (namespace_id, TemporalDouble01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_double_02 ON executions_visibility (namespace_id, TemporalDouble02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_int_01 ON executions_visibility (namespace_id, TemporalInt01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_int_02 ON executions_visibility (namespace_id, TemporalInt02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_01 ON executions_visibility (namespace_id, TemporalKeyword01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_02 ON executions_visibility (namespace_id, TemporalKeyword02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_03 ON executions_visibility (namespace_id, TemporalKeyword03, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_04 ON executions_visibility (namespace_id, TemporalKeyword04, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_text_01 ON executions_visibility USING GIN (namespace_id, TemporalText01); -CREATE INDEX by_temporal_text_02 ON executions_visibility USING GIN (namespace_id, TemporalText02); -CREATE INDEX by_temporal_keyword_list_01 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList01 jsonb_path_ops); -CREATE INDEX by_temporal_keyword_list_02 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList02 jsonb_path_ops); \ No newline at end of file diff --git a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql b/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql deleted file mode 100644 index 5b34b2a38c7..00000000000 --- a/schema/postgresql/v12/visibility/versioned/v1.10/add_archetype_search_attributes.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Pre-allocated archetype search attributes -ALTER TABLE executions_visibility - ADD COLUMN TemporalBool01 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool01')::boolean) STORED, - ADD COLUMN TemporalBool02 BOOLEAN GENERATED ALWAYS AS ((search_attributes->'TemporalBool02')::boolean) STORED, - ADD COLUMN TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime01')) STORED, - ADD COLUMN TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (convert_ts(search_attributes->>'TemporalDatetime02')) STORED, - ADD COLUMN TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble01')::decimal) STORED, - ADD COLUMN TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS ((search_attributes->'TemporalDouble02')::decimal) STORED, - ADD COLUMN TemporalInt01 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt01')::bigint) STORED, - ADD COLUMN TemporalInt02 BIGINT GENERATED ALWAYS AS ((search_attributes->'TemporalInt02')::bigint) STORED, - ADD COLUMN TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword01') STORED, - ADD COLUMN TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword02') STORED, - ADD COLUMN TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword03') STORED, - ADD COLUMN TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (search_attributes->>'TemporalKeyword04') STORED, - ADD COLUMN TemporalText01 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText01')::tsvector) STORED, - ADD COLUMN TemporalText02 TSVECTOR GENERATED ALWAYS AS ((search_attributes->>'TemporalText02')::tsvector) STORED, - ADD COLUMN TemporalKeywordList01 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList01') STORED, - ADD COLUMN TemporalKeywordList02 JSONB GENERATED ALWAYS AS (search_attributes->'TemporalKeywordList02') STORED, - --- Indexes for the pre-allocated Archetype search attributes -CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_bool_02 ON executions_visibility (namespace_id, TemporalBool02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_datetime_01 ON executions_visibility (namespace_id, TemporalDatetime01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_datetime_02 ON executions_visibility (namespace_id, TemporalDatetime02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_double_01 ON executions_visibility (namespace_id, TemporalDouble01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_double_02 ON executions_visibility (namespace_id, TemporalDouble02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_int_01 ON executions_visibility (namespace_id, TemporalInt01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_int_02 ON executions_visibility (namespace_id, TemporalInt02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_01 ON executions_visibility (namespace_id, TemporalKeyword01, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_02 ON executions_visibility (namespace_id, TemporalKeyword02, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_03 ON executions_visibility (namespace_id, TemporalKeyword03, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_04 ON executions_visibility (namespace_id, TemporalKeyword04, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_text_01 ON executions_visibility USING GIN (namespace_id, TemporalText01); -CREATE INDEX by_temporal_text_02 ON executions_visibility USING GIN (namespace_id, TemporalText02); -CREATE INDEX by_temporal_keyword_list_01 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList01 jsonb_path_ops); -CREATE INDEX by_temporal_keyword_list_02 ON executions_visibility USING GIN (namespace_id, TemporalKeywordList02 jsonb_path_ops); diff --git a/schema/postgresql/v12/visibility/versioned/v1.10/manifest.json b/schema/postgresql/v12/visibility/versioned/v1.10/manifest.json deleted file mode 100644 index e2a407dc71a..00000000000 --- a/schema/postgresql/v12/visibility/versioned/v1.10/manifest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "CurrVersion": "1.10", - "MinCompatibleVersion": "0.1", - "Description": "add archetype search attributes columns and indices", - "SchemaUpdateCqlFiles": [ - "add_archetype_search_attributes.sql" - ] -} diff --git a/schema/sqlite/v3/visibility/schema.sql b/schema/sqlite/v3/visibility/schema.sql index 2ee74fef35f..ff48c35ff6b 100644 --- a/schema/sqlite/v3/visibility/schema.sql +++ b/schema/sqlite/v3/visibility/schema.sql @@ -65,24 +65,6 @@ CREATE TABLE executions_visibility ( KeywordList02 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.KeywordList02")) STORED, KeywordList03 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.KeywordList03")) STORED, - -- Pre-allocated archetype search attributes - TemporalBool01 BOOLEAN GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalBool01")), - TemporalBool02 BOOLEAN GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalBool02")), - TemporalDatetime01 TIMESTAMP GENERATED ALWAYS AS (STRFTIME('%Y-%m-%d %H:%M:%f+00:00', JSON_EXTRACT(search_attributes, "$.TemporalDatetime01"))), - TemporalDatetime02 TIMESTAMP GENERATED ALWAYS AS (STRFTIME('%Y-%m-%d %H:%M:%f+00:00', JSON_EXTRACT(search_attributes, "$.TemporalDatetime02"))), - TemporalDouble01 DECIMAL(20, 5) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalDouble01")), - TemporalDouble02 DECIMAL(20, 5) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalDouble02")), - TemporalInt01 BIGINT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalInt01")), - TemporalInt02 BIGINT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalInt02")), - TemporalKeyword01 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword01")), - TemporalKeyword02 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword02")), - TemporalKeyword03 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword03")), - TemporalKeyword04 VARCHAR(255) GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeyword04")), - TemporalText01 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalText01")) STORED, - TemporalText02 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalText02")) STORED, - TemporalKeywordList01 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeywordList01")) STORED, - TemporalKeywordList02 TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalKeywordList02")) STORED, - PRIMARY KEY (namespace_id, run_id) ); @@ -136,26 +118,11 @@ CREATE INDEX by_keyword_08 ON executions_visibility (namespace_id, Keyword08, CREATE INDEX by_keyword_09 ON executions_visibility (namespace_id, Keyword09, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); CREATE INDEX by_keyword_10 ON executions_visibility (namespace_id, Keyword10, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); --- Indexes for the pre-allocated Archetype search attributes -CREATE INDEX by_temporal_bool_01 ON executions_visibility (namespace_id, TemporalBool01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_bool_02 ON executions_visibility (namespace_id, TemporalBool02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_datetime_01 ON executions_visibility (namespace_id, TemporalDatetime01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_datetime_02 ON executions_visibility (namespace_id, TemporalDatetime02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_double_01 ON executions_visibility (namespace_id, TemporalDouble01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_double_02 ON executions_visibility (namespace_id, TemporalDouble02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_int_01 ON executions_visibility (namespace_id, TemporalInt01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_int_02 ON executions_visibility (namespace_id, TemporalInt02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_01 ON executions_visibility (namespace_id, TemporalKeyword01, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_02 ON executions_visibility (namespace_id, TemporalKeyword02, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_03 ON executions_visibility (namespace_id, TemporalKeyword03, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); -CREATE INDEX by_temporal_keyword_04 ON executions_visibility (namespace_id, TemporalKeyword04, (COALESCE(close_time, '9999-12-31 23:59:59+00:00')) DESC, start_time DESC, run_id); CREATE VIRTUAL TABLE executions_visibility_fts_text USING fts5 ( Text01, Text02, Text03, - TemporalText01, - TemporalText02, content='executions_visibility', tokenize="unicode61 remove_diacritics 2" ); @@ -173,8 +140,6 @@ CREATE VIRTUAL TABLE executions_visibility_fts_keyword_list USING fts5 ( KeywordList01, KeywordList02, KeywordList03, - TemporalKeywordList01, - TemporalKeywordList02, content='executions_visibility', tokenize="unicode61 remove_diacritics 0 categories 'C* L* M* N* P* S* Z*' separators '♡'" ); @@ -186,16 +151,12 @@ BEGIN rowid, Text01, Text02, - Text03, - TemporalText01, - TemporalText02 + Text03 ) VALUES ( NEW.rowid, NEW.Text01, NEW.Text02, - NEW.Text03, - NEW.TemporalText01, - NEW.TemporalText02 + NEW.Text03 ); -- insert into fts_keyword_list table INSERT INTO executions_visibility_fts_keyword_list ( @@ -206,9 +167,7 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03, - TemporalKeywordList01, - TemporalKeywordList02 + KeywordList03 ) VALUES ( NEW.rowid, NEW.TemporalChangeVersion, @@ -217,9 +176,7 @@ BEGIN NEW.TemporalPauseInfo, NEW.KeywordList01, NEW.KeywordList02, - NEW.KeywordList03, - NEW.TemporalKeywordList01, - NEW.TemporalKeywordList02 + NEW.KeywordList03 ); END; @@ -231,17 +188,13 @@ BEGIN rowid, Text01, Text02, - Text03, - TemporalText01, - TemporalText02 + Text03 ) VALUES ( 'delete', OLD.rowid, OLD.Text01, OLD.Text02, - OLD.Text03, - OLD.TemporalText01, - OLD.TemporalText02 + OLD.Text03 ); -- delete from fts_keyword_list table INSERT INTO executions_visibility_fts_keyword_list ( @@ -253,9 +206,7 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03, - TemporalKeywordList01, - TemporalKeywordList02 + KeywordList03 ) VALUES ( 'delete', OLD.rowid, @@ -265,9 +216,7 @@ BEGIN OLD.TemporalPauseInfo, OLD.KeywordList01, OLD.KeywordList02, - OLD.KeywordList03, - OLD.TemporalKeywordList01, - OLD.TemporalKeywordList02 + OLD.KeywordList03 ); END; @@ -279,32 +228,24 @@ BEGIN rowid, Text01, Text02, - Text03, - TemporalText01, - TemporalText02 + Text03 ) VALUES ( 'delete', OLD.rowid, OLD.Text01, OLD.Text02, - OLD.Text03, - OLD.TemporalText01, - OLD.TemporalText02 + OLD.Text03 ); INSERT INTO executions_visibility_fts_text ( rowid, Text01, Text02, - Text03, - TemporalText01, - TemporalText02 + Text03 ) VALUES ( NEW.rowid, NEW.Text01, NEW.Text02, - NEW.Text03, - NEW.TemporalText01, - NEW.TemporalText02 + NEW.Text03 ); -- update fts_keyword_list table INSERT INTO executions_visibility_fts_keyword_list ( @@ -316,9 +257,7 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03, - TemporalKeywordList01, - TemporalKeywordList02 + KeywordList03 ) VALUES ( 'delete', OLD.rowid, @@ -328,9 +267,7 @@ BEGIN OLD.TemporalPauseInfo, OLD.KeywordList01, OLD.KeywordList02, - OLD.KeywordList03, - OLD.TemporalKeywordList01, - OLD.TemporalKeywordList02 + OLD.KeywordList03 ); INSERT INTO executions_visibility_fts_keyword_list ( rowid, @@ -340,9 +277,7 @@ BEGIN TemporalPauseInfo, KeywordList01, KeywordList02, - KeywordList03, - TemporalKeywordList01, - TemporalKeywordList02 + KeywordList03 ) VALUES ( NEW.rowid, NEW.TemporalChangeVersion, @@ -351,8 +286,6 @@ BEGIN NEW.TemporalPauseInfo, NEW.KeywordList01, NEW.KeywordList02, - NEW.KeywordList03, - NEW.TemporalKeywordList01, - NEW.TemporalKeywordList02 + NEW.KeywordList03 ); END; From b4650a1727c73c3c5db8ca499991777a091a5940 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 30 Sep 2025 16:02:13 -0400 Subject: [PATCH 11/11] Update proto files --- api/persistence/v1/cluster_metadata.pb.go | 35 ++++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/api/persistence/v1/cluster_metadata.pb.go b/api/persistence/v1/cluster_metadata.pb.go index 78ac72b8f6f..06b05df9726 100644 --- a/api/persistence/v1/cluster_metadata.pb.go +++ b/api/persistence/v1/cluster_metadata.pb.go @@ -243,11 +243,15 @@ const file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDesc = " "\x05value\x18\x02 \x01(\v29.temporal.server.api.persistence.v1.IndexSearchAttributesR\x05value:\x028\x01\x1a7\n" + "\tTagsEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x9d\x02\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xaf\x04\n" + "\x15IndexSearchAttributes\x12\x8f\x01\n" + - "\x18custom_search_attributes\x18\x01 \x03(\v2U.temporal.server.api.persistence.v1.IndexSearchAttributes.CustomSearchAttributesEntryR\x16customSearchAttributes\x1ar\n" + + "\x18custom_search_attributes\x18\x01 \x03(\v2U.temporal.server.api.persistence.v1.IndexSearchAttributes.CustomSearchAttributesEntryR\x16customSearchAttributes\x12\x98\x01\n" + + "\x1barchetype_search_attributes\x18\x02 \x03(\v2X.temporal.server.api.persistence.v1.IndexSearchAttributes.ArchetypeSearchAttributesEntryR\x19archetypeSearchAttributes\x1ar\n" + "\x1bCustomSearchAttributesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12=\n" + + "\x05value\x18\x02 \x01(\x0e2'.temporal.api.enums.v1.IndexedValueTypeR\x05value:\x028\x01\x1au\n" + + "\x1eArchetypeSearchAttributesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12=\n" + "\x05value\x18\x02 \x01(\x0e2'.temporal.api.enums.v1.IndexedValueTypeR\x05value:\x028\x01B6Z4go.temporal.io/server/api/persistence/v1;persistenceb\x06proto3" var ( @@ -262,28 +266,31 @@ func file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDescGZIP( return file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDescData } -var file_temporal_server_api_persistence_v1_cluster_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_temporal_server_api_persistence_v1_cluster_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_temporal_server_api_persistence_v1_cluster_metadata_proto_goTypes = []any{ (*ClusterMetadata)(nil), // 0: temporal.server.api.persistence.v1.ClusterMetadata (*IndexSearchAttributes)(nil), // 1: temporal.server.api.persistence.v1.IndexSearchAttributes nil, // 2: temporal.server.api.persistence.v1.ClusterMetadata.IndexSearchAttributesEntry nil, // 3: temporal.server.api.persistence.v1.ClusterMetadata.TagsEntry nil, // 4: temporal.server.api.persistence.v1.IndexSearchAttributes.CustomSearchAttributesEntry - (*v1.VersionInfo)(nil), // 5: temporal.api.version.v1.VersionInfo - (v11.IndexedValueType)(0), // 6: temporal.api.enums.v1.IndexedValueType + nil, // 5: temporal.server.api.persistence.v1.IndexSearchAttributes.ArchetypeSearchAttributesEntry + (*v1.VersionInfo)(nil), // 6: temporal.api.version.v1.VersionInfo + (v11.IndexedValueType)(0), // 7: temporal.api.enums.v1.IndexedValueType } var file_temporal_server_api_persistence_v1_cluster_metadata_proto_depIdxs = []int32{ - 5, // 0: temporal.server.api.persistence.v1.ClusterMetadata.version_info:type_name -> temporal.api.version.v1.VersionInfo + 6, // 0: temporal.server.api.persistence.v1.ClusterMetadata.version_info:type_name -> temporal.api.version.v1.VersionInfo 2, // 1: temporal.server.api.persistence.v1.ClusterMetadata.index_search_attributes:type_name -> temporal.server.api.persistence.v1.ClusterMetadata.IndexSearchAttributesEntry 3, // 2: temporal.server.api.persistence.v1.ClusterMetadata.tags:type_name -> temporal.server.api.persistence.v1.ClusterMetadata.TagsEntry 4, // 3: temporal.server.api.persistence.v1.IndexSearchAttributes.custom_search_attributes:type_name -> temporal.server.api.persistence.v1.IndexSearchAttributes.CustomSearchAttributesEntry - 1, // 4: temporal.server.api.persistence.v1.ClusterMetadata.IndexSearchAttributesEntry.value:type_name -> temporal.server.api.persistence.v1.IndexSearchAttributes - 6, // 5: temporal.server.api.persistence.v1.IndexSearchAttributes.CustomSearchAttributesEntry.value:type_name -> temporal.api.enums.v1.IndexedValueType - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 5, // 4: temporal.server.api.persistence.v1.IndexSearchAttributes.archetype_search_attributes:type_name -> temporal.server.api.persistence.v1.IndexSearchAttributes.ArchetypeSearchAttributesEntry + 1, // 5: temporal.server.api.persistence.v1.ClusterMetadata.IndexSearchAttributesEntry.value:type_name -> temporal.server.api.persistence.v1.IndexSearchAttributes + 7, // 6: temporal.server.api.persistence.v1.IndexSearchAttributes.CustomSearchAttributesEntry.value:type_name -> temporal.api.enums.v1.IndexedValueType + 7, // 7: temporal.server.api.persistence.v1.IndexSearchAttributes.ArchetypeSearchAttributesEntry.value:type_name -> temporal.api.enums.v1.IndexedValueType + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_temporal_server_api_persistence_v1_cluster_metadata_proto_init() } @@ -297,7 +304,7 @@ func file_temporal_server_api_persistence_v1_cluster_metadata_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDesc), len(file_temporal_server_api_persistence_v1_cluster_metadata_proto_rawDesc)), NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, },