Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.1.20-rc: opt: add GenerateTrigramSimilarityInvertedIndexScans rule #122683

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,10 @@ func (m *sessionDataMutator) SetOptimizerUseProvidedOrderingFix(val bool) {
m.data.OptimizerUseProvidedOrderingFix = val
}

func (m *sessionDataMutator) SetOptimizerUseTrigramSimilarityOptimization(val bool) {
m.data.OptimizerUseTrigramSimilarityOptimization = val
}

// Utility functions related to scrubbing sensitive information on SQL Stats.

// quantizeCounts ensures that the Count field in the
Expand Down
7 changes: 4 additions & 3 deletions pkg/sql/logictest/testdata/logic_test/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -4612,19 +4612,19 @@ statement ok
CREATE SEQUENCE test_seq_3 AS smallint

statement ok
CREATE SEQUENCE test_seq_4 AS integer
CREATE SEQUENCE test_seq_4 AS integer

statement ok
CREATE SEQUENCE test_seq_5 AS bigint

statement ok
CREATE SEQUENCE test_seq_6 AS INT2
CREATE SEQUENCE test_seq_6 AS INT2

statement ok
CREATE SEQUENCE test_seq_7 AS INT4

statement ok
CREATE SEQUENCE test_seq_8 AS INT8
CREATE SEQUENCE test_seq_8 AS INT8

query TTTTIIITTTTT colnames
SELECT * FROM information_schema.sequences
Expand Down Expand Up @@ -5345,6 +5345,7 @@ optimizer_use_limit_ordering_for_streaming_group_by on
optimizer_use_multicol_stats on
optimizer_use_not_visible_indexes off
optimizer_use_provided_ordering_fix on
optimizer_use_trigram_similarity_optimization off
override_multi_region_zone_config off
parallelize_multi_key_lookup_joins_enabled off
password_encryption scram-sha-256
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -2830,6 +2830,7 @@ optimizer_use_limit_ordering_for_streaming_group_by on N
optimizer_use_multicol_stats on NULL NULL NULL string
optimizer_use_not_visible_indexes off NULL NULL NULL string
optimizer_use_provided_ordering_fix on NULL NULL NULL string
optimizer_use_trigram_similarity_optimization off NULL NULL NULL string
override_multi_region_zone_config off NULL NULL NULL string
parallelize_multi_key_lookup_joins_enabled off NULL NULL NULL string
password_encryption scram-sha-256 NULL NULL NULL string
Expand Down Expand Up @@ -2992,6 +2993,7 @@ optimizer_use_limit_ordering_for_streaming_group_by on N
optimizer_use_multicol_stats on NULL user NULL on on
optimizer_use_not_visible_indexes off NULL user NULL off off
optimizer_use_provided_ordering_fix on NULL user NULL on on
optimizer_use_trigram_similarity_optimization off NULL user NULL off off
override_multi_region_zone_config off NULL user NULL off off
parallelize_multi_key_lookup_joins_enabled off NULL user NULL false false
password_encryption scram-sha-256 NULL user NULL scram-sha-256 scram-sha-256
Expand Down Expand Up @@ -3153,6 +3155,7 @@ optimizer_use_limit_ordering_for_streaming_group_by NULL NULL NULL
optimizer_use_multicol_stats NULL NULL NULL NULL NULL
optimizer_use_not_visible_indexes NULL NULL NULL NULL NULL
optimizer_use_provided_ordering_fix NULL NULL NULL NULL NULL
optimizer_use_trigram_similarity_optimization NULL NULL NULL NULL NULL
override_multi_region_zone_config NULL NULL NULL NULL NULL
parallelize_multi_key_lookup_joins_enabled NULL NULL NULL NULL NULL
password_encryption NULL NULL NULL NULL NULL
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ optimizer_use_limit_ordering_for_streaming_group_by on
optimizer_use_multicol_stats on
optimizer_use_not_visible_indexes off
optimizer_use_provided_ordering_fix on
optimizer_use_trigram_similarity_optimization off
override_multi_region_zone_config off
parallelize_multi_key_lookup_joins_enabled off
password_encryption scram-sha-256
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt/exec/execbuilder/relational.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,12 @@ func (b *Builder) buildScan(scan *memo.ScanExpr) (execPlan, error) {
}
}

if scan.Flags.ForceInvertedIndex && !scan.IsInvertedScan() {
if scan.Flags.ForceInvertedIndex && !scan.IsInvertedScan(md) {
return execPlan{}, fmt.Errorf("could not produce a query plan conforming to the FORCE_INVERTED_INDEX hint")
}

idx := tab.Index(scan.Index)
if idx.IsInverted() && len(scan.InvertedConstraint) == 0 {
if idx.IsInverted() && len(scan.InvertedConstraint) == 0 && scan.Constraint == nil {
return execPlan{},
errors.AssertionFailedf("expected inverted index scan to have an inverted constraint")
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/opt/invertedidx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ go_library(
"//pkg/sql/types",
"//pkg/util/encoding",
"//pkg/util/json",
"//pkg/util/trigram",
"@com_github_cockroachdb_errors//:errors",
"@com_github_golang_geo//r1",
"@com_github_golang_geo//s1",
Expand All @@ -47,13 +48,14 @@ go_test(
size = "small",
srcs = [
"geo_test.go",
"inverted_index_expr_test.go",
"json_array_test.go",
"trigram_test.go",
"tsearch_test.go",
],
args = ["-test.timeout=55s"],
embed = [":invertedidx"],
deps = [
":invertedidx",
"//pkg/geo",
"//pkg/geo/geoindex",
"//pkg/geo/geopb",
Expand Down