GPUdb.filter_by_string( table_name = None, view_name = '', expression = None,
mode = None, column_names = None, options = {} )
Calculates which objects from a table, collection, or view match a string expression for the given string columns. The 'mode' may be:
ex. perfect union - will match any record containing "perfect", "union", or both.
ex. "Perfect Union" - will only match the exact phrase "Perfect Union"
ex. justice AND tranquility - will match only those records containing both justice and tranquility
ex. justice - peace - will match records containing "justice" or "peace", but not both
ex, est*is* - will match any records containing a word that starts with "est" and ends with "sh", such as "establish", "establishable", and "establishment"
ex. est???is* - will only match strings that start with "est", followed by exactly three letters, followed by "is", followed by one more letter. This would only match "establish"
ex. rear~ will match rear,fear,bear,read,etc.
ex. "Union Tranquility"~10 will match any record that has the words Union and Tranquility within 10 words of eachother
ex. [100 TO 200] will find all strings between 100 and 200 inclusive. ex. {alpha to beta} will find all strings between alpha and beta, but not the words alpha or beta
escaping special characters - Special characters are escaped with a backslash(), special characters are: + - && || ! ( ) { } [ ] ^ " ~ * ? :
equals: exact whole-string match (accelerated)
contains: partial substring match (not accelerated). If the column is a string type (non-charN) and the number of records is too large, it will return 0.
starts_with: strings that start with the given expression (not accelerated), If the column is a string type (non-charN) and the number of records is too large, it will return 0.
regex: full regular expression search (not accelerated). If the column is a string type (non-charN) and the number of records is too large, it will return 0.
The options 'case_sensitive' can be used to modify the behavior for all modes except 'search'
Input Parameter Description
Name | Type | Description | ||||
---|---|---|---|---|---|---|
table_name | str | Name of the table on which the filter operation will be performed. Must be a valid GPUdb table, collection or view. | ||||
view_name | str | If provided, then this will be the name of the view containing the results. Must not be an already existing collection, table or view. Default value is ''. | ||||
expression | str | The expression with which to filter the table. | ||||
mode | str | The string filtering mode to apply. See above for details. The allowed values are:
|
||||
column_names | list of str | List of columns on which to apply the filter. Ignored for 'search' mode. | ||||
options | dict of str | Optional parameters. Default value is an empty dict ( {} ).
|
Output Parameter Description
Name | Type | Description |
---|---|---|
count | long | The number of records that passed the string filter. |