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

[Bug] Fix issue #2087: Handle multiple schema files in gen-schema-vie… #2223

Merged

Conversation

Gustolandia
Copy link
Contributor

Description:

Issue: The gen-schema-views script failed to process multiple schema files passed via the --schema-files flag. When multiple schema files were provided as a comma-separated string, the script treated them as a single file path, resulting in the error: No schema files found!

Cause: The --schema-files flag input was not being split into individual file paths in non-interactive mode, and the expandGlobs function did not handle this case.

Fix:

Updated the expandGlobs function in schema-loader-utils.ts to:
Split comma-separated schema file paths into individual paths.
Trim and process each path individually.
Logically expand glob patterns for each path.
Added functionality in parseConfig to ensure that schema file paths are split correctly before being passed to readSchemas.
Tested the fix with:
A single schema file.
Multiple schema files passed as a comma-separated list.
Cleaned up debugging console.log statements after confirming the fix.
Testing:

Successfully tested the fix locally using:
npx ts-node ./src/index.ts
--non-interactive
--project=extensions-testing
--big-query-project=extensions-testing
--dataset=firestore_export
--table-name-prefix=posts
--schema-files=./schemas/test.json,./schemas/user_full.json
Verified that multiple schema files were processed correctly, and BigQuery views were created for each schema.
Notes:

This PR addresses issue #2087.
The fix ensures backward compatibility for single schema files and supports both interactive and non-interactive modes.

Copy link
Contributor

@cabljac cabljac left a comment

Choose a reason for hiding this comment

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

Can we add tests to cover this case please? Otherwise lgtm!

… list in schema-loader-utils

- Updated `readSchemas` in `schema-loader-utils.ts` to correctly parse and handle multiple schema files passed as a comma-separated list.
- Added a test case to validate functionality for multiple schemas in `schema-loader-utils.test.ts`.

Addresses issue #2087.
[Bug] Fix issue #2087: Handle multiple schema files in gen-schema-views script
@Gustolandia Gustolandia force-pushed the @invertase/Extensions/firestore-bigquery-export/issue#2087 branch from 3a00cdb to 718163a Compare December 3, 2024 14:37
@Gustolandia
Copy link
Contributor Author

I added a test.

@Gustolandia Gustolandia requested a review from cabljac December 3, 2024 14:40
@cabljac cabljac merged commit 4aae718 into next Dec 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension: firestore-bigquery-export Related to firestore-bigquery-export extension type: bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

2 participants