Skip to content

Commit 2bc5331

Browse files
committed
Helper to add pre-join computed columns
1 parent 8463096 commit 2bc5331

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

dataikuapi/dss/recipe.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,14 @@ def add_virtual_input(self, input_dataset_index):
842842
"""
843843
self.raw_virtual_inputs.append({"index": input_dataset_index})
844844

845+
def add_computed_column(self, virtual_input_index, computed_column):
846+
"""
847+
Adds a computed column to a virtual input
848+
849+
Use :class:`dataikuapi.dss.utils.DSSComputedColumn` to build the computed_column object
850+
"""
851+
self.raw_virtual_inputs[virtual_input_index]["computedColumns"].append(computed_column)
852+
845853
def add_join(self, join_type="LEFT", input1=0, input2=1):
846854
"""
847855
Adds a join between two virtual inputs. The join is initialized with no condition.

dataikuapi/dss/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def with_selected_partitions(self, ids):
4141
self.selection["selectedPartitions"] = ids
4242
return self
4343

44+
class DSSComputedColumn(object):
45+
46+
@staticmethod
47+
def formula(name, formula, type="double"):
48+
return {"expr": formula, "mode": "GREL", "name": name, "type": type}
4449

4550
class DSSFilterBuilder(object):
4651
"""

0 commit comments

Comments
 (0)