Created
November 16, 2021 16:19
-
-
Save depesz/39096aef34b88e03bc83c829aed1f742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHARD_REGEXP = %r{("?)(canvas|cluster\d+(?:_shard_\d+)?)\1\.}.freeze | |
query = 'select * from "cluster123_shard_3".xx join cluster123_shard_3.yy on a = b' | |
counts = Hash.new(0) | |
n_query = query.gsub(SHARD_REGEXP) do | s | counts[s]+=1; "SOME_SHARD."; end | |
# At the end counts is: | |
# {"\"cluster123_shard_3\"."=>1, "cluster123_shard_3."=>1} | |
# And I'd like it to be: | |
# {"cluster123_shard_3"=>2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment