Home
Turium Algoreus
Turium Algoreus
  • Turium Algoreus Documentation
    • Turium Algoreus Overview
      • How to Guides
        • Axons (Pipeline) User Guide
          • Algoreus Genesis
          • Algoreus Node
          • Steps for a simple batch Axon in Algoreus
          • Configuring Axon in Algoreus
          • Deploying an Axon in Algoreus
          • Running an Axon in Algoreus
          • Viewing and downloading logs in the Genesis in Algoreus
          • Scheduling an Axon in Algoreus
          • Reusable Axons in Algoreus
          • Using Triggers in Algoreus
          • Working with multiple versions of the same node in Algoreus
          • Modifying a draft Axon in Algoreus
          • Editing a deployed Axon in Algoreus
          • Duplicating An Axon in Algoreus
          • Deleting an Axon in Algoreus
          • Deploying nodes from the Algoreus Hub
          • Using node templates in Algoreus
          • Exporting and importing Axons in Algoreus
          • Dynamic resource configuration in Algoreus
          • Working with namespaces in Algoreus
        • Soma (Transformation) User Guide
          • Algoreus Soma Overview
          • Algoreus Soma Concepts
          • Algoreus Soma UI components
          • Working with multiple datasets
          • Navigating between Soma and Algoreus Genesis
          • Editing a transformation created in the Soma
          • Soma data types
          • Working with connections in Soma
          • Parsing a CSV file
          • Strings Formatting
          • Sending records to error
          • Working with numbers in Soma
          • Working with Decimal types in Soma
          • Performing date transformations in Soma
          • Filtering records
          • Finding and replacing values in a column
          • Filling null or empty cells
          • Copying, deleting, and keeping columns
          • Renaming a column
          • Joining two columns
          • Swapping two column names
          • Extracting fields to retrieve values
          • Exploding fields
          • Masking data
          • Encoding records to store or transfer data
          • Decoding records to store or transfer data
          • Applying a Hashing algorithm to a column
          • Upgrading the Soma transformation node version
          • Viewing and downloading a schema in Soma
          • Viewing Soma Service logs
        • Cerebellum (Operations and Monitoring) User Guide
          • Logging and Monitoring
          • Metrics
          • Dashboard and Reports
          • Preferences and Runtime Arguments
          • Transaction Service Maintenance
        • Engram (Metadata) User Guide
          • System Metadata
          • Discovery and Lineage
          • Audit Logging
          • Metadata Management
          • Accessing Metadata Programmatically
          • Metadata Field-Level Lineage
        • Clone (Replication) User Guide
          • Cloning overview
          • Clone Concepts
          • Adding Transformations to a Cloning Job
          • Deleting a Cloning Job
          • Tutorial: Cloning data from Oracle Database to BigQuery
        • Algology (Visualisation) User Guide
          • Dashboards
            • Using Dashboards
            • Building Dashboards
            • Manage dashboards
            • Publishing Dashboard
            • Playlist
            • Create and manage reports
            • Share dashboards and panels
            • Access Dashboard Usage
            • Search Dashboards
          • Panel Editor
            • Configure Panel Options
            • Configure standard options
          • Visualisations
            • Alert List
            • Bar Chart
            • Bar Gauge
            • Candlestick Panel
            • Canvas
            • Dashboard List
            • Flame Graph
            • Gauge
            • Heatmap
            • Histogram
            • Logs
            • Node Graph
            • Traces Panel
            • Pie Chart
            • State Timeline
            • Stat Panel
            • Time series
            • Trend Panel
            • Text Panel
            • Table
            • GeoMap
            • Datagrid Panel
            • Status history
            • Annotations
          • Explore
            • Logs in Explore
            • Queries in Explore
            • Tracing in Explore
            • Inspector in Explore
    • Turium Algoreus Connectors
Powered by GitBook
On this page
  • Before you begin
  • Reading decimal type data
  • Transforming decimal data
  • Transformation Example Code Snippets

