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

Generated FindFooByBar doesn't work well with null-filtered indices on spanner emulator #99

Open
JohnTitor opened this issue Jun 15, 2022 · 0 comments

Comments

@JohnTitor
Copy link
Contributor

Consider the following schema:

CREATE TABLE User (
  Foo STRING(MAX) NOT NULL,
  Bar STRING(MAX),
) PRIMARY KEY(Foo);

CREATE UNIQUE NULL_FILTERED INDEX User_Bar_index ON User(Bar);

Yo will generate a FindUserByBar fn looking at its unique index. But if we run tests against that fn on spanner emu, it will fail because of this:

absl::Status NullFilteredIndexUnusable(absl::string_view index_name) {
  return absl::Status(
      absl::StatusCode::kInvalidArgument,
      absl::Substitute(
          "The emulator is not able to determine whether the "
          "null filtered index $0 can be used to answer this query as it "
          "may filter out nulls that may be required to answer the query. "
          "Please test this query against Cloud Spanner. If you confirm "
          "against Cloud Spanner that the null filtered index can be used to "
          "answer the query, set the hint @{spanner_emulator."
          "disable_query_null_filtered_index_check=true} on the table "
          "to bypass this check in the emulator. This hint will be ignored by "
          "the production Cloud Spanner service and the emulator will accept "
          "the query and return a valid result when it is run with the check "
          "disabled.",
          index_name));
}

https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/blob/4bc1ce05ee511713318e991fbd076b884ea404cc/common/errors.cc#L1788-L1804

A simple way to make it work would be passing spanner_emulator.disable_query_null_filtered_index_check=true to the emu but AFAIK there's no option on yo to do that. Maybe custom template would be a workaround here but It'd be great if upstream has a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant