Study guide

5.3 In-Memory DataTable Transformations & Column Operations

UiPath Automation Developer Professional UiPath-ADPv1

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Exam Overview & Blueprint Map

1.1 About the UiPath-ADPv1 Exam: Format, Fees & Policies 1.2 The Exam Topics Mapped to This Guide & a Study Plan

2 Chapter 2: REFramework Architecture & State Dynamics

2.1 State Machine Architecture & The Four Core States 2.2 Configuration Management: Settings, Constants, and Assets 2.3 Transaction Types & The Dispatcher vs. Performer Architecture 2.4 Adapting REFramework: Tabular Data, Collections & Linear Processes

3 Chapter 3: REFramework Exception Handling & Recovery

3.1 BusinessRuleException vs. System.Exception Handling Patterns 3.2 Retry Mechanisms: Queue Retries vs. REFramework MaxRetryNumber 3.3 Consecutive System Exceptions & Graceful Process Termination

4 Chapter 4: State Machines, Custom Log Fields & REFramework Testing

4.1 Building State Machine Projects in Studio 4.2 Logging Levels, Robot Logs & Custom Log Fields in REFramework 4.3 Testing a REFramework Project With and Without Orchestrator Queues

5 Chapter 5: LINQ Queries & DataTable Operations

5.1 LINQ Essentials for Collections & Filtering 5.2 Advanced DataTable Querying with LINQ 5.3 In-Memory DataTable Transformations & Column Operations

6 Chapter 6: Regex, DateTime, JSON & Invoke Activities

6.1 Regular Expressions & Text Parsing for Automation 6.2 DateTime Formatting, Timezone Conversions & TimeSpan Calculations 6.3 JSON Parsing, JSONPath & Serialization with Newtonsoft.Json 6.4 Invoke Method & Invoke Code Activities 6.5 Data Referencing in Invokes: DataTable, List & Dictionary Arguments

7 Chapter 7: Modern UI Automation & Unified Targeting

7.1 Modern Design Experience & The Unified Target Concept 7.2 Anchors, Relative Elements & UI Automation Activities 7.3 Dynamic Selectors, Variables & Wildcards in Selectors

8 Chapter 8: Object Repository, Computer Vision & Remote Runtime

8.1 Object Repository & UI Descriptor Libraries 8.2 AI Computer Vision for Unattended & Remote Interfaces 8.3 Automation in Virtual Environments & UiPath Remote Runtime

9 Chapter 9: Advanced UI Automation: Browser Modes, Agentic UI & macOS

9.1 Browser Automation with the WebDriver Protocol 9.2 Agentic UI Automation: ScreenPlay, Semantic Activities & Healing Agent 9.3 macOS Automation: Native Apps, Office Apps & AppleScript

10 Chapter 10: Advanced Control Flow & Exception Architecture

10.1 Flowcharts, Sequences & Parallel Control Flow Patterns 10.2 Global Exception Handler Architecture & ErrorAction Directives 10.3 TryCatch, Retry Scope & Custom Exception Architectures

11 Chapter 11: Orchestrator Queues & Transaction Management

11.1 Queue Architecture, SpecificContent & Transaction Lifecycles 11.2 Queue Items SLA, Postpone, Deadlines & Priority Scheduling 11.3 Bulk Operations, Transaction Status Updates & Queue Triggers

12 Chapter 12: Orchestrator Tenant & Folder Entities

12.1 Asset Types, Per-Robot Assets & External Credential Stores 12.2 Modern Folder Hierarchy, User/Robot Assignment & Permissions 12.3 Storage Buckets, Webhooks & Environment Promotion 12.4 Orchestrator Tags: Labels, Properties & Governance

13 Chapter 13: Unattended Execution, API Triggers & Cloud Robots

13.1 Unattended Job Execution: Folders, Priorities, Background vs. Foreground & Runtimes 13.2 API Triggers: Starting Jobs from External Systems over HTTP 13.3 Serverless and Cloud VM Robots: Cloud-Hosted Execution Options

