def test_tuple_with_bag(self): pig_schema_to_py_struct = self._get_target() s = '(b: bag{(a: chararray, b: int)})' expected = (('b', [(('a', 'chararray'), ('b', 'int'))]), ) self.assertEqual(pig_schema_to_py_struct(s), expected) s = '(b: bag{tuple(a: chararray, b: int)})' self.assertEqual(pig_schema_to_py_struct(s), expected)
def test_mixed_complex(self): pig_schema_to_py_struct = self._get_target() s = ','.join(['(s: chararray, t: tuple(i: int, s: chararray)', 'b: bag{(s: chararray, i: int)})']) expected = (('s', 'chararray'), ('t', (('i', 'int'), ('s', 'chararray'))), ('b', [(('s', 'chararray'), ('i', 'int'))])) self.assertEqual(pig_schema_to_py_struct(s), expected)
def test_invalid_schema(self): pig_schema_to_py_struct = self._get_target() s = 'foo: bar' with self.assertRaisesRegex(TypeError, 'Unknown schema'): pig_schema_to_py_struct(s)
def test_tuple_with_tuples(self): pig_schema_to_py_struct = self._get_target() s = '(t1: tuple(a: chararray, b: int), t2: tuple(b: chararray, c: int))' self.assertEqual(pig_schema_to_py_struct(s), (('t1', (('a', 'chararray'), ('b', 'int'))), ('t2', (('b', 'chararray'), ('c', 'int')))))
def test_tuple_with_fields(self): pig_schema_to_py_struct = self._get_target() self.assertEqual(pig_schema_to_py_struct('(a: chararray, i: int)'), (('a', 'chararray'), ('i', 'int')))
def test_simple_outer_tuple(self): pig_schema_to_py_struct = self._get_target() self.assertEqual(pig_schema_to_py_struct('()'), ())
def test_one_simple_type(self): pig_schema_to_py_struct = self._get_target() self.assertEqual(pig_schema_to_py_struct('a: chararray'), 'chararray') self.assertEqual(pig_schema_to_py_struct('i: int'), 'int')