Forum Discussion
%%tsql magic in spark notebook
- 7 months ago
HI woldea ,
You can use Spark Synapse SQL connector for your usecase.
adding same code for your reference.
# IMPORTSimport com.microsoft.spark.fabric
from com.microsoft.spark.fabric.Constants import Constants
# Code
spark.read.option(Constants.DatabaseName, "<warehouse/lakeshouse name>").synapsesql("<T-SQL Query>")
You can these docs for refernce.
https://learn.microsoft.com/en-us/fabric/data-engineering/spark-data-warehouse-connector?tabs=pyspark
Hope this helps. Let me know if you have any other questions.
Hi woldea,
What you can do is use synapseSQL to interact with the warehouse directly from a Spark notebook.
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.