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

Spanner Emulator固有hint #148

Open
sinmetal opened this issue Sep 4, 2022 · 1 comment
Open

Spanner Emulator固有hint #148

sinmetal opened this issue Sep 4, 2022 · 1 comment

Comments

@sinmetal
Copy link
Member

sinmetal commented Sep 4, 2022

https://github.com/GoogleCloudPlatform/cloud-spanner-emulator には固有のhintが存在する
どこかにdocumentがあるのかもしれないが、よく分からなかったので、メモしておく

@sinmetal
Copy link
Member Author

sinmetal commented Sep 4, 2022

spanner_emulator.disable_query_null_filtered_index_check

spanner emulatorで NULL_FILTERED INDEX に対してFORCE_INDEXでQueryを実行すると以下のように言われる。
(FORCE_INDEXじゃなくても言われることがあるのかもしれない)

The emulator is not able to determine whether the null filtered index SampleByNameNoNulls 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.

言われたとおりに spanner_emulator.disable_query_null_filtered_index_check=true を入れると動く

Sample Schema and Query

gcloud spanner databases ddl update sinmetal --instance test-instance --ddl='CREATE TABLE Sample (
  Id INT64 NOT NULL,
  Name STRING(255),
) PRIMARY KEY(Id);
CREATE NULL_FILTERED INDEX SampleByNameNoNulls
ON Sample (
    Name
);

gcloud spanner databases execute-sql sinmetal --instance test-instance --sql='SELECT Id,Name FROM Sample@{FORCE_INDEX=SampleByNameNoNulls,spanner_emulator.disable_query_null_filtered_index_check=true} WHERE Name = "hoge" LIMIT 1'

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