Skip to content

Commit 149756a

Browse files
author
Christopher Merrick
committed
new function: write_schema
1 parent 2a36b96 commit 149756a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
description-file = README.md

stitchstream/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .main import write_records, write_bookmark
1+
from .main import write_records, write_bookmark, write_schema

stitchstream/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,27 @@ def _write_headers():
1616
_writeline('--')
1717
_headers_written = True
1818

19-
def write_records(stream_name, schema, records):
19+
def write_records(stream_name, records):
2020
_write_headers()
2121
for record in records:
2222
_writeline(json.dumps({'type': 'RECORD',
2323
'stream': stream_name,
24-
'schema': schema,
2524
'record': record}))
2625

26+
def write_schema(stream_name, schema):
27+
_write_headers()
28+
_writeline(json.dumps({'type': 'SCHEMA',
29+
'stream': stream_name,
30+
'schema': schema}))
31+
2732
def write_bookmark(value):
2833
_write_headers()
2934
_writeline(json.dumps({'type': 'BOOKMARK',
3035
'value': value}))
3136

3237

3338
if __name__ == "__main__":
39+
write_schema('test',
40+
{'properties':{'id': {'type': 'string', 'key': True}}})
3441
write_records('test',
35-
{'properties':{'id': {'type': 'string', 'key': True}}},
3642
[{'id': 'b'}, {'id':'d'}])

0 commit comments

Comments
 (0)