[SYSTEMDS-3857] Set/GetNames on Data Frames #2281
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SYSTEMDS-3857: Set/Get Column Names
Brief Description
This PR adds two new DML builtin functions,
getNames()
andsetNames()
, to manage column names in Frame objects, addressing the need for programmatic column name manipulation in DML scripts.Detailed Description
This contribution enhances flexibility for working with
Frame
objects in DML scripts by providing programmatic access to their column names.The following changes have been implemented:
FrameBlock Class:
public FrameBlock getNames()
method: Returns a single-rowFrameBlock
with current column names (default "C1", "C2", ... or user defined), based ongetColumnNamesAsFrame()
.public void setNames(FrameBlock names)
method: Sets custom column names for theFrameBlock
, with strict validation checking for null input, single-row requirement, and matching column count.DML Builtin Functions Integration:
getNames
andsetNames
as newBuiltin
functions inBuiltinFunctionExpression
, with integrated validation (e.g, type checking and argument count) during compilation to ensure correct usage in DML scripts.Testing
Unit tests are implemented in
org.apache.sysds.test.functions.builtin.BuiltinGetSetNamesTest.java
to validate the correctness Covering:getNames()
returns default names ("C1", "C2", ...).setNames()
applies custom column names (e.g, 2 columns like "name", "age") andgetNames()
retrieves them as expected.setNames()
:null
input tosetNames()
.FrameBlock
with incorrect row count (e.g, 2 rows with 2 columns).Frame
(e.g, 3 vs. 2 columns).Tests validate core functionality and pass successfully.