Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a helper class for using the Databricks ODBC driver #615

Merged
merged 1 commit into from
Nov 14, 2023

Commits on Nov 14, 2023

  1. Add a helper class for using the Databricks ODBC driver.

    The official Databricks ODBC driver supports a number of authentication
    methods but these are difficult to use correctly and require users to
    pass them manually rather than picking up on ambient credentials as
    other Databricks SDKs do.
    
    This commit adds a high-level helper class that implements (a subset of)
    the Databricks client unified authentication model [0] in its
    dbConnect() method and should make connection code that runs on
    Databricks-aware environments work automatically without manual
    configuration.
    
    Compare the interface from this commit:
    
        DBI::dbConnect(
          odbc::databricks(),
          http_path = "sql/protocolv1/o/4425955464597947/1026-023828-vn51jugj"
        )
    
    with filling all of the required parameters out manually:
    
        DBI::dbConnect(
          odbc::odbc(),
          driver = "/opt/simba/spark/lib/64/libsparkodbc_sb64.so",
          host = gsub("https://", "", Sys.getenv("DATABRICKS_HOST")),
          HTTPPath = "sql/protocolv1/o/4425955464597947/1026-023828-vn51jugj"
          ThriftTransport = 2,
          UserAgentEntry = Sys.getenv("SPARK_CONNECT_USER_AGENT"),
          port = 443,
          Protocol = "https",
          SSL = 1,
          AuthMech = 11,
          Auth_Flow = 0,
          Auth_AccessToken = "<your OAuth token>"
        )
    
    [0]: https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication
    
    Signed-off-by: Aaron Jacobs <[email protected]>
    atheriel committed Nov 14, 2023
    Configuration menu
    Copy the full SHA
    92e9184 View commit details
    Browse the repository at this point in the history