Class RenameFlux

All Implemented Interfaces:
Expression, HasImports

public final class RenameFlux extends AbstractParametrizedFlux
Rename will rename specified columns in a table. If a column is renamed and is part of the group key, the column name in the group key will be updated. See SPEC.

Options

  • columns - The map of columns to rename and their corresponding new names. Cannot be used with fn. [map of columns]
  • fn - The function which takes a single string parameter (the old column name) and returns a string representing the new column name. Cannot be used with columns. [function(column)]

Example

 Map<String, String> map = new HashMap<>();
 map.put("host", "server");
 map.put("_value", "val");

 Flux flux = Flux
     .from("telegraf")
     .rename(map);

 Flux flux = Flux
     .from("telegraf")
     .rename("\"{col}_new\"");
 
Author:
Jakub Bednar (bednar@github) (02/08/2018 11:48)
  • Constructor Details

    • RenameFlux

      public RenameFlux(@Nonnull Flux source)
  • Method Details

    • operatorName

      @Nonnull protected String operatorName()
      Specified by:
      operatorName in class AbstractParametrizedFlux
      Returns:
      name of function
    • withColumns

      @Nonnull public RenameFlux withColumns(@Nonnull Map<String,String> columns)
      Parameters:
      columns - The map of columns to rename and their corresponding new names.
      Returns:
      this
    • withFunction

      @Nonnull public RenameFlux withFunction(@Nonnull String function)
      Parameters:
      function - The function which takes a single string parameter (the old column name) and returns a string representing the new column name.
      Returns:
      this
    • collectImports

      public void collectImports(@Nonnull Set<String> collectedImports)
      Description copied from class: Flux
      Collects all imports of the flux.
      Overrides:
      collectImports in class Flux
      Parameters:
      collectedImports - a set to be filled by the used imports