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

Add custom SQL field for Views #18

Open
jaumard opened this issue Aug 22, 2022 · 5 comments
Open

Add custom SQL field for Views #18

jaumard opened this issue Aug 22, 2022 · 5 comments

Comments

@jaumard
Copy link
Contributor

jaumard commented Aug 22, 2022

My use case here is that I have a huge table with billions of entries. To improve a bit performance I want a view with let say the data since two years only. By allowing a custom field where I can add a custom SQL I would be able to do that.
Hope that's clear enough ^^ or let me know

@schultek
Copy link
Owner

So would a custom additional field to the SELECT portion of the query enough or do you want to du custom joins also?

@schultek
Copy link
Owner

There is also something experimental called Transformers, that I added for a custom use-case. These do not create a new field, but 'transform' an existing, e.g. filtering or aggregating a list, performing a calculation etc.
Maybe this can be extended to allow arbitrary statements. But those too only are applied to the SELECT part.

@jaumard
Copy link
Contributor Author

jaumard commented Aug 22, 2022

So for my specific use case it would be more a WHERE clause.
Example, currently we have this generated:

CREATE VIEW fake_models_view AS 
SELECT "fake_models".*
FROM "fake_models"
WHERE '_#07c2fe9ce829535a5eed01abe7b2eaa32ac021cb#_' IS NOT NULL;

I would like to be able to do something like:

CREATE VIEW fake_models_view AS 
SELECT "fake_models".*
FROM "fake_models"
WHERE '_#07c2fe9ce829535a5eed01abe7b2eaa32ac021cb#_' IS NOT NULL
 AND created > DATEADD(yy,-2,GETDATE());

Something like this.

Transformers looks interesting also :D

@schultek
Copy link
Owner

But cant you do the where using the QueryParams object?

@jaumard
Copy link
Contributor Author

jaumard commented Aug 22, 2022

I can but I'll have to think of adding it in all QueryParams of the projects where by doing it here it's once for the all project and all queryparam I'll do would be about business logic and not about making the date lighter

@schultek schultek closed this as completed Dec 7, 2022
@schultek schultek reopened this Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants