-
Notifications
You must be signed in to change notification settings - Fork 89
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
Sqlfluff linting existing clickhouse queries pt2 #6311
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
SELECT | ||
COUNT(issues.title) as number_of_open_disabled_tests | ||
SELECT COUNT(issues.title) AS number_of_open_disabled_tests | ||
FROM | ||
default.issues final | ||
default.issues FINAL | ||
WHERE | ||
issues.title LIKE '%DISABLED%' | ||
AND issues.state = {state: String} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
-- A simple query to get a job by name | ||
SELECT DISTINCT | ||
job.id, | ||
job.name | ||
job.id, | ||
job.name | ||
FROM | ||
default.workflow_job job FINAL | ||
INNER JOIN workflow_run workflow FINAL on workflow.id = job.run_id | ||
default.workflow_job job FINAL | ||
INNER JOIN workflow_run workflow FINAL ON workflow.id = job.run_id | ||
WHERE | ||
workflow.id = { workflowId: Int64 } | ||
AND job.name LIKE { jobName: String } | ||
workflow.id = { workflowId: Int64 } | ||
AND job.name LIKE { jobName: String } | ||
ORDER BY | ||
job.name | ||
job.name |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
SELECT | ||
COUNT(*) AS COUNT, | ||
workflow.name as name | ||
FROM | ||
workflow_job job | ||
JOIN workflow_run workflow on workflow.id = job.run_id | ||
JOIN push ON workflow.head_commit.'id' = push.head_commit.'id' | ||
WHERE | ||
job.name NOT LIKE '%generate-matrix%' | ||
AND job.name NOT LIKE '%unittests%' | ||
AND workflow.name NOT IN ('cron', 'Bandit', 'tests', 'Lint') | ||
AND push.ref = 'refs/heads/nightly' | ||
AND push.repository.'owner'.'name' = 'pytorch' | ||
AND push.repository.'name' IN ('pytorch', 'vision', 'audio') | ||
AND job.created_at >= {startTime: DateTime64(3)} | ||
AND job.created_at < {stopTime: DateTime64(3)} | ||
AND job.conclusion IN ('failure', 'timed_out', 'cancelled') | ||
GROUP BY | ||
workflow.name | ||
SELECT | ||
COUNT(*) AS COUNT, | ||
WORKFLOW.NAME AS NAME | ||
FROM | ||
WORKFLOW_JOB JOB | ||
JOIN WORKFLOW_RUN WORKFLOW ON WORKFLOW.ID = JOB.RUN_ID | ||
JOIN PUSH ON WORKFLOW.HEAD_COMMIT.'id' = PUSH.HEAD_COMMIT.'id' | ||
WHERE | ||
JOB.NAME NOT LIKE '%generate-matrix%' | ||
AND JOB.NAME NOT LIKE '%unittests%' | ||
AND WORKFLOW.NAME NOT IN ('cron', 'Bandit', 'tests', 'Lint') | ||
AND PUSH.REF = 'refs/heads/nightly' | ||
AND PUSH.REPOSITORY.'owner'.'name' = 'pytorch' | ||
AND PUSH.REPOSITORY.'name' IN ('pytorch', 'vision', 'audio') | ||
AND JOB.CREATED_AT >= {startTime: DateTime64(3)} | ||
AND JOB.CREATED_AT < {stopTime: DateTime64(3)} | ||
AND JOB.CONCLUSION IN ('failure', 'timed_out', 'cancelled') | ||
GROUP BY | ||
WORKFLOW.NAME |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
SELECT | ||
COUNT(*) AS COUNT, | ||
job.name as name | ||
COUNT(*) AS COUNT, | ||
JOB.NAME AS NAME | ||
FROM | ||
workflow_job job | ||
JOIN workflow_run workflow ON workflow.id = job.run_id | ||
join push on push.head_commit.'id' = workflow.head_commit.'id' | ||
WORKFLOW_JOB JOB | ||
JOIN WORKFLOW_RUN WORKFLOW ON WORKFLOW.ID = JOB.RUN_ID | ||
JOIN PUSH ON PUSH.HEAD_COMMIT.'id' = WORKFLOW.HEAD_COMMIT.'id' | ||
WHERE | ||
job.name NOT LIKE '%generate-matrix%' | ||
AND job.name NOT LIKE '%unittests%' | ||
AND workflow.name NOT IN ('cron', 'Bandit', 'tests') | ||
AND push.ref = 'refs/heads/nightly' | ||
AND push.repository.'owner'.'name' = 'pytorch' | ||
AND push.repository.'name' = {repo: String } | ||
AND job.conclusion IN ('failure', 'timed_out', 'cancelled') | ||
AND job.completed_at >= today() - 1 | ||
GROUP BY job.name | ||
JOB.NAME NOT LIKE '%generate-matrix%' | ||
AND JOB.NAME NOT LIKE '%unittests%' | ||
AND WORKFLOW.NAME NOT IN ('cron', 'Bandit', 'tests') | ||
AND PUSH.REF = 'refs/heads/nightly' | ||
AND PUSH.REPOSITORY.'owner'.'name' = 'pytorch' | ||
AND PUSH.REPOSITORY.'name' = {repo: String } | ||
AND JOB.CONCLUSION IN ('failure', 'timed_out', 'cancelled') | ||
AND JOB.COMPLETED_AT >= today() - 1 | ||
GROUP BY JOB.NAME | ||
ORDER BY COUNT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
select | ||
SUM(LENGTH(p.commits)) as num | ||
from | ||
SELECT SUM(LENGTH(p.commits)) AS num | ||
FROM | ||
push p | ||
where | ||
WHERE | ||
p.repository.full_name = 'pytorch/pytorch' | ||
and p.ref = 'refs/heads/main' | ||
AND p.ref = 'refs/heads/main' | ||
AND p.head_commit.'timestamp' >= {startTime: DateTime64(3)} | ||
AND p.head_commit.'timestamp' < {stopTime: DateTime64(3)} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
--- This query is used by HUD metrics page to get the list of queued jobs | ||
with possible_queued_jobs as ( | ||
select id, run_id | ||
from default.workflow_job -- FINAL not needed since we just use this to filter a table that has already been FINALed | ||
where status = 'queued' | ||
AND created_at < (CURRENT_TIMESTAMP() - INTERVAL 5 MINUTE) | ||
AND created_at > (CURRENT_TIMESTAMP() - INTERVAL 1 WEEK) | ||
select | ||
id, | ||
run_id | ||
from default.workflow_job -- FINAL not needed since we just use this to filter a table that has already been FINALed | ||
where | ||
status = 'queued' | ||
and created_at < (CURRENT_TIMESTAMP() - interval 5 minute) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @clee2000 do you know if we also want to have this behavior where if the file starts off with sql commands in lowercase that it makes everything else lowercase? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it would be better to always stick to either upper case or lower case |
||
and created_at > (CURRENT_TIMESTAMP() - interval 1 week) | ||
) | ||
SELECT | ||
DATE_DIFF( | ||
'second', | ||
job.created_at, | ||
CURRENT_TIMESTAMP() | ||
) AS queue_s, | ||
CONCAT(workflow.name, ' / ', job.name) AS name, | ||
job.html_url, | ||
IF( | ||
LENGTH(job.labels) = 0, | ||
'N/A', | ||
|
||
select | ||
DATE_DIFF( | ||
'second', | ||
job.created_at, | ||
CURRENT_TIMESTAMP() | ||
) as queue_s, | ||
CONCAT(workflow.name, ' / ', job.name) as name, | ||
job.html_url, | ||
IF( | ||
LENGTH(job.labels) > 1, | ||
job.labels[2], | ||
job.labels[1] | ||
) | ||
) AS machine_type | ||
FROM | ||
default.workflow_job job final | ||
JOIN default.workflow_run workflow final ON workflow.id = job.run_id | ||
WHERE | ||
job.id in (select id from possible_queued_jobs) | ||
and workflow.id in (select run_id from possible_queued_jobs) | ||
and workflow.repository.'full_name' = 'pytorch/pytorch' | ||
AND job.status = 'queued' | ||
/* These two conditions are workarounds for GitHub's broken API. Sometimes */ | ||
/* jobs get stuck in a permanently "queued" state but definitely ran. We can */ | ||
/* detect this by looking at whether any steps executed (if there were, */ | ||
/* obviously the job started running), and whether the workflow was marked as */ | ||
/* complete (somehow more reliable than the job-level API) */ | ||
AND LENGTH(job.steps) = 0 | ||
AND workflow.status != 'completed' | ||
ORDER BY | ||
queue_s DESC | ||
LENGTH(job.labels) = 0, | ||
'N/A', | ||
IF( | ||
LENGTH(job.labels) > 1, | ||
job.labels[2], | ||
job.labels[1] | ||
) | ||
) as machine_type | ||
from | ||
default.workflow_job job final | ||
join default.workflow_run workflow final on workflow.id = job.run_id | ||
where | ||
job.id in (select id from possible_queued_jobs) | ||
and workflow.id in (select run_id from possible_queued_jobs) | ||
and workflow.repository.'full_name' = 'pytorch/pytorch' | ||
and job.status = 'queued' | ||
/* These two conditions are workarounds for GitHub's broken API. Sometimes */ | ||
/* jobs get stuck in a permanently "queued" state but definitely ran. We can */ | ||
/* detect this by looking at whether any steps executed (if there were, */ | ||
/* obviously the job started running), and whether the workflow was marked as */ | ||
/* complete (somehow more reliable than the job-level API) */ | ||
and LENGTH(job.steps) = 0 | ||
and workflow.status != 'completed' | ||
order by | ||
queue_s desc | ||
settings allow_experimental_analyzer = 1; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
select | ||
t.name, | ||
t.classname, | ||
t.file, | ||
t.invoking_file, | ||
maxMerge(t.last_run) as last_run | ||
t.name, | ||
t.classname, | ||
t.file, | ||
t.invoking_file, | ||
maxMerge(t.last_run) as last_run | ||
from | ||
tests.distinct_names t | ||
tests.distinct_names t | ||
where | ||
t.name like {name: String} | ||
and t.classname like {suite: String} | ||
and t.file like {file: String} | ||
t.name like {name: String} | ||
and t.classname like {suite: String} | ||
and t.file like {file: String} | ||
group by | ||
t.name, | ||
t.classname, | ||
t.file, | ||
t.invoking_file | ||
t.name, | ||
t.classname, | ||
t.file, | ||
t.invoking_file | ||
order by | ||
t.name, t.classname, t.file, t.invoking_file | ||
t.name, t.classname, t.file, t.invoking_file | ||
limit | ||
{per_page: Int} | ||
offset | ||
{offset: Int} | ||
{per_page: Int} | ||
offset | ||
{offset: Int} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clee2000 is this the correct behavior? I'm not too familiar with clickhouse so I wasn't sure if this syntax is correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think all of the capitalizations it changed here should not be done