Page tree

Trifacta Dataprep



Contents:

   

Evaluates a String input against the Object datatype. If the input matches, the function outputs an Object value. Input can be a literal, a column of values, or a function returning String values.

After you have converted your strings to objects, if a sufficient percentage of input strings from a column are successfully converted to the other data type, the column may be retyped. 

Tip: If the column is not automatically retyped as a result of this function, you can manually set the type to Object in a subsequent recipe step.

Wrangle vs. SQL: This function is part of Wrangle , a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.


Basic Usage

parseobject(strInput)

Output: Returns the Object data type value for strInput String values.

Syntax and Arguments

parseobject(str_input)


ArgumentRequired?Data TypeDescription
str_inputYStringLiteral, name of a column, or a function returning String values to match

For more information on syntax standards, see Language Documentation Syntax Notes.

str_input

Literal, column name, or function returning String values that are to be evaluated for conversion to Object values.

  • Missing values for this function in the source data result in null values in the output.
  • Multiple columns and wildcards are not supported.

Usage Notes:


Required?Data TypeExample Value
YesString{"1","2","3"}


Examples

Tip: For additional examples, see Common Tasks.

Example - parsing strings as objects

The following table shows a series of requests for inventory on three separate products. These are rolling requests, so inventory levels in the subsequent request are decreased based on the previous request.

datereqProdIdreqValueprodAprodBprodC
5/10/21prodA1090100100
5/10/21prodC209010080
5/10/21prodA157510080
5/11/21prodB25757580
5/11/21prodA5707580
5/11/21prodC30707550
5/12/21prodB10706550

You must create a column containing the request information and the inventory level information for the requested product after the request has been fulfilled.

Transformation:

The five data columns must be nested into an Object. The generated column is called inventoryLevels.

Transformation Name Nest columns into Objects
Parameter: Columns reqProdId,reqValue,prodA,prodB,prodC
Parameter: Nest columns to Object
Parameter: New column name inventoryLevels

You can then build the inventory response column (inventoryResponse) using the FILTEROBJECT function:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula filterobject(parseobject(inventoryRequest), ['reqProdId','reqValue',reqProdId])
Parameter: New column name inventoryResponse

Results:

The inventoryResponse column contains the request information and the response information after the request has been fulfilled.

datereqProdIdreqValueprodAprodBprodCinventoryLevelsinventoryResponse
5/10/21prodA1090100100{"reqProdId":"prodA","reqValue":"10","prodA":"90","prodB":"100","prodC":"100"}{"reqProdId":"prodA","reqValue":"10","prodA":"90"}
5/10/21prodC209010080{"reqProdId":"prodC","reqValue":"20","prodA":"90","prodB":"100","prodC":"80"}{"reqProdId":"prodC","reqValue":"20","prodC":"80"}
5/10/21prodA157510080{"reqProdId":"prodA","reqValue":"15","prodA":"75","prodB":"100","prodC":"80"}{"reqProdId":"prodA","reqValue":"15","prodA":"75"}
5/11/21prodB25757580{"reqProdId":"prodB","reqValue":"25","prodA":"75","prodB":"75","prodC":"80"}{"reqProdId":"prodB","reqValue":"25","prodB":"75"}
5/11/21prodA5707580{"reqProdId":"prodA","reqValue":"5","prodA":"70","prodB":"75","prodC":"80"}{"reqProdId":"prodA","reqValue":"5","prodA":"70"}
5/11/21prodC30707550{"reqProdId":"prodC","reqValue":"30","prodA":"70","prodB":"75","prodC":"50"}{"reqProdId":"prodC","reqValue":"30","prodC":"50"}
5/12/21prodB10706550{"reqProdId":"prodB","reqValue":"10","prodA":"70","prodB":"65","prodC":"50"}{"reqProdId":"prodB","reqValue":"10","prodB":"65"}


This page has no comments.