Copilot commented on code in PR #807: URL: https://github.com/apache/sedona-db/pull/807#discussion_r3193359253
########## python/sedonadb/python/sedonadb/expr/__init__.py: ########## @@ -14,3 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + +from sedonadb.expr.expression import Expr, col +from sedonadb.expr.literal import Literal, lit + +__all__ = ["Expr", "Literal", "col", "lit"] Review Comment: `sedonadb.expr.lit` is re-exported from `sedonadb.expr.literal.lit` (returns `Literal`), but the PR description calls out `sedonadb.expr.lit(value)` as part of the new DataFusion-backed `Expr` surface. This is confusing for users because `lit()` does not currently construct an `Expr::Literal`. Either update the PR description / module docs to clarify that `lit()` returns a `Literal` (SQL param wrapper), or add a separate `lit()` (or `expr_lit()`/`lit_expr()`) that returns an `Expr` while keeping the existing `Literal` API for `with_params()` compatibility. ########## python/sedonadb/python/sedonadb/expr/expression.py: ########## @@ -0,0 +1,186 @@ +# 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. + +from typing import Any, Iterable, Optional + +from sedonadb._lib import InternalExpr as _InternalExpr +from sedonadb._lib import expr_col as _expr_col +from sedonadb._lib import expr_lit as _expr_lit +from sedonadb.expr.literal import Literal + + +class Expr: + """A column expression. + + `Expr` represents a logical expression that will be evaluated against a + `DataFrame` when the frame is executed. Expressions are pure syntax — they + do not carry data and are not bound to a particular frame at construction + time. Errors such as referring to a column that does not exist surface only + when the expression is consumed (for example, by `DataFrame.select()` or + `DataFrame.filter()`). + + Construct an `Expr` with `col(name)`. Plain Python values composed with an + `Expr` via operators are coerced to literal expressions automatically. Review Comment: The `Expr` docstring says that plain Python values composed with an `Expr` via operators are coerced to literals automatically, but this PR intentionally does not implement operator overloading yet. This makes the current documentation inaccurate (today, coercion only happens in places like `Expr.isin()` that call `_to_expr`). Consider rewording to describe the current behavior and/or note that operator-based coercion will be added in a follow-up PR. -- 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]
