Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion google/cloud/bigtable/row_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,18 @@ def to_pb(self):


class ExactValueFilter(ValueRegexFilter):
"""Row filter for an exact value.
"""Row filter for an exact integer value.


:type value: bytes or str or int
:param value:
a literal string encodable as ASCII, or the
equivalent bytes, or an integer (which will be packed into 8-bytes).

When passing non-integer ``value``, it must be valid RE2 patterns. See Google's
`RE2 reference`_ for the accepted syntax.

.. _RE2 reference: https://github.com/google/re2/wiki/Syntax
Comment on lines +471 to +474
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. I think the value needs to be properly escaped. ie if I pass the number 46 (ascii for .), it will match every single byte value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke offline, the current behavior is very surprising and not very useful. In case users using the current behavior, we can't change it.

Instead I propose that we add a new LiteralValueFilter that

  1. for ints converts them into bytestrings using the current logic
  2. for strs converts them to bytestrings
  3. accepts bytestrings as is
  4. once everything is normalized to a bytestring, iterate over the bytes and properly escape the bytes to encure they don't get interpreted as control characters. Example: https://github.com/googleapis/java-bigtable/blob/main/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RegexUtil.java#L53-L81
  5. Deprecate ExactValueFilter and encourage people to migrate to the new filter
  6. Next major version drop ExactValueFilter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a LiteralValueFilter implementation PR for the v3 branch: #767 (review)

"""

def __init__(self, value):
Expand Down