def extract_data_types(data_rows): datatypes = None for _entity_id, values in data_rows: row_datatypes = [datatype.extract_from_value(value) for value in values] if datatypes is None: datatypes = row_datatypes else: datatypes = datatype.max_datatypes(datatypes, row_datatypes) return datatypes
def test_extract_from_value(): eq_(datatype.extract_from_value(""), "smallint") eq_(datatype.extract_from_value("100"), "smallint") eq_(datatype.extract_from_value("100000"), "integer") eq_(datatype.extract_from_value("10,89"), "smallint[]") eq_(datatype.extract_from_value([10, 89]), "smallint[]") eq_(datatype.extract_from_value("1000000,89"), "integer[]") eq_(datatype.extract_from_value([1000000, 89]), "integer[]") eq_(datatype.extract_from_value(["eueou", "oeu"]), "text[]") eq_(datatype.extract_from_value("10,89au"), "text") eq_(datatype.extract_from_value(12.34), "real") eq_(datatype.extract_from_value(0.0), "real") eq_(datatype.extract_from_value(10.5), "real") eq_(datatype.extract_from_value(22.3), "real") eq_(datatype.extract_from_value(30.0), "real") eq_(datatype.extract_from_value("30.0"), "real") eq_(datatype.extract_from_value("0.0"), "real") eq_(datatype.extract_from_value(decimal.Decimal("528676.842519685039")), "numeric") eq_(datatype.extract_from_value(decimal.Decimal("6.842519685039")), "numeric")