Skip to content

Commit 68dd514

Browse files
authored
pass hive location from client (#90)
* pass hive location from client * fix message display
1 parent c33548e commit 68dd514

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

proto/sqlflow/proto/sqlflow.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ message Session {
2424
string db_conn_str = 2;
2525
bool exit_on_submit = 3;
2626
string user_id = 4;
27+
// for loading CSV to hive
28+
string hive_location = 5;
29+
string hdfs_namenode_addr = 6;
2730
}
2831

2932
// SQL statements to run

sqlflow/client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ def sql_request(self, sql):
6767
db_conn_str = os.getenv("SQLFLOW_DATASOURCE", "")
6868
exit_on_submit_env = os.getenv("SQLFLOW_EXIT_ON_SUBMIT", "True")
6969
user_id = os.getenv("SQLFLOW_USER_ID", "")
70+
hive_location = os.getenv("SQLFLOW_HIVE_LOCATION", "")
71+
hdfs_namenode_addr = os.getenv("SQLFLOW_HDFS_NAMENODE_ADDR", "")
7072
if exit_on_submit_env.isdigit():
7173
exit_on_submit = bool(int(exit_on_submit_env))
7274
else:
7375
exit_on_submit = exit_on_submit_env.lower() == "true"
74-
se = pb.Session(token=token, db_conn_str=db_conn_str, exit_on_submit=exit_on_submit, user_id=user_id)
76+
se = pb.Session(token=token,
77+
db_conn_str=db_conn_str,
78+
exit_on_submit=exit_on_submit,
79+
user_id=user_id,
80+
hive_location=hive_location,
81+
hdfs_namenode_addr=hdfs_namenode_addr)
7582
try:
7683
sql = self._expander.expand(sql)
7784
except Exception as e:
@@ -127,13 +134,15 @@ def display(cls, stream_response):
127134
else:
128135
all_messages = []
129136
all_messages.append(first.message.message)
137+
eoe = None
130138
for res in stream_response:
131139
if res.WhichOneof('response') == 'eoe':
132140
_LOGGER.info("end execute %s, spent: %d" % (res.eoe.sql, res.eoe.spent_time_seconds))
133-
compound_message.add_message('\n'.join(all_messages), res)
141+
eoe = res
134142
break
135143
_LOGGER.debug(res.message.message)
136144
all_messages.append(res.message.message)
145+
compound_message.add_message('\n'.join(all_messages), eoe)
137146
else:
138147
column_names = [column_name for column_name in first.head.column_names]
139148
def rows_gen():

sqlflow/compound_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _repr_html_(self):
4444
if isinstance(r[0], Rows):
4545
all_html = ''.join([all_html, r[0]._repr_html_()])
4646
else:
47-
all_html = ''.join([all_html, "<p>%s</p>" % (r[0].__str__())])
47+
all_html = ''.join([all_html, "<p>%s</p>" % (r[0].__str__().replace("\n", "<br>"))])
4848
return all_html
4949

5050
def get(self, idx):

0 commit comments

Comments
 (0)