jeqo commented on code in PR #12637: URL: https://github.com/apache/kafka/pull/12637#discussion_r1167626084
########## connect/transforms/src/main/java/org/apache/kafka/connect/transforms/field/FieldSyntaxVersion.java: ########## @@ -0,0 +1,112 @@ +/* + * 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. + */ +package org.apache.kafka.connect.transforms.field; + +import org.apache.kafka.common.config.AbstractConfig; +import org.apache.kafka.common.config.ConfigDef; +import org.apache.kafka.common.config.ConfigException; + +import java.util.Arrays; + +/** + * Defines semantics of field paths by versioning. + * <p> + * See KIP-821. + * + * @see SingleFieldPath + * @see MultiFieldPaths + */ +public enum FieldSyntaxVersion { + /** + * No support for nested fields. Only access attributes on the root data value. + * Backward compatibility before KIP-821. + */ + V1("V1"), + /** + * Support for nested fields using dotted notation with backtick pairs to wrap field names that + * include dots. + * @since 3.x + */ + V2("V2"); + + public static final String FIELD_SYNTAX_VERSION_CONFIG = "field.syntax.version"; + public static final String FIELD_SYNTAX_VERSION_DOC = + "Defines the version of the syntax to access fields. " + + "If set to `V1`, then the field paths are limited to access the elements at the root level of the struct or map." + + "If set to `V2`, the syntax will support accessing nested elements. To access nested elements, " + + "dotted notation is used. If dots are already included in the field name, then backtick pairs " + + "can be used to wrap field names containing dots. " + + "e.g. to access elements from a field in a struct/map named \"foo.bar\", " + + "the following format can be used to access its elements: \"`foo.bar`.baz\"."; + + public static final String FIELD_SYNTAX_VERSION_DEFAULT_VALUE = V1.name(); + public static final ConfigDef.Validator FIELD_SYNTAX_VERSION_VALIDATOR = new Validator(); + + public static ConfigDef baseConfigDef() { Review Comment: Good catch. I see also `new ConfigDef(base)` may be cover this already, but that would assume existing transformers are creating ConfigDefs from scratch. What about adding this method to `ConfigDef` itself? I gave a try and added `ConfigDef addDefinition(ConfigDef toAdd)` to `ConfigDef`. Let me know what you think -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org