Chapter 2: Reading and Writing Data from and to Various Azure Services and File Formats
Azure Databricks provides options for data engineers, data scientists, and data analysts to read and write data from and to various sources such as different file formats, databases, NoSQL databases, Azure Storage, and so on. Users get a lot of flexibility in ingesting and storing data in various formats as per business requirements, using Databricks. It also provides libraries to ingest data from streaming systems such as Events Hub and Kafka.
In this chapter, we will learn how we can read data from different file formats, such as comma-separated values (CSV), Parquet, and JavaScript Object Notation (JSON), and how to use native connectors to read and write data from and to Azure SQL Database and Azure Synapse Analytics. We will also learn how to read and store data in Azure Cosmos DB.
By the end of this chapter, you will have built a foundation for reading data from various sources that are required to work on the end-to-end (E2E) scenarios of a data ingestion pipeline. You will learn how and when to use JavaScript Database Connectivity (JDBC) drivers and Apache Spark connectors to ingest into the Azure SQL Database.
We're going to cover the following recipes in this chapter:
- Mounting Azure Data Lake Storage Gen2 (ADLS Gen2) and Azure Blob storage to Azure Databricks File System (DBFS)
- Reading and writing data from and to Azure Blob storage
- Reading and writing data from and to ADLS Gen2
- Reading and writing data from and to an Azure SQL database using native connectors
- Reading and writing data from and to Azure Synapse Dedicated Structured Query Language (SQL) Pool using native connectors
- Reading and writing data from and to the Azure Cosmos DB
- Reading and writing data from and to CSV and Parquet
- Reading and writing data from and to JSON, including nested JSON