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

Cloud Bigtable: CheckAndMutateRow : ExactValueFilter #567

Open
sumith-tempus opened this issue Apr 13, 2022 · 2 comments
Open

Cloud Bigtable: CheckAndMutateRow : ExactValueFilter #567

sumith-tempus opened this issue Apr 13, 2022 · 2 comments
Labels
api: bigtable Issues related to the googleapis/python-bigtable API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@sumith-tempus
Copy link

sumith-tempus commented Apr 13, 2022

Steps to reproduce

  1. Run the given code example to re-produce the error

ExactValueFilter is a subclass of ValueRegexFilter but I think I believe it should not care about when the filter is ExactValueFilter. I am not quite confident whether this is an issue or a feature request.

I am trying to understand, Is there a way to do CheckAndMutateRow for the column value(update if and only if the value is changed)

Code example

client = bigtable.Client()
instance = client.instance("instance-name")
table_id = "table-name"
table = instance.table(table_id)
row_key = "row_key_1"
col_name = "col_name1"
cell_val = "test(value.pdf"
col1_filter = row_filters.ColumnQualifierRegexFilter(col_name)
label1_filter = row_filters.ExactValueFilter(cell_val)
chain1 = row_filters.RowFilterChain(filters=[col1_filter, label1_filter])

row_obj = table.conditional_row(row_key, filter_=chain1)
row_obj.set_cell("test_family_1", col_name, cell_val, state=False)
row_obj.commit()

Stack trace

/var/folders/t7/znmnfd3x2191zm8hybnnt5fx8zypkn/T/ipykernel_49224/1449758387.py in <module>
----> 1 row_obj.commit()

/usr/local/lib/python3.9/site-packages/google/cloud/bigtable/row.py in commit(self)
    590 
    591         data_client = self._table._instance._client.table_data_client
--> 592         resp = data_client.check_and_mutate_row(
    593             table_name=self._table.name,
    594             row_key=self._row_key,

/usr/local/lib/python3.9/site-packages/google/cloud/bigtable_v2/services/bigtable/client.py in check_and_mutate_row(self, request, table_name, row_key, predicate_filter, true_mutations, false_mutations, app_profile_id, retry, timeout, metadata)
    999 
   1000         # Send the request.
-> 1001         response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
   1002 
   1003         # Done; return the response.

/usr/local/lib/python3.9/site-packages/google/api_core/gapic_v1/method.py in __call__(self, *args, **kwargs)
    143             kwargs["metadata"] = metadata
    144 
--> 145         return wrapped_func(*args, **kwargs)
    146 
    147 

/usr/local/lib/python3.9/site-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     67             return callable_(*args, **kwargs)
     68         except grpc.RpcError as exc:
---> 69             six.raise_from(exceptions.from_grpc_error(exc), exc)
     70 
     71     return error_remapped_callable

/usr/local/lib/python3.9/site-packages/six.py in raise_from(value, from_value)

InvalidArgument: 400 Error in chained row filter #1 : Error in field 'value_regex_filter' : Invalid RE2 regular expression 'test(value.pdf': missing ): test(value.pdf

Happy to Provide more information if needed

@product-auto-label product-auto-label bot added the api: bigtable Issues related to the googleapis/python-bigtable API. label Apr 13, 2022
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 13, 2022
@Mariatta Mariatta added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Aug 4, 2022
@Mariatta
Copy link
Contributor

Mariatta commented Aug 4, 2022

This might have been due to poor documentation about the ExactValueFilter. As you found out, indeed it derives from the ValueRegexFilter, so it expects a valid regex still. You can escape the ( in the value:

cell_val = "test\(value.pdf"
label1_filter = row_filters.ExactValueFilter(cell_val)

should do it.
Alternatively, can you try using the ValueRangeFilter ?

cell_val = "test(value.pdf"
row_filters.ValueRangeFilter(start_value=cell_val, end_value=cell_val)

@igorbernstein2
Copy link
Contributor

ExactValueFilter seems to have very broken semantics. I dont think we can fix it in place (in case other customers depend on the broken behavior). Instead we will provide a new filter with correct semantics:
#620 (comment)

@Mariatta Mariatta added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/python-bigtable API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants