<?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: Why does soda not initialize? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/why-does-soda-not-initialize/m-p/103044#M41308</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/119002"&gt;@sakuraDev&lt;/a&gt;&amp;nbsp;is this still an ongoing issue? If so, could you please share the error stacktrace as a file attachment? Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Dec 2024 16:35:56 GMT</pubDate>
    <dc:creator>VZLA</dc:creator>
    <dc:date>2024-12-23T16:35:56Z</dc:date>
    <item>
      <title>Why does soda not initialize?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-soda-not-initialize/m-p/88912#M37660</link>
      <description>&lt;P&gt;Hey everyone, im using autoloader x soda.&lt;/P&gt;&lt;P&gt;I'm new to both,&lt;/P&gt;&lt;P&gt;The idea is to ingest with quality checks in my silver table for every batch in a continuous ingestion.&lt;/P&gt;&lt;P&gt;I tried to configure soda as str just like the docs show, but its seems that it keeps on trying to find a configuration file.&lt;/P&gt;&lt;P&gt;please feel free to comment on any bad practice if you see it:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def process_batch(df, batch_id):
    soda_config ="""
        soda_cloud:
        host: cloud.soda.io
        api_key_id: x
        api_key_secret: x
    """ #move to enviroment
    checks = """
    checks for dfSilver:
    - missing_count(site) = 0:
        name: Ensure there are no null values in the Site column
        fail: 1
        warn: 0
    - missing_count(meter) = 0:
        name: Ensure there are no null values in the Meter column
        fail: 1
        warn: 0

    - missing_count(device_time) = 0:
        name: Ensure there are no null values in the Device Time column
        fail: 1
        warn: 0

    - missing_count(energy_cumulative_active_value) = 0:
        name: Ensure there are no null values in the Cumulative Active Energy Value column
        fail: 1
        warn: 0

    - missing_count(energy_cumulative_active_unit) = 0:
        name: Ensure there are no null values in the Cumulative Active Energy Unit column
        fail: 1
        warn: 0

    - missing_count(power_instantaneous_active_value) = 0:
        name: Ensure there are no null values in the Instantaneous Active Power Value column
        fail: 1
        warn: 0

    - missing_count(power_instantaneous_active_unit) = 0:
        name: Ensure there are no null values in the Instantaneous Active Power Unit column
        fail: 1
        warn: 0

    - missing_count(power_average_active_value) = 0:
        name: Ensure there are no null values in the Average Active Power Value column
        fail: 1
        warn: 0

    - missing_count(power_average_active_unit) = 0:
        name: Ensure there are no null values in the Average Active Power Unit column
        fail: 1
        warn: 0

    - invalid(energy_cumulative_active_unit) in ("kWh"):
        name: Ensure valid units in the Active Energy Unit column
        fail: 1
        warn: 0

        """

    # Initialize the Soda Scan for each batch
    scan = Scan()
    scan.add_configuration_yaml_str(soda_config)
    scan.set_scan_definition_name("Silver Ingestion DQs")
    scan.add_sodacl_yaml_str(checks)
    scan.set_data_source_name("dfSilver")

    # Run Soda checks on the batch
    scan.execute()

    # Filter records with no null values (applying your filtering logic)
    df_filtered = df.filter(
        (~isnull(col("site"))) &amp;amp;
        (~isnull(col("meter"))) &amp;amp;
        (~isnull(col("device_time"))) &amp;amp;
        (~isnull(col("data.energy.cumulative.active.value"))) &amp;amp;
        (~isnull(col("data.energy.cumulative.active.unit"))) &amp;amp;
        (~isnull(col("data.power.instantaneous.active.value"))) &amp;amp;
        (~isnull(col("data.power.instantaneous.active.unit"))) &amp;amp;
        (~isnull(col("data.power.average.active.value"))) &amp;amp;
        (~isnull(col("data.power.average.active.unit")))
    )

    # Write the filtered data to the Silver table (or another target)
    df_filtered.write \
        .format("delta") \
        .mode("append") \
        .save(silver_table_path)



dfSilver.writeStream \
    .foreachBatch(process_batch) \
    .trigger(processingTime="1 second") \
    .start()
    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the error i get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sakuraDev_0-1725645131588.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/10995i9F119D0ACE69C3A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sakuraDev_0-1725645131588.png" alt="sakuraDev_0-1725645131588.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 17:52:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-soda-not-initialize/m-p/88912#M37660</guid>
      <dc:creator>sakuraDev</dc:creator>
      <dc:date>2024-09-06T17:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why does soda not initialize?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-soda-not-initialize/m-p/103044#M41308</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/119002"&gt;@sakuraDev&lt;/a&gt;&amp;nbsp;is this still an ongoing issue? If so, could you please share the error stacktrace as a file attachment? Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2024 16:35:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-soda-not-initialize/m-p/103044#M41308</guid>
      <dc:creator>VZLA</dc:creator>
      <dc:date>2024-12-23T16:35:56Z</dc:date>
    </item>
  </channel>
</rss>

