<?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 How does Databricks handle registration and discovery of custom PySpark data sources in SDPs? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160948#M54964</link>
    <description>&lt;P class=""&gt;I'm working with Databricks declarative pipelines and have defined a custom PySpark data source (CDS) in its own standalone Python module. I include this module as part of the pipeline resources.&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;What I find interesting is that, even without explicitly importing this module in my pipeline code, the custom data source is registered and available when I reference it with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;spark.read.format("my_custom_source")&lt;/P&gt;&lt;P class=""&gt;I’m trying to understand how Databricks manages the registration and discovery of custom data sources in this scenario. Specifically:&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;Does Databricks automatically scan and execute code from modules included as pipeline resources&amp;nbsp;for data source registration when a custom format is referenced?&lt;/LI&gt;&lt;LI&gt;Is there any documentation or explanation for this behavior?&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;Any insights or pointers to relevant documentation would be greatly appreciated!&lt;/P&gt;&lt;P class=""&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jun 2026 11:56:06 GMT</pubDate>
    <dc:creator>mnissen1337</dc:creator>
    <dc:date>2026-06-30T11:56:06Z</dc:date>
    <item>
      <title>How does Databricks handle registration and discovery of custom PySpark data sources in SDPs?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160948#M54964</link>
      <description>&lt;P class=""&gt;I'm working with Databricks declarative pipelines and have defined a custom PySpark data source (CDS) in its own standalone Python module. I include this module as part of the pipeline resources.&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;What I find interesting is that, even without explicitly importing this module in my pipeline code, the custom data source is registered and available when I reference it with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;spark.read.format("my_custom_source")&lt;/P&gt;&lt;P class=""&gt;I’m trying to understand how Databricks manages the registration and discovery of custom data sources in this scenario. Specifically:&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;Does Databricks automatically scan and execute code from modules included as pipeline resources&amp;nbsp;for data source registration when a custom format is referenced?&lt;/LI&gt;&lt;LI&gt;Is there any documentation or explanation for this behavior?&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;Any insights or pointers to relevant documentation would be greatly appreciated!&lt;/P&gt;&lt;P class=""&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2026 11:56:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160948#M54964</guid>
      <dc:creator>mnissen1337</dc:creator>
      <dc:date>2026-06-30T11:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How does Databricks handle registration and discovery of custom PySpark data sources in SDPs?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160996#M54974</link>
      <description>&lt;P data-pm-slice="1 1 []"&gt;You're not hitting a hidden Databricks feature that scans your pipeline resources for data sources. This is just how Lakeflow Spark Declarative Pipelines runs your code.&lt;/P&gt;
