示例#1
0
 def test_table_reference_multi_dataset(self):
     # type: () -> None
     new_table_context = DatasetTableContext({
         'project1': {
             'dataset1': {
                 'table1': TypedDataFrame(pd.DataFrame(), [])
             },
             'dataset2': {
                 'table2': TypedDataFrame(pd.DataFrame(), [])
             }
         },
     })
     table_ref = TableReference(('table1', ))
     expected_error = "Non-fully-qualified table \\('table1',\\) with multiple possible "\
         "datasets \\['dataset1', 'dataset2'\\]"
     with self.assertRaisesRegexp(ValueError, expected_error):
         table_ref.get_dataframe(new_table_context)
示例#2
0
    def test_table_reference(self, reference):
        # type: (Tuple[str, ...]) -> None
        table_ref = TableReference(reference)
        dataframe, table_name = table_ref.get_dataframe(self.table_context)

        self.assertEqual(table_name, 'my_table')
        self.assertEqual(dataframe.to_list_of_lists(), [[1], [2], [3]])
        self.assertEqual(list(dataframe.dataframe), ['a'])
        self.assertEqual(dataframe.types, [BQScalarType.INTEGER])