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

Function get_hs2_impala_cursor

tests/performance/query_exec_functions.py:85–110  ·  view source on GitHub ↗

Get a cursor to an impalad Args: impalad: A string in form 'hostname:port' or 'hostname' use_kerberos: boolean indication whether to get a secure connection. database: default db to use in the connection. Returns: HiveServer2Cursor if the connection suceeds, None otherwise.

(impalad, use_kerberos=False, database=None)

Source from the content-addressed store, hash-verified

83
84
85def get_hs2_impala_cursor(impalad, use_kerberos=False, database=None):
86 """Get a cursor to an impalad
87
88 Args:
89 impalad: A string in form 'hostname:port' or 'hostname'
90 use_kerberos: boolean indication whether to get a secure connection.
91 database: default db to use in the connection.
92
93 Returns:
94 HiveServer2Cursor if the connection suceeds, None otherwise.
95 """
96 try:
97 host, port = impalad.split(":")
98 except ValueError:
99 host, port = impalad, DEFAULT_HS2_PORT
100 cursor = None
101 try:
102 conn = connect(host=host,
103 port=port,
104 database=database,
105 auth_mechanism="GSSAPI" if use_kerberos else "NOSASL")
106 cursor = conn.cursor()
107 LOG.info("Connected to {0}:{1}".format(host, port))
108 except Exception as e:
109 LOG.error("Error connecting: {0}".format(str(e)))
110 return cursor
111
112
113def execute_using_impala_hs2(query, query_config):

Callers 1

execute_using_impala_hs2Function · 0.85

Calls 3

cursorMethod · 0.45
formatMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected