twalthr commented on a change in pull request #15896: URL: https://github.com/apache/flink/pull/15896#discussion_r630984925
########## File path: flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/factories/DataGenTableSourceFactoryOptions.java ########## @@ -0,0 +1,97 @@ +/* + * 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.flink.table.factories; + +import org.apache.flink.configuration.ConfigOption; +import org.apache.flink.configuration.ConfigOptions; + +import static org.apache.flink.configuration.ConfigOptions.key; + +/** {@link ConfigOption}s for {@link DataGenTableSourceFactory}. */ +public class DataGenTableSourceFactoryOptions { + + public static final Long ROWS_PER_SECOND_DEFAULT_VALUE = 10000L; + + public static final String FIELDS = "fields"; + public static final String KIND = "kind"; + public static final String START = "start"; + public static final String END = "end"; + public static final String MIN = "min"; + public static final String MAX = "max"; + public static final String LENGTH = "length"; + + public static final String SEQUENCE = "sequence"; + public static final String RANDOM = "random"; + + public static final ConfigOption<Long> ROWS_PER_SECOND = + key("rows-per-second") + .longType() + .defaultValue(ROWS_PER_SECOND_DEFAULT_VALUE) + .withDescription("Rows per second to control the emit rate."); + + public static final ConfigOption<Long> NUMBER_OF_ROWS = + key("number-of-rows") + .longType() + .noDefaultValue() + .withDescription( + "Total number of rows to emit. By default, the source is unbounded."); + + /** Placeholder {@link ConfigOption}. Not used for retrieving values. */ + public static final ConfigOption<String> FIELD_KIND = + ConfigOptions.key(String.format("%s.#.%s", FIELDS, KIND)) + .stringType() + .defaultValue("random") + .withDescription("Generator of this '#' field. Can be 'sequence' or 'random'."); + + /** Placeholder {@link ConfigOption}. Not used for retrieving values. */ + public static final ConfigOption<String> FIELD_MIN = + ConfigOptions.key(String.format("%s.#.%s", FIELDS, MIN)) + .stringType() + .defaultValue("(Minimum value possible for the type of the field)") + .withDescription("Minimum value to generate for fields of kind 'random'."); + + /** Placeholder {@link ConfigOption}. Not used for retrieving values. */ + public static final ConfigOption<String> FIELD_MAX = + ConfigOptions.key(String.format("%s.#.%s", FIELDS, MAX)) + .stringType() + .defaultValue("(Maximum value possible for the type of the field)") Review comment: nit: shall we do `.noDefaultValue()` for this and the option above? It could explode the website formatting and is actually obvious or could be moved to the description. ########## File path: flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/factories/DataGenTableSourceFactoryOptions.java ########## @@ -0,0 +1,97 @@ +/* + * 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.flink.table.factories; + +import org.apache.flink.configuration.ConfigOption; +import org.apache.flink.configuration.ConfigOptions; + +import static org.apache.flink.configuration.ConfigOptions.key; + +/** {@link ConfigOption}s for {@link DataGenTableSourceFactory}. */ +public class DataGenTableSourceFactoryOptions { Review comment: annotate with `@Internal` and prevent instantiation ########## File path: flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/factories/DataGenTableSourceFactory.java ########## @@ -85,8 +60,17 @@ public String factoryIdentifier() { @Override public Set<ConfigOption<?>> optionalOptions() { Set<ConfigOption<?>> options = new HashSet<>(); - options.add(ROWS_PER_SECOND); - options.add(NUMBER_OF_ROWS); + options.add(DataGenTableSourceFactoryOptions.ROWS_PER_SECOND); Review comment: make the code more readable by calling this `DataGenOptions` similar to `KafkaOptions` etc. -- 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. For queries about this service, please contact Infrastructure at: [email protected]
