java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.RenameNode
- Record Components:
relationName- the new relation name; empty for a column-only rename, and when present must not be blankattributes- positional new attribute names (arity-checked); empty unless this is the positional formpairs-old → newcolumn renames; empty unless this is the pair forminput- the source relation; must not be nulllocation- the source location of this node; never null
- All Implemented Interfaces:
RelNode
public record RenameNode(Optional<String> relationName, List<String> attributes, List<RenameNode.RenamePair> pairs, RelNode input, SourceLocation location)
extends Record
implements RelNode
Rename (ρ) — renames a relation and optionally reassigns its attribute names.
Three column-naming forms, distinguished at parse time:
- relation-only —
ρ E (Employees): rename the relation label, leave every column untouched. Bothattributes()andpairs()are empty. - positional —
ρ E (id, name) (Employees): rename the columns positionally; the list must match the input arity exactly. Carried inattributes(). - pairs —
ρ E (name → room_name, id → room_id) (Employees): rename only the listed columns (old → new); unlisted columns pass through unchanged. Carried inpairs(). This is the textbook ρ_{a→b}(R) form.
The positional and pair forms are mutually exclusive — a single rename may
not mix bare names and old → new pairs.
The new relation name is optional: ρ (name → room_name) (Employees)
renames columns without re-anchoring the relation label, so surviving columns
keep their existing origin qualifier. When present, the relation name
re-anchors every output column's provenance to it (this is what makes a
self-join distinguishable).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA singleold → newcolumn rename within the pair form. -
Constructor Summary
ConstructorsConstructorDescriptionRenameNode(String relationName, List<String> attributes, RelNode input) Convenience constructor for tests; usesSourceLocation.UNKNOWN.RenameNode(String relationName, List<String> attributes, RelNode input, SourceLocation location) Convenience constructor for the relation-and-positional-columns form (a new relation name plus a possibly-empty positional attribute list).RenameNode(Optional<String> relationName, List<String> attributes, List<RenameNode.RenamePair> pairs, RelNode input, SourceLocation location) Creates an instance of aRenameNoderecord class. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) Returns the value of theattributesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.location()Returns the value of thelocationrecord component.pairs()Returns the value of thepairsrecord component.Returns the value of therelationNamerecord component.booleanTrue iff this rename reassigns any column names (positional or pair form).final StringtoString()Returns a string representation of this record class.Returns a copy of this node overnewInput, preserving all rename metadata.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.ast.RelNode
children, mapChildren, materializationMode, prettyPrint
-
Constructor Details
-
RenameNode
public RenameNode(Optional<String> relationName, List<String> attributes, List<RenameNode.RenamePair> pairs, RelNode input, SourceLocation location) Creates an instance of aRenameNoderecord class.- Parameters:
relationName- the value for therelationNamerecord componentattributes- the value for theattributesrecord componentpairs- the value for thepairsrecord componentinput- the value for theinputrecord componentlocation- the value for thelocationrecord component
-
RenameNode
public RenameNode(String relationName, List<String> attributes, RelNode input, SourceLocation location) Convenience constructor for the relation-and-positional-columns form (a new relation name plus a possibly-empty positional attribute list). Preserves the original(String, List, RelNode, SourceLocation)signature so existing call sites are unchanged. -
RenameNode
Convenience constructor for tests; usesSourceLocation.UNKNOWN.
-
-
Method Details
-
renamesColumns
public boolean renamesColumns()True iff this rename reassigns any column names (positional or pair form). -
withInput
Returns a copy of this node overnewInput, preserving all rename metadata. -
accept
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
relationName
Returns the value of therelationNamerecord component.- Returns:
- the value of the
relationNamerecord component
-
attributes
Returns the value of theattributesrecord component.- Returns:
- the value of the
attributesrecord component
-
pairs
Returns the value of thepairsrecord component.- Returns:
- the value of the
pairsrecord component
-
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
location
Returns the value of thelocationrecord component.
-