org.apache.spark.sql.catalyst.expressions.Cast Java Examples
The following examples show how to use
org.apache.spark.sql.catalyst.expressions.Cast.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EncoderHelpers.java From beam with Apache License 2.0 | 5 votes |
/** * Wrap a Beam coder into a Spark Encoder using Catalyst Expression Encoders (which uses java code * generation). */ public static <T> Encoder<T> fromBeamCoder(Coder<T> coder) { Class<? super T> clazz = coder.getEncodedTypeDescriptor().getRawType(); ClassTag<T> classTag = ClassTag$.MODULE$.apply(clazz); List<Expression> serializers = Collections.singletonList( new EncodeUsingBeamCoder<>(new BoundReference(0, new ObjectType(clazz), true), coder)); return new ExpressionEncoder<>( SchemaHelpers.binarySchema(), false, JavaConversions.collectionAsScalaIterable(serializers).toSeq(), new DecodeUsingBeamCoder<>( new Cast(new GetColumnByOrdinal(0, BinaryType), BinaryType), classTag, coder), classTag); }