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

Can we add custom translations ? #1341

Closed
moodymudskipper opened this issue Jul 31, 2023 · 2 comments
Closed

Can we add custom translations ? #1341

moodymudskipper opened this issue Jul 31, 2023 · 2 comments
Labels
feature a feature request or enhancement

Comments

@moodymudskipper
Copy link

moodymudskipper commented Jul 31, 2023

In sql_substr() we have an example showing us how to add a new variant.

I think I understand the general mechanism, sql_variant() receives "translators" which are environments containing functions creating strings of class "sql". I see also that sql_translator() has a .parent arg so we can inherit from a higher level translator.

But I don't quite understand how to idiomatically add a new translation to an existing variant.

A hack that I think will work OK for my project is to edit the base_odbc_scalar, base_odbc_agg, and base_odbc_win environments directly since they're exported and not locked, another would be to overwrite dbplyr:::sql_translation.Oracle (Since that's Oracle in my case) but seems a bit clunky as well.

I thought about using a super class of my "Oracle" too but it seems I'd have to set new methods for at least tbl() and probably more, that seems like a rabbit hole.

My use case FWIW is to add a series of functions such as count_if(), which don't exist in neither R or Oracle, I'd like also to implement some translations from str_replace to REGEXP_EXTRACT, the general idea is that I'd like this code to work the same before or after collecting.

Can you recommend a way to go at this ?

@moodymudskipper
Copy link
Author

Might be a duplicate of #247

@hadley hadley added the feature a feature request or enhancement label Nov 2, 2023
@hadley
Copy link
Member

hadley commented Dec 19, 2023

Duplicate of #309. Still don't have any good model for how we should implement this 😞

@hadley hadley closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants