Skip to content

Commit ef3ff6d

Browse files
skuttlemanbryantgrayhumbamp123
committed
Update schema generation and bump version for v6 deploy
Co-authored-by: Bryant Gray <bryant.gray@qlik.com> Co-authored-by: Andres Pineda <andres.pineda@qlik.com>
1 parent bce5c23 commit ef3ff6d

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 6.2.2
4+
* Updates json schema generation to not emit dates
5+
* Handle multiple schemas with anyOf and emit them in a specific order
6+
* Do not emit error messages when checking multiple schemas and a subsequent schema passes
7+
* [#179](https://github.com/singer-io/singer-python/pull/179)
8+
39
## 6.2.1
410
* Fixes json schema generation to not treat numbers as dates
511
* Fixes json schema generation to handle empty arrays

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import subprocess
55

66
setup(name="singer-python",
7-
version='6.2.1',
7+
version='6.2.2',
88
description="Singer.io utility library",
99
author="Stitch",
1010
classifiers=['Programming Language :: Python :: 3 :: Only'],

singer/schema_generation.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ def add_observations(acc, path, data):
3737
return acc
3838
except (ValueError, TypeError):
3939
pass
40-
try:
41-
# If the string parses as a date, add an observation that it's a date
42-
dateutil.parser.parse(data)
43-
add_observation(acc, path + ["date"])
44-
return acc
45-
except (dateutil.parser.ParserError, OverflowError):
46-
pass
4740
add_observation(acc, path + ["string"])
4841
elif isinstance(data, bool):
4942
add_observation(acc, path + ["boolean"])
@@ -60,7 +53,10 @@ def add_observations(acc, path, data):
6053

6154
def to_json_schema(obs):
6255
types = []
63-
for key in obs:
56+
# add schema types in a specific order to anyOf list
57+
for key in ['array', 'object', 'number', 'integer', 'boolean', 'string', 'null']:
58+
if key not in obs:
59+
continue
6460

6561
result = {'type': ['null']}
6662

@@ -75,10 +71,6 @@ def to_json_schema(obs):
7571
result['type'] += ['array']
7672
result['items'] = to_json_schema(obs['array'])
7773

78-
elif key == 'date':
79-
result['type'] += ['string']
80-
result['format'] = 'date-time'
81-
8274
elif key == 'string':
8375
result['type'] += ['string']
8476

tests/test_schema_generation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_simple_schema(self):
1010
'a': {'type': ['null', 'integer']},
1111
'b': {'type': ['null', 'string']},
1212
'c': {'type': ['null', 'boolean']},
13-
'dt': {'type': ['null', 'string'], 'format': 'date-time'}
13+
'dt': {'type': ['null', 'string']}
1414
}
1515
}
1616
self.assertEqual(expected_schema, generate_schema(records))
@@ -24,11 +24,11 @@ def test_mix_n_match_records_schema(self):
2424
expected_schema = {
2525
'type': ['null', 'object'],
2626
'properties': {'a': {'anyOf': [{'type': ['null', 'integer']},
27-
{'type': ['null', 'string']},
28-
{'type': ['null', 'boolean']}]},
27+
{'type': ['null', 'boolean']},
28+
{'type': ['null', 'string']}]},
2929
'b': {'type': ['null', 'string']},
30-
'c': {'anyOf': [{'type': ['null', 'integer']},
31-
{'type': ['null', 'string'], 'format': 'singer.decimal'}]},
30+
'c': {'anyOf': [{'type': ['null', 'string'], 'format': 'singer.decimal'},
31+
{'type': ['null', 'integer']}]},
3232
'd': {'anyOf': [{'type': ['null', 'array'],
3333
'items': {'anyOf': [{'type': ['null', 'integer']},
3434
{'type': ['null', 'string']}]}},

0 commit comments

Comments
 (0)