Ejemplo n.º 1
0
 def test_presto_consolidate_array_data_into_data(self):
     data = [
         {
             "arr_col": [[1], [2]],
             "int_col": 3
         },
         {
             "arr_col": [[11], [22]],
             "int_col": 33
         },
     ]
     array_data = {
         0: [
             {
                 "arr_col": [[1], [2]],
                 "arr_col.nested_row": 1
             },
             {
                 "arr_col": "",
                 "arr_col.nested_row": 2,
                 "int_col": ""
             },
         ],
         1: [
             {
                 "arr_col": [[11], [22]],
                 "arr_col.nested_row": 11
             },
             {
                 "arr_col": "",
                 "arr_col.nested_row": 22,
                 "int_col": ""
             },
         ],
     }
     PrestoEngineSpec._consolidate_array_data_into_data(data, array_data)
     expected_data = [
         {
             "arr_col": [[1], [2]],
             "arr_col.nested_row": 1,
             "int_col": 3
         },
         {
             "arr_col": "",
             "arr_col.nested_row": 2,
             "int_col": ""
         },
         {
             "arr_col": [[11], [22]],
             "arr_col.nested_row": 11,
             "int_col": 33
         },
         {
             "arr_col": "",
             "arr_col.nested_row": 22,
             "int_col": ""
         },
     ]
     self.assertEqual(data, expected_data)
Ejemplo n.º 2
0
 def test_presto_consolidate_array_data_into_data(self):
     data = [
         {
             'arr_col': [[1], [2]],
             'int_col': 3
         },
         {
             'arr_col': [[11], [22]],
             'int_col': 33
         },
     ]
     array_data = {
         0: [
             {
                 'arr_col': [[1], [2]],
                 'arr_col.nested_row': 1
             },
             {
                 'arr_col': '',
                 'arr_col.nested_row': 2,
                 'int_col': ''
             },
         ],
         1: [
             {
                 'arr_col': [[11], [22]],
                 'arr_col.nested_row': 11
             },
             {
                 'arr_col': '',
                 'arr_col.nested_row': 22,
                 'int_col': ''
             },
         ],
     }
     PrestoEngineSpec._consolidate_array_data_into_data(data, array_data)
     expected_data = [
         {
             'arr_col': [[1], [2]],
             'arr_col.nested_row': 1,
             'int_col': 3
         },
         {
             'arr_col': '',
             'arr_col.nested_row': 2,
             'int_col': ''
         },
         {
             'arr_col': [[11], [22]],
             'arr_col.nested_row': 11,
             'int_col': 33
         },
         {
             'arr_col': '',
             'arr_col.nested_row': 22,
             'int_col': ''
         },
     ]
     self.assertEqual(data, expected_data)