Skip to contents

Methods


Method new()

Creates a new instance of this R6 class.

Note that this object is typically constructed via db_sql_client().

Usage

DatabricksSqlClient$new(
  host,
  token,
  http_path,
  catalog,
  schema,
  use_cloud_fetch,
  session_configuration,
  ...
)

Arguments

host

(character(1))
See db_sql_client().

token

(character(1))
See db_sql_client().

http_path

(character(1))
See db_sql_client().

catalog

(character(1))
See db_sql_client().

schema

(character(1))
See db_sql_client().

use_cloud_fetch

(logical(1))
See db_sql_client().

session_configuration

(list(...))
See db_sql_client().

...

Parameters passed to connection method

Returns

DatabricksSqlClient.


Method columns()

Execute a metadata query about the columns.

Usage

DatabricksSqlClient$columns(
  catalog_name = NULL,
  schema_name = NULL,
  table_name = NULL,
  column_name = NULL,
  as_tibble = TRUE
)

Arguments

catalog_name

(character(1))
A catalog name to retrieve information about. The % character is interpreted as a wildcard.

schema_name

(character(1))
A schema name to retrieve information about. The % character is interpreted as a wildcard.

table_name

(character(1))
A table name to retrieve information about. The % character is interpreted as a wildcard.

column_name

(character(1))
A column name to retrieve information about. The % character is interpreted as a wildcard.

as_tibble

(logical(1))
If TRUE (default) will return tibble::tibble, otherwise returns arrow::Table.

Returns

tibble::tibble or arrow::Table.

Examples

\dontrun{
  client$columns(catalog_name = "defa%")
  client$columns(catalog_name = "default", table_name = "gold_%")
}


Method catalogs()

Execute a metadata query about the catalogs.

Usage

DatabricksSqlClient$catalogs(as_tibble = TRUE)

Arguments

as_tibble

(logical(1))
If TRUE (default) will return tibble::tibble, otherwise returns arrow::Table.

Returns

tibble::tibble or arrow::Table.

Examples

\dontrun{
  client$catalogs()
}


Method schemas()

Execute a metadata query about the schemas.

Usage

DatabricksSqlClient$schemas(
  catalog_name = NULL,
  schema_name = NULL,
  as_tibble = TRUE
)

Arguments

catalog_name

(character(1))
A catalog name to retrieve information about. The % character is interpreted as a wildcard.

schema_name

(character(1))
A schema name to retrieve information about. The % character is interpreted as a wildcard.

as_tibble

(logical(1))
If TRUE (default) will return tibble::tibble, otherwise returns arrow::Table.

Returns

tibble::tibble or arrow::Table.

Examples

\dontrun{
  client$schemas(catalog_name = "main")
}


Method tables()

Execute a metadata query about tables and views

Usage

DatabricksSqlClient$tables(
  catalog_name = NULL,
  schema_name = NULL,
  table_name = NULL,
  table_types = NULL,
  as_tibble = TRUE
)

Arguments

catalog_name

(character(1))
A catalog name to retrieve information about. The % character is interpreted as a wildcard.

schema_name

(character(1))
A schema name to retrieve information about. The % character is interpreted as a wildcard.

table_name

(character(1))
A table name to retrieve information about. The % character is interpreted as a wildcard.

table_types

(character())
A list of table types to match, for example "TABLE" or "VIEW".

as_tibble

(logical(1))
If TRUE (default) will return tibble::tibble, otherwise returns arrow::Table.

Returns

tibble::tibble or arrow::Table.


Method execute()

Prepares and then runs a database query or command.

Usage

DatabricksSqlClient$execute(operation, parameters = NULL, as_tibble = TRUE)

Arguments

operation

(character(1))
The query or command to prepare and then run.

parameters

(list())
Optional. A sequence of parameters to use with the operation parameter.

as_tibble

(logical(1))
If TRUE (default) will return tibble::tibble, otherwise returns arrow::Table.

Returns

tibble::tibble or arrow::Table.

Examples

\dontrun{
 client$execute("select 1")
 client$execute("select * from x.y.z limit 100")
 client$execute(
   operation = "select * from x.y.z where a < %(threshold)s limit 1000",
   parameters = list(threshold = 100)
 )
}


Method execute_many()

Prepares and then runs a database query or command using all parameter sequences in the seq_of_parameters argument. Only the final result set is retained.

Usage

DatabricksSqlClient$execute_many(
  operation,
  seq_of_parameters = NULL,
  as_tibble = TRUE
)

Arguments

operation

(character(1))
The query or command to prepare and then run.

seq_of_parameters

(list(list()))
A sequence of many sets of parameter values to use with the operation parameter.

as_tibble

(logical(1))
If TRUE (default) will return tibble::tibble, otherwise returns arrow::Table.

Returns

tibble::tibble or arrow::Table.

Examples

\dontrun{
 client$execute_many(
   operation = "select * from x.y.z where a < %(threshold)s limit 1000",
   seq_of_parameters = list(
     list(threshold = 100),
     list(threshold = 200),
     list(threshold = 300)
   )
 )
}


Method clone()

The objects of this class are cloneable with this method.

Usage

DatabricksSqlClient$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `DatabricksSqlClient$columns`
## ------------------------------------------------

if (FALSE) { # \dontrun{
  client$columns(catalog_name = "defa%")
  client$columns(catalog_name = "default", table_name = "gold_%")
} # }

## ------------------------------------------------
## Method `DatabricksSqlClient$catalogs`
## ------------------------------------------------

if (FALSE) { # \dontrun{
  client$catalogs()
} # }

## ------------------------------------------------
## Method `DatabricksSqlClient$schemas`
## ------------------------------------------------

if (FALSE) { # \dontrun{
  client$schemas(catalog_name = "main")
} # }

## ------------------------------------------------
## Method `DatabricksSqlClient$execute`
## ------------------------------------------------

if (FALSE) { # \dontrun{
 client$execute("select 1")
 client$execute("select * from x.y.z limit 100")
 client$execute(
   operation = "select * from x.y.z where a < %(threshold)s limit 1000",
   parameters = list(threshold = 100)
 )
} # }

## ------------------------------------------------
## Method `DatabricksSqlClient$execute_many`
## ------------------------------------------------

if (FALSE) { # \dontrun{
 client$execute_many(
   operation = "select * from x.y.z where a < %(threshold)s limit 1000",
   seq_of_parameters = list(
     list(threshold = 100),
     list(threshold = 200),
     list(threshold = 300)
   )
 )
} # }