data.world-py icon indicating copy to clipboard operation
data.world-py copied to clipboard

String literal 'NONE' gets mapped to Python None value in result sets

Open bryonjacob opened this issue 8 years ago • 3 comments

In a SQL or SPARQL response, the literal string value 'NONE' (case-insensitive) is converted into the python value None:

>>> datadotworld.query('bryon/odin-2015-2016', 'SELECT ?value WHERE{ BIND("NONE" AS ?value)}', query_type='sparql').table
[OrderedDict([('value', None)])]
>>> datadotworld.query('bryon/odin-2015-2016', 'SELECT ?value WHERE{ BIND("ABCD" AS ?value)}', query_type='sparql').table
[OrderedDict([('value', 'ABCD')])]
>>> datadotworld.query('bryon/odin-2015-2016', 'SELECT "NONE" AS value').table
[OrderedDict([('value', None)])]
>>> datadotworld.query('bryon/odin-2015-2016', 'SELECT "ABCD" AS value').table
[OrderedDict([('value', 'ABCD')])]

bryonjacob avatar Oct 08 '17 19:10 bryonjacob

UGH. so, this is because we are depending on the datapackage library which is hardcoded to treat any of these strings:

['null', 'none', 'nil', 'nan', '-']

as None when they occur as a value in a StringValue-typed column. In the context of returning query results from our servers, this is always wrong - we have the capacity to handle null results just fine explicitly.

bryonjacob avatar Oct 08 '17 20:10 bryonjacob

Some work here is still necessary after Bryon's hotfix to ensure that there is no broader impact and, possibly, a simpler and more generalized solution.

rflprr avatar Oct 10 '17 17:10 rflprr

Py: Small bugs

rflprr avatar Jul 30 '18 13:07 rflprr