-
Notifications
You must be signed in to change notification settings - Fork 131
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
enable jet.Windows passed in RawArgs to Raw expressions? #106
Comments
Hello, try using this method, until those aggregate functions are added. func PERCENTILE_DISC(fraction float64, withinGroup Column) Expression {
raw := fmt.Sprintf("PERCENTILE_DISC(#fraction) WITHIN GROUP (ORDER BY %s.%s)", withinGroup.TableName(), withinGroup.Name())
return Raw(raw, RawArgs{"#fraction": fraction})
} |
Hello, thanks for alternative suggestion, it won't scale well into some of the more intricate uses cases with different expressions in the order by, like having to represent a quotient from two db columns etc, will end up with several variations of this snippet for each form, would like to avoid that from onset. If that can be accomplished through Raw substitution would be one way to resolve, or if there was way for clients to implement their own expressions in a given dialect, we could attempt to implement our own expressions with sql builders for specific custom dialect functions we unfortunately have to deal with that aren't mapped yet, like PERCENTILE_DISC and WITHIN_GROUP. Thanks for quick response, much appreciated! |
Expression serialize method is not exposed(for safety reasons), so I don't see alternative. You'll have to hard code expression part into new functions. |
You can now find postgres PERCENTILE_DISC implementation on |
Looks great, I will try out the branch, thanks for adding that support. |
confirmed using |
Order set aggregate functions added in Release 2.7.0. jet/tests/postgres/chinook_db_test.go Lines 748 to 758 in 3e802f8
|
Hello I'm using some of the Raw Expressions to use custom functions of postgres that aren't mapped in gojet yet, such as
percentile_disc
andwithin group
, I'm running into limitation of using the Raw format, where I havewithin group
in raw, but it needs to contain a standardORDER BY
clause inside it, there's no way for me to substitute the jet.ORDER_BY window into the Raw string via RawArgs, could that be enabled as a feature?would look something like:
Otherwise, have to resort to hardcoding the full raw snippet including the ORDER BY clause and its table/column references, which defeats the purpose of using the lib. Is it possible to achieve this any other ways?
The text was updated successfully, but these errors were encountered: