Ejemplo n.º 1
0
 def test_from_data(self):
     column_names = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
     data = [
         {'a': '1', 'b': 'n', 'c': 'test', 'd': '3.2',
          'e': '20180806T11:33:29.320Z', 'f': 'True', 'g': 'NULL'},
         {'a': '2', 'b': 'y', 'c': 'asdf', 'd': '900',
          'e': '20180806T11:35:29.320Z', 'f': 'False', 'g': 'a string'}
     ]
     tbl = agate_helper.table_from_data(data, column_names)
     self.assertEqual(len(tbl), len(EXPECTED))
     for idx, row in enumerate(tbl):
         self.assertEqual(list(row), EXPECTED[idx])
Ejemplo n.º 2
0
    def get_catalog(self, manifest: Manifest) -> agate.Table:
        schemas = manifest.get_used_schemas()

        columns = []
        for database, schema in schemas:
            relations = self.list_relations(database, schema)
            for relation in relations:
                properties = self.get_properties(relation)
                logger.debug("Getting table schema for relation {}".format(
                    relation))  # noqa
                table_columns = self.get_columns_in_relation(relation)
                rel_type = self.get_relation_type(relation)
                columns += self._parse_relation(relation, table_columns,
                                                rel_type, properties)

        return table_from_data(columns, SparkAdapter.COLUMN_NAMES)