@Experimental(value=SCHEMAS) public abstract class Cast<T> extends PTransform<PCollection<T>,PCollection<Row>>
Modifier and Type | Class and Description |
---|---|
static class |
Cast.CompatibilityError
Describes compatibility errors during casting.
|
static class |
Cast.Narrowing
Narrowing changes type without guarantee to preserve data.
|
static interface |
Cast.Validator
Interface for statically validating casts.
|
static class |
Cast.Widening
Widening changes to type that can represent any possible value of the original type.
|
name
Constructor and Description |
---|
Cast() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Number |
castNumber(java.lang.Number value,
Schema.TypeName input,
Schema.TypeName output) |
static Row |
castRow(Row input,
Schema inputSchema,
Schema outputSchema) |
static java.lang.Object |
castValue(java.lang.Object inputValue,
Schema.FieldType input,
Schema.FieldType output) |
PCollection<Row> |
expand(PCollection<T> input)
Override this method to specify how this
PTransform should be expanded on the given
InputT . |
static boolean |
isDecimal(Schema.TypeName type)
Checks if type is decimal.
|
static boolean |
isIntegral(Schema.TypeName type)
Checks if type is integral.
|
static <T> Cast<T> |
narrowing(Schema outputSchema) |
static <T> Cast<T> |
of(Schema outputSchema,
Cast.Validator validator) |
abstract Schema |
outputSchema() |
abstract Cast.Validator |
validator() |
void |
verifyCompatibility(Schema inputSchema) |
static <T> Cast<T> |
widening(Schema outputSchema) |
compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validate
public abstract Schema outputSchema()
public abstract Cast.Validator validator()
public static <T> Cast<T> of(Schema outputSchema, Cast.Validator validator)
public static boolean isIntegral(Schema.TypeName type)
public static boolean isDecimal(Schema.TypeName type)
public void verifyCompatibility(Schema inputSchema)
public PCollection<Row> expand(PCollection<T> input)
PTransform
PTransform
should be expanded on the given
InputT
.
NOTE: This method should not be called directly. Instead apply the PTransform
should
be applied to the InputT
using the apply
method.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
expand
in class PTransform<PCollection<T>,PCollection<Row>>
public static java.lang.Number castNumber(java.lang.Number value, Schema.TypeName input, Schema.TypeName output)
public static java.lang.Object castValue(java.lang.Object inputValue, Schema.FieldType input, Schema.FieldType output)