-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tls): enable tls authentication
- update client for better metadata headers - add feature flag for tls to enable connection to Databricks - update sparksession builder to accetp &str and not String for connection string
- Loading branch information
Showing
11 changed files
with
270 additions
and
101 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// This example demonstrates connecting to a Databricks Cluster via a | ||
// tls connection. | ||
// | ||
// This demo requires access to a Databricks Workspace, a personal access token, | ||
// and a cluster id. The cluster should be running a 13.3LTS runtime or greater. Populate | ||
// the remote URL string between the `<>` with the appropriate details. | ||
// | ||
// To view the connected Spark Session, go to the cluster Spark UI and select the 'Connect' tab. | ||
|
||
use spark_connect_rs::{SparkSession, SparkSessionBuilder}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let spark: SparkSession = SparkSessionBuilder::remote("sc://<workspace id>:443/;token=<personal access token>;x-databricks-cluster-id=<cluster-id>") | ||
.build() | ||
.await?; | ||
|
||
spark | ||
.range(None, 10, 1, Some(1)) | ||
.selectExpr(vec!["id * 4"]) | ||
.show(Some(10), None, None) | ||
.await | ||
.unwrap(); | ||
|
||
// +-------------+ | ||
// | show_string | | ||
// +-------------+ | ||
// | +--------+ | | ||
// | |(id * 4)| | | ||
// | +--------+ | | ||
// | |0 | | | ||
// | |4 | | | ||
// | |8 | | | ||
// | |12 | | | ||
// | |16 | | | ||
// | |20 | | | ||
// | |24 | | | ||
// | |28 | | | ||
// | |32 | | | ||
// | |36 | | | ||
// | +--------+ | | ||
// | | | ||
// +-------------+ | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.