cockroachdb / cockroachdb/cockroach

enforce_home_region mode mistakenly errors out a two lookup join query

Open
#107,153 0 comments 0 reactions 0 assignees View on GitHub
C-bug T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

This issue was found during testing of #106334.
The following test case in test file `regional_by_row_query_behavior` can now execute in the local home region, but it is erroring out statically because `Optimizer.stateMap` is empty in the execbuilder phase. This issue is opened to make this query not error out statically when `enforce_home_region` is true, and allow `Optimizer.GetLookupJoinLookupTableDistribution` to function properly in the execbuilder:

```
# This query should error out dynamically during execution, but
# `Optimizer.GetLookupJoinLookupTableDistribution` doesn't currently work in
# the execbuilder phase because `Optimizer.stateMap` is empty.
# TODO(msirek): Fix this test case to not error out statically.
statement error pq: Query has no home region\. Try adding a filter on o\.crdb_region and/or on key column \(o\.cust_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
SELECT 'a' FROM customers c JOIN orders o ON c.id = o.cust_id AND
(c.crdb_region = o.crdb_region) WHERE c.id = '69a1c2c2-5b18-459e-94d2-079dc53a4dd0'
```

Jira issue: CRDB-29917

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.