Class BeamTableUtils

java.lang.Object
org.apache.beam.sdk.extensions.sql.impl.schema.BeamTableUtils

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

TODO: Does not yet support nested types.

  • Constructor Details

    • BeamTableUtils

      public BeamTableUtils()
  • Method Details

    • csvLines2BeamRows

      public static Iterable<Row> csvLines2BeamRows(CSVFormat csvFormat, String line, 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 String beamRow2CsvLine(Row row, CSVFormat csvFormat)
    • autoCastField

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