14 Chapter 14: Monitoring, Recording & Solutions Management

14.1 Orchestrator Monitoring, Trigger Alerts & Job Health 14.2 Job and Transaction Recording: Troubleshooting Faulted Unattended Jobs 14.3 Solutions Management: Packaging and Deploying Automations with Their Resources

15 Chapter 15: Debugging, Remote Debugging & Profiling

15.1 Studio Debugging Tools: Breakpoints, Panels & Execution Control 15.2 Remote Debugging: Remote Machine and Unattended Robot Connections 15.3 Profile Execution: Finding Performance Bottlenecks in Studio

16 Chapter 16: RPA Testing & Test Suite

16.1 UiPath Test Suite Overview, Test Cases & Given-When-Then Structure 16.2 Data-Driven Testing, Test Verification Activities & Mock Activities 16.3 CI/CD Pipelines with uipcli & Test Manager Traceability

17 Chapter 17: Long-Running Workflows, Action Center & Apps

17.1 Long-Running Workflows: Persistence, Suspend and Resume 17.2 Action Center & Human-in-the-Loop Orchestration 17.3 UiPath Apps: Action Apps, Automations & Integration Service

18 Chapter 18: Trigger-Based Attended Automation & Callouts

18.1 Trigger-Based Attended Automation: Forms, Triggers & Global Variables 18.2 Running Local Triggers & the Event Inspection Tool 18.3 Callouts & Forms for Attended Guidance

19 Chapter 19: UiPath Assistant & Robot Sessions

19.1 UiPath Assistant: Automations, Reminders, Widgets & Configuration 19.2 Robot Session (Picture in Picture): Child Session vs. Virtual Desktop

20 Chapter 20: Autopilot for Developers & Autopilot for Everyone

20.1 Autopilot for Developers: AI Assistance in Studio and Studio Web 20.2 Autopilot for Everyone: Chat, Automations & Clipboard AI

21 Chapter 21: API Automation & Integration Service

21.1 Integration Service: Connectors, Connections & Connector Activities 21.2 API Workflows in Studio Web 21.3 HTTP Requests: Web APIs, the Orchestrator API & Connector Requests 21.4 Connector Builder: Custom Integration Service Connectors 21.5 Integration Service Event Triggers: Connected and Disconnected 21.6 GenAI Activities: Generative AI Inside Workflows

22 Chapter 22: Data Service, Context Grounding & Coded Workflows

22.1 Data Fabric (Data Service) Entities: Modeling Business Data 22.2 Data Fabric Activities and the Platform Connector 22.3 Context Grounding: Retrieval-Augmented Generation with Company Data 22.4 Coded Automations: Structure, Arguments & Invoking Workflows 22.5 Coded Automation Services: Orchestrator, UI Automation, Microsoft 365 & Custom Services

23 Chapter 23: Integrated Scenario Practice

23.1 Integrated Scenario Practice: Designing an End-to-End Solution

5.3 In-Memory DataTable Transformations & Column Operations

Key Takeaways Explain This Topic AI

DataTable.Clone() copies only the schema (columns, types, constraints) with zero rows, while DataTable.Copy() copies the schema and all rows; assigning one variable to another only copies the reference.

DataColumn.Expression creates calculated columns (for example 'Quantity * UnitPrice' or IIF conditions), and DataTable.Compute returns a single aggregate such as Sum(Amount) for a filter.

Merge Data Table's MissingSchemaAction decides how extra source columns are handled: Add, Ignore, Error, or AddWithKey.

dt.DefaultView.Sort and RowFilter, followed by ToTable(), sort and filter in memory; ToTable(True, columns...) also removes duplicates across the chosen columns.

DataTable is safe for concurrent reads only, so row updates should run on a single thread.

Last updated: September 2026

5.3 In-Memory DataTable Transformations & Column Operations

While LINQ queries excel at filtering and querying data rows, enterprise automations frequently demand structural modifications to DataTable objects. Developers must dynamically add computed columns, modify data types, consolidate disparate vendor reports through table merges, and eliminate duplicate records prior to queue dispatching or database staging.

Executing these structural changes efficiently requires deep mastery of the ADO.NET architecture under the hood of UiPath Studio. This section covers schema cloning versus deep copying, dynamic expression columns, missing schema collision policies during table merges, and high-performance DataView operations for sorting and deduplication.

1. Schema Cloning vs. Deep Copying vs. Variable Aliasing

A frequent source of bugs in enterprise UiPath workflows is the improper duplication of DataTable variables. Developers often confuse structural replication with data replication, or unwittingly introduce reference aliasing bugs.

The Variable Assignment Trap ( dt_Target = dt_Source )

In .NET, DataTable is a reference type. Assigning one variable to another ( dt_Target = dt_Source ) does not create a new table. Instead, it copies the memory reference pointer. Both variables point to the exact same object on the managed heap. Any row added, edited, or removed through dt_Target immediately alters dt_Source .

Structural Replication: dt.Clone()

The .Clone() method creates a new, independent DataTable with the identical schema as the source table, but zero rows :

It duplicates all DataColumn definitions (column names, DataType , AllowDBNull , DefaultValue , MaxLength , and Expression ).

It duplicates primary keys, table constraints, and extended properties.

It allocates no row storage, making it the ideal pattern for initializing filtered target tables.

Deep Replication: dt.Copy()

The .Copy() method creates a completely independent deep copy of the table, replicating both the structural schema and all DataRow elements:

All rows are cloned into the new table.

Row states ( DataRowState.Added , Modified , Unchanged , Deleted ) and row versions ( DataRowVersion.Original , Current ) are preserved.

Modifications made to rows in the copied table have no effect on the original source table.

  • Operation Duplicates Schema? Duplicates Data Rows? Preserves Constraints? Common Automation Use Case
  • dt.Clone() Yes No (0 rows) Yes Initializing empty output tables for LINQ .CopyToDataTable() fallback
  • dt.Copy() Yes Yes (all rows) Yes Snapshotting raw input data prior to destructive transformations or filtering

dt_B = dt_A Pointer alias Pointer alias Pointer alias Passing table references between workflow arguments (in/out) ' VB.NET: Demonstrating Clone vs Copy

  • Dim dt_EmptyTemplate As DataTable = dt_RawData.Clone() ' Schema only; 0 rows
  • Dim dt_BackupSnapshot As DataTable = dt_RawData.Copy() ' Schema + all rows
  • 2. Adding and Configuring Columns Programmatically

UiPath provides the visual Add Data Column activity, but configuring columns in code via an Invoke Code activity or within expressions grants precise control over column types and positions.

Specifying Native System Types

When adding columns, developers should assign strongly typed System.Type definitions rather than accepting default object representations: ' VB.NET: Adding strongly typed columns to a DataTable

  • dt_Transactions.Columns.Add("ProcessingTimestamp", GetType(DateTime))
  • dt_Transactions.Columns.Add("TaxRate", Type.GetType("System.Double"))
  • dt_Transactions.Columns.Add("IsAudited", GetType(Boolean)) // C#: Adding strongly typed columns to a DataTable
  • dt_Transactions.Columns.Add("ProcessingTimestamp", typeof(DateTime));
  • dt_Transactions.Columns.Add("TaxRate", Type.GetType("System.Double"));
  • dt_Transactions.Columns.Add("IsAudited", typeof(bool));
  • Modifying Column Ordinal Positions

By default, new columns are appended to the far right of the table. To position a column at a specific zero-based index (for instance, making a generated status column the first column in an export file), use .SetOrdinal() : ' Move the "Status" column to the first column position (index 0)

  • dt_Transactions.Columns("Status").SetOrdinal(0)
  • Renaming and Deleting Columns ' Rename an imported header
  • dt_Transactions.Columns("Old_Vendor_Num").ColumnName = "VendorID"
  • ' Remove temporary staging column
  • dt_Transactions.Columns.Remove("TempCalculation")
  • 3. Dynamic Computed Expression Columns ( DataColumn.Expression )

