Skip to content

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

@JohnTitor

Description

@JohnTitor

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions