✅ What you’ll learn in this module:
- What the
/schemaendpoint does; - How to define tables, primary keys, and fields;
- How to return a valid schema to Weld;
- How to test your
/schemaresponse locally.
📦 What is the /schema endpoint?
This is the first of two required endpoints.
Weld calls /schema to understand:
- What tables your connector provides
- What the primary key is for each table
- (Optionally) what fields and data types each table contains
Weld uses this schema to:
- Validate your connector
- Auto-infer missing fields
- Create the correct structure in your data warehouse
🧱 Example schema response
Here’s a minimal valid schema definition for a single table called forms:
1{
2 "schema": {
3 "forms": {
4 "primary_key": "id",
5 "fields": [
6 {
7 "name": "id",
8 "type": "string"
9 },
10 {
11 "name": "title",
12 "type": "string"
13 },
14 {
15 "name": "created_at",
16 "type": "datetime"
17 }
18 ]
19 }
20 }
21}Weld supports the following types:
stringintlongdoublebooleandatetimearray(stored as a JSON string)object(stored as a JSON string)- Nullable types like
["null", "string"]
🛠 Add it to your code
Update your main.py to respond differently depending on the request path:
1import functions_framework
2from flask import jsonify, Request
3
4
5@functions_framework.http
6def handler(request: Request):
7 if request.path == "/schema":
8 return jsonify(get_schema()), 200
9 return "Hello, Weld!", 200
10
11
12def get_schema():
13 return {
14 "schema": {
15 "forms": {
16 "primary_key": "id",
17 "fields": [
18 {"name": "id", "type": "string"},
19 {"name": "title", "type": "string"},
20 {"name": "created_at", "type": "datetime"}
21 ]
22 }
23 }
24 }
25🧪 Test it locally
- Restart your dev server:
functions-framework --target=handler --debug
- In Postman: - Send a
GETrequest tohttp://localhost:8080/schema- You should receive the JSON schema in the response
✅ You now have a working /schema endpoint!
Next up
Creating the / (root) endpoint
Send your actual data to Weld - one page at a time.
Go to module