sqlCreateTable | R Documentation |
Creates an interface to compose CREATE EXTERNAL TABLE
.
## S4 method for signature 'AthenaConnection'
sqlCreateTable(
con,
table,
fields,
field.types = NULL,
partition = NULL,
s3.location = NULL,
file.type = c("tsv", "csv", "parquet", "json"),
compress = FALSE,
...
)
con |
A database connection. |
table |
The table name, passed on to
|
fields |
Either a character vector or a data frame. A named character vector: Names are column names, values are types.
Names are escaped with A data frame: field types are generated using
|
field.types |
Additional field types used to override derived types. |
partition |
Partition Athena table (needs to be a named list or vector) for example: |
s3.location |
s3 bucket to store Athena table, must be set as a s3 uri for example ("s3://mybucket/data/").
By default s3.location is set s3 staging directory from |
file.type |
What file type to store data.frame on s3, noctua currently supports ["tsv", "csv", "parquet", "json"]. Default delimited file type is "tsv", in previous versions
of |
compress |
|
... |
Other arguments used by individual methods. |
sqlCreateTable
returns data.frame's DDL
in the SQL
format.
sqlCreateTable
## Not run:
# Note:
# - Require AWS Account to run below example.
# - Different connection methods can be used please see `noctua::dbConnect` documnentation
library(DBI)
# Demo connection to Athena using profile name
con <- dbConnect(noctua::athena())
# Create DDL for iris data.frame
sqlCreateTable(con, "iris", iris, s3.location = "s3://path/to/athena/table")
# Create DDL for iris data.frame with partition
sqlCreateTable(con, "iris", iris,
partition = "timestamp",
s3.location = "s3://path/to/athena/table"
)
# Create DDL for iris data.frame with partition and file.type parquet
sqlCreateTable(con, "iris", iris,
partition = "timestamp",
s3.location = "s3://path/to/athena/table",
file.type = "parquet"
)
# Disconnect from Athena
dbDisconnect(con)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.