Class BeamTableUtils


  • public final class BeamTableUtils
    extends java.lang.Object
    Utility methods for working with BeamTable.

    TODO: Does not yet support nested types.

    • Constructor Summary

      Constructors 
      Constructor Description
      BeamTableUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object autoCastField​(org.apache.beam.sdk.schemas.Schema.Field field, @Nullable java.lang.Object rawObj)
      Attempt to cast an object to a specified Schema.Field.Type.
      static java.lang.String beamRow2CsvLine​(org.apache.beam.sdk.values.Row row, org.apache.commons.csv.CSVFormat csvFormat)  
      static java.lang.Iterable<org.apache.beam.sdk.values.Row> csvLines2BeamRows​(org.apache.commons.csv.CSVFormat csvFormat, java.lang.String line, org.apache.beam.sdk.schemas.Schema schema)
      Decode zero or more CSV records from the given string, according to the specified CSVFormat, and converts them to Rows with the specified Schema.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BeamTableUtils

        public BeamTableUtils()
    • Method Detail

      • csvLines2BeamRows

        public static java.lang.Iterable<org.apache.beam.sdk.values.Row> csvLines2BeamRows​(org.apache.commons.csv.CSVFormat csvFormat,
                                                                                           java.lang.String line,
                                                                                           org.apache.beam.sdk.schemas.Schema schema)
        Decode zero or more CSV records from the given string, according to the specified CSVFormat, and converts them to Rows with the specified Schema.

        A single "line" read from e.g. TextIO can have zero or more records, depending on whether the line was split on the same characters that delimite CSV records, and whether the CSVFormat ignores blank lines.

      • beamRow2CsvLine

        public static java.lang.String beamRow2CsvLine​(org.apache.beam.sdk.values.Row row,
                                                       org.apache.commons.csv.CSVFormat csvFormat)
      • autoCastField

        public static java.lang.Object autoCastField​(org.apache.beam.sdk.schemas.Schema.Field field,
                                                     @Nullable java.lang.Object rawObj)
        Attempt to cast an object to a specified Schema.Field.Type.
        Returns:
        The casted object in Schema.Field.Type.
        Throws:
        java.lang.IllegalArgumentException - if the value cannot be cast to that type.