Implementation:Lance format Lance Java ProjectOp: Difference between revisions
Auto-imported from implementations/Lance_format_Lance_Java_ProjectOp.md |
Sync from local file |
||
| Line 90: | Line 90: | ||
== Related Pages == | == Related Pages == | ||
* [[Lance_format_Lance_Java_MergeOp]] -- Adds columns with data via schema evolution | * [[Implementation:Lance_format_Lance_Java_MergeOp]] -- Adds columns with data via schema evolution | ||
* [[Lance_format_Lance_Java_OverwriteOp]] -- Overwrites the entire dataset including schema | * [[Implementation:Lance_format_Lance_Java_OverwriteOp]] -- Overwrites the entire dataset including schema | ||
* [[Lance_format_Lance_Java_ColumnAlteration]] -- Alters column properties such as rename, nullable, and type cast | * [[Implementation:Lance_format_Lance_Java_ColumnAlteration]] -- Alters column properties such as rename, nullable, and type cast | ||
[[Category:Implementations]] | [[Category:Implementations]] | ||
[[Category:Implementations]] | [[Category:Implementations]] | ||
Latest revision as of 10:43, 27 September 2026
| Knowledge Sources | |
|---|---|
| Domains | Java_SDK, Dataset_Management |
| Last Updated | 2026-02-08 19:33 GMT |
Overview
Description
The Project class is an immutable operation that changes the schema of a Lance dataset without modifying the underlying data. It extends SchemaOperation (which implements Operation) and carries only an Arrow Schema as its payload.
Project modifies column positions but does not change field IDs. When columns are removed via a Project operation, the physical data files are not immediately deleted; the data is removed after a subsequent compaction operation. This makes Project a lightweight metadata-only operation.
Usage
Use Project for schema-only transformations such as removing columns (logically), reordering columns, or renaming columns. Since it does not touch data files, it executes quickly regardless of dataset size. Physical cleanup of removed column data occurs during compaction.
Code Reference
Source Location
java/src/main/java/org/lance/operation/Project.java
Signature
public class Project extends SchemaOperation {
public static Builder builder();
public Schema schema(); // inherited from SchemaOperation
public long exportSchema(BufferAllocator allocator); // inherited
public String name(); // returns "Project"
}
Import
import org.lance.operation.Project;
I/O Contract
| Parameter | Type | Required | Description |
|---|---|---|---|
| schema | org.apache.arrow.vector.types.pojo.Schema |
Yes | The new schema to project the dataset to |
| Return | Type | Description |
|---|---|---|
| schema() | Schema |
The projected schema |
| exportSchema(allocator) | long |
Memory address of the exported Arrow C schema for JNI |
| name() | String |
Returns "Project" for JNI dispatch
|
Usage Examples
// Remove a column by projecting to a schema without it
Schema projectedSchema = new Schema(List.of(
Field.nullable("id", new ArrowType.Int(64, true)),
Field.nullable("name", new ArrowType.Utf8())
// "deprecated_column" is excluded from the projection
));
Project projectOp = Project.builder()
.schema(projectedSchema)
.build();
String opName = projectOp.name(); // "Project"
Related Pages
- Implementation:Lance_format_Lance_Java_MergeOp -- Adds columns with data via schema evolution
- Implementation:Lance_format_Lance_Java_OverwriteOp -- Overwrites the entire dataset including schema
- Implementation:Lance_format_Lance_Java_ColumnAlteration -- Alters column properties such as rename, nullable, and type cast