Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r081

D toc

Excerpt

Extracts the key values from an Object data type column and stores them in an array of String values.

D s lang vs sql

D s
snippetBasic

Column reference example:

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:keys('object1') as:'objKeys'

keys('object1')

Output: Returns an array of all of the keys found in the key-value Objects found in the object1 column.

D s
snippetSyntax

D lang syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:keys(obj_col)

keys(obj_col)


ArgumentRequired?Data TypeDescription
obj_colYString or ObjectName of column or Object literal whose keys are to be extracted into an array

D s lang notes

obj_col

Object literal or name of the Object column whose keys you want to extract into an array.

D s
snippetusage

Required?Data TypeExample Value
YesObject literal or column referencemyObj

D s
snippetExamples

Example - Basic keys example

Source:

Following dataset contains configuration blocks for individual features. These example blocks are of Object type.

Code formatting has been applied to the Object data to improve legibility.

FeatureNameConfiguration
Whiz Widget
Code Block
{
 "enabled": "true",
 "maxRows": "1000",
 "maxCols": "100"
}
Magic Button
Code Block
{
 "enabled": "false",
 "startDirectory": "/home",
 "maxDepth": "15"
}
Happy Path Finder
Code Block
{
 "enabled": "true"
}

Transformation:

The following transformation extracts the key values from the Object data in the Configuration column.

D trans
RawWrangletrue
p03Value'keys_Configuration'
Typestep
WrangleTextderive type:single value: keys(Configuration) as: 'keys_Configuration'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuekeys(Configuration)
p03NameNew column name
SearchTermNew formula

Results:

The keys_Configuration column contains the arrays of the key values.

FeatureNameConfigurationkeys_Configuration
Whiz Widget
Code Block
{
 "enabled": "true",
 "maxRows": "1000",
 "maxCols": "100"
}
Code Block
["enabled","maxRows","maxCols"]
Magic Button
Code Block
{
 "enabled": "false",
 "startDirectory": "/home",
 "maxDepth": "15"
}
Code Block
["enabled","startDirectory","maxDepth"]
Happy Path Finder
Code Block
{
 "enabled": "true"
}
Code Block
["enabled"]

Example - Create an Object of product properties

Include Page
EXAMPLE - ARRAYSTOMAP Function
EXAMPLE - ARRAYSTOMAP Function

D s also
labelnested