ctas_profile: Generate a Drill CTAS Statement from a Query

Description Usage Arguments Note Examples

View source: R/ctas-profile.R

Description

When working with CSV[H] files in Drill 1.15.0+ everything comes back VARCHAR since that's the way it should be. The old behaviour of sergeant to auto-type convert was kinda horribad wrong. However, it's a royal pain to make CTAS queries from a giant list of VARCHAR field by hand. So, this is a helper function to do that, inspired by David Severski.

Usage

1
ctas_profile(x, new_table_name = "CHANGE____ME")

Arguments

x

a tbl

new_table_name

a new Drill data source spec (e.g. dfs.xyz.`a.parquet`)

Note

WIP!

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
db <- src_drill("localhost")

# Test with bare data source
flt1 <- tbl(db, "dfs.d.`/flights.csvh`")

cat(ctas_profile(flt1))

# Test with SELECT
flt2 <- tbl(db, sql("SELECT `year`, tailnum, time_hour FROM dfs.d.`/flights.csvh`"))

cat(ctas_profile(flt2, "dfs.d.`flights.parquet`"))


## End(Not run)

sergeant documentation built on Nov. 30, 2021, 1:06 a.m.