raminqaf commented on code in PR #30033: URL: https://github.com/apache/flink/pull/30033#discussion_r4640933551
########## docs/data/functions/boolean/logical_operators.yml: ########## @@ -0,0 +1,115 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License + +name: Logical operators +summary: Returns whether both conditions hold with `AND`, whether either holds with `OR`, or the opposite of a condition with `NOT`. + +syntax: + sql: | + expr1 AND expr2 + expr1 OR expr2 + NOT expr + java: | + $("expr1").and($("expr2")) + and($("expr1"), $("expr2"), ...) + $("expr1").or($("expr2")) + or($("expr1"), $("expr2"), ...) + $("expr").not() + not($("expr")) + python: | + col("expr1") & col("expr2") + and_(col("expr1"), col("expr2"), ...) + col("expr1") | col("expr2") + or_(col("expr1"), col("expr2"), ...) + ~col("expr") + not_(col("expr")) + +arguments: + - name: expr1, expr2 + type: BOOLEAN + required: true + description: The conditions that `AND` and `OR` combine. In the Table API, `and` and `or` take two or more conditions. + - name: expr + type: BOOLEAN + required: true + description: The condition that `NOT` negates. + +returns: + description: "`AND` returns TRUE if both conditions are TRUE. `OR` returns TRUE if either condition is TRUE. `NOT` returns TRUE for FALSE and FALSE for TRUE." + nulls: Returns NULL if a condition is NULL and the result depends on it. If `x` is NULL, `FALSE AND x` is FALSE and `TRUE OR x` is TRUE, while `TRUE AND x`, `FALSE OR x` and `NOT x` are NULL. + type: "`BOOLEAN`, nullable if a condition is nullable." + +notes: + - Comparisons and `IS` tests bind tighter than `NOT`, `NOT` tighter than `AND`, and `AND` tighter than `OR`. So `NOT qty > 10` means `NOT (qty > 10)`, and `a OR b AND c` means `a OR (b AND c)`. + - "`WHERE NOT active` drops the rows where `active` is NULL, as `WHERE active` does. To keep them, use `WHERE active IS NOT TRUE`." + +see_also: + - {name: IS TRUE, ref: boolean/is-true} + - {name: IS FALSE, ref: boolean/is-false} + - {name: IS UNKNOWN, ref: boolean/is-unknown} + +examples: + - title: Combine conditions + description: Test two conditions on each row. + sql: | + SELECT id, + qty > 10 AND price > 10 AS both_hold, + qty > 10 OR price > 10 AS either_holds, + NOT qty > 10 AS small_order + FROM (VALUES (1, 5, 20.0), (2, 50, 8.0), (3, 12, 15.0)) AS t(id, qty, price); Review Comment: addressed here and everywhere else -- 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]
