jackye1995 commented on a change in pull request #3387:
URL: https://github.com/apache/iceberg/pull/3387#discussion_r743219566
##########
File path: core/src/main/java/org/apache/iceberg/TableProperties.java
##########
@@ -244,4 +245,41 @@ private TableProperties() {
public static final String UPSERT_MODE_ENABLE = "write.upsert.enable";
public static final boolean UPSERT_MODE_ENABLE_DEFAULT = false;
+
+ /**
+ * Get a table property for a specific Iceberg action's config option.
+ * <p>
+ * For example, {@link
org.apache.iceberg.actions.RewriteDataFiles#TARGET_FILE_SIZE_BYTES} corresponds
to
+ * table property actions.rewrite-data-files.target-file-size-bytes
+ *
+ * @param action name of the iceberg action, retrieved from the NAME
variable of the specific action if exists.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @param option config option name, typically defined as public static
variables in the specific action.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @return table property name
+ */
+ public static String actionTableProperty(String action, String option) {
+ return String.format("actions.%s.%s", action, option);
+ }
+
+ /**
+ * Get a table property for a specific Iceberg action and strategy's config
option.
+ * <p>
+ * For example, {@link
org.apache.iceberg.actions.BinPackStrategy#MIN_INPUT_FILES} corresponds to
+ * table property
actions.rewrite-data-files.strategies.binpack.min-input-files
+ *
+ * @param action name of the iceberg action, retrieved from the NAME
variable of the specific action if exists.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @param strategy name of the strategy, retrieved from the name method of
the specific strategy,
+ * such as {@link
org.apache.iceberg.actions.RewriteStrategy#name()}.
+ * The name is assumed to be in
CAPITALIZED_CASE_SNAKE_STYLE, and is converted to
Review comment:
I am trying to just define the rules here, because if there is no rule
then there are too many ways the input string will be like and it's hard to
convert.
For strategy we already have `BINPACK` and `SORT`, so I do a conversion for
it.
For option keys, we are already following the kebab style, so I just don't
convert it.
Since we don't have any definition of the action name, I am trying to just
define the rule upfront.
##########
File path: core/src/main/java/org/apache/iceberg/TableProperties.java
##########
@@ -244,4 +245,41 @@ private TableProperties() {
public static final String UPSERT_MODE_ENABLE = "write.upsert.enable";
public static final boolean UPSERT_MODE_ENABLE_DEFAULT = false;
+
+ /**
+ * Get a table property for a specific Iceberg action's config option.
+ * <p>
+ * For example, {@link
org.apache.iceberg.actions.RewriteDataFiles#TARGET_FILE_SIZE_BYTES} corresponds
to
+ * table property actions.rewrite-data-files.target-file-size-bytes
+ *
+ * @param action name of the iceberg action, retrieved from the NAME
variable of the specific action if exists.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @param option config option name, typically defined as public static
variables in the specific action.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @return table property name
+ */
+ public static String actionTableProperty(String action, String option) {
+ return String.format("actions.%s.%s", action, option);
+ }
+
+ /**
+ * Get a table property for a specific Iceberg action and strategy's config
option.
+ * <p>
+ * For example, {@link
org.apache.iceberg.actions.BinPackStrategy#MIN_INPUT_FILES} corresponds to
+ * table property
actions.rewrite-data-files.strategies.binpack.min-input-files
+ *
+ * @param action name of the iceberg action, retrieved from the NAME
variable of the specific action if exists.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @param strategy name of the strategy, retrieved from the name method of
the specific strategy,
+ * such as {@link
org.apache.iceberg.actions.RewriteStrategy#name()}.
+ * The name is assumed to be in
CAPITALIZED_CASE_SNAKE_STYLE, and is converted to
+ * lower-case-kebab-style in the config key.
+ * @param option config option name, typically defined as public static
variables in the specific strategy.
+ * The name is assumed to be in lower-case-kebab-style.
+ * @return table property name
+ */
+ public static String actionStrategyTableProperty(String action, String
strategy, String option) {
Review comment:
Yes that's right. The intention here is to allow users to be able to
find the option, as the option itself is defined in the strategy class instead
of the action class. For example, when seeing
`actions.rewrite-data-files.strategies.binpack.min-input-files`, users
immediately know the option is defined in the `BinPackStrategy` class. But I am
also fine with not having that, no strong preference here.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]