-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from youngsofun/cookie
feat: support temp table.
- Loading branch information
Showing
8 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
databend-client/src/main/java/com/databend/client/GlobalCookieJar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.databend.client; | ||
|
||
import okhttp3.Cookie; | ||
import okhttp3.CookieJar; | ||
import okhttp3.HttpUrl; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class GlobalCookieJar implements CookieJar { | ||
private final Map<String, Cookie> cookieStore = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) { | ||
for (Cookie cookie : cookies) { | ||
cookieStore.put(cookie.name(), cookie); | ||
} | ||
} | ||
|
||
@Override | ||
public List<Cookie> loadForRequest(HttpUrl url) { | ||
return new ArrayList<>(cookieStore.values()); | ||
} | ||
|
||
public void add(Cookie cookie) { | ||
cookieStore.put(cookie.name(), cookie); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
databend-jdbc/src/test/java/com/databend/jdbc/TestTempTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.databend.jdbc; | ||
|
||
import org.junit.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
public class TestTempTable { | ||
|
||
@Test | ||
public void testTempTable() throws SQLException { | ||
try(Connection c1 = Utils.createConnection()) { | ||
Statement statement= c1.createStatement(); | ||
statement.execute("create or replace temp table table1(i int)"); | ||
statement.execute("insert into table1 values (1), (2)"); | ||
statement.executeQuery("select * from table1"); | ||
ResultSet rs = statement.getResultSet(); | ||
Assert.assertEquals(true, rs.next()); | ||
Assert.assertEquals(1, rs.getInt(1)); | ||
Assert.assertEquals(true, rs.next()); | ||
Assert.assertEquals(2, rs.getInt(1)); | ||
Assert.assertEquals(false, rs.next()); | ||
} | ||
} | ||
} |