[Bug] Fix issue #2087: Handle multiple schema files in gen-schema-vie… #2223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.