# Databricks and Julia

**URL:** <https://discourse.julialang.org/t/databricks-and-julia/83617>\
**Category:** General Usage\
**Created:** [July 1, 2022, 12:48pm UTC](https://discourse.julialang.org/t/databricks-and-julia/83617 "2022-07-01T12:48:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderChen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexanderchen/32/22007_2.png) [@AlexanderChen](https://discourse.julialang.org/u/AlexanderChen)\
**Post date:** [July 1, 2022, 12:48pm UTC](https://discourse.julialang.org/t/databricks-and-julia/83617/1 "2022-07-01T12:48:08Z")

</div>

hi,

for my job we are exploring the datalakehouse possibilities in DataBricks. Also we probably need to write new code (currently in PL/SQL) into a language that is accepted in the databricks envirroment.

Question:  
I am new to the databricks field, I have seen that spark and Julia should work together but I don’t see any explicit teamups with Julia and Databricks. Does that mean I can’t use Julia in DataBricks or because spark is the underlying technology that is being used by Databricks I CAN use Julia in Databricks?if yes, what are you experiences with Databricks and Julia?

best,

---

<div class="post-metadata">

**Author:** ![dfdx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfdx/32/120_2.png) [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Post date:** [July 1, 2022, 9:35pm UTC](https://discourse.julialang.org/t/databricks-and-julia/83617/2 "2022-07-01T21:35:25Z")

</div>

As far as I know, Databircks uses their own Spark cluster manager not available in the open source version, so Spark.jl is unlikely to work out of the box there. However, if you manage to link Spark.jl to the Databrick’s libraries instead of building the open source version, I’d expect APIs to be compatible.

---

<div class="post-metadata">

**Author:** ![drizk1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drizk1/32/208422_2.png) [@drizk1](https://discourse.julialang.org/u/drizk1)\
**Post date:** [June 29, 2024, 9:34am UTC](https://discourse.julialang.org/t/databricks-and-julia/83617/3 "2024-06-29T09:34:59Z")

</div>

@AlexanderChen I know its a few years later, but TidierDB.jl now supports Databricks as a backend for querying. It works thru the rest api. further documentation can be found [here](https://tidierorg.github.io/TidierDB.jl/latest/examples/generated/UserGuide/databricks/)

connecting and querying is as simple as:

```julia
instance_id = "string_id"
token "string_token"
warehouse_id = "e673cd4f387f964a"
con = connect(:databricks, instance_id, token, "DEMODB", "PUBLIC", warehouse_id)
# After connection is established, a you may begin querying.

@chain db_table(con, "mtcars") begin
   @select(wt)
   @mutate(test = wt *2)
   @aside @show_query _
   @collect
end

```

```julia

WITH cte_2 AS (
SELECT wt, wt * 2 AS test
        FROM tidierdb.default.mtcars)  
SELECT *
        FROM cte_2
32×2 DataFrame
 Row │ wt test    
     │ Float64 Float64 
─────┼──────────────────
   1 │ 2.62 5.24
   2 │ 2.875 5.75
   3 │ 2.32 4.64
   4 │ 3.215 6.43
  ⋮ │ ⋮ ⋮
  29 │ 3.17 6.34
  30 │ 2.77 5.54
  31 │ 3.57 7.14
  32 │ 2.78 5.56
         24 rows omitted

```

---

<div class="post-metadata">

**Author:** ![Sanderson10453](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sanderson10453/32/225556_2.png) [@Sanderson10453](https://discourse.julialang.org/u/Sanderson10453)\
**Post date:** [December 1, 2026, 2:55pm UTC](https://discourse.julialang.org/t/databricks-and-julia/83617/4 "2026-12-01T14:55:36Z")

</div>

@AlexanderChen Jumping in rather late on this too - our organization also recently switched over to using Databricks. Given how much of our code is in julia, I wrote a package called Brickster.jl (borrowed the name from the R package) that allows for easy interface with Databricks.

Generally speaking, to start querying from databricks it’s a few steps:

1. Import Brickster
2. Create the connection by adding the host name and a token
3. Select a databricks compute
4. Run a provided query and receive a DataFrames.jl dataframe

```julia-auto
using Pkg
Pkg.add("Brickster")
using Brickster

# Create the client
client = BricksterClient(token, host_name)

# Connect to a specific compute
con = connect_compute(client, "Serverless")

# Create a dataframe from databricks query
query = "select * from test_catalog.test_schema.table limit 10"
df = query_db(client, query, "test_catalog", "test_schema")
```
