Skip to content

Commit 6ff4e62

Browse files
authored
Get rid all BNF lines in QueryCondition docstring (#2028)
1 parent aa4a346 commit 6ff4e62

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

tiledb/query_condition.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,73 +39,54 @@ class QueryCondition:
3939
(https://docs.tiledb.com/main/background/internal-mechanics/writing#default-fill-values).
4040
An example may be found in `examples/query_condition_dense.py`.
4141
42-
**BNF:**
43-
4442
A query condition is made up of one or more Boolean expressions. Multiple
4543
Boolean expressions are chained together with Boolean operators. The ``or_op``
4644
Boolean operators are given lower presedence than ``and_op``.
4745
48-
``query_cond ::= bool_term | query_cond or_op bool_term``
49-
50-
``bool_term ::= bool_expr | bool_term and_op bool_expr``
51-
52-
Logical ``and`` and bitwise ``&`` Boolean operators are given equal precedence.
53-
54-
``and_op ::= and | &``
55-
56-
Likewise, ``or`` and ``|`` are given equal precedence.
57-
58-
``or_op ::= or | |``
59-
60-
We intend to support ``not`` in future releases.
46+
A Bitwise expression may either be a comparison expression or membership
47+
expression.
6148
6249
A Boolean expression may either be a comparison expression or membership
6350
expression.
6451
65-
``bool_expr ::= compare_expr | member_expr``
66-
6752
A comparison expression contains a comparison operator. The operator works on a
6853
TileDB attribute or dimension name (hereby known as a "TileDB variable") and value.
6954
70-
``compare_expr ::= var compare_op val
71-
| val compare_op var
72-
| val compare_op var compare_op val``
73-
7455
All comparison operators are supported.
7556
76-
``compare_op ::= < | > | <= | >= | == | !=``
57+
Bitwise operators are given higher precedence than comparison operators.
58+
Boolean operators are given lower precedence than comparison operators.
7759
7860
If an attribute name has special characters in it, you can wrap ``namehere``
7961
in ``attr("namehere")``.
8062
8163
A membership expression contains the membership operator, ``in``. The operator
8264
works on a TileDB variable and list of values.
8365
84-
``member_expr ::= var in <list>``
85-
8666
TileDB variable names are Python valid variables or a ``attr()`` or ``dim()`` casted string.
8767
88-
``var ::= <variable> | attr(<str>) | dim(<str>)``
89-
9068
Values are any Python-valid number or string. datetime64 values should first be
9169
cast to UNIX seconds. Values may also be casted with ``val()``.
9270
93-
``val ::= <num> | <str> | val(val)``
94-
9571
**Example:**
9672
9773
>>> with tiledb.open(uri, mode="r") as A:
9874
>>> # Select cells where the values for `foo` are less than 5
9975
>>> # and `bar` equal to string "asdf".
10076
>>> # Note precedence is equivalent to:
10177
>>> # tiledb.QueryCondition("foo > 5 or ('asdf' == var('b a r') and baz <= val(1.0))")
102-
>>> qc = tiledb.QueryCondition("foo > 5 or 'asdf' == var('b a r') and baz <= val(1.0)")
103-
>>> A.query(cond=qc)
78+
>>> A.query(cond=tiledb.QueryCondition("foo > 5 or 'asdf' == var('b a r') and baz <= val(1.0)"))
10479
>>>
10580
>>> # Select cells where the values for `foo` are equal to 1, 2, or 3.
10681
>>> # Note this is equivalent to:
10782
>>> # tiledb.QueryCondition("foo == 1 or foo == 2 or foo == 3")
10883
>>> A.query(cond=tiledb.QueryCondition("foo in [1, 2, 3]"))
84+
>>>
85+
>>> # Example showing that bitwise operators (| ^ &) are given higher precedence than comparison operators
86+
>>> # and comparison operators are given higher precedence than logical operators.
87+
>>> # Note this is equivalent to:
88+
>>> # tiledb.QueryCondition("((foo == 1) or (foo == 2)) and ('xyz' == var('b a r')) and ((foo & 1) == 0"))
89+
>>> A.query(cond=tiledb.QueryCondition("foo == 1 or foo == 2 and 'xyz' == var('b a r') and foo & 1 == 0"))
10990
"""
11091

11192
expression: str

0 commit comments

Comments
 (0)