CTOD
  • 2 Minutes to read
  • Dark
    Light
  • PDF

CTOD

  • Dark
    Light
  • PDF

Article summary

String: CTOD

Attempts to create a new discrete field, usually by having applied a filter to a continuous string, integer or double.

Purpose

Use this function to:
  • Create a discrete field from a continuous field
  • Create a copy of a continuous field for use as a dimension in a profile
  • Create a copy of a field for use in a join
  • Turn a C (continuous) into a D (discrete)
Processing Time
CTOD can take a long time to run (i.e., upwards of 1 minute) if the following conditions are met:
  • Large number of records on the table (> 50 million)
  • Large number of discrete values (>300,000)
CTOD will fail if the number of discrete values in field A exceeds the threshold which is 300,000 by default.     The threshold can be increased by running a BuildBakedField method in script editor and setting MAX_ENTRIES up to 2 million.   However, this can increase processing time significantly, so should only be done where necessary.  

Return Value


PropertyValue
FieldTypeString  / Integer / Long(Integer) / Double 
FieldSizeLow / Med / High 
DataTypeDiscrete 
DataSizeShort / Integer / LongInteger / Double
Example Return Value: Return values are unchanged from Input value.   CTOD is not applicable for Dates or DateTimes.

CTOD_Sample


Parameters

ParameterJSONDescription
Table“targetTable”: “MyTableName”The target table on which the new field will be created
Filter“dataset”: {DataSet_JSON}Optional.   If a filter is applied, records not in the filter recordset will be returned as null.
Function"function":""String
String Function“p1”: “CTOD(A)”CTOD(A)
A“p2”:Required.   The discrete field to copy as a continuous field.
Supports:  
  • DataType: Discrete
  • Field Type: Integer, Double, String
MAX_ENTRIES
The threshold for crossing from discrete data type to continuous data type.

JSON Sample

{
  "method": "BuildBakedField",
  "targetTable": "BikeTripData",
  "overwrite": true,
  "name": "Journey_Random2",
  "function": "string",
  "p1": "CTOD(A)",
  "p2": "Journey_ID",
  "MAX_ENTRIES": 1000000,
  "project": "Model1"
}


Usage Notes

On very large tables, it may be necessary to use a filter in order to extract a discrete field from a continuous field.  In the example below, a random sampe of size 800,000 has been applied to the BikeTripData table in order to create the Journey_Random field. 

CTOD_Example1


Another approach is to use the BuildBakedField method and extend the MAX_ENTRIES threshold.   This approach should be used with care, as DataJet's threshold limits are designed to maximize performance across the application.  Having a large number of very high cardinality indexed fields (i.e., string fields above 200,000 unique values) may result in a perceptible (i.e., greater than 1 second) response time for operations such as populating the Context Panel grid.

<<TODO:   Analyse field function >>

CTOD_Example2

See Also:   

Example

ExampleDetails
DescriptionConvert a continuous string field to a discrete string
Input
  • Table: = [BikeTripData]
  • Filter: = [No Filter]
  • Function: = String
  • String Function: = CTOD(A)
  • A:= [BikeTripData].[JourneyID]
  • Name: = Journey_Random2
SampleCTOD_Example3





Was this article helpful?