YenFuChen opened a new pull request, #2281:
URL: https://github.com/apache/systemds/pull/2281

   ### SYSTEMDS-3857: Set/Get Column Names
   
   ### Brief Description
   This PR adds two new DML builtin functions, `getNames()` and `setNames()`, 
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:
   1. **FrameBlock Class:**
      - Added `public FrameBlock getNames()` method: Returns a single-row 
`FrameBlock` with current column names (default "C1", "C2", ... or user 
defined), based on `getColumnNamesAsFrame()`.
      - Added `public void setNames(FrameBlock names)` method: Sets custom 
column names for the `FrameBlock`, with strict validation checking for null 
input, single-row requirement, and matching column count.
   
   2. **DML Builtin Functions Integration:**
      - Registered `getNames` and `setNames` as new `Builtin` functions in 
`BuiltinFunctionExpression`, 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:
   - **Default Names:** Ensures `getNames()` returns default names ("C1", "C2", 
...).
   - **Custom Name Setting & Getting:** Verifies that `setNames()` applies 
custom column names (e.g, 2 columns like "name", "age") and `getNames()` 
retrieves them as expected.
   - **Error Handling for `setNames()`:**
     - Handles `null` input to `setNames()`.
     - Rejects `FrameBlock` with incorrect row count (e.g, 2 rows with 2 
columns).
     - Detects mismatch in column count between input and target `Frame` (e.g, 
3 vs. 2 columns).
   Tests validate core functionality and pass successfully.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@systemds.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to