Fokko commented on code in PR #1862: URL: https://github.com/apache/iceberg-python/pull/1862#discussion_r2029319471
########## mkdocs/docs/expression-dsl.md: ########## @@ -0,0 +1,261 @@ +<!-- + - 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. + --> + +# Expression DSL + +The PyIceberg library provides a powerful expression DSL (Domain Specific Language) for building complex row filter expressions. This guide will help you understand how to use the expression DSL effectively. This DSL allows you to build type-safe expressions for use in the `row_filter` scan argument. + +They are composed of terms, predicates, and logical operators. + +## Basic Concepts + +### Terms + +Terms are the basic building blocks of expressions. They represent references to fields in your data: + +```python +from pyiceberg.expressions import Reference + +# Create a reference to a field named "age" +age_field = Reference("age") +``` + +### Predicates + +Predicates are expressions that evaluate to a boolean value. They can be combined using logical operators. + +#### Comparison Predicates + +```python +from pyiceberg.expressions import EqualTo, NotEqualTo, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual + +# age equals 18 +age_equals_18 = EqualTo("age", 18) + +# age is not equal to 18 +age_not_equals_18 = NotEqualTo("age", 18) + +# age is less than 18 +age_less_than_18 = LessThan("age", 18) + +# Less than or equal to +age_less_than_or_equal_18 = LessThanOrEqual("age", 18) + +# Greater than +age_greater_than_18 = GreaterThan("age", 18) + +# Greater than or equal to +age_greater_than_or_equal_18 = GreaterThanOrEqual("age", 18) +``` + +#### Set Predicates + +```python +from pyiceberg.expressions import In, NotIn + +# age is one of 18, 19, 20 +age_in_set = In("age", [18, 19, 20]) + +# age is not 18, 19, oer 20 +age_not_in_set = NotIn("age", [18, 19, 20]) +``` + +#### Null Predicates Review Comment: ```suggestion #### Unary Predicates ``` Should we also include `IsNaN`, `NotNaN`? -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org