<?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: %%tsql magic in spark notebook in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923446#M14704</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370"&gt;@woldea&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're not meant to mix Spark and TSQL. If you're applying transformations in a Lakehouse, you can use a Spark notebook with %%pyspark or %%sql magic commands.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand, if you're applying transformation into a Warehouse, you can use a Python notebook with %%tsql magic command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jan 2026 12:04:33 GMT</pubDate>
    <dc:creator>deborshi_nag</dc:creator>
    <dc:date>2026-01-22T12:04:33Z</dc:date>
    <item>
      <title>%%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4922865#M14682</link>
      <description>&lt;P&gt;I am using fabric notebook to dynamically ingest tables from lakehouse to warehouse. I need to use pySpark as notebook default language for all the cells but I want to execute SQL code on warehouse from the same notebook . I tried to bind a variable from spark cell to SQL cell using like this :&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%%&lt;/SPAN&gt;&lt;SPAN&gt;tsql &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;artifact warehouse_name &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;type Warehouse &lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;bind upsert_query&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;EXEC&lt;/SPAN&gt;&lt;SPAN&gt;(@upsert_query);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;the magic %%tsql is not available to select with Pyspark language default. UsageError: &lt;STRONG&gt;Cell magic '%%tsql' not found.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;If I change the default language to python , I get t-sql functionality but it failed to import some modules like&amp;nbsp;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; com.microsoft.spark.fabric for other spark cells that are forced to run in pyspark using the magic&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%%pyspark . Does anyone has a workaround to handle both spark and SQL warehouse operation in the same notebook ? &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Jan 2026 20:01:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4922865#M14682</guid>
      <dc:creator>woldea</dc:creator>
      <dc:date>2026-01-21T20:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4922912#M14683</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370"&gt;@woldea&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You cannot mix TSQL and PySpark notebooks I believe.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can however mix PySpark and SparkSQL. I recommend using a SparkSQL cell to do your SQL with.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/spark-data-warehouse-connector?tabs=pyspark" target="_blank"&gt;Spark connector for Microsoft Fabric Data Warehouse - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Though generally, I find it best to do all your transformations in a lakehouse, which is easier to work with, and then move your data to a warehouse after it is all nice and pretty.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jan 2026 22:16:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4922912#M14683</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2026-01-21T22:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4922981#M14686</link>
      <description>&lt;DIV class=""&gt;Thank you tayloramy!&lt;/DIV&gt;&lt;DIV class=""&gt;I was able to convert my transformation into SQL and accomplished my goal in the warehouse cell. My question here is I want to run the python transformation in the same notebook but with a tsql command as the transformation impacts the warehouse. &amp;nbsp;From what I read, this can be achieved using %%tsql .Spark SQL still uses spark engine and cannot execute transformation in warehouse.&amp;nbsp;So, what is the use of %%tsql and how to implement it in the notebook ? What changes are needed in the notebook setting?&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Thanks&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Jan 2026 02:39:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4922981#M14686</guid>
      <dc:creator>woldea</dc:creator>
      <dc:date>2026-01-22T02:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923059#M14696</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370"&gt;@woldea&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;You can use Spark Synapse SQL connector for your usecase.&amp;nbsp;&lt;BR /&gt;adding same code for your reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# IMPORTS&lt;/P&gt;&lt;P&gt;import com.microsoft.spark.fabric&lt;BR /&gt;from com.microsoft.spark.fabric.Constants import Constants&lt;BR /&gt;&lt;BR /&gt;# Code&lt;BR /&gt;spark.read.option(Constants.DatabaseName, "&amp;lt;warehouse/lakeshouse name&amp;gt;").synapsesql("&amp;lt;T-SQL Query&amp;gt;")&lt;BR /&gt;&lt;BR /&gt;You can these docs for refernce.&amp;nbsp;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/spark-data-warehouse-connector?tabs=pyspark" target="_blank"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/spark-data-warehouse-connector?tabs=pyspark&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope this helps. Let me know if you have any other questions.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jan 2026 05:26:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923059#M14696</guid>
      <dc:creator>chetanhiwale</dc:creator>
      <dc:date>2026-01-22T05:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923446#M14704</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370"&gt;@woldea&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're not meant to mix Spark and TSQL. If you're applying transformations in a Lakehouse, you can use a Spark notebook with %%pyspark or %%sql magic commands.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand, if you're applying transformation into a Warehouse, you can use a Python notebook with %%tsql magic command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jan 2026 12:04:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923446#M14704</guid>
      <dc:creator>deborshi_nag</dc:creator>
      <dc:date>2026-01-22T12:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923844#M14713</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370"&gt;@woldea&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What you can do is use synapseSQL to interact with the warehouse directly from a Spark notebook.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THough tI stronmgly recommend doing your transformations that require spark all in a lakehouse, and then copying the final table over using a pipeline or copy job.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jan 2026 02:46:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4923844#M14713</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2026-01-23T02:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4932615#M14792</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370"&gt;@woldea&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for reaching out to Microsoft Fabric Community.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1445078"&gt;@deborshi_nag&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1340679"&gt;@tayloramy&lt;/a&gt;&amp;nbsp;for the prompt response.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As we haven’t heard back from you, we wanted to kindly follow up to&amp;nbsp;check if the solution provided by the user's for the issue worked?&amp;nbsp;or let us know if you need any further assistance.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;
&lt;P&gt;Anjan Kumar Chippa&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jan 2026 13:16:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4932615#M14792</guid>
      <dc:creator>v-achippa</dc:creator>
      <dc:date>2026-01-27T13:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: %%tsql magic in spark notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4974256#M14889</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1454370" target="_blank"&gt;@woldea&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We wanted to kindly follow up to&amp;nbsp;check if the solution provided by the user's for the issue worked?&amp;nbsp;or let us know if you need any further assistance.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;
&lt;P&gt;Anjan Kumar Chippa&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2026 18:51:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/tsql-magic-in-spark-notebook/m-p/4974256#M14889</guid>
      <dc:creator>v-achippa</dc:creator>
      <dc:date>2026-01-30T18:51:21Z</dc:date>
    </item>
  </channel>
</rss>

