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

(Tiny) Fix JSON formatting for metadata downloads #451

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

aswallace
Copy link
Contributor

Context

"Save metadata as JSON" was creating improperly formatted JSON files (used new lines instead of array format)
closes #423

Changes

Adds DuckDB's format option to the SQL

Testing

Manually tested by downloading JSON files from the Variance dataset, and verified that csv and parquet still work correctly

@aswallace aswallace linked an issue Feb 26, 2025 that may be closed by this pull request
@aswallace aswallace requested a review from kmitcham February 26, 2025 18:15
@aswallace aswallace changed the title update json format options in SQL (Tiny) Fix JSON formatting for metadata downloads Feb 26, 2025
@aswallace aswallace requested a review from toloudis February 26, 2025 18:16
@@ -38,7 +38,8 @@ export default class DatabaseServiceWeb extends DatabaseService {
}

const resultName = `${destination}.${format}`;
const finalSQL = `COPY (${sql}) TO '${resultName}' (FORMAT '${format}');`;
const formatOptions = format === "json" ? ", ARRAY true" : "";
const finalSQL = `COPY (${sql}) TO '${resultName}' (FORMAT '${format}'${formatOptions});`;

Choose a reason for hiding this comment

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

I'm suspicious that there should be a space (or some other character) between FORMAT '${format}' and ${formatOptions} but don't actually know if that is a problem.

Copy link
Contributor Author

@aswallace aswallace Feb 26, 2025

Choose a reason for hiding this comment

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

I left it out since I stuck a comma + space in formatOptions instead so that if there's nothing there it can just be (FORMAT format)

@aswallace aswallace merged commit d06863b into main Feb 26, 2025
7 checks passed
@aswallace aswallace deleted the bugfix/save-as-json-format branch February 26, 2025 19:33
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.

save metadata as json creates badly formatted json
3 participants