Issue
I have data saved in one of view created in Azure synapse dedicated pools? I need to access this data into the jupyter notebook for further processing ? would there any way to access/extract the data from dedciated pools in jupyter notebook written in python.
Solution
The Azure Synapse Dedicated SQL Pool Connector for Apache Spark in Azure Synapse Analytics enables efficient transfer of large data sets between the Apache Spark runtime and the Dedicated SQL pool. The connector is shipped as a default library with Azure Synapse Workspace.
Sample code -
# Add required imports
import com.microsoft.spark.sqlanalytics
from com.microsoft.spark.sqlanalytics.Constants import Constants
from pyspark.sql.functions import col
# Read from existing internal table
dfToReadFromTable = (spark.read
# If `Constants.SERVER` is not provided, the `<database_name>` from the three-part table name argument
# to `synapsesql` method is used to infer the Synapse Dedicated SQL End Point.
.option(Constants.SERVER, "<sql-server-name>.sql.azuresynapse.net")
# Defaults to storage path defined in the runtime configurations
.option(Constants.TEMP_FOLDER, "abfss://<container_name>@<storage_account_name>.dfs.core.windows.net/<some_base_path_for_temporary_staging_folders>")
# Three-part table name from where data will be read.
.synapsesql("<database_name>.<schema_name>.<table_name>")
# Column-pruning i.e., query select column values.
.select("<some_column_1>", "<some_column_5>", "<some_column_n>")
# Push-down filter criteria that gets translated to SQL Push-down Predicates.
.filter(col("Title").contains("E"))
# Fetch a sample of 10 records
.limit(10))
# Show contents of the dataframe
dfToReadFromTable.show()
You can refer this link for more information
Answered By - AbhishekKhandave-MT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.