&lt;P&gt;When a pipeline plans its graph, it evaluates every file you've configured as pipeline source, and it &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/python-ref" target="_blank"&gt;does that more than once across planning and the run&lt;/A&gt;. So if the module with your custom data source is one of those source files and it calls &lt;CODE&gt;spark.dataSource.register(...)&lt;/CODE&gt; at the top level, that line runs whenever the file gets evaluated. The format ends up registered without you importing anything, because the registration already happened as a side effect of the pipeline reading your source files.&lt;/P&gt;
&lt;P&gt;The line that matters is configured source file vs. everything else:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;A configured source file gets evaluated, so top-level code in it (your &lt;CODE&gt;register()&lt;/CODE&gt; call) runs on its own.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;A utility module, a wheel, or an &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/external-dependencies" target="_blank"&gt;env dependency only lands on &lt;/A&gt;&lt;CODE&gt;sys.path&lt;/CODE&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/developer/external-dependencies" target="_blank"&gt; so you can import it&lt;/A&gt;. It won't run until a source file imports it, so the registration won't happen on its own.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;On your two questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P&gt;There's no "discover and auto-register data sources" mechanism. What you're seeing falls out of the pipeline evaluating your source files, and your registration module happens to be one of them.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;The docs describe the explicit path, not this implicit one. &lt;A href="https://docs.databricks.com/aws/en/ldp/load" target="_blank"&gt;Load data in pipelines&lt;/A&gt; assumes the source "has been registered using &lt;CODE&gt;spark.dataSource.register&lt;/CODE&gt;" before you read it, and the &lt;A href="https://docs.databricks.com/aws/en/pyspark/datasources" target="_blank"&gt;PySpark custom data sources&lt;/A&gt; page shows the same explicit &lt;CODE&gt;register()&lt;/CODE&gt; call.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Two things worth planning for:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;Since the pipeline evaluates your code more than once, a top-level &lt;CODE&gt;register()&lt;/CODE&gt; can run several times. That's fine in practice, just keep top-level side effects cheap and idempotent.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;For a data source spread across several modules, the pattern SDP is happiest with is a single source file. The Databricks Labs &lt;A href="https://github.com/databrickslabs/lakeflow-community-connectors/blob/master/tools/scripts/merge_python_source.py" target="_blank"&gt;lakeflow-community-connectors&lt;/A&gt; project does this for you: it inlines the data source code into one source file and appends the &lt;CODE&gt;spark.dataSource.register(...)&lt;/CODE&gt; call. If you're importing across modules today, consolidating into one source file (or borrowing that project's approach) is the dependable route.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;What I'd do: keep the registration explicit so it doesn't ride on which file the pipeline happens to evaluate. Put &lt;CODE&gt;spark.dataSource.register(MyDataSource)&lt;/CODE&gt; in a configured source file, or import the module from one. For anything beyond a single module, the merged single-file pattern the connectors project uses is the way to go.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2026 18:17:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160996#M54974</guid>
      <dc:creator>anagilla</dc:creator>
      <dc:date>2026-06-30T18:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: How does Databricks handle registration and discovery of custom PySpark data sources in SDPs?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160999#M54976</link>
      <description>&lt;P&gt;That is a great observation! You aren't actually triggering a hidden "auto-discovery" feature for custom data sources. Instead, what you are seeing is a byproduct of how Spark Declarative Pipelines (SDPs) evaluate pipeline resources.&lt;/P&gt;&lt;P&gt;To answer your specific questions:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Does Databricks automatically scan for data source registration?&lt;/STRONG&gt; No, it doesn't actively scan for custom data sources specifically. However, when Databricks builds and plans the pipeline graph, it has to evaluate the top-level code of every Python file configured as a &lt;STRONG&gt;pipeline source&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Because your custom module is included as a source file, Databricks runs its top-level code during this graph-planning phase. Assuming your spark.dataSource.register(...) call is at the top level of that module, it gets executed automatically as a side effect of this evaluation. Therefore, by the time your main pipeline code runs, the format is already registered, making the explicit import unnecessary.&lt;/P&gt;&lt;P&gt;&lt;I&gt;(Note: This only happens for configured source files. If your module was packaged as a standard wheel dependency or utility module in your environment, it wouldn't run until explicitly imported).&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. Is there documentation for this?&lt;/STRONG&gt; There isn't specific documentation for "implicit custom data source discovery" because it technically isn't a standalone feature. The official docs for &lt;A class="" href="https://docs.databricks.com/aws/en/pyspark/datasources" target="_blank"&gt;PySpark Custom Data Sources&lt;/A&gt; assume the standard, explicit path of importing and calling spark.dataSource.register() before reading.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A quick tip for best practice:&lt;/STRONG&gt; Because pipeline planning can evaluate source files multiple times, your top-level register() call might run multiple times. While this is usually harmless, it's generally safer to keep registration explicit (e.g., importing the module and registering it in your main pipeline file) rather than relying on the side effects of file evaluation.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2026 19:50:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-databricks-handle-registration-and-discovery-of-custom/m-p/160999#M54976</guid>
      <dc:creator>aliyasingh</dc:creator>
      <dc:date>2026-06-30T19:50:19Z</dc:date>
    </item>
  </channel>
</rss>

