A function for retrieving and processing schema information from a Singer catalog for a specific stream. This function extracts the schema definition and ensures proper formatting for array types.
// Get schema for a specific streamconst userSchema = gs.getCatalogSchema("users");// Use schema with export functionsgs.toExport(df, "users", "./output", { exportFormat: 'singer', schema: userSchema});
The function throws errors in the following cases:
No catalog found: When the catalog file cannot be read or doesn’t exist
Stream not found: When the specified stream doesn’t exist in the catalog
Copy
Ask AI
try { const schema = gs.getCatalogSchema("nonexistent_stream");} catch (error) { console.error(error.message); // "No schema found in catalog for stream nonexistent_stream"}