<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Snowflake Data Formatting Issue in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/snowflake-data-formatting-issue/m-p/41117#M775</link>
    <description>&lt;P&gt;explicit casting seems like the way to go.&lt;BR /&gt;First try with one column, to see if that solves your issue.&lt;BR /&gt;If so, you can write a function that casts all decimal columns to a certain precision, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def convert_decimal_precision_scale(df, precision, scale):
    # Iterate through each column and convert decimal columns to the specified precision and scale
    for column in df.columns:
        data_type = df.schema[column].dataType
        if isinstance(data_type, DecimalType):
            df = df.withColumn(column, col(column).cast(DecimalType(precision, scale)))
    return df&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2023 08:25:58 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2023-08-23T08:25:58Z</dc:date>
    <item>
      <title>Snowflake Data Formatting Issue</title>
      <link>https://community.databricks.com/t5/get-started-discussions/snowflake-data-formatting-issue/m-p/41089#M771</link>
      <description>&lt;P&gt;I'm loading snowflake data to delta tables in databricks, few columns in snowflake data have datatype as Number (20,7) after loading to delta table it is taking as decimal (20,7), for example, if the value is 0.0000000 in snowflake then it is showing as 0E-7 in delta table, but i need it as 0.0000000 in delta table, I can't perform formatting function because there are many columns with data type as Number and with different decimal ranges, Please suggest how can I load it as 0.0000000&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 06:20:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/snowflake-data-formatting-issue/m-p/41089#M771</guid>
      <dc:creator>rohithmalla</dc:creator>
      <dc:date>2023-08-23T06:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Snowflake Data Formatting Issue</title>
      <link>https://community.databricks.com/t5/get-started-discussions/snowflake-data-formatting-issue/m-p/41117#M775</link>
      <description>&lt;P&gt;explicit casting seems like the way to go.&lt;BR /&gt;First try with one column, to see if that solves your issue.&lt;BR /&gt;If so, you can write a function that casts all decimal columns to a certain precision, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def convert_decimal_precision_scale(df, precision, scale):
    # Iterate through each column and convert decimal columns to the specified precision and scale
    for column in df.columns:
        data_type = df.schema[column].dataType
        if isinstance(data_type, DecimalType):
            df = df.withColumn(column, col(column).cast(DecimalType(precision, scale)))
    return df&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 08:25:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/snowflake-data-formatting-issue/m-p/41117#M775</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-08-23T08:25:58Z</dc:date>
    </item>
  </channel>
</rss>

