Skip to content

Commit 2128bd3

Browse files
authored
Merge pull request #299 from youngsofun/warehouse
feat: set warehouse header according to settings
2 parents 50cdcad + af58e42 commit 2128bd3

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

databend-jdbc/src/main/java/com/databend/jdbc/DatabendConnection.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,22 @@ private ClientSettings.Builder makeClientSettings(String queryID, String host) {
786786

787787
private Map<String, String> setAdditionalHeaders() {
788788
Map<String, String> additionalHeaders = new HashMap<>();
789-
if (!this.driverUri.getWarehouse().isEmpty()) {
790-
additionalHeaders.put(DatabendWarehouseHeader, this.driverUri.getWarehouse());
789+
790+
DatabendSession session = this.getSession();
791+
String warehouse = null;
792+
if (session != null ) {
793+
Map<String, String> settings = session.getSettings();
794+
if (settings != null) {
795+
warehouse = settings.get("warehouse");
796+
}
797+
}
798+
if (warehouse == null && !this.driverUri.getWarehouse().isEmpty()) {
799+
warehouse = this.driverUri.getWarehouse();
791800
}
801+
if (warehouse!=null) {
802+
additionalHeaders.put(DatabendWarehouseHeader, warehouse);
803+
}
804+
792805
if (!this.driverUri.getTenant().isEmpty()) {
793806
additionalHeaders.put(DatabendTenantHeader, this.driverUri.getTenant());
794807
}

databend-jdbc/src/main/java/com/databend/jdbc/DatabendStatement.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,6 @@ private void clearCurrentResults() {
165165
currentResult.set(null);
166166
}
167167

168-
private void updateClientSession(QueryResults q) {
169-
if (q == null) {
170-
return;
171-
}
172-
DatabendSession session = q.getSession();
173-
if (session == null) {
174-
return;
175-
}
176-
// current query has result on update client session
177-
DatabendConnection connection = this.connection.get();
178-
connection.setSession(session);
179-
}
180-
181168
final boolean internalExecute(String sql, StageAttachment attachment) throws SQLException {
182169
clearCurrentResults();
183170
checkOpen();

0 commit comments

Comments
 (0)