Use filters
Bigtable provides the following types of filters:
- Limiting filters, which control which rows or cells are included in the response.
- Modifying filters, which affect the data or metadata for individual cells.
- Composing filters, which allow you to combine multiple filters into one.
This page describes each Bigtable filter in detail and shows how to use each type of filter using the Cloud Client Libraries. Before you read this page, read Filters.
Additional samples showing how to use filters to read multiple rows of data are available on Reading data.
Data for examples
The examples on this page assume that you're storing time-series data for
smartphones and tablets, and that the following data has been written to a
table. The table has two column families, stats_summary and cell_plan.
Each column family has three columns.
| stats_summary | cell_plan | |||||
|---|---|---|---|---|---|---|
| row key | connected_cell | connected_wifi | os_build | data_plan_01gb | data_plan_05gb | data_plan_10gb |
| phone#4c410523#20190501 | 1 | 1 | PQ2A.190405.003 | true@time minus one hour false@time |
true | |
| phone#4c410523#20190502 | 1 | 1 | PQ2A.190405.004 | true | ||
| phone#4c410523#20190505 | 0 | 1 | PQ2A.190406.000 | true | ||
| phone#5c10102#20190501 | 1 | 1 | PQ2A.190401.002 | true | ||
| phone#5c10102#20190502 | 1 | 0 | PQ2A.190406.000 | true |
Limiting filters
The following sections describe each limiting filter. Limiting filters control which rows or cells are included in the response, based on whether they match specific criteria.
When you use a chain to combine multiple limiting filters, keep in mind that the input row for each filter in the chain is the output row from the previous filter in the chain. For example, if you chain two filters, and the first filter outputs only two of the cells from the original row, the second filter sees only those two cells.
Row selection filters
This section describes the filters that you can use to retrieve rows in a table.
Row sample
This filter lets you retrieve a random sample of rows within a given range. Based on a probability that you specify, the filter chooses at random whether the output row should be the same as the input row or whether it should be omitted from the results.
For example, if your table has millions of phone records and you want to inspect a representative subset without reading every row, you can use a row sample filter.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Row key regex
This filter checks whether the input row's row key matches a regular expression.
The regular expression must use RE2 syntax. Because row keys can
contain arbitrary bytes, use \C as the wildcard expression instead of the .
expression to match any character, including newlines.
To improve performance, Bigtable attempts to optimize the filter by extracting a literal prefix from the start of the regular expression. If a prefix is identified, Bigtable narrows its search to the key range that begins with that prefix, avoiding a full table scan.
This optimization only occurs under the following conditions:
- The prefix can only contain alphanumeric characters and the following
unescaped symbols:
-,_,:,,. - The prefix extraction stops at the first unescaped character that is not in
the allowed set. For example, common key separators such as a hash (
#) or regular expression metacharacters, such as an unescaped period (.), stop the extraction. To include special characters in the optimized prefix, escape them with a backslash (\) or use RE2 client library functions such asRE2.quoteMetain Java. - A pipe character (
|) is not supported.
If your regular expression can't be resolved to a literal prefix—for example, if it begins with a wildcard or searches for a substring, Bigtable requires a full table scan.
The following code samples use the regular expression .*#20190501$ to
retrieve phone records from May 1, 2019, across all devices. When applied to
the example dataset, this filter returns all cells for the two
matching rows: phone#4c410523#20190501 and phone#5c10102#20190501.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Cell selection filters
This section describes the filters that you can use to retrieve cells in a table.
Cells per column limit
This filter limits the number of cells in each column that are included in the output row. When this filter is applied, each output row includes the N most recent cells from each column and omits all other cells from that column.
If you are also using an interleave filter and the interleave filter produces duplicate copies of a cell, each copy counts towards the limit.
This filter is useful when columns store a history of timestamped values, such as changes to a device's data plan, and you only want to read the most recent values. The following code samples limit each column to its two most recent cells. The example dataset returns the following cells, while omitting any older cells if more than two existed:
Both timestamped cells (
false@timeandtrue@time minus one hour) in thecell_plan:data_plan_01gbcolumn for rowphone#4c410523#20190501The single cell in each of the other populated columns
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python ayncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Cells per row limit
This filter limits the number of cells in each output row. When this filter is applied, each output row includes the first N cells from the input row and omits all of the following cells from that row. The first N cells are read regardless of which column they are in, in the order in which they are stored in Bigtable.
To learn more about how data is stored in Bigtable, see Schema design best practices.
A column in a row can contain multiple cells. Each cell contains a value for the column and a unique timestamp. As a result, limiting a row to N cells might differ from retrieving the first N columns from the row. For example, if you use a filter with a cell per row limit of 20 to read a row that has 30 columns, and each column has 10 timestamped cells, the output row returns values from only the first two columns in the row (2 * 10 = 20).
Using this filter in combination with an offset filter is useful for pagination if you need to read a large row.
The following code samples limit each output row to its first two cells—for example, to retrieve the first page of cells when paginating through a row. When applied to the example dataset, this filter returns the first two cells for each of the five rows. To retrieve the next page of cells, pair this filter with a cells per row offset filter.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Cells per row offset
This filter omits the first N cells from each output row. All of the remaining cells are included in the output row. The first N cells are skipped regardless of which column they are in.
A column in a row can contain multiple cells. Each cell contains a value for the column and a unique timestamp. As a result, skipping the first N cells from a row might differ from skipping the first N columns in the row. For example, if you use a filter with a cell per row offset of 20 to read a row that has 30 columns, and each column has 10 timestamped cells, the output row returns values all cells in the row except for those in the first two columns (2 * 10 = 20).
If you are also using an interleave filter, and the interleave filter produces duplicate copies of a cell, each copy counts towards the offset.
The following code samples use an offset of 2 to skip the first two cells in
each row—for example, to retrieve the next page of cells after reading the
first two cells with a cells per row limit filter. When
applied to the example dataset, this filter skips the first two cells
and returns all remaining cells for each of the five rows.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Column family regex
This filter includes cells in the output row only if the column family for a cell matches a regular expression.
The regular expression must use RE2 syntax. The regular expression
must not contain the : character, even if the character is not used as a
literal. Because column families cannot contain newline characters, you can use
either . or \C as the wildcard expression.
For example, if you want to read device summary statistics without retrieving
data plan columns, you can filter for the stats_summary column family. The
following code samples use the regular expression stats_.*$, which returns
all cells in the stats_summary column family for all five rows in the
example dataset and omits all cells in cell_plan.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Column qualifier regex
This filter includes cells in the output row only if the column qualifier for a cell matches a regular expression.
The regular expression must use RE2 syntax. Because column
qualifiers can contain arbitrary bytes, including newline characters, you should
use \C as the wildcard expression in most cases. The . expression does not
match newline characters.
For example, if you only want to check cellular and Wi-Fi connectivity for each
device, you can filter for column qualifiers that begin with connected_. The
following code samples use the regular expression connected_.*$, which
returns only the connected_cell and connected_wifi cells for each of the
five rows in the example dataset and omits os_build and all
cell_plan columns.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Column range
This filter includes cells in the output row only if they are in a specific column family, and only if their column qualifiers are within a specific range. You specify the range by providing a start qualifier and an end qualifier.
The following code samples filter the cell_plan column family for column
qualifiers from data_plan_01gb (inclusive) to data_plan_10gb
(exclusive)—for example, to check which records use the 1 GB or
5 GB data plans. In the example dataset, this filter returns the
data_plan_01gb and data_plan_05gb cells for the three phone#4c410523
rows. Because the two phone#5c10102 rows only have cell_plan values in
data_plan_10gb, those rows have no matching cells and aren't returned.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Value range
This filter includes cells in the output row only if their values are within a specific range. You specify the range by providing a start value and an end value.
- To get cells whose value comes before a specific value, specify that value as the exclusive end value, and omit the start value.
- To get cells whose value is equal to or after a specific value, specify that value as the inclusive start value, and omit the end value.
The following code samples filter for cell values between PQ2A.190405 and
PQ2A.190406 to find records with OS builds in that range. In the
example dataset, this filter returns only the stats_summary:os_build
cell for phone#4c410523#20190501 and phone#4c410523#20190502, omitting all
other cells and the remaining three rows whose os_build values fall outside
the range.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Value regex
This filter includes cells in the output row only if the value of the cell matches a regular expression.
The regular expression must use RE2 syntax. Because values can
contain arbitrary bytes, including newline characters, you should use \C as
the wildcard expression in most cases. The . expression does not match newline
characters.
The following code samples use the regular expression PQ2A.*$ to match cell
values that start with PQ2A—for example, to retrieve OS build versions
in the PQ2A release family. When applied to the example dataset,
this filter returns only the stats_summary:os_build cell for each of the five
rows and omits all other cells.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python ayncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Timestamp range
This filter includes cells in the output row only if their timestamps are within a specific range. You specify the range by providing a start time, which is inclusive, and an end time, which is exclusive. The default unit is microseconds, and the timestamp must be a multiple of 1,000.
- To get cells whose timestamps are older than a specific time, specify that time as the end time, and omit the start time to make it unbounded.
- To get cells whose timestamps are equal to or newer than a specific time, specify that time as the start time, and omit the end time to make it unbounded.
The following code samples filter for cells written an hour ago or earlier. In
the example dataset, where all other cells are written at @time,
this filter returns only the true@time minus one hour cell in the
cell_plan:data_plan_01gb column for row phone#4c410523#20190501.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
Note: The methods startOpen() and endClosed() are not supported for timestamp range filters in
this client library.
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Advanced single filters
The following filters can be difficult to use.
Block all
This filter removes all of the cells from the output row.
If you are using an interleave filter, you can combine the block all filter with the chain filter to temporarily disable part of the interleave.
The following code samples apply a block all filter to a read request. When run against the example dataset, this filter removes all cells from all five rows and returns an empty response.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
This client library does not support this filter.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Pass all
This filter includes all of the input row's cells in the output row. It is equivalent to a read with no filter.
The pass all filter can be useful if you are composing multiple filters, and you need to output cells in some cases but not others.
The following code samples apply a pass all filter to a read request. When run
against the example dataset, this filter returns every cell across all
five rows in the table, including both timestamped cells in
cell_plan:data_plan_01gb for row phone#4c410523#20190501.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
This client library does not support this filter.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Sink
This filter copies all of the input row's cells into the final output row, even if another filter would normally remove or change those cells.
When you use a chain of filters, other limiting filters can only affect their own output row, which becomes the input row for the next filter in the chain. The sink filter is different—it inserts cells directly into the final output row, which appears in the read results.
For example, suppose that you create a chain of two filters:
- The sink filter
- The block all filter, which deletes all cells from the row
On its own, the block all filter would result in an empty row, which wouldn't be included in the read results. However, the sink filter forces all of the cells from the input row to be copied to the final output row, regardless of what other filters in the chain might do. As a result, combining the sink filter and the block all filter has the same effect as not using a filter at all, and the original input row, with all of its cells, appears in the read results.
Modifying filters
The following sections describe each modifying filter. Modifying filters affect the data or metadata for individual cells.
Apply label
This filter adds a label to all of the cells in a row. Use this filter as part of an interleave to indicate which filter caused a cell to be included in the output row. Your application can use each cell's label to perform additional client-side processing.
Each label must be no longer than 15 characters. In addition, each label must
match the RE2 regular expression [a-z0-9\\-]+.
Each cell can have only one label. As a result, a chain of filters can include the apply label filter only once.
The following code samples apply the label labelled to cells read from the
table. When run against the example dataset, this filter returns all
cells across all five rows with the labelled metadata label attached to each
cell.
Go
This client library does not support this filter.
HBase
This client library does not support this filter.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Strip value
This filter replaces the value of each cell with an empty string. Use this filter when you only need to count the number of rows or cells that match your criteria, rather than retrieving all of the data from those rows or cells.
The following code samples apply a strip value filter to retrieve cell metadata
without transferring cell values. When run against the example dataset,
this filter returns all cells across all five rows with their row keys, column
families, column qualifiers, and timestamps intact, but replaces every cell
value, such as 1, PQ2A.190405.003, or true, with an empty string.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
In the HBase client library, the strip value filter is called
KeyOnlyFilter. A sample is not available.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Composing filters
The following sections describe each composing filter. Composing filters allow you to combine multiple filters into one, which makes it possible to apply more than one filter to a single read request.
Chain
This filter applies a series of filters, in order, to each output row. A chain filter is like using a logical AND.
Each filter in the chain sees only the output of the previous filter. For example, if you chain two filters, and the first filter removes half of the cells from the output row, the second filter does not have access to the cells that were removed.
In other words, the order of the filters is important. If you change the order of chained filters, you might get different data in your output rows.
For example, if you want to check only the most recent data plan settings for
each record without reading stats_summary columns, you can chain a
cells per column limit filter of 1 with a
column family regex filter for cell_plan. In the
example dataset, the following code samples omit all stats_summary
cells and return only the newest cell for each populated cell_plan column.
For row phone#4c410523#20190501, the older true@time minus one hour cell
in data_plan_01gb is omitted, returning only the false@time cell in
data_plan_01gb and the cell in data_plan_05gb, while the other four rows
each return their single cell_plan cell.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Interleave
This filter sends the input row through multiple component filters, generating a temporary output row from each component filter. All of the cells from the temporary output rows are then combined into a final output row. An interleave filter is like using a logical OR.
Interleaves can cause cells to be duplicated in the output row. For example, if your interleave includes two filters, and both filters include a specific cell in their temporary output rows, the final output row will include two copies of that cell.
If the component filters output multiple cells that all have the same column family, column qualifier, and timestamp, the final output row will group all of those cells together in an unspecified order.
For example, if you want to read each device's OS build version along with any
data plan cells that are set to true in a single request, you can combine
those two criteria in an interleave filter. The following code samples
interleave a value regex filter for true with a
column qualifier regex filter for os_build. When
applied to the example dataset, this filter returns the
stats_summary:os_build cell and all cell_plan cells whose value is true
for each of the five rows, omitting the false@time cell in
cell_plan:data_plan_01gb for phone#4c410523#20190501 and the
connected_cell and connected_wifi columns.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Condition
This filter applies either a true filter or a false filter to the input row.
To choose between the true and false filters, a predicate filter is applied to the input row. If the predicate filter's output contains at least one cell, the true filter is applied. If the predicate filter's output is empty, the false filter is applied.
The predicate filter's output row is used only to choose between the true and false filters. It does not appear in the response to your read request.
The predicate filter is not executed atomically with the true or false filter. In other words, the data in the input row can change between the time when the predicate filter is executed and the time when the true or false filter is executed. This behavior can lead to inconsistent or unexpected results.
When you use the condition filter, you can omit the true or false filter. Omitting a filter is the same as specifying the block all filter. If the predicate filter chooses a condition that you omitted, the output row will be empty.
The following code samples use a predicate filter that chains a
column qualifier regex filter for data_plan_10gb
with a value regex filter for true to check whether a record
has an active 10 GB data plan. In the example dataset, rows
phone#5c10102#20190501 and phone#5c10102#20190502 match the predicate, so
the true filter applies the label passed-filter to all cells in those two
rows. The three phone#4c410523 rows don't have a matching cell in
data_plan_10gb, so the false filter applies the label filtered-out to all
cells in those rows.
Go
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
HBase
This client library does not support this filter.
Java
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Python asyncio
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C++
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.js
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHP
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Ruby
To learn how to install and use the client library for Bigtable, see Bigtable client libraries.
To authenticate to Bigtable, set up Application Default Credentials. For more information, see Set up authentication for client libraries.