DATABRICKS DBFS - azure

I need some clarity on Databricks DBFS.
In simple basic terms, what is it, what is the purpose of it and what does it allow me to do?
The documentation on databricks, says to this effect..
"Files in DBFS persist to Azure Blob storage, so you won’t lose data even after you terminate a cluster."
Any insight will be helpful, haven't been able to find documentation that goes into the details of it from architecture and usage perspective

I have experience with DBFS, it is a great storage which is holding data which you can upload from your local computer using DBFS CLI! The CLI setup a bit tricky, but when you manage, you can easily move whole folders around in this environment (remember using -overwrite! )
create folders
upload files
modify, remove files and folders
With Scala you can easily pull in the data you store in this storage with a code like this:
val df1 = spark
.read
.format("csv")
.option("header", "true")
.option("inferSchema", "true")
.load("dbfs:/foldername/test.csv")
.select(some_column_name)
Or read in the whole folder to process all csv the files available:
val df1 = spark
.read
.format("csv")
.option("header", "true")
.option("inferSchema", "true")
.load("dbfs:/foldername/*.csv")
.select(some_column_name)
I think it is easy to use and learn, I hope you find this info helpful!

Databricks File System (DBFS) is a distributed file system mounted into a Databricks workspace and available on Databricks clusters.
DBFS is an abstraction on top of scalable object storage and offers the following benefits:
1) Allows you to mount storage objects so that you can seamlessly access data without requiring credentials.
2) Allows you to interact with object storage using directory and file semantics instead of storage URLs.
Persists files to object storage(Blob), so you won’t lose data after you terminate a cluster.
Below link will help you to get more understanding on the Databricks utils commands:
databricks-file-system link

A few points in addition to the other answers worth mentioning:
AFAIK, You don’t pay for storage costs associated with DBFS. Instead you pay an hourly fee to run jobs on DBX.
Even though it is storing the data in blob/s3 in the cloud, you can’t access that storage directly. That means you have to use the DBX APIs or cli to access this storage.
Which leads to the third and obvious point, Using DBFS will more tightly couple your spark applications to DBX. Which may or may not be what you want to do.

Related

pyspark partitioning create an extra empty file for every partition

I am facing with one problem in Azure Databricks. In my notebook I am executing simple write command with partitioning:
df.write.format('parquet').partitionBy("startYear").save(output_path,header=True)
And I see something like this:
Can someone explain why spark is creating this additional empty files for every partition and how to disable it?
I tried different mode for write, different partitioning and spark versions
I reproduced the above and got the same results when I use Blob Storage.
Can someone explain why spark is creating this additional empty files
for every partition and how to disable it?
Spark won't create these types of files. Blob Storage creates the blobs like above when we create parquet files by partitions.
We cannot avoid these if you use Blob Storage. You can avoid it by using ADLS Storage.
These are my Results with ADLS:

How to access delta tables from azure data lake in jupyter notebook using pyspark

spark.read.format("delta").load("/tmp/delta/people10m")
How to give correct path to adls delta folder?
spark.read.format("delta").load("/tmp/delta/people10m")
tried above command, but not working
if you mean the direct access to ADLS, then you need to give a full path, like, abfss://<container>#<storage-acct>.dfs.core.windows.net/<path> - just following documentation about it (there are different authentication options available, so select what works for you).

How to read/load local files in Databricks?

is there anyway of reading files located in my local machine other than navigating to 'Data'> 'Add Data' on Databricks.
in my past experience using Databricks, when using s3 buckets, I was able to just read and load a dataframe by just specifying the path like so: i.e
df = spark.read.format('delta').load('<path>')
is there any way i can do something like this using databricks to read local files?
If you use the Databricks Connect client library you can read local files into memory on a remote Databricks Spark cluster. See details here.
The alternative is to use the Databricks CLI (or REST API) and push local data to a location on DBFS, where it can be read into Spark from within a Databricks notebook. A similar idea would be to use the AWS CLI to put local data into an S3 bucket that can be accessed from Databricks.
It sounds like what you are looking for is Databricks Connect, which works with many popular IDEs.

Read Azure Synapse table with Spark

