MCPcopy Create free account
hub / github.com/apache/impala / change_database

Method change_database

tests/common/impala_test_suite.py:1191–1213  ·  view source on GitHub ↗

Change impala_client to point to approriate database under test and revert it to default database once it exit the with scope. Restore client configuration back to its default when getting in and getting out of 'with' scope. Test method should try to use fully qualified table name in the

(cls, impala_client, table_format=None, db_name=None,
                      scale_factor=None)

Source from the content-addressed store, hash-verified

1189 @classmethod
1190 @contextlib.contextmanager
1191 def change_database(cls, impala_client, table_format=None, db_name=None,
1192 scale_factor=None):
1193 """Change impala_client to point to approriate database under test and revert
1194 it to default database once it exit the with scope.
1195 Restore client configuration back to its default when getting in and getting out of
1196 'with' scope. Test method should try to use fully qualified table name in the test
1197 query as much as possible and only use this context manager function when it is
1198 not practical to do so.
1199 Sample usage:
1200
1201 with ImpalaTestSuite.change_database(client, db_name='functional_parquet'):
1202 # client clear configuration and pointing to 'functional_parquet' database here.
1203 client.execute('show tables')
1204 # client clear configuration and pointing to 'default' database after it exit the
1205 # 'with' scope.
1206 client.execute('show tables')
1207 """
1208 try:
1209 cls.__change_client_database(impala_client, table_format=table_format,
1210 db_name=db_name, scale_factor=scale_factor)
1211 yield
1212 finally:
1213 cls.__change_client_database(impala_client, db_name='default')
1214
1215 def execute_wrapper(function):
1216 """

Calls 1

Tested by

no test coverage detected