Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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')))))
Ejemplo n.º 5
0
 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')))
Ejemplo n.º 6
0
 def test_simple_outer_tuple(self):
     pig_schema_to_py_struct = self._get_target()
     self.assertEqual(pig_schema_to_py_struct('()'), ())
Ejemplo n.º 7
0
 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')