Repository: ibis-project/ibis

Issue:
bug(bigquery): failing tests in regex methods on HEAD
### What happened?

I think I merged #6950 a little too quickly. The following tests are failing:

```
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_group_at_end] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_group_2] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_whole_group] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_search_substring] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_group] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_group_at_beginning] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_group_3] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_replace] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_extract_group_1] - AssertionError: Series are different
FAILED ibis/backends/tests/test_string.py::test_string[bigquery-re_search] - AssertionError: Series are different
```

Note: this is likely due to the extra "raw string" identified in https://github.com/ibis-project/ibis-bigquery/issues/110 which I believe was masking https://github.com/ibis-project/ibis/issues/6949.

### What version of ibis are you using?

master branch

### What backend(s) are you using, if any?

bigquery

### Relevant log output

```sh
...
            ),
            param(
                lambda t: t.date_string_col[-2],
                lambda t: t.date_string_col.str[-2],
                id="negative-index",
                marks=[
                    pytest.mark.broken(["druid"], raises=sa.exc.ProgrammingError),
                    pytest.mark.broken(["datafusion", "impala"], raises=AssertionError),
                    pytest.mark.notimpl(["pyspark"], raises=NotImplementedError),
                ],
            ),
            param(
                lambda t: t.date_string_col[t.date_string_col.length() - 1 :],
                lambda t: t.date_string_col.str[-1:],
                id="expr_slice_begin",
                # TODO: substring #2553
                marks=[
                    pytest.mark.notimpl(
                        ["pyspark"],
                        raises=NotImplementedError,
                        reason=(
                            "Specifying `start` or `length` with column expressions is not supported."
                        ),
                    ),
                    pytest.mark.notimpl(
                        ["polars"],
                        raises=com.UnsupportedArgumentError,
                        reason=(
                            "Polars does not support columnar argument Subtract(StringLength(date_string_col), 1)"
                        ),
                    ),
                    pytest.mark.broken(
                        ["dask"],
                        reason="'Series' object has no attribute 'items'",
                        raises=AttributeError,
                    ),
                    pytest.mark.broken(["druid"], raises=sa.exc.ProgrammingError),
                ],
            ),
            param(
                lambda t: t.date_string_col[: t.date_string_col.length()],
                lambda t: t.date_string_col,
                id="expr_slice_end",
                # TODO: substring #2553
                marks=[
                    pytest.mark.notimpl(
                        ["pyspark"],
                        raises=NotImplementedError,
                        reason=(
                            "Specifying `start` or `length` with column expressions is not supported."
                        ),
                    ),
                    pytest.mark.notimpl(
                        ["polars"],
                        raises=com.UnsupportedArgumentError,
                        reason=(
                            "Polars does not support columnar argument Subtract(StringLength(date_string_col), 1)"
                        ),
                    ),
                    pytest.mark.broken(
                        ["dask"],
                        reason="'Series' object has no attribute 'items'",
                        raises=AttributeError,
                    ),
                    pytest.mark.broken(["druid"], raises=sa.exc.ProgrammingError),
                ],
            ),
            param(
                lambda t: t.date_string_col[:],
                lambda t: t.date_string_col,
                id="expr_empty_slice",
                # TODO: substring #2553
                marks=[
                    pytest.mark.notimpl(
                        ["pyspark"],
                        raises=NotImplementedError,
                        reason=(
                            "Specifying `start` or `length` with column expressions is not supported."
                        ),
                    ),
                    pytest.mark.notimpl(
                        ["polars"],
                        raises=com.UnsupportedArgumentError,
                        reason=(
                            "Polars does not support columnar argument "
                            "Subtract(StringLength(date_string_col), 0)"
                        ),
                    ),
                    pytest.mark.broken(
                        ["dask"],
                        reason="'Series' object has no attribute 'items'",
                        raises=AttributeError,
                    ),
                    pytest.mark.broken(["druid"], raises=sa.exc.ProgrammingError),
                ],
            ),
            param(
                lambda t: t.date_string_col[
                    t.date_string_col.length() - 2 : t.date_string_col.length() - 1
                ],
                lambda t: t.date_string_col.str[-2:-1],
                id="expr_slice_begin_end",
                # TODO: substring #2553
                marks=[
                    pytest.mark.notimpl(
                        ["pyspark"],
                        raises=NotImplementedError,
                        reason=(
                            "Specifying `start` or `length` with column expressions is not supported."
                        ),
                    ),
                    pytest.mark.notimpl(
                        ["polars"],
                        raises=com.UnsupportedArgumentError,
                        reason=(
                            "Polars does not support columnar argument Subtract(StringLength(date_string_col), 1)"
                        ),
                    ),
                    pytest.mark.broken(
                        ["dask"],
                        reason="'Series' object has no attribute 'items'",
                        raises=AttributeError,
                    ),
                    pytest.mark.broken(["druid"], raises=sa.exc.ProgrammingError),
                ],
            ),
            param(
                lambda t: t.date_string_col.split("/"),
                lambda t: t.date_string_col.str.split("/"),
                id="split",
                marks=pytest.mark.notimpl(
                    [
                        "dask",
                        "datafusion",
                        "impala",
                        "mysql",
                        "sqlite",
                        "mssql",
                        "druid",
                        "oracle",
                    ],
                    raises=com.OperationNotDefinedError,
                ),
            ),
            param(
                lambda t: ibis.literal("-").join(["a", t.string_col, "c"]),
                lambda t: "a-" + t.string_col + "-c",
                id="join",
            ),
            param(
                lambda t: t.string_col + t.date_string_col,
                lambda t: t.string_col + t.date_string_col,
                id="concat_columns",
            ),
            param(
                lambda t: t.string_col + "a",
                lambda t: t.string_col + "a",
                id="concat_column_scalar",
            ),
            param(
                lambda t: "a" + t.string_col,
                lambda t: "a" + t.string_col,
                id="concat_scalar_column",
            ),
            param(
                lambda t: t.string_col.replace("1", "42"),
                lambda t: t.string_col.str.replace("1", "42"),
                id="replace",
            ),
        ],
    )
    def test_string(backend, alltypes, df, result_func, expected_func):
        expr = result_func(alltypes).name("tmp")
        result = expr.execute()
    
        expected = backend.default_series_rename(expected_func(df))
>       backend.assert_series_equal(result, expected)

ibis/backends/tests/test_string.py:841: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ibis/backends/tests/base.py:58: in assert_series_equal
    return super().assert_series_equal(left, right, *args, **kwargs)
ibis/backends/tests/base.py:181: in assert_series_equal
    tm.assert_series_equal(left, right, *args, **kwargs)
pandas/_libs/testing.pyx:52: in pandas._libs.testing.assert_almost_equal
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   AssertionError: Series are different
E   
E   Series values are different (100.0 %)
E   [index]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...]
E   [left]:  [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, ...]
E   [right]: [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, ...]
E   At positional index 0, first diff: False != True

pandas/_libs/testing.pyx:172: AssertionError
```


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct


Discussion:

Resolving patch:
diff --git a/ibis/backends/bigquery/registry.py b/ibis/backends/bigquery/registry.py
--- a/ibis/backends/bigquery/registry.py
+++ b/ibis/backends/bigquery/registry.py
@@ -243,20 +243,15 @@ def _string_find(translator, op):
     )
 
 
-def _translate_pattern(translator, op):
-    # add 'r' to string literals to indicate to BigQuery this is a raw string
-    return "r" * isinstance(op, ops.Literal) + translator.translate(op)
-
-
 def _regex_search(translator, op):
     arg = translator.translate(op.arg)
-    regex = _translate_pattern(translator, op.pattern)
+    regex = translator.translate(op.pattern)
     return f"REGEXP_CONTAINS({arg}, {regex})"
 
 
 def _regex_extract(translator, op):
     arg = translator.translate(op.arg)
-    regex = _translate_pattern(translator, op.pattern)
+    regex = translator.translate(op.pattern)
     index = translator.translate(op.index)
     matches = f"REGEXP_CONTAINS({arg}, {regex})"
     # non-greedily match the regex's prefix so the regex can match as much as possible
@@ -272,7 +267,7 @@ def _regex_extract(translator, op):
 
 def _regex_replace(translator, op):
     arg = translator.translate(op.arg)
-    regex = _translate_pattern(translator, op.pattern)
+    regex = translator.translate(op.pattern)
     replacement = translator.translate(op.replacement)
     return f"REGEXP_REPLACE({arg}, {regex}, {replacement})"
 


Test patch: