Copilot commented on code in PR #650: URL: https://github.com/apache/sedona-db/pull/650#discussion_r2835055915
########## rust/sedona-functions/src/sd_simplifystorage.rs: ########## @@ -0,0 +1,304 @@ +// 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. + +use std::sync::Arc; + +use arrow_array::ArrayRef; +use arrow_schema::{DataType, FieldRef, UnionFields}; +use datafusion_common::{config::ConfigOptions, datatype::DataTypeExt, Result, ScalarValue}; +use datafusion_expr::{ColumnarValue, Volatility}; +use sedona_common::sedona_internal_err; +use sedona_expr::scalar_udf::{SedonaScalarKernel, SedonaScalarUDF}; +use sedona_schema::datatypes::SedonaType; + +/// SD_SimplifyStorage() scalar UDF implementation +/// +/// This function is invoked to strip dictionary, run-end-encoded, or dictionary +/// types from storage if needed (or return the input otherwise). This is to support +/// integration with other libraries like GDAL that haven't yet supported these +/// types. Review Comment: Doc comment repeats "dictionary" twice ("strip dictionary, run-end-encoded, or dictionary types"). Please correct the wording (e.g., "strip view, dictionary, or run-end encoded types") to match the actual behavior. ```suggestion /// This function is invoked to strip strip view, dictionary, or run-end encoded /// types from storage if needed (or return the input otherwise). This is to support /// integration with other libraries like GDAL that haven't yet supported these /// storage encodings. ``` ########## rust/sedona/src/context.rs: ########## @@ -451,6 +457,27 @@ impl SedonaDataFrame for DataFrame { DataFrame::new(ctx.ctx.state(), plan).collect().await } + + fn simplify_storage_types(self, ctx: &SedonaContext) -> Result<DataFrame> { + let sd_simplify_storage_udf: ScalarUDF = ctx + .functions + .scalar_udf("sd_simplifystorage") + .ok_or_else(|| sedona_internal_datafusion_err!("foofy"))? Review Comment: The internal error here uses a placeholder message ("foofy"), which makes debugging failures difficult if the UDF isn’t registered. Please replace it with a descriptive message like "sd_simplifystorage UDF does not exist" (consistent with other uses of sedona_internal_datafusion_err). ```suggestion .ok_or_else(|| sedona_internal_datafusion_err!("sd_simplifystorage UDF does not exist"))? ``` -- 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]
