org.apache.spark.sql.catalyst.expressions.AttributeReference Java Examples
The following examples show how to use
org.apache.spark.sql.catalyst.expressions.AttributeReference.
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: SparkBenchmarkUtil.java From iceberg with Apache License 2.0 | 6 votes |
public static UnsafeProjection projection(Schema expectedSchema, Schema actualSchema) { StructType struct = SparkSchemaUtil.convert(actualSchema); List<AttributeReference> refs = JavaConverters.seqAsJavaListConverter(struct.toAttributes()).asJava(); List<Attribute> attrs = Lists.newArrayListWithExpectedSize(struct.fields().length); List<Expression> exprs = Lists.newArrayListWithExpectedSize(struct.fields().length); for (AttributeReference ref : refs) { attrs.add(ref.toAttribute()); } for (Types.NestedField field : expectedSchema.columns()) { int indexInIterSchema = struct.fieldIndex(field.name()); exprs.add(refs.get(indexInIterSchema)); } return UnsafeProjection.create( JavaConverters.asScalaBufferConverter(exprs).asScala().toSeq(), JavaConverters.asScalaBufferConverter(attrs).asScala().toSeq()); }
Example #2
Source File: RowDataReader.java From iceberg with Apache License 2.0 | 6 votes |
private static UnsafeProjection projection(Schema finalSchema, Schema readSchema) { StructType struct = SparkSchemaUtil.convert(readSchema); List<AttributeReference> refs = JavaConverters.seqAsJavaListConverter(struct.toAttributes()).asJava(); List<Attribute> attrs = Lists.newArrayListWithExpectedSize(struct.fields().length); List<org.apache.spark.sql.catalyst.expressions.Expression> exprs = Lists.newArrayListWithExpectedSize(struct.fields().length); for (AttributeReference ref : refs) { attrs.add(ref.toAttribute()); } for (Types.NestedField field : finalSchema.columns()) { int indexInReadSchema = struct.fieldIndex(field.name()); exprs.add(refs.get(indexInReadSchema)); } return UnsafeProjection.create( JavaConverters.asScalaBufferConverter(exprs).asScala().toSeq(), JavaConverters.asScalaBufferConverter(attrs).asScala().toSeq()); }
Example #3
Source File: Reader.java From iceberg with Apache License 2.0 | 6 votes |
private static UnsafeProjection projection(Schema finalSchema, Schema readSchema) { StructType struct = convert(readSchema); List<AttributeReference> refs = seqAsJavaListConverter(struct.toAttributes()).asJava(); List<Attribute> attrs = Lists.newArrayListWithExpectedSize(struct.fields().length); List<org.apache.spark.sql.catalyst.expressions.Expression> exprs = Lists.newArrayListWithExpectedSize(struct.fields().length); for (AttributeReference ref : refs) { attrs.add(ref.toAttribute()); } for (Types.NestedField field : finalSchema.columns()) { int indexInReadSchema = struct.fieldIndex(field.name()); exprs.add(refs.get(indexInReadSchema)); } return UnsafeProjection.create( asScalaBufferConverter(exprs).asScala().toSeq(), asScalaBufferConverter(attrs).asScala().toSeq()); }