SchemaVersion
The SchemaVersion resource allows you to manage AWS Glue SchemaVersions for your data catalog. This resource provides capabilities to define and update the schema for your datasets.
Minimal Example
Section titled “Minimal Example”Create a basic SchemaVersion with required properties and an optional adoption flag.
import AWS from "alchemy/aws/control";
const schemaVersion = await AWS.Glue.SchemaVersion("basicSchemaVersion", { SchemaDefinition: JSON.stringify({ type: "record", name: "User", fields: [ { name: "id", type: "int" }, { name: "name", type: "string" }, { name: "email", type: "string" } ] }), Schema: { Name: "UserSchema", Version: 1 }, adopt: true // Allows for adoption of an existing schema resource});
Advanced Configuration
Section titled “Advanced Configuration”Define a SchemaVersion with a more complex schema definition.
const advancedSchemaVersion = await AWS.Glue.SchemaVersion("advancedSchemaVersion", { SchemaDefinition: JSON.stringify({ type: "record", name: "Order", fields: [ { name: "orderId", type: "string" }, { name: "userId", type: "int" }, { name: "items", type: { type: "array", items: { type: "record", name: "Item", fields: [ { name: "productId", type: "string" }, { name: "quantity", type: "int" }, { name: "price", type: "float" } ] } }}, { name: "orderDate", type: "string" } ] }), Schema: { Name: "OrderSchema", Version: 2 }});
Version Management
Section titled “Version Management”Create a new SchemaVersion to update an existing schema.
const updatedSchemaVersion = await AWS.Glue.SchemaVersion("updatedSchemaVersion", { SchemaDefinition: JSON.stringify({ type: "record", name: "Order", fields: [ { name: "orderId", type: "string" }, { name: "userId", type: "int" }, { name: "items", type: { type: "array", items: { type: "record", name: "Item", fields: [ { name: "productId", type: "string" }, { name: "quantity", type: "int" }, { name: "price", type: "float" } ] } }}, { name: "orderDate", type: "string" }, { name: "status", type: "string" } // New field added in this version ] }), Schema: { Name: "OrderSchema", Version: 3 }});