JingsongLi commented on code in PR #1447: URL: https://github.com/apache/paimon-rust/pull/1447#discussion_r4643318978
########## crates/paimon/src/spec/generated_column.rs: ########## @@ -0,0 +1,499 @@ +// 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. + +//! Generated-column metadata protection, without expression evaluation. + +use std::collections::{HashMap, HashSet}; +use std::sync::LazyLock; + +use regex::Regex; + +use crate::spec::{CoreOptions, DataField, DataType}; +use crate::{Error, Result}; + +pub(super) fn validate_schema( + fields: &[DataField], + options: &HashMap<String, String>, +) -> Result<()> { + let core_options = CoreOptions::new(options); + for field in fields { + validate_no_nested_generated_columns(field.data_type())?; + if field.generation_expression().is_none() { + continue; Review Comment: **[P2] Validate newly authored generated expressions before publishing them** The new public `SchemaBuilder::field` accepts an opaque `generationExpression` at CREATE. I reproduced this through `FileSystemCatalog`: define `source INT` and `generated STRING` with expression `source`, then create the table. Rust returns success and publishes the definition although that expression has type INT. A Java/Flink writer that omits the generated field invokes Java's generated-column evaluator, which rejects the stored type mismatch. Java schema validation rejects it too. [Java generated-column type check](https://github.com/apache/paimon/blob/902489339f5cbacdf36506179f68b9370d0d661f/paimon-common/src/main/java/org/apache/paimon/utils/GeneratedColumn.java#L45-L55) Preserve opaque metadata when reading and evolving existing schemas. For new definitions, validate the expression against the schema before CREATE, or limit new authoring until that validation is available. -- 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]
