jet
jet copied to clipboard
Add support for postgres TABLESAMPLE
The is the query i am trying to create:
SELECT project.slug AS "project.slug" FROM public."project" AS project TABLESAMPLE SYSTEM_ROWS(1) LIMIT $1;
Which i can start off with:
stmt := table.Project.SELECT(table.Project.Slug).
FROM(table.Project).
LIMIT(1)
But the rest (TABLESAMPLE SYSTEM_ROWS(1)) i can't work out, is it possible?
Thanks.
Unfortunately, customizing table sources is not supported, you'll have to fallback to RawStatements.
Okay thanks!
Forgot to mention, if your TABLESAMPLE table is part of bigger join, you can avoid making the whole statemnet raw statement, by moving just TABLESAMPLE table into CTE or sub-query.
Check faq.
For instance:
projectTS := CTE("project")
projectTSAllColumns := Project.AllColumns.From(projectTS)
stmt := WITH(
projectTS.AS(
RawStatement(`
select *
from project TABLESAMPLE SYSTEM_ROWS(1)
`),
),
)(
SELECT(projectTSAllColumns).
FROM(
projectTS.INNER_JOIN(...),
),
)
I'll repopen the issue, since TABLESAMPLE is a valid feature request.