Kickstart your Apache Spark learning in Azure Synapse with immediately available samples

Published Dec 18 2020 09:00 AM 4,667 Views
Microsoft

Apache Spark has been a long-time favorite tool amongst data engineers and data scientists; it is well known for handling large scale data processing and complex machine learning workloads.

 

Azure Synapse Analytics offers a fully managed and integrated Apache Spark experience. By leveraging Apache Spark in Azure Synapse, you can benefit from integrated security, fully managed provisioning, and tight-coupling to other Azure services, such as SQL databases (dedicated and serverless), Azure Key Vault , ADLS Gen2, and Azure Blob Storage as well as fast starting, high performance compute instances.

 

Deploying an Apache Spark pool from the Synapse Studio

In the Synapse Studio, access the Manage Hub by selecting the briefcase icon in the left menu. In the blade menu, select Apache Spark pools from beneath the Analytics pools heading. In the toolbar of the Apache Spark pool screen, select the + New button.

 

image.png

In the Manage Hub, Apache Spark pools screen, the + New button is selected.

 

The Create Apache Spark pool blade will display on the right side of the screen. In this form, the only value you must enter is the Apache Spark pool name field. Enter your desired name and let the rest of the fields retain their default values. Select the Review + Create button, and after validation has succeeded, select Create.

 
 

image.png

The Create Apache Spark pool form is shown.

 

In a few moments, the newly created Apache Spark pool will display in the Apache Spark pool screen listing. Notice how fast and easy it was to get started using Apache Spark in Azure Synapse.

 

image.png

The new Apache Spark Pool is shown in the listing.

 

Learning Apache Spark using Knowledge Center samples

If you are new to Apache Spark, the Knowledge Center directly available in Azure Synapse contains fully functional samples that you can quickly deploy into your workspace to kickstart your learning process. To access the Knowledge Center, expand the ? menu located next to your user account information in the Synapse Studio header, and select the Knowledge center item.

 

image.png

The question mark menu is expanded in the header with the Knowledge center item selected.

 

In the Knowledge Center, select the Use samples immediately card.

 

image.png

In the Knowledge center screen, the Use samples immediately card is selected.

 

The Use samples immediately blade will display on the screen’s right. Select the Explore sample data with Spark item.

 

image.png

The Use samples immediately blade is shown with the Explore sample data with Spark item selected.

 

The Knowledge center will then deploy a notebook named Explore sample data with Spark in the Develop Hub, and if your permissions allow it, it will also create a new Apache Spark pool named SampleSpark.

 

After the sample’s deployment is complete, Synapse Studio will redirect you to the Develop Hub with the sample notebook open. A notebook is a collection of cells, some containing text (markdown) and others containing executable code. The sample notebook is not published (saved) by default. If you wish to keep the notebook, select the Publish all button in the Synapse Studio toolbar.

 

image.png

The Publish all button is shown in the toolbar.

 

The Explore sample data with Spark notebook will walk you loading, interpreting, aggregating, and visualizing NYC Yellow Taxi data obtained from Azure Open Datasets.

 

Let’s do a quick exploration of the toolbar of the notebook. The + Cell menu expands to provide the options of adding a code cell or text cell to the current notebook. The Run all button will execute all code cells in the order they appear in the notebook. The Publish button will save the current notebook in your workspace. The Attach to field lists the Spark pool options available in your environment. You can set this to either the Spark pool we created earlier or the SampleSpark pool created when the Knowledge center deployed the sample. The Language field indicates the primary/default language of the notebook. It’s important to note that you can mix and match languages in a single notebook using magic commands in a cell.

 

 

image.png

The Spark notebook toolbar is shown with each menu expanded.

 

Directly below the notebook toolbar is a secondary toolbar that displays the current state of the Spark session. The Spark session will start once a code cell in the notebook executes or the Run all button is selected. It takes a few minutes for the Spark session to be provisioned and started.

 

image.png

The Spark notebook Session toolbar is shown in a Not started state.

 

When the Spark session reaches the Ready state, you can hover over the status and view how much time you have left before the session expires. Every time code executes in the notebook, this timer resets. This timeout is a cost-saving measure to deprovision unused compute resources.

 

image.png

The Spark notebook Session toolbar is shown in a Ready state with the timeout tooltip showing.

 

On the Spark session toolbar’s right, you will find a Stop session button that immediately stops the current section and releases the associated Spark resources and a Configure session (gear) button that allows you to modify settings such as Session timeout.

 

image.png

The right hand side of the Spark Session toolbar is shown with the Stop Session and Configure Session buttons.

 

image.png

The Configure session blade is shown.

 

When you enter a code cell in the notebook, it becomes the active cell. A Run cell button appears in the margin space on the cell’s left-hand side. Selecting this button executes the code in the cell. Directly below the code, the Job execution details and output of the code displays.

 

Click on the sample notebook’s first code cell (labeled Cell 3) to enter the cell. The code in this cell imports the NYC Yellow Taxi dataset from Azure Open Datasets. It then retrieves all data between a start and end date from that dataset and loads it into a dataframe. Select the Run cell button in the left margin of the cell to execute the code. If the session has not already started this can take 2-3 min, however once its started the cell will execute in a few moments andthe output of the code displays beneath the cell. This cell does not have any printed output; however, you can expand the Job execution section in the output to see the details of the execution.

 

image.png

Cell 3 of the notebook is displayed with its associated output

 

The next code cell in the notebook (Cell 5) executes the printSchema command on the dataframe loaded with the data from the NYC Yellow Taxi dataset. Execute the cell’s code and observe the data’s schema/structure is printed in the output section.

 

image.png

Cell 5 of the notebook is displayed with its associated output

 

In Cell 6, the first line of code imports a SQL function library so you can execute queries against the dataframe. The next line of code performs an aggregation query against the original dataset and calculates the average trip distance and total trip distance grouped by the passenger count. A new dataframe gets created with the results of this query. The last line of code displays this new dataframe in the cell’s output, defaulting the view to display the data in a tabular format.

 

image.png

Cell 6 of the notebook is displayed with its associated output in tabular format.

 

In the output for Cell 6, toggle the View field to the Chart setting to see the resulting data in a chart format. The icon on the top right of the chart allows you to change the type of chart and its settings.

 

image.png

Cell 6 of the notebook is displayed with its associated output in chart format.

 

You are not limited to using the built-in charting functionality to visualize your data. You can import many popular data visualization libraries, including Matplotlib, Bokeh, and Seaborn. There is a long list of libraries automatically included with Apache Spark pools in Azure Synapse.

 

Alternatively, you can manage the libraries available to an Apache Spark pool by uploading a requirements.txt file in pip freeze format that lists the desired libraries along with the specific version information. All libraries must be available from the PyPi package index.

 

Moving along to Cell 8 in the sample notebook, you will find code that leverages the Matplotlib and Seaborn libraries to plot a line chart with the same aggregated data shown in Cell 6.

 

image.png

Cell 8 of the sample notebook is displayed with its associated output in chart format.

 

Creating a shared Apache Spark pool

Due to the deep integration of Azure Synapse Analytics services, we can easily share data between. We will create a Spark pool that can be shared not only with current and future Spark pools but with the serverless SQL pool engine as well.

 

Recall that in Cell 6 of the Explore sample data with Spark notebook, we’ve already created a dataframe (df_nyc) based on an aggregation query against the NYC Yellow Taxi data obtained from Azure Open Datasets. It would be great to share this data with the serverless SQL capabilities found in Azure Synapse. To implement this, add a new code cell to the current notebook, and add the following code to create a Spark database.

 

spark.sql("CREATE DATABASE IF NOT EXISTS NycAggregates")

Next, we’ll add our data into a table in this shared database. Append the following code to the same cell to write the contents of the df_nyc dataframe to a table in the NycAggregates database, then run the cell.

 

df_nyc.write.mode("overwrite").saveAsTable("NycAggregates.PassengerCountAggregates")
 

image.png

The code mentioned above is shown in a cell with its associated output.

 

From the left menu of Synapse Studio, select the Data Hub, which is identified by the cylinder icon. In the Data blade, expand the Databases section, and you will see the nycaggregates Spark database listed. Expand the database node as well as the Tables folder. There you will find the passengercountaggregates table. Next to this table, open the Actions menu, and select New SQL script, then Select TOP 100 rows.

 

image.png

The passengercountaggregates table actions menu is expanded with New SQL script and Select TOP 100 rows selected.

 

A new SQL script tab displays populated with a query to retrieve the data from the table we created from the df_nyc dataframe in the notebook. Note that the SQL script toolbar is pre-populated to connect to the Built-in serverless SQL pool, and the database selected is the one that we created in the notebook (nycaggregates). Select the Run button in the query tab toolbar to view the results of the query. Observe that similar to the notebook experience; you also can toggle the View from Table to a Chart visualization.

 

image.png

The query and the tabular result of the Select TOP 100 query on the passengercountaggregates is shown.

 

Clean up

Let’s take a moment now to remove the items created during this tutorial. Add a new code cell to the Explore sample data with Spark notebook, add the following code, and run the cell to delete the Spark table and database that we created.

 

spark.sql("DROP TABLE IF EXISTS NycAggregates.PassengerCountAggregates")
spark.sql("DROP DATABASE IF EXISTS NycAggregates")

Access the Data Hub (cylinder icon) from the left menu, and in the Data blade, expand the Databases section. Open the Actions menu next to the nycaggregates database and select Delete.

 

image.png

The Actions menu next to the nycaggregates database is expanded with Delete selected.

 

To delete the notebook, select the Develop Hub (paper icon) from the left menu, and in the Develop blade, expand the Notebooks section. Open the Actions menu next to the Explore sample data with Spark notebook and select Delete.

 

image.png

The Actions menu next to the sample notebook is expanded with Delete selected.

 

Next, select the Manage Hub (briefcase icon) from the left menu of Synapse Studio. Then in the blade menu, select Apache Spark pools. In the Apache Spark pool listing, hover over the row for the SampleSpark item, then expand the ellipsis () menu and select Delete.

 

image.png

The ellipsis menu is expanded on a Spark pool with the Delete item selected.

 

Repeat the same steps for the Spark pool you created in the first exercise.

Conclusion

In this post, we explored some of the capabilities of Apache Spark in Azure Synapse. We created an Apache Spark pool from the Synapse Studio and deployed a ready-to-use sample notebook from the Knowledge Center that leveraged taxi data from Azure Open Datasets. We walked through each of the code cells in the notebook and learned how to read data, perform queries, and investigate some data visualization options. We then created a shared Spark pool and table populated with our dataframe’s data and queried it using a serverless SQL pool.

 

Try out this tutorial today by creating an Azure Synapse workspace with a dedicated SQL pool.

- Euan Garden, Principal Program Manager, Azure Synapse

image.png

%3CLINGO-SUB%20id%3D%22lingo-sub-1988136%22%20slang%3D%22en-US%22%3EKickstart%20your%20Apache%20Spark%20learning%20in%20Azure%20Synapse%20with%20immediately%20available%20samples%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1988136%22%20slang%3D%22en-US%22%3E%3CP%3EApache%20Spark%20has%20been%20a%20long-time%20favorite%20tool%20amongst%20data%20engineers%20and%20data%20scientists%3B%20it%20is%20well%20known%20for%20handling%20large%20scale%20data%20processing%20and%20complex%20machine%20learning%20workloads.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAzure%20Synapse%20Analytics%20offers%20a%20fully%20managed%20and%20integrated%20Apache%20Spark%20experience.%20By%20leveraging%20Apache%20Spark%20in%20Azure%20Synapse%2C%20you%20can%20benefit%20from%20integrated%20security%2C%20fully%20managed%20provisioning%2C%20and%20tight-coupling%20to%20other%20Azure%20services%2C%20such%20as%20SQL%20databases%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fspark%2Fsynapse-spark-sql-pool-import-export%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ededicated%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql%2Fdevelop-storage-files-spark-tables%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eserverless%3C%2FA%3E)%2C%20Azure%20Key%20Vault%20%2C%20ADLS%20Gen2%2C%20and%20Azure%20Blob%20Storage%20as%20well%20as%20fast%20starting%2C%20high%20performance%20compute%20instances.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--557555050%22%20id%3D%22toc-hId--557555053%22%3E%3CA%20target%3D%22_blank%22%20name%3D%22Xca5ce72d4e05e86755f474165fddec43a98f14a%22%3E%3C%2FA%3EDeploying%20an%20Apache%20Spark%20pool%20from%20the%20Synapse%20Studio%3C%2FH2%3E%0A%3CP%3EIn%20the%20Synapse%20Studio%2C%20access%20the%20%3CSTRONG%3EManage%20Hub%3C%2FSTRONG%3E%20by%20selecting%20the%20briefcase%20icon%20in%20the%20left%20menu.%20In%20the%20blade%20menu%2C%20select%20%3CSTRONG%3EApache%20Spark%20pools%3C%2FSTRONG%3E%20from%20beneath%20the%20%3CSTRONG%3EAnalytics%20pools%3C%2FSTRONG%3E%20heading.%20In%20the%20toolbar%20of%20the%20%3CSTRONG%3EApache%20Spark%20pool%3C%2FSTRONG%3E%20screen%2C%20select%20the%20%3CSTRONG%3E%2B%20New%3C%2FSTRONG%3E%20button.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240829i5CCE268B5271BB4A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EIn%20the%20Manage%20Hub%2C%20Apache%20Spark%20pools%20screen%2C%20the%20%2B%20New%20button%20is%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3ECreate%20Apache%20Spark%20pool%3C%2FSTRONG%3E%20blade%20will%20display%20on%20the%20right%20side%20of%20the%20screen.%20In%20this%20form%2C%20the%20only%20value%20you%20must%20enter%20is%20the%20%3CSTRONG%3EApache%20Spark%20pool%20name%3C%2FSTRONG%3E%20field.%20Enter%20your%20desired%20name%20and%20let%20the%20rest%20of%20the%20fields%20retain%20their%20default%20values.%20Select%20the%20%3CSTRONG%3EReview%20%2B%20Create%3C%2FSTRONG%3E%20button%2C%20and%20after%20validation%20has%20succeeded%2C%20select%20%3CSTRONG%3ECreate%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240830i198BB99013409B51%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Create%20Apache%20Spark%20pool%20form%20is%20shown.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20a%20few%20moments%2C%20the%20newly%20created%20Apache%20Spark%20pool%20will%20display%20in%20the%20%3CSTRONG%3EApache%20Spark%20pool%3C%2FSTRONG%3E%20screen%20listing.%20Notice%20how%20fast%20and%20easy%20it%20was%20to%20get%20started%20using%20Apache%20Spark%20in%20Azure%20Synapse.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240831i1457E64816555D49%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20new%20Apache%20Spark%20Pool%20is%20shown%20in%20the%20listing.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1929957783%22%20id%3D%22toc-hId-1929957780%22%3ELearning%20Apache%20Spark%20using%20Knowledge%20Center%20samples%3C%2FH2%3E%0A%3CP%3EIf%20you%20are%20new%20to%20Apache%20Spark%2C%20the%20Knowledge%20Center%20directly%20available%20in%20Azure%20Synapse%20contains%20fully%20functional%20samples%20that%20you%20can%20quickly%20deploy%20into%20your%20workspace%20to%20kickstart%20your%20learning%20process.%20To%20access%20the%20Knowledge%20Center%2C%20expand%20the%20%3CSTRONG%3E%3F%3C%2FSTRONG%3E%20menu%20located%20next%20to%20your%20user%20account%20information%20in%20the%20Synapse%20Studio%20header%2C%20and%20select%20the%20%3CSTRONG%3EKnowledge%20center%3C%2FSTRONG%3E%20item.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240832i1C7C9019F4791B87%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20question%20mark%20menu%20is%20expanded%20in%20the%20header%20with%20the%20Knowledge%20center%20item%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20Knowledge%20Center%2C%20select%20the%20%3CSTRONG%3EUse%20samples%20immediately%3C%2FSTRONG%3E%20card.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_5%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240833i5E298AD4D867D705%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EIn%20the%20Knowledge%20center%20screen%2C%20the%20Use%20samples%20immediately%20card%20is%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3EUse%20samples%20immediately%3C%2FSTRONG%3E%20blade%20will%20display%20on%20the%20screen%E2%80%99s%20right.%20Select%20the%20%3CSTRONG%3EExplore%20sample%20data%20with%20Spark%3C%2FSTRONG%3E%20item.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_6%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240834iA728D9C286439BCB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Use%20samples%20immediately%20blade%20is%20shown%20with%20the%20Explore%20sample%20data%20with%20Spark%20item%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Knowledge%20center%20will%20then%20deploy%20a%20notebook%20named%20%3CSTRONG%3EExplore%20sample%20data%20with%20Spark%3C%2FSTRONG%3E%20in%20the%20Develop%20Hub%2C%20and%20if%20your%20permissions%20allow%20it%2C%20it%20will%20also%20create%20a%20new%20Apache%20Spark%20pool%20named%20%3CSTRONG%3ESampleSpark%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20the%20sample%E2%80%99s%20deployment%20is%20complete%2C%20Synapse%20Studio%20will%20redirect%20you%20to%20the%20Develop%20Hub%20with%20the%20sample%20notebook%20open.%20A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fspark%2Fapache-spark-development-using-notebooks%3Ftabs%3Dclassical%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Enotebook%3C%2FA%3E%20is%20a%20collection%20of%20cells%2C%20some%20containing%20text%20(markdown)%20and%20others%20containing%20executable%20code.%20The%20sample%20notebook%20is%20not%20published%20(saved)%20by%20default.%20If%20you%20wish%20to%20keep%20the%20notebook%2C%20select%20the%20%3CSTRONG%3EPublish%20all%3C%2FSTRONG%3E%20button%20in%20the%20Synapse%20Studio%20toolbar.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_7%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240835i7B52BA205F1EB72F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Publish%20all%20button%20is%20shown%20in%20the%20toolbar.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3EExplore%20sample%20data%20with%20Spark%3C%2FSTRONG%3E%20notebook%20will%20walk%20you%20loading%2C%20interpreting%2C%20aggregating%2C%20and%20visualizing%20NYC%20Yellow%20Taxi%20data%20obtained%20from%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fopen-datasets%2Fcatalog%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Open%20Datasets%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20do%20a%20quick%20exploration%20of%20the%20toolbar%20of%20the%20notebook.%20The%20%3CSTRONG%3E%2B%20Cell%3C%2FSTRONG%3E%20menu%20expands%20to%20provide%20the%20options%20of%20adding%20a%20code%20cell%20or%20text%20cell%20to%20the%20current%20notebook.%20The%20%3CSTRONG%3ERun%20all%3C%2FSTRONG%3E%20button%20will%20execute%20all%20code%20cells%20in%20the%20order%20they%20appear%20in%20the%20notebook.%20The%20%3CSTRONG%3EPublish%3C%2FSTRONG%3E%20button%20will%20save%20the%20current%20notebook%20in%20your%20workspace.%20The%20%3CSTRONG%3EAttach%20to%3C%2FSTRONG%3E%20field%20lists%20the%20Spark%20pool%20options%20available%20in%20your%20environment.%20You%20can%20set%20this%20to%20either%20the%20Spark%20pool%20we%20created%20earlier%20or%20the%20%3CSTRONG%3ESampleSpark%3C%2FSTRONG%3E%20pool%20created%20when%20the%20Knowledge%20center%20deployed%20the%20sample.%20The%20%3CSTRONG%3ELanguage%3C%2FSTRONG%3E%20field%20indicates%20the%20primary%2Fdefault%20language%20of%20the%20notebook.%20It%E2%80%99s%20important%20to%20note%20that%20you%20can%20mix%20and%20match%20languages%20in%20a%20single%20notebook%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fspark%2Fapache-spark-development-using-notebooks%3Ftabs%3Dclassical%23magic-commands%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Emagic%20commands%3C%2FA%3E%20in%20a%20cell.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_8%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240836i8C3C9660FE9D4FBB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Spark%20notebook%20toolbar%20is%20shown%20with%20each%20menu%20expanded.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDirectly%20below%20the%20notebook%20toolbar%20is%20a%20secondary%20toolbar%20that%20displays%20the%20current%20state%20of%20the%20Spark%20session.%20The%20Spark%20session%20will%20start%20once%20a%20code%20cell%20in%20the%20notebook%20executes%20or%20the%20%3CSTRONG%3ERun%20all%3C%2FSTRONG%3E%20button%20is%20selected.%20It%20takes%20a%20few%20minutes%20for%20the%20Spark%20session%20to%20be%20provisioned%20and%20started.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_9%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240837iE93368587CF64E13%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Spark%20notebook%20Session%20toolbar%20is%20shown%20in%20a%20Not%20started%20state.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20the%20Spark%20session%20reaches%20the%20Ready%20state%2C%20you%20can%20hover%20over%20the%20status%20and%20view%20how%20much%20time%20you%20have%20left%20before%20the%20session%20expires.%20Every%20time%20code%20executes%20in%20the%20notebook%2C%20this%20timer%20resets.%20This%20timeout%20is%20a%20cost-saving%20measure%20to%20deprovision%20unused%20compute%20resources.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_10%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240838i60D4BA656AA23FD8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Spark%20notebook%20Session%20toolbar%20is%20shown%20in%20a%20Ready%20state%20with%20the%20timeout%20tooltip%20showing.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20the%20Spark%20session%20toolbar%E2%80%99s%20right%2C%20you%20will%20find%20a%20%3CSTRONG%3EStop%20session%3C%2FSTRONG%3E%20button%20that%20immediately%20stops%20the%20current%20section%20and%20releases%20the%20associated%20Spark%20resources%20and%20a%20%3CSTRONG%3EConfigure%20session%3C%2FSTRONG%3E%20(gear)%20button%20that%20allows%20you%20to%20modify%20settings%20such%20as%20%3CSTRONG%3ESession%20timeout%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_11%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240839i8CBA0005BC305522%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20right%20hand%20side%20of%20the%20Spark%20Session%20toolbar%20is%20shown%20with%20the%20Stop%20Session%20and%20Configure%20Session%20buttons.%3C%2FEM%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_12%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20370px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240841i0BA8DBEF496385B7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Configure%20session%20blade%20is%20shown.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20you%20enter%20a%20code%20cell%20in%20the%20notebook%2C%20it%20becomes%20the%20active%20cell.%20A%20%3CSTRONG%3ERun%20cell%3C%2FSTRONG%3E%20button%20appears%20in%20the%20margin%20space%20on%20the%20cell%E2%80%99s%20left-hand%20side.%20Selecting%20this%20button%20executes%20the%20code%20in%20the%20cell.%20Directly%20below%20the%20code%2C%20the%20Job%20execution%20details%20and%20output%20of%20the%20code%20displays.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EClick%20on%20the%20sample%20notebook%E2%80%99s%20first%20code%20cell%20(labeled%20Cell%203)%20to%20enter%20the%20cell.%20The%20code%20in%20this%20cell%20imports%20the%20NYC%20Yellow%20Taxi%20dataset%20from%20Azure%20Open%20Datasets.%20It%20then%20retrieves%20all%20data%20between%20a%20start%20and%20end%20date%20from%20that%20dataset%20and%20loads%20it%20into%20a%20dataframe.%20Select%20the%20%3CSTRONG%3ERun%20cell%3C%2FSTRONG%3E%20button%20in%20the%20left%20margin%20of%20the%20cell%20to%20execute%20the%20code.%20If%20the%20session%20has%20not%20already%20started%20this%20can%20take%202-3%20min%2C%20however%20once%20its%20started%20the%20cell%20will%20execute%20in%20a%20few%20moments%20andthe%20output%20of%20the%20code%20displays%20beneath%20the%20cell.%20This%20cell%20does%20not%20have%20any%20printed%20output%3B%20however%2C%20you%20can%20expand%20the%20%3CSTRONG%3EJob%20execution%3C%2FSTRONG%3E%20section%20in%20the%20output%20to%20see%20the%20details%20of%20the%20execution.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_13%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240842i3AA47808DA41F91E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3ECell%203%20of%20the%20notebook%20is%20displayed%20with%20its%20associated%20output%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20next%20code%20cell%20in%20the%20notebook%20(Cell%205)%20executes%20the%20printSchema%20command%20on%20the%20dataframe%20loaded%20with%20the%20data%20from%20the%20NYC%20Yellow%20Taxi%20dataset.%20Execute%20the%20cell%E2%80%99s%20code%20and%20observe%20the%20data%E2%80%99s%20schema%2Fstructure%20is%20printed%20in%20the%20output%20section.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_14%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240843i3FCFD6252D2CB4BA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3ECell%205%20of%20the%20notebook%20is%20displayed%20with%20its%20associated%20output%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Cell%206%2C%20the%20first%20line%20of%20code%20imports%20a%20SQL%20function%20library%20so%20you%20can%20execute%20queries%20against%20the%20dataframe.%20The%20next%20line%20of%20code%20performs%20an%20aggregation%20query%20against%20the%20original%20dataset%20and%20calculates%20the%20average%20trip%20distance%20and%20total%20trip%20distance%20grouped%20by%20the%20passenger%20count.%20A%20new%20dataframe%20gets%20created%20with%20the%20results%20of%20this%20query.%20The%20last%20line%20of%20code%20displays%20this%20new%20dataframe%20in%20the%20cell%E2%80%99s%20output%2C%20defaulting%20the%20view%20to%20display%20the%20data%20in%20a%20tabular%20format.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_15%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240844i8C726554B7D365E2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3ECell%206%20of%20the%20notebook%20is%20displayed%20with%20its%20associated%20output%20in%20tabular%20format.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20output%20for%20Cell%206%2C%20toggle%20the%20%3CSTRONG%3EView%3C%2FSTRONG%3E%20field%20to%20the%20%3CSTRONG%3EChart%3C%2FSTRONG%3E%20setting%20to%20see%20the%20resulting%20data%20in%20a%20chart%20format.%20The%20icon%20on%20the%20top%20right%20of%20the%20chart%20allows%20you%20to%20change%20the%20type%20of%20chart%20and%20its%20settings.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_16%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240845i13D17C4763684BC4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3ECell%206%20of%20the%20notebook%20is%20displayed%20with%20its%20associated%20output%20in%20chart%20format.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20are%20not%20limited%20to%20using%20the%20built-in%20charting%20functionality%20to%20visualize%20your%20data.%20You%20can%20import%20many%20popular%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fspark%2Fapache-spark-data-visualization%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edata%20visualization%20libraries%2C%3C%2FA%3E%20including%20Matplotlib%2C%20Bokeh%2C%20and%20Seaborn.%20There%20is%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fspark%2Fapache-spark-version-support%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elong%20list%20of%20libraries%3C%2FA%3E%20automatically%20included%20with%20Apache%20Spark%20pools%20in%20Azure%20Synapse.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlternatively%2C%20you%20can%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fspark%2Fapache-spark-azure-portal-add-libraries%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Emanage%20the%20libraries%3C%2FA%3E%20available%20to%20an%20Apache%20Spark%20pool%20by%20uploading%20a%20requirements.txt%20file%20in%20pip%20freeze%20format%20that%20lists%20the%20desired%20libraries%20along%20with%20the%20specific%20version%20information.%20All%20libraries%20must%20be%20available%20from%20the%20%3CA%20href%3D%22https%3A%2F%2Fpypi.org%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EPyPi%20package%20index%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMoving%20along%20to%20Cell%208%20in%20the%20sample%20notebook%2C%20you%20will%20find%20code%20that%20leverages%20the%20Matplotlib%20and%20Seaborn%20libraries%20to%20plot%20a%20line%20chart%20with%20the%20same%20aggregated%20data%20shown%20in%20Cell%206.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_17%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240847i60F06D6017C9171C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3ECell%208%20of%20the%20sample%20notebook%20is%20displayed%20with%20its%20associated%20output%20in%20chart%20format.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-122503320%22%20id%3D%22toc-hId-122503317%22%3ECreating%20a%20shared%20Apache%20Spark%20pool%3C%2FH2%3E%0A%3CP%3EDue%20to%20the%20deep%20integration%20of%20Azure%20Synapse%20Analytics%20services%2C%20we%20can%20easily%20share%20data%20between.%20We%20will%20create%20a%20Spark%20pool%20that%20can%20be%20shared%20not%20only%20with%20current%20and%20future%20Spark%20pools%20but%20with%20the%20serverless%20SQL%20pool%20engine%20as%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERecall%20that%20in%20Cell%206%20of%20the%20%3CSTRONG%3EExplore%20sample%20data%20with%20Spark%3C%2FSTRONG%3E%20notebook%2C%20we%E2%80%99ve%20already%20created%20a%20dataframe%20(%3CSTRONG%3Edf_nyc%3C%2FSTRONG%3E)%20based%20on%20an%20aggregation%20query%20against%20the%20NYC%20Yellow%20Taxi%20data%20obtained%20from%20Azure%20Open%20Datasets.%20It%20would%20be%20great%20to%20share%20this%20data%20with%20the%20serverless%20SQL%20capabilities%20found%20in%20Azure%20Synapse.%20To%20implement%20this%2C%20add%20a%20new%20code%20cell%20to%20the%20current%20notebook%2C%20and%20add%20the%20following%20code%20to%20create%20a%20Spark%20database.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CSPAN%3Espark.sql(%3C%2FSPAN%3E%3CSPAN%3E%22CREATE%26nbsp%3BDATABASE%26nbsp%3BIF%26nbsp%3BNOT%26nbsp%3BEXISTS%26nbsp%3BNycAggregates%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%3ENext%2C%20we%E2%80%99ll%20add%20our%20data%20into%20a%20table%20in%20this%20shared%20database.%20Append%20the%20following%20code%20to%20the%20same%20cell%20to%20write%20the%20contents%20of%20the%20df_nyc%20dataframe%20to%20a%20table%20in%20the%20NycAggregates%20database%2C%20then%20run%20the%20cell.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CSPAN%3Edf_nyc.write.mode(%3C%2FSPAN%3E%3CSPAN%3E%22overwrite%22%3C%2FSPAN%3E%3CSPAN%3E).saveAsTable(%3C%2FSPAN%3E%3CSPAN%3E%22NycAggregates.PassengerCountAggregates%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_18%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240850i851AA9A1EB96E4C3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20code%20mentioned%20above%20is%20shown%20in%20a%20cell%20with%20its%20associated%20output.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20left%20menu%20of%20Synapse%20Studio%2C%20select%20the%20Data%20Hub%2C%20which%20is%20identified%20by%20the%20cylinder%20icon.%20In%20the%20Data%20blade%2C%20expand%20the%20Databases%20section%2C%20and%20you%20will%20see%20the%20%3CSTRONG%3Enycaggregates%3C%2FSTRONG%3E%20Spark%20database%20listed.%20Expand%20the%20database%20node%20as%20well%20as%20the%20Tables%20folder.%20There%20you%20will%20find%20the%20%3CSTRONG%3Epassengercountaggregates%3C%2FSTRONG%3E%20table.%20Next%20to%20this%20table%2C%20open%20the%20Actions%20menu%2C%20and%20select%20%3CSTRONG%3ENew%20SQL%20script%3C%2FSTRONG%3E%2C%20then%20%3CSTRONG%3ESelect%20TOP%20100%20rows%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_19%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240851i86FCFE62C9E48BCA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20passengercountaggregates%20table%20actions%20menu%20is%20expanded%20with%20New%20SQL%20script%20and%20Select%20TOP%20100%20rows%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20new%20SQL%20script%20tab%20displays%20populated%20with%20a%20query%20to%20retrieve%20the%20data%20from%20the%20table%20we%20created%20from%20the%20%3CSTRONG%3Edf_nyc%3C%2FSTRONG%3E%20dataframe%20in%20the%20notebook.%20Note%20that%20the%20SQL%20script%20toolbar%20is%20pre-populated%20to%20connect%20to%20the%20%3CSTRONG%3EBuilt-in%3C%2FSTRONG%3E%20serverless%20SQL%20pool%2C%20and%20the%20database%20selected%20is%20the%20one%20that%20we%20created%20in%20the%20notebook%20(%3CSTRONG%3Enycaggregates%3C%2FSTRONG%3E).%20Select%20the%20%3CSTRONG%3ERun%3C%2FSTRONG%3E%20button%20in%20the%20query%20tab%20toolbar%20to%20view%20the%20results%20of%20the%20query.%20Observe%20that%20similar%20to%20the%20notebook%20experience%3B%20you%20also%20can%20toggle%20the%20%3CSTRONG%3EView%3C%2FSTRONG%3E%20from%20%3CSTRONG%3ETable%3C%2FSTRONG%3E%20to%20a%20%3CSTRONG%3EChart%3C%2FSTRONG%3E%20visualization.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_20%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240852i988D5A4043ECDE3F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20query%20and%20the%20tabular%20result%20of%20the%20Select%20TOP%20100%20query%20on%20the%20passengercountaggregates%20is%20shown.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1684951143%22%20id%3D%22toc-hId--1684951146%22%3EClean%20up%3C%2FH2%3E%0A%3CP%3ELet%E2%80%99s%20take%20a%20moment%20now%20to%20remove%20the%20items%20created%20during%20this%20tutorial.%20Add%20a%20new%20code%20cell%20to%20the%20%3CSTRONG%3EExplore%20sample%20data%20with%20Spark%3C%2FSTRONG%3E%20notebook%2C%20add%20the%20following%20code%2C%20and%20run%20the%20cell%20to%20delete%20the%20Spark%20table%20and%20database%20that%20we%20created.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CSPAN%3Espark.sql(%3C%2FSPAN%3E%3CSPAN%3E%22DROP%26nbsp%3BTABLE%26nbsp%3BIF%26nbsp%3BEXISTS%26nbsp%3BNycAggregates.PassengerCountAggregates%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3Espark.sql(%3C%2FSPAN%3E%3CSPAN%3E%22DROP%26nbsp%3BDATABASE%26nbsp%3BIF%26nbsp%3BEXISTS%26nbsp%3BNycAggregates%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%3EAccess%20the%20Data%20Hub%20(cylinder%20icon)%20from%20the%20left%20menu%2C%20and%20in%20the%20Data%20blade%2C%20expand%20the%20Databases%20section.%20Open%20the%20Actions%20menu%20next%20to%20the%20%3CSTRONG%3Enycaggregates%3C%2FSTRONG%3E%20database%20and%20select%20%3CSTRONG%3EDelete%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditoreuanga_21%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240853iDFEF470CCCA4F4B5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Actions%20menu%20next%20to%20the%20nycaggregates%20database%20is%20expanded%20with%20Delete%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20delete%20the%20notebook%2C%20select%20the%20%3CSTRONG%3EDevelop%20Hub%3C%2FSTRONG%3E%20(paper%20icon)%20from%20the%20left%20menu%2C%20and%20in%20the%20Develop%20blade%2C%20expand%20the%20%3CSTRONG%3ENotebooks%3C%2FSTRONG%3E%20section.%20Open%20the%20Actions%20menu%20next%20to%20the%20%3CSTRONG%3EExplore%20sample%20data%20with%20Spark%3C%2FSTRONG%3E%20notebook%20and%20select%20%3CSTRONG%3EDelete%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240855i9CFD004D2251F765%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20Actions%20menu%20next%20to%20the%20sample%20notebook%20is%20expanded%20with%20Delete%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENext%2C%20select%20the%20%3CSTRONG%3EManage%20Hub%3C%2FSTRONG%3E%20(briefcase%20icon)%20from%20the%20left%20menu%20of%20Synapse%20Studio.%20Then%20in%20the%20blade%20menu%2C%20select%20%3CSTRONG%3EApache%20Spark%20pools%3C%2FSTRONG%3E.%20In%20the%20Apache%20Spark%20pool%20listing%2C%20hover%20over%20the%20row%20for%20the%20%3CSTRONG%3ESampleSpark%3C%2FSTRONG%3E%20item%2C%20then%20expand%20the%20ellipsis%20(%3CSTRONG%3E%E2%80%A6%3C%2FSTRONG%3E)%20menu%20and%20select%20%3CSTRONG%3EDelete%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20560px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240859i55DBAE35EDABBFFB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3EThe%20ellipsis%20menu%20is%20expanded%20on%20a%20Spark%20pool%20with%20the%20Delete%20item%20selected.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERepeat%20the%20same%20steps%20for%20the%20Spark%20pool%20you%20created%20in%20the%20first%20exercise.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-802561690%22%20id%3D%22toc-hId-802561687%22%3EConclusion%3C%2FH2%3E%0A%3CP%3EIn%20this%20post%2C%20we%20explored%20some%20of%20the%20capabilities%20of%20Apache%20Spark%20in%20Azure%20Synapse.%20We%20created%20an%20Apache%20Spark%20pool%20from%20the%20Synapse%20Studio%20and%20deployed%20a%20ready-to-use%20sample%20notebook%20from%20the%20Knowledge%20Center%20that%20leveraged%20taxi%20data%20from%20Azure%20Open%20Datasets.%20We%20walked%20through%20each%20of%20the%20code%20cells%20in%20the%20notebook%20and%20learned%20how%20to%20read%20data%2C%20perform%20queries%2C%20and%20investigate%20some%20data%20visualization%20options.%20We%20then%20created%20a%20shared%20Spark%20pool%20and%20table%20populated%20with%20our%20dataframe%E2%80%99s%20data%20and%20queried%20it%20using%20a%20serverless%20SQL%20pool.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20out%20this%20tutorial%20today%20by%20creating%20an%20Azure%20Synapse%20workspace%20with%20a%20dedicated%20SQL%20pool.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Ffree%2Fsynapse-analytics%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESign%20up%20for%20an%20Azure%20free%20account%3C%2FA%3E%26nbsp%3Band%20receive%20%24200%20of%20credit%20to%20try%20Azure%20Synapse%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fquickstart-create-workspace%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreate%20an%20Azure%20Synapse%20workspace%20in%20minutes%3C%2FA%3E%26nbsp%3Bto%20access%20these%20new%20features%3C%2FLI%3E%0A%3CLI%3EEmbark%20on%20your%20Azure%20Synapse%20self-study%20journey%20with%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Faka.ms%252FAzureLearn_SynapseAnalytics%26amp%3Bdata%3D04%257C01%257CKaiser.Larsen%2540microsoft.com%257Ca93118ee4aa446b41ffc08d89bb657fa%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C1%257C637430554742229151%257CUnknown%257CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%253D%257C1000%26amp%3Bsdata%3DR8Y9wc8ixh%252FshXOf7o26cw1NmqNHGh7975Xfk2k6%252FK8%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EMicrosoft%20Learn%20materials%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECheck%26nbsp%3B%3CA%20href%3D%22http%3A%2F%2Faka.ms%2Fsynapse-ga%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%20blog%20daily%20to%20see%20a%20roundup%20of%20all%20the%20new%20tutorial%20blogs%20that%3C%2FA%3E%26nbsp%3Bhave%20been%20posted%20as%20part%20of%20%3CSTRONG%3E10%20days%20of%20Azure%20Synapse%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E-%20Euan%20Garden%2C%20Principal%20Program%20Manager%2C%20Azure%20Synapse%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F240865i290EC7518C92CB8B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1988136%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3EUse%20this%20step-by-step%20tutorial%20focused%20on%20using%20Apache%20Spark%20for%20big%20data%20workloads%20in%20Azure%20Synapse%20Analytics.%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1988136%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20Spark%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Sep 15 2021 12:14 PM
Updated by: