Overview
Re-infer the schema for a source, and update the source with the new schema. Before updating, verify the new schema to spot any changes that affect segmentations, windows, or validators.Steps
1
Create the entry point
Import the required modules and create an entry point that takes the
source_id of the source whose JTD schema you want to update.2
Create a function to get the schema
Create a function that accepts a client, a credential for authentication, and the project, dataset, and table to infer the schema for. In the later steps, these values come from the source itself.
3
Create a function to verify the schema
Write a function that accepts a source ID and a schema, so you can verify the schema before updating the source. The verification ensures that the new schema doesn’t affect any current segmentations, windows, or validators.
4
Get the source config
Create a function that accepts a client and the source to update the JTD schema for. Start by fetching the current source config. The credential ID, project, dataset, and table are needed to re-infer the schema.
5
Infer the schema
Call the
get_jtd_schema function with the credential and configuration of the source. This returns the current JTD schema for the source.6
Update the source
Pass the source ID and the new JTD schema to
sourceUpdate. The source is now updated with the new JTD schema.Full code sample
Python