Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara mengonversi kolom menjadi desimal dan melakukan
transformasi pada kolom tersebut saat Anda menyiapkan data di ruang kerja Wrangler di
Cloud Data Fusion Studio.
Membuka objek, seperti tabel, dari database atau file Cloud Storage.
Untuk database atau koneksi BigQuery, jika tabel memiliki kolom desimal, Wrangler akan mengonversinya menjadi jenis BigDecimal. Saat
Anda membuat pipeline dari Wrangler, kolom tersebut akan dikonversi ke
jenis data decimal.
Jika set data Anda berisi data non-desimal yang ingin dikonversi ke
desimal, gunakan perintah set-column:
DECIMAL_COLUMN: kolom desimal yang akan
ditransformasikan. Setelah perintah dieksekusi, jenis data kolom
akan berubah menjadi BigDecimal, dan skema juga berisi
jenis data yang sesuai.
INPUT_COLUMN: kolom yang dikonversi, yang dapat berupa salah satu dari jenis berikut: STRING, INTEGER, LONG, FLOAT, atau DOUBLE.
Jika set data Anda menyertakan nilai dengan skala yang bervariasi, seperti 1,05, 2,698,
5,8745512, tetapkan skala dengan perintah Wrangler dan edit
skema dalam pipeline untuk menetapkan skala kolom desimal.
Untuk menetapkan skala di Wrangler, gunakan perintah yang mirip dengan
berikut:
Contoh berikut mengonversi kolom bernama cost dari string menjadi
desimal, menetapkan skala 9, dan menampilkan hasilnya ke kolom baru
yang disebut output-column:
Kolom desimal di Wrangler menggunakan class BigDecimal Java.
Setelah kolom dikonversi ke jenis data BigDecimal, ubah kolom dengan metode dari Class BigDecimal.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[[["\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)."]]