Was this helpful?

  1. Turium Algoreus Documentation
  2. Turium Algoreus Overview
  3. How to Guides
  4. Soma (Transformation) User Guide

Working with Decimal types in Soma

  • Before you begin

  • Reading decimal type data

  • Transforming decimal data

  • Transformation Example Code Snippets

This article describes how to convert fields into decimal types in Algoreus and perform transformations on them.


Before you begin

This article presumes that you have set up a Algoreus node connection to a database, file system, or another supported storage system that contains your data.


Reading decimal type data

Open an object in Algoreus.

In the case of a database or a BigQuery connection, if the table has a decimal column, Algoreus automatically converts it into a BigDecimal type.

When you create an axon from Algoreus, such a column will automatically get mapped to the Algoreus decimal type.

On the other hand, if your dataset contains non-decimal data that you want to convert into a decimal type, you can do it using the set-column directive as shown below:

set-column :decimal_column exp:{new("java.math.BigDecimal", <input column name>)}

Once this directive is executed, the column’s data type changes to BigDecimal, and similar to the previous steps, the schema also contains the appropriate data type.

Note: The <input column> can be of type String, Integer, Long, Float, or Double.

If your dataset includes values with varying scale, such as 1.05, 2.698, 5.8745512, you need to set the scale with Algoreus directive and also edit the schema in the axon to set the scale for the decimal column. To set the scale in the Algoreus, use a directive similar to the following:

set-column :ouput_col exp:{new("java.math.BigDecimal", decimal_col).setScale()}

For example, to convert a column of string called cost to decimal with a scale of 9 and output the results to a new column called output_col, use the following directive:

set-column :output_col exp:{new("java.math.BigDecimal", "cost").setScale(9)}


Transforming decimal data

Since the underlying data type for decimal columns in Algoreus is the Java BigDecimal class, you can use methods of the BigDecimal class to transform these columns, once they are converted into BigDecimal. In all the following directives, decimal_col is the decimal column that will be transformed, while output_column is the output of the operation


Transformation Example Code Snippets

  • Get the absolute value

set-column :output_col decimal_col.abs()

  • Get the precision of a decimal value

set-column :output_col decimal_col.precision()

  • Get the scale of a decimal value

set-column :output_col decimal_col.scale()

  • Get the unscaled value of a decimal value

set-column :output_col decimal_col.unscaledValue()

  • Add two decimal columns

set-column :output_col decimal_col.add(another_col)

  • Subtract a decimal from another

set-column :output_col decimal_col.subtract(another_col)

  • Multiply a decimal with another

set-column :output_col decimal_col.multiply(another_col)

  • Divide a decimal column by another and return the quotient

set-column :output_col decimal_col.divide(another_col)

  • Divide a decimal column by another and return the remainder

set-column :output_col decimal_col.remainder(another_col)

  • Convert decimal to a integer

set-column :output_col decimal_col.intValue()

  • Convert decimal to a long

set-column :output_col decimal_col.longValue()

  • Convert decimal to a float

set-column :output_col decimal_col.floatValue()

  • Convert decimal to a double

set-column :output_col decimal_col.doubleValue()

  • Check if a decimal value is equal to another

set-column :output_col decimal_col.equals(another_col)

  • Find the maximum of two decimal columns

set-column :output_col decimal_col.max(another_col)

  • Find the minimum of two decimal columns

set-column :output_col decimal_col.min(another_col)

  • Move the decimal point n places to the left

set-column :output_col decimal_col.movePointLeft(n)

  • Move the decimal point n places to the right

set-column :output_col decimal_col.movePointRight(n)

  • Get the nth power of a decimal

set-column :output_col decimal_col.pow(n)

  • Negate a decimal

set-column :output_col decimal_col.negate()

  • Strip trailing zeros in a decimal

set-column :output_col decimal_col.stripTrailingZeros()


PreviousWorking with numbers in SomaNextPerforming date transformations in Soma

Last updated 1 year ago

Was this helpful?