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

Implement viewing of query results as a CSV #784

Merged
merged 1 commit into from
Mar 17, 2021

Conversation

edoardopirovano
Copy link
Contributor

This pull request addresses the second part of #342 by introducing an option when right clicking a completed query in the query history view to see a CSV of the results. If the CSV results for the query have been viewed before, the file is simply opened. If they have not been viewed before, the CSV is generated (in the temporary directory for the query's execution) using a call to the CLI, and is then opened.

@@ -629,6 +640,9 @@ export class CodeQLCliServer implements Disposable {
}
}

async generateResultsCsv(metadata: { kind: string; id: string; scored?: string }, resultsPath: string, csvPath: string, sourceInfo?: SourceInfo): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...the scored parameter is unused here. I'm not sure if it is even used when generating csv. @henrymercer is it worth passing in the scored value as we're doing for sarif interpretation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still producing interpreted alerts here AIUI, so yes I think we'd need to forward the scored query metadata here so that queries with alert scores are interpreted correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is being forwarded correctly? It's one of the keys in the metadata parameter, which is passed on and used in line 605. Do you have an example query with the scored metadata I could use to test this? As far as I can tell none of the standard library queries use it unless I'm missing something...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah...yes. My mistake. It is being used correctly. The scored parameter is something that @henrymercer has been working on to implement ranked queries that order results by confidence. It's still experimental, and it is only enabled when you enter canary mode, which explicitly opts into experimental features.

What would be useful here is if you could replace { kind: string; id: string; scored?: string } with QueryMetadata from interface-types.ts since it really is the same type.

Once that is changed, I think this is good to go in.

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@aeisenberg aeisenberg merged commit dbaed3a into github:main Mar 17, 2021
@edoardopirovano edoardopirovano deleted the csv-results branch March 19, 2021 18:29
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

Successfully merging this pull request may close these issues.

3 participants