Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public class TableSinkConfig extends PluginConfig {
  @Name(Properties.Table.NAME)
  @Description("Name of the table. If the table does not already exist, one will be created.")
  // The name of the table can be specified by a runtime macro, by default macros are disabled for fields.
  @Macro 
  private String name;

  @Name(Properties.Table.PROPERTY_SCHEMA)
  @Description("schema of the table as a JSON Object. If the table does not already exist, one will be " +
    "created with this schema, which will allow the table to be explored through Hive. If no schema is given, the " +
    "table created will not be explorable.")
  @Nullable
  private String schemaStr;

  @Name(Properties.Table.PROPERTY_SCHEMA_ROW_FIELD)
  @Description("The name of the record field that should be used as the row key when writing to the table.")
  private String rowField;
}

...


PluginConfig Changes:

Code Block
@Beta
public abstract interfaceclass PluginConfigurerPluginConfig extends DatasetConfigurer {
  /** Config implements Serializable {

  /**
   * Returns the {@link PluginProperties}.
   */
  public final PluginProperties getProperties() {
    return properties;
  }
 
  /**
   * Returns false if the field is not annotated as a macro. If field is annotated as macro, 
   * If the plugin field canvalue acceptis macro andchecked if the config for the plugin has its a macro, based thenon returnthe true,check elseit returnreturns true/false.  
   */
   public final boolean isMacro(String fieldName); {
       ...
   }
}

The method will return whether or not the property with the provided fieldName contains a macro at configure time. We don't want to force deferring macros to runtime in the case that a field is macroable but actually has no macro provided in its configuration. This allows optional checking of properties at configure time for simple pipelines.  

...

Code Block
titleExample usage
private final TableSinkConfig sinkConfig;
@Override
void configurePipeline(PipelineConfigurer pipelineConfigurer) {
  if (!pipelineConfigurersinkConfig.isMacro("datasetNamename")) {
 	// create dataset if the datasetName field is not a macro
    pipelineConfigurer.createDataset(datasetNamename, datasetType, DatasetProperties.builder().addAll(properties).build());
  }
  ...
}

...