Michael-J-Ward commented on issue #667:
URL: 
https://github.com/apache/datafusion-python/issues/667#issuecomment-2099599913

   
   TLDR: Use the bitwise operators `&` and `|`, which get mapped to the magic 
methods `__and__` and `__or__`. 
   
   This is a python quirk [see this 
table](https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not).
 
   
   - `x or y` means `if x is true, then x, else y`
   - `x and y` means `if x is false, then x, else y`
   
   Basically, the evaluation mechanics make it impossible for `x or y` to 
create the combined expression you're looking for.
   
   ```python
   a_eq_1 = column("a") == literal(1)
   a_eq_3 = column("a") == literal(3)
   
   print("using `or`:",  a_eq_1 or a_eq_3)
   print("using `and`:", a_eq_1 and a_eq_3)
   print("using `|`:",  a_eq_1 | a_eq_3)
   print("using `&`:", a_eq_1 & a_eq_3)
   ```
   
   ```console
   using `or`: Expr(a = Int64(1))
   using `and`: Expr(a = Int64(3))
   using `|`: Expr(a = Int64(1) OR a = Int64(3))
   using `&`: Expr(a = Int64(1) AND a = Int64(3))
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to