I'm looking for, with no success, how to read a Azure Synapse table from Scala Spark. I found in https://learn.microsoft.com connectors for others Azure Databases with Spark but nothing with the new Azure Data Warehouse.
Does anyone know if it is possible?
It is now directly possible, and with trivial effort (there is even a right-click option added in the UI for this), to read data from a DEDICATED SQL pool in Azure Synapse (the new Analytics workspace, not just the DWH) for Scala (and unfortunately, ONLY Scala right now).
Within Synapse workspace (there is of course a write API as well):
val df = spark.read.sqlanalytics("<DBName>.<Schema>.<TableName>")
If outside of the integrated notebook experience, need to add imports:
import com.microsoft.spark.sqlanalytics.utils.Constants
import org.apache.spark.sql.SqlAnalyticsConnector._
It sounds like they are working on expanding to SERVERLESS SQL pool, as well as other SDKs (e.g. Python).
Read top portion of this article as reference: https://learn.microsoft.com/en-us/learn/modules/integrate-sql-apache-spark-pools-azure-synapse-analytics/5-transfer-data-between-sql-spark-pool
maybe I misunderstood your question, but normally you would use jdbc connection in Spark to use data from remote database
check this doc
https://docs.databricks.com/data/data-sources/azure/synapse-analytics.html
keep in mind, Spark would have to ingest data from Synapse tables into memory for processing and perform transformations there, so it is not going to push down operations into Synapse.
Normally, you want to run SQL query against source database and only bring results of SQL into Spark dataframe.

For Hadoop, which data storage to choose, Amazon S3 or Azure Blob Store?

I am working on a Hadoop project and generating lots of data in my local cluster. Sooner later I will be using cloud based Hadoop solution because my Hadoop cluster is very small comparative to real work load, however I dont have a choice as of now which one I will be using i.e. Windows Azure based, EMR or something else. I am generating lots of data locally and want to store this data to some cloud based storage based on the fact that I will use this data with Hadoop later but very soon.
I am looking for suggestion to decided which cloud store to choose based in someone experience. Thanks in advance.
First of all it is a great question. Let's try to understand "How data is processed in Hadoop":
In Hadoop all the data is processed on Hadoop cluster means when you process any data, that data is copied from its sources to HDFS, which is an essential component of Hadoop.
When data is copied to HDFS only after your run Map/Reduce jobs in it to get your results.
That means it does not matter what and where your data sources is(Amazon S3, Azure Blob, SQL Azure, SQL Server, on premise source etc), you will have to move/transfer/copy your data from source to HDFS, within the limits of Hadoop.
Once data is processed in Hadoop cluster, the result will be stored the location you would have configured in your job. The output data source can be HDFS or an outside location accessible from Hadoop Cluster
Once you have data copied to HDFS you can keep it one HDFS as long as you want but you will have to pay the price to use the Hadoop cluster.
In some cases when you are running Hadoop Job between some interval and data move/copy can be done faster, it is good to have a strategy to 1) acquire Hadoop cluster 2) copy data 3) run job 4) release cluster.
So based on above details, when you choose a data source in Cloud for your Hadoop Cluster you would have to consider the following:
If you have large data (which is normal with Hadoop clusters) to process, consider different data sources and the time it will take to copy/move data from those data source to HDFS because this will be your first step.
You would need to choose a data source which must have the lowest network latency so you can get data in and out, as fast as possible.
You also need to consider how you will move large amount of data from your current location to any cloud store. The best option would be to have a storage where you can send your data disk (HDD/Tape etc) because uploading multiple TB data will take great amount of time.
Amazon EMR (already available), Windows Azure (HadoopOnAzure in CTP) and Google (BigQuery in Preview, based on Google Dremel) provides pre-configured Hadoop clusters in cloud so you can choose where you would want to run your Hadoop job then you can consider the cloud storage.
Even if you choose one cloud data storage and decide to move to other because you want to use other Hadoop cluster in cloud, you sure can transfer the data however consider the time and data transfer support available to you.
For example, with HadooponAzure you can connect various data sources i.e. Amazon S3, Azure Blob Storage, SQL Server and SQL Azure etc so a variety of data sources are the best with any cloud Hadoop cluster.

Resources