Skip to content

Commit be2754e

Browse files
authored
Merge branch 'master' into trino_query_explain
2 parents e9d1b4d + fe9968c commit be2754e

File tree

5 files changed

+94
-2
lines changed

5 files changed

+94
-2
lines changed

apps/impala/src/impala/conf.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
type=coerce_bool,
7474
dynamic_default=is_impersonation_enabled)
7575

76+
COORDINATOR_UI_SPNEGO = Config(
77+
key='coordinator_ui_spnego',
78+
help=_t("Impala Coordinator Web Server has Spnego enabled."),
79+
type=coerce_bool,
80+
default=False)
81+
7682
QUERYCACHE_ROWS = Config(
7783
key='querycache_rows',
7884
help=_t("Number of initial rows of a resultset to ask Impala to cache in order to"
@@ -121,7 +127,8 @@
121127
USER_SCRATCH_DIR_PERMISSION = Config(
122128
key="user_scratch_dir_permission",
123129
help=_t("Due to IMPALA-10272, the importer fails with READ permissions."
124-
"Setting this to True, means setting the scratch directory and its file to 777 so the importer does not fail with permission issue."),
130+
"Setting this to True, means setting the scratch directory and its file to 777 so the importer "
131+
"does not fail with permission issue."),
125132
type=coerce_bool,
126133
default=False
127134
)

apps/jobbrowser/src/jobbrowser/apis/query_api.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
from babel import localtime
2828
import os
2929

30+
from urllib.parse import urlparse
31+
3032
from desktop.lib import export_csvxls
33+
from impala.conf import COORDINATOR_UI_SPNEGO
3134
from libanalyze import analyze as analyzer, rules
3235
from notebook.conf import ENABLE_QUERY_ANALYSIS
3336

@@ -158,12 +161,16 @@ def app(self, appid):
158161
}
159162
app = apps.get('apps')[0]
160163
progress_groups = re.search(r"([\d\.\,]+)%", app.get('progress'))
164+
parsed_api_url = urlparse(self.api.url)
165+
161166
app.update({
162167
'progress': float(progress_groups.group(1)) \
163168
if progress_groups and progress_groups.group(1) else 100 \
164169
if self._api_status(app.get('status')) in ['SUCCEEDED', 'FAILED'] else 1,
165170
'type': 'queries',
166-
'doc_url': "%s/query_plan?query_id=%s" % (self.api.url, appid),
171+
'doc_url': '%s/query_plan?query_id=%s' % (self.api.url, appid) if not COORDINATOR_UI_SPNEGO.get() else
172+
'%s/query_plan?scheme=%s&host=%s&port=%s&query_id=%s' %
173+
(self.api.url, parsed_api_url.scheme, parsed_api_url.hostname, parsed_api_url.port, appid),
167174
'properties': {
168175
'memory': '',
169176
'profile': '',

apps/jobbrowser/src/jobbrowser/apis/query_api_tests.py

+72
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from desktop.auth.backend import rewrite_user
2929
from desktop.lib.django_test_util import make_logged_in_client
30+
from impala.conf import COORDINATOR_UI_SPNEGO
3031
from useradmin.models import User
3132

3233
from jobbrowser.apis.query_api import QueryApi
@@ -102,3 +103,74 @@ def test_download_profile(self):
102103
assert_equal(resp.status_code, 200)
103104
assert_equal(resp['Content-Disposition'], 'attachment; filename="query-profile_00001.txt"')
104105
assert_equal(resp.content, b'Query (id=d94d2fb4815a05c4:b1ccec1500000000):\n Summary:...')
106+
107+
def test_doc_url(self):
108+
with patch('jobbrowser.apis.query_api._get_api') as _get_api:
109+
with patch('jobbrowser.apis.query_api.QueryApi.apps') as apps:
110+
_get_api.return_value = Mock(
111+
url='https://coordinator:25000'
112+
)
113+
114+
apps.return_value = {
115+
"apps": [{
116+
"id": "b246701d30ab0dd1:afc9f65900000000",
117+
"name": "SELECT *\nFROM `default`.web_logs\nLIMIT 100",
118+
"status": "FINISHED",
119+
"apiStatus": "SUCCEEDED",
120+
"type": "QUERY",
121+
"user": "test",
122+
"queue": "root.test",
123+
"progress": "4 / 4 ( 100%)",
124+
"isRunning": False,
125+
"canWrite": True,
126+
"duration": 1291.0,
127+
"submitted": "2024-03-06 17:59:15.304000",
128+
"rows_fetched": 100,
129+
"waiting": True,
130+
"waiting_time": "2s610ms"
131+
}],
132+
"total": 1
133+
}
134+
135+
result = QueryApi(self.user).app('b246701d30ab0dd1:afc9f65900000000')
136+
assert_equal(result.get('doc_url'),
137+
'https://coordinator:25000/query_plan?query_id=b246701d30ab0dd1:afc9f65900000000')
138+
139+
def test_doc_url_spnego(self):
140+
resets = [
141+
COORDINATOR_UI_SPNEGO.set_for_testing(True)
142+
]
143+
with patch('jobbrowser.apis.query_api._get_api') as _get_api:
144+
with patch('jobbrowser.apis.query_api.QueryApi.apps') as apps:
145+
_get_api.return_value = Mock(
146+
url='https://coordinator:25000'
147+
)
148+
149+
apps.return_value = {
150+
"apps": [{
151+
"id": "b246701d30ab0dd1:afc9f65900000000",
152+
"name": "SELECT *\nFROM `default`.web_logs\nLIMIT 100",
153+
"status": "FINISHED",
154+
"apiStatus": "SUCCEEDED",
155+
"type": "QUERY",
156+
"user": "test",
157+
"queue": "root.test",
158+
"progress": "4 / 4 ( 100%)",
159+
"isRunning": False,
160+
"canWrite": True,
161+
"duration": 1291.0,
162+
"submitted": "2024-03-06 17:59:15.304000",
163+
"rows_fetched": 100,
164+
"waiting": True,
165+
"waiting_time": "2s610ms"
166+
}],
167+
"total": 1
168+
}
169+
try:
170+
result = QueryApi(self.user).app('b246701d30ab0dd1:afc9f65900000000')
171+
assert_equal(result.get('doc_url'),
172+
'https://coordinator:25000/query_plan?'
173+
'scheme=https&host=coordinator&port=25000&query_id=b246701d30ab0dd1:afc9f65900000000')
174+
finally:
175+
for reset in resets:
176+
reset()

desktop/conf.dist/hue.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,9 @@ submit_to=True
15061506
# Turn on/off impersonation mechanism when talking to Impala
15071507
## impersonation_enabled=False
15081508

1509+
# Impala Coordinator Web Server has Spnego enabled
1510+
## coordinator_ui_spnego=false
1511+
15091512
# Number of initial rows of a result set to ask Impala to cache in order
15101513
# to support re-fetching them for downloading them.
15111514
# Set to 0 for disabling the option and backward compatibility.

desktop/conf/pseudo-distributed.ini.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,9 @@
14881488
# Turn on/off impersonation mechanism when talking to Impala
14891489
## impersonation_enabled=False
14901490

1491+
# Impala Coordinator Web Server has Spnego enabled
1492+
## coordinator_ui_spnego=false
1493+
14911494
# Number of initial rows of a result set to ask Impala to cache in order
14921495
# to support re-fetching them for downloading them.
14931496
# Set to 0 for disabling the option and backward compatibility.

0 commit comments

Comments
 (0)