[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eWrangler in Cloud Data Fusion automatically converts decimal columns from databases or BigQuery into \u003ccode\u003eBigDecimal\u003c/code\u003e type, which then becomes the \u003ccode\u003edecimal\u003c/code\u003e data type when a pipeline is created.\u003c/p\u003e\n"],["\u003cp\u003eNon-decimal data can be converted to decimals in Wrangler using the \u003ccode\u003eset-column\u003c/code\u003e directive with the \u003ccode\u003enew("java.math.BigDecimal", INPUT_COLUMN)\u003c/code\u003e expression, allowing the transformation of data types like \u003ccode\u003eSTRING\u003c/code\u003e, \u003ccode\u003eINTEGER\u003c/code\u003e, \u003ccode\u003eLONG\u003c/code\u003e, \u003ccode\u003eFLOAT\u003c/code\u003e, or \u003ccode\u003eDOUBLE\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eset-column\u003c/code\u003e directive in Wrangler can be used to adjust the scale of decimal values with varying precision using the \u003ccode\u003e.setScale()\u003c/code\u003e method, ensuring consistent formatting.\u003c/p\u003e\n"],["\u003cp\u003eOnce columns are converted to \u003ccode\u003eBigDecimal\u003c/code\u003e, you can apply various transformations like absolute value, precision, scale, addition, subtraction, division, and type conversions using methods from the \u003ccode\u003eClass BigDecimal\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eMultiple methods to transform decimal data are available in the \u003ccode\u003eClass BigDecimal\u003c/code\u003e using \u003ccode\u003eset-column\u003c/code\u003e directives, such as comparing values, determining the maximum or minimum of two columns, adjusting the decimal point, and calculating powers.\u003c/p\u003e\n"]]],[],null,["# Work with decimal data\n\nThis page explains how to convert fields into the decimals and perform\ntransformations on them when you prepare data in the Wrangler workspace of the\nCloud Data Fusion Studio.\n\nRead decimal data\n-----------------\n\n1. [Go to the Wrangler workspace in Cloud Data Fusion](/data-fusion/docs/concepts/wrangler-overview#navigate-to-wrangler).\n2. Open an object, such as a table, from a database or a Cloud Storage file.\n\n - For a database or a BigQuery connection, if the table has a decimal column, Wrangler converts it into a `BigDecimal` type. When you create the pipeline from Wrangler, the column is then converted to the `decimal` data type.\n - If your dataset contains non-decimal data that you want to convert to\n decimals, use the `set-column` directive:\n\n set-column : \u003cvar translate=\"no\"\u003eDECIMAL_COLUMN\u003c/var\u003e exp:{new(\"java.math.BigDecimal\", \u003cvar translate=\"no\"\u003eINPUT_COLUMN\u003c/var\u003e)}\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDECIMAL_COLUMN\u003c/var\u003e: the decimal column to be\n transformed. After the directive executes, the column's data type\n changes to `BigDecimal`, and the schema also contains the\n appropriate data type.\n\n - \u003cvar translate=\"no\"\u003eINPUT_COLUMN\u003c/var\u003e: the column that gets converted,\n which can be one of the following types: `STRING`, `INTEGER`,\n `LONG`, `FLOAT`, or `DOUBLE`.\n\n - If your dataset includes values with varying scale, such as 1.05, 2.698,\n 5.8745512, set the scale with a Wrangler directive and edit the\n schema in the pipeline to set the scale for the decimal column.\n\n To set the scale in the Wrangler, use a directive similar to the\n following: \n\n set-column : \u003cvar translate=\"no\"\u003eOUTPUT_COLUMN\u003c/var\u003e exp:{new(\"java.math.BigDecimal\", \u003cvar translate=\"no\"\u003eDECIMAL_COLUMN\u003c/var\u003e).setScale()}\n\n The following example converts a column called `cost` from a string to a\n decimal, sets a scale of 9, and outputs the results to a new column\n called `output-column`: \n\n set-column : output-column exp:{new(\"java.math.BigDecimal\", \"cost\").setScale(9)}\n\nTransform decimal data\n----------------------\n\nDecimal columns in Wrangler use the Java BigDecimal class.\nAfter the columns are converted to the BigDecimal data type, transform the\ncolumns with methods from [`Class BigDecimal`](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html).\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eOUTPUT_COLUMN\u003c/var\u003e: the column containing the output of the operation.\n- \u003cvar translate=\"no\"\u003eDECIMAL_COLUMN\u003c/var\u003e: the decimal column that's transformed.\n- \u003cvar translate=\"no\"\u003eDECIMAL_COLUMN_2\u003c/var\u003e: the second decimal column included in the operation, such as when you add the values from two decimal columns together.\n\nWhat's next\n-----------\n\n- Learn more about [Wrangler directives](/data-fusion/docs/concepts/wrangler-overview#apply_directives)."]]