One of the most powerful and underutilized features of ADO.NET in UiPath automations is the DataColumn.Expression property. Setting an expression turns a column into a computed virtual column :

Values are calculated dynamically by the ADO.NET engine whenever row values change.

Calculations execute in native compiled code without procedural looping across rows.

Computed columns do not consume storage space for raw cell values.

  • Arithmetic and Text Expressions ' Arithmetic calculation across numeric columns
  • dt_Orders.Columns("SubTotal").Expression = "Quantity * UnitPrice"
  • ' Discounted total with conditional tax
  • dt_Orders.Columns("FinalTotal").Expression = "(Quantity * UnitPrice) * (1 - Discount) + TaxAmount"
  • ' String concatenation combining names
  • dt_Staff.Columns("FullName").Expression = "LastName + ', ' + FirstName"
  • Conditional Logic ( IIF Expressions)

The expression syntax supports the IIF(expr, truepart, falsepart) conditional operator, allowing complex status classification without a single visual activity: ' Classify transactions based on threshold

dt_Orders.Columns("AuditCategory").Expression = "IIF(FinalTotal > 50000, 'Tier 1 Review', IIF(FinalTotal > 10000, 'Tier 2 Review', 'Standard'))"

Aggregates with DataTable.Compute

For a single total or average over the whole table, or over a filtered subset, use the Compute method instead of adding a column: ' Total of the Amount column for one department

  • Dim itTotal As Object = dt_Expenses.Compute("Sum(Amount)", "Department = 'IT'")
  • ' Number of open orders
  • Dim openCount As Object = dt_Orders.Compute("Count(OrderID)", "Status = 'Open'")

Compute returns an Object (or DBNull when no rows match), so convert the result before using it in arithmetic.

4. Transforming Row Values: LINQ vs. For Each Row vs. Invoke Code

When updating existing column values (e.g., trimming whitespace from every cell in a column, converting string dates to standardized ISO formats), developers must balance performance against implementation complexity:

For Each Row in Data Table Activity : Suitable when updating rows requires invoking UI elements, orchestrator queue calls, or external REST APIs. However, for pure in-memory data sanitization across 20,000+ rows, the activity execution loop introduces significant lag.

LINQ Projection into Cloned Table : Projects rows into modified structures and materializes via .CopyToDataTable() . Fast, but requires recreating row instances.

Invoke Code loop : Updates rows in place inside one activity, which avoids the per-row activity overhead of For Each Row. ' VB.NET inside Invoke Code (argument: in_Customers As DataTable, direction In)

  • For Each row As DataRow In in_Customers.Rows
  • If Not row.IsNull("Email") Then
  • row("Email") = row("Email").ToString().Trim().ToLower()
  • End If
  • If Not row.IsNull("Phone") Then
  • row("Phone") = System.Text.RegularExpressions.Regex.Replace(row("Phone").ToString(), "[^0-9]", "")
  • End If
  • Next

Warning

Do not update a DataTable from several threads at once, for example with Parallel.ForEach . Microsoft documents DataTable as safe for multithreaded reads only; concurrent writes must be synchronized or they can corrupt the table's internal indexes.

5. Merging DataTables and MissingSchemaAction Policies

The Merge Data Table activity (or native dt_Target.Merge(dt_Source) method) combines rows from a source table into a target destination table. When the schemas of both tables do not align perfectly, the MissingSchemaAction property dictates how the engine resolves discrepancies. ' Method signature

  • dt_Target.Merge(dt_Source, preserveChanges:=False, missingSchemaAction:=MissingSchemaAction.Add)
  • The Four MissingSchemaAction Enum Behaviors

MissingSchemaAction Value Schema Resolution Behavior Exception Thrown? Best Use Case

MissingSchemaAction.Add Appends missing columns from source table to target table schema; populates incoming data. No Consolidating disparate reports where all vendor-specific data fields must be preserved.

MissingSchemaAction.Ignore Discards any source columns that do not exist in the target schema. Only matching columns are transferred. No Standardizing unstructured input files into a rigid enterprise master template.

MissingSchemaAction.Error Requires the target to already have every source column. Throws an exception if the source contains extra columns. Yes Strict compliance automations where schema drift indicates an upstream file error.

MissingSchemaAction.AddWithKey Appends missing columns AND imports primary key constraints and unique index definitions from source. No Merging relational dataset snapshots where primary key uniqueness must be enforced.

The preserveChanges Parameter

When merging tables that possess a primary key, existing records are updated rather than appended. The preserveChanges boolean parameter controls row version priority:

preserveChanges = True : Retains local changes made in the target table, ignoring incoming source updates for conflicting rows.

preserveChanges = False (Default): Overwrites target table rows with incoming source data.

6. High-Performance Sorting and Deduplication with DataView

Every DataTable contains a DefaultView property returning a System.Data.DataView instance. The DataView provides high-speed native sorting, row filtering, and projection capabilities without requiring complex LINQ syntax or external loops.

In-Memory Sorting with DataView.Sort

Sorting a DataTable via its DefaultView uses the view's own index inside ADO.NET, so no workflow loop is needed. The sorted view can then be converted back to a DataTable via .ToTable() : ' VB.NET: Sort table by Priority ascending, then by Amount descending

  • dt_Transactions.DefaultView.Sort = "Priority ASC, Amount DESC"
  • Dim dt_Sorted As DataTable = dt_Transactions.DefaultView.ToTable()
  • In-Memory Filtering with DataView.RowFilter

The RowFilter property applies expression-based filtering equivalent to an SQL WHERE clause: ' VB.NET: Filter rows using RowFilter

  • dt_Transactions.DefaultView.RowFilter = "Status = 'Open' AND Amount >= 5000 AND OrderDate >= #2026-01-01#"
  • Dim dt_Filtered As DataTable = dt_Transactions.DefaultView.ToTable()
  • Column Projection and Deduplication: ToTable(isDistinct, ...)

The .ToTable() method features an overload that accepts a boolean isDistinct flag and a ParamArray of column names: ' Signature:

dt.DefaultView.ToTable(isDistinct As Boolean, ParamArray columnNames As String())

This single method call performs two critical operations simultaneously:

Column Filtering (Projection) : It extracts only the specified columns, discarding all others.

Deduplication ( Distinct ) : If isDistinct is set to True , it eliminates duplicate rows, retaining only unique combinations of the selected column values. ' VB.NET: Extract unique combinations of CustomerID and Region into a new table

Dim dt_UniqueClients As DataTable = dt_Sales.DefaultView.ToTable(True, "CustomerID", "Region")

  • ' C#: Extract unique combinations of CustomerID and Region into a new table
  • DataTable dt_UniqueClients = dt_Sales.DefaultView.ToTable(true, "CustomerID", "Region");

Tip

dt.DefaultView.ToTable(True, "Col1", "Col2") removes duplicates across a subset of columns in one call and keeps the column types, without writing a LINQ .GroupBy() query.

7. Memory Management and Enterprise Cleanup Patterns

DataTable objects can hold a large amount of managed memory, including the indexes behind views, sorting, and primary keys. In long-running unattended automations processing millions of rows, keeping large tables alive longer than needed can lead to excessive memory consumption.

Call dt.Clear() to remove all rows while retaining table schema.

Set dt = Nothing (or null in C#) once data processing is complete to allow the garbage collector to reclaim generation 2 heap memory.

When processing massive files in batches, initialize tables within localized inner scopes rather than maintaining global workflow variables.

Loading diagram... In-Memory DataTable Transformation, DataView, and Merge Pipelines