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 next

...

Other 

D s item
data types
data types
 can be referenced as column references. For literal values of these data types, you can insert them into your expressions as strings. Transforms cause the resulting values to be re-inferred for their data type.

...

Column reference

A reference to the values stored in a column in your dataset.

...

Columns can be referenced by the plain-text value for the column name.

Example: value parameter references the myCol column.

D code

derive type:single value: myCol as:'myNewCol'

...

Functions

Some parameters accept functions as inputs. Where values or formulas are calculated, you can reference one of the dozens of functions available in

D s lang
.

Example:

D code

derive type:single value:MULTIPLY(3,2) as:'six'

...

Nested expressions

...

Individual parameters within a function can be computed expressions themselves. These nested expressions can be calculated using constants, other functions, and column references.

Example: Computes a column whose only value is ten divided by three, rounded to the nearest integer (3)

...

:

D code

derive type:single value:ROUND(DIVIDE(10,3),0) as:'three'

Integer

A valid integer value within the accepted range of values for the Integer datatype. For more information, see Supported Data Types.

Example: Generates a column called, my13 which is the sum of the Integer values 5 and 8:

...

D code

derive type:single value: (5 + 8) as:'my13'

Decimal

A valid floating point value within the accepted range of values for the Decimal datatype. For more information, see Supported Data Types.

Example: Generates a column of values that computes the approximate circumference of the values in the diameter column:

D code

derive type:single value: (3.14159 * diameter) as: 'circumference'

Boolean

A true or false value.

Example: If the value in the order column is more than 1,000,000, then the value in the bigOrder column is true.

D code

derive type:single value:IF(order > 1000000, true, false) as:'bigOrder'

String

A string literal value is the baseline datatype.

...

String literals must be enclosed in single quotes.

Example: Creates a column called, StringCol containing the value myString.

D code

derive type:single value:'myString' as:'StringCol'

D s item
pattern
pattern

D s product
supports a special syntax, which simplifies the generation of matching patterns for string values.

Patterns must be enclosed in accent marks ( `MyPattern`).

...

For more information, see Text Matching.

Example: Extracts up to 10 values from the MyData column that match the basic pattern for social security numbers (XXX-XX-XXXX):

D code

extract col: MyData on:`%{3}-%{2}-%{4}` limit:10

...

Regular expression

Regular expressions are a common standard for defining matching patterns. Regex is a very powerful tool but can be easily misconfigured.

Regular expressions must be enclosed in slashes ( /MyPattern/ ).

Example: Deletes all two-digit numbers from the qty column:

D code

replace col: qty on: /^\d$|^\d\d$/ with: '' global: true

Datetime

A valid date or time value that matches the requirements of the Datetime datatype. See Supported Data Types.

Datetime values can be formatted with specific formatting strings. See DATEFORMAT Function.

Example: Generates a new column containing the values from the myDate column reformatted in yyyymmdd format:

D code

derive type:single value:DATEFORMAT(myDate, 'yyyymmdd')

Array

A valid array of values matching the Array data type.

Example:

Code Block
[0,1,2,3,4,5,6,7,8]

See Supported Data Types.

Example: Generates a column with the number of elements in the listed array (7):

D code

derive type:single value: ARRAYLEN('["red", "orange", "yellow", "green", "blue", "indigo", "violet"]')

Object

A valid set of values matching the Object data type.

Example:

Code Block
{"brand":"Subaru","model":"Impreza","color","green"}

See Supported Data Types.

Example: Generates separate columns for each of the specified keys in the object ( brand, model, color), containing the corresponding value for each row:

D code

unnest col:myCol keys:'brand','model','color'

Interactions between
D s lang
 and the Application

...