Java Code Examples for org.apache.iceberg.Schema#asStruct()
The following examples show how to use
org.apache.iceberg.Schema#asStruct() .
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: TypeUtil.java From iceberg with Apache License 2.0 | 6 votes |
public static Schema select(Schema schema, Set<Integer> fieldIds) { Preconditions.checkNotNull(schema, "Schema cannot be null"); Preconditions.checkNotNull(fieldIds, "Field ids cannot be null"); Type result = visit(schema, new PruneColumns(fieldIds)); if (schema.asStruct() == result) { return schema; } else if (result != null) { if (schema.getAliases() != null) { return new Schema(result.asNestedType().fields(), schema.getAliases()); } else { return new Schema(result.asNestedType().fields()); } } return new Schema(ImmutableList.of(), schema.getAliases()); }
Example 2
Source File: ORCSchemaUtil.java From iceberg with Apache License 2.0 | 5 votes |
public static TypeDescription convert(Schema schema) { final TypeDescription root = TypeDescription.createStruct(); final Types.StructType schemaRoot = schema.asStruct(); for (Types.NestedField field : schemaRoot.asStructType().fields()) { TypeDescription orcColumType = convert(field.fieldId(), field.type(), field.isRequired()); root.addField(field.name(), orcColumType); } return root; }
Example 3
Source File: IcebergInputFormat.java From iceberg with Apache License 2.0 | 5 votes |
private CloseableIterable<T> applyResidualFiltering(CloseableIterable<T> iter, Expression residual, Schema readSchema) { boolean applyResidual = !context.getConfiguration().getBoolean(SKIP_RESIDUAL_FILTERING, false); if (applyResidual && residual != null && residual != Expressions.alwaysTrue()) { Evaluator filter = new Evaluator(readSchema.asStruct(), residual, caseSensitive); return CloseableIterable.filter(iter, record -> filter.eval((StructLike) record)); } else { return iter; } }
Example 4
Source File: ParquetUtil.java From iceberg with Apache License 2.0 | 5 votes |
private static boolean shouldStoreBounds(ColumnPath columnPath, Schema schema) { Iterator<String> pathIterator = columnPath.iterator(); Type currentType = schema.asStruct(); while (pathIterator.hasNext()) { if (currentType == null || !currentType.isStructType()) { return false; } String fieldName = pathIterator.next(); currentType = currentType.asStructType().fieldType(fieldName); } return currentType != null && currentType.isPrimitiveType(); }
Example 5
Source File: StrictMetricsEvaluator.java From iceberg with Apache License 2.0 | 4 votes |
public StrictMetricsEvaluator(Schema schema, Expression unbound) { this.schema = schema; this.struct = schema.asStruct(); this.expr = Binder.bind(struct, rewriteNot(unbound), true); }
Example 6
Source File: InclusiveMetricsEvaluator.java From iceberg with Apache License 2.0 | 4 votes |
public InclusiveMetricsEvaluator(Schema schema, Expression unbound, boolean caseSensitive) { StructType struct = schema.asStruct(); this.expr = Binder.bind(struct, rewriteNot(unbound), caseSensitive); }
Example 7
Source File: FixupTypes.java From iceberg with Apache License 2.0 | 4 votes |
private FixupTypes(Schema referenceSchema) { this.referenceSchema = referenceSchema; this.sourceType = referenceSchema.asStruct(); }
Example 8
Source File: ParquetDictionaryRowGroupFilter.java From iceberg with Apache License 2.0 | 4 votes |
public ParquetDictionaryRowGroupFilter(Schema schema, Expression unbound, boolean caseSensitive) { StructType struct = schema.asStruct(); this.expr = Binder.bind(struct, Expressions.rewriteNot(unbound), caseSensitive); }
Example 9
Source File: ParquetMetricsRowGroupFilter.java From iceberg with Apache License 2.0 | 4 votes |
public ParquetMetricsRowGroupFilter(Schema schema, Expression unbound, boolean caseSensitive) { this.schema = schema; StructType struct = schema.asStruct(); this.expr = Binder.bind(struct, Expressions.rewriteNot(unbound), caseSensitive); }
Example 10
Source File: GenericRecord.java From iceberg with Apache License 2.0 | 4 votes |
public static GenericRecord create(Schema schema) { return new GenericRecord(schema.asStruct()); }