How to use the omniduct.databases._namespaces.ParsedNamespaces.from_name function in omniduct

To help you get started, we’ve selected a few omniduct examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_separator(self):
        namespace = ParsedNamespaces.from_name(
            name='cat|my_db|my_table',
            namespaces=['catalog', 'database', 'table'],
            separator='|'
        )

        assert namespace.catalog == 'cat'
        assert namespace.database == 'my_db'
        assert namespace.table == 'my_table'
        assert namespace.as_dict() == {
            'catalog': 'cat',
            'database': 'my_db',
            'table': 'my_table'
        }
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_not_encapsulated(self):
        namespace = ParsedNamespaces.from_name('my_db.my_table', ['database', 'table'])
        assert namespace.as_dict() == {'database': 'my_db', 'table': 'my_table'}

        with pytest.raises(ValueError):
            ParsedNamespaces.from_name(namespace, ['schema', 'table'])
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_not_encapsulated(self):
        namespace = ParsedNamespaces.from_name('my_db.my_table', ['database', 'table'])
        assert namespace.as_dict() == {'database': 'my_db', 'table': 'my_table'}

        with pytest.raises(ValueError):
            ParsedNamespaces.from_name(namespace, ['schema', 'table'])
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_parsing_failure(self):
        with pytest.raises(ValueError):
            ParsedNamespaces.from_name(
                name='my_db.my_table',
                namespaces=['table']
            )
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_casting(self):
        namespace = ParsedNamespaces.from_name(
            name='my_db.my_table',
            namespaces=['catalog', 'database', 'table']
        )

        assert str(namespace) == '"my_db"."my_table"'
        assert bool(namespace) is True
        assert namespace.__bool__() == namespace.__nonzero__()  # Python 2/3 compatibility
        assert repr(namespace) == 'Namespace<"my_db"."my_table">'
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_nonexistent_namespace(self):
        with pytest.raises(AttributeError):
            ParsedNamespaces.from_name(
                name='my_table',
                namespaces=['table']
            ).database
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_empty(self):
        namespace = ParsedNamespaces.from_name("", ['database', 'table'])

        assert bool(namespace) is False
        assert namespace.database is None
        assert namespace.table is None
        assert str(namespace) == ''
        assert repr(namespace) == 'Namespace<>'
github airbnb / omniduct / omniduct / databases / base.py View on Github external
def _parse_namespaces(self, name, level=0, defaults=None):
        return ParsedNamespaces.from_name(
            name,
            self.NAMESPACE_NAMES[:-level] if level > 0 else self.NAMESPACE_NAMES,
            quote_char=self.NAMESPACE_QUOTECHAR,
            separator=self.NAMESPACE_SEPARATOR,
            defaults=self.NAMESPACE_DEFAULT if defaults is None else defaults
        )