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

Adds Teradata translation #43

Merged
merged 24 commits into from Oct 25, 2017
Merged

Adds Teradata translation #43

merged 24 commits into from Oct 25, 2017

Conversation

@edgararuiz
Copy link
Collaborator

@edgararuiz edgararuiz commented Oct 19, 2017

This change includes the new Teradata translation, and its corresponding tests.

The new translations was tested using dbtest, here are the results:

teradata-test

Fixes: tidyverse/dplyr#3040

@@ -9,6 +9,7 @@ base_odbc_scalar <- sql_translator(.parent = base_scalar,
as.character = sql_cast("STRING"),
as.Date = sql_cast("DATE"),
paste0 = sql_prefix("CONCAT"),
sd = sql_prefix("STDDEV_SAMP"),

This comment has been minimized.

@hadley

hadley Oct 23, 2017
Member

Are you sure this is ok to add here?

build_sql(
"SUBSTR(", x, ", ", start, ", ", len, ")"
)},
paste = sql_not_supported("paste()")

This comment has been minimized.

@edgararuiz

edgararuiz Oct 23, 2017
Author Collaborator

Right, I use CONCAT for paste0. CONCAT does not add a separator like paste does by default.

paste0 = sql_prefix("CONCAT"),

This comment has been minimized.

@hadley

hadley Oct 23, 2017
Member

Ah got it. Might be better to have a more helpful error here? i.e. try paste0() instead

This comment has been minimized.

@edgararuiz

edgararuiz Oct 23, 2017
Author Collaborator

Good idea, I'd like to use a function for that, can I add sql_not_supported() a new instead argument? Or should I create a new function?

This comment has been minimized.

@hadley

hadley Oct 24, 2017
Member

I think you can just create a new function inline

if (isTRUE(all.equal(base, exp(1)))) {
build_sql("ln(", x, ")")
} else {
# Use log change-of-base because postgres doesn't support the

This comment has been minimized.

@hadley

hadley Oct 23, 2017
Member

Is this true for teradata too? If so we should pull out into a resuable function

This comment has been minimized.

@edgararuiz

edgararuiz Oct 23, 2017
Author Collaborator

Ok, where should I place the function? I'm thinking traslate-sql-helpers.R

This comment has been minimized.

@hadley

hadley Oct 23, 2017
Member

Yeah, sounds good.

@edgararuiz
Copy link
Collaborator Author

@edgararuiz edgararuiz commented Oct 24, 2017

Ok, I moved log to its own function. I noticed that cot was in the same situation so I moved that formula as well. I also added, and updated, the corresponding tests.

PTAL @hadley


#' @rdname sql_variant
#' @export
sql_formula_log <- function(f, base = exp(1)) {

This comment has been minimized.

@hadley

hadley Oct 24, 2017
Member

I think these can just be sql_log and sql_cot, and like sql_cast() etc should return functions

sql("CAST(`field_name` AS VARCHAR(MAX))")
)
})
test_that("log10() translates to LOG ", {

This comment has been minimized.

@hadley

hadley Oct 24, 2017
Member

Now that we have sql_log() used in multiple places, there's no need to test for each individual driver that uses it.


# Teradata base_agg conversions -----------------------------------------

test_that("sd() translates to STDEV ", {

This comment has been minimized.

@hadley

hadley Oct 24, 2017
Member

Can you please bundle these all into one test, writing a function as needed to reduce duplication?

@edgararuiz
Copy link
Collaborator Author

@edgararuiz edgararuiz commented Oct 25, 2017

PTAL @hadley

@hadley hadley merged commit 0e2075c into tidyverse:master Oct 25, 2017
3 checks passed
3 checks passed
codecov/patch 90.41% of diff hit (target 75.89%)
Details
codecov/project 76.25% (+0.36%) compared to 7e4c462
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.