You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kylin.apache.org by GitBox <gi...@apache.org> on 2018/06/20 11:32:45 UTC

[GitHub] shaofengshi closed pull request #90: satisfy multi-path of domain for kylin connection (against master)

shaofengshi closed pull request #90: satisfy multi-path of domain for kylin connection (against master)
URL: https://github.com/apache/kylin/pull/90
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java
index 6fb228afb9..991eca353c 100644
--- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java
+++ b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java
@@ -52,12 +52,12 @@ protected KylinConnection(UnregisteredDriver driver, KylinJdbcFactory factory, S
 
         String odbcUrl = url;
         odbcUrl = odbcUrl.replaceAll((Driver.CONNECT_STRING_PREFIX + "[[A-Za-z0-9]*=[A-Za-z0-9]*;]*//").toString(), "");
-        
+
         String[] temps = odbcUrl.split("/");
-        assert temps.length == 2;
+        assert temps.length >= 2;
 
-        this.baseUrl = temps[0];
-        this.project = temps[1];
+        this.project = temps[temps.length - 1];
+        this.baseUrl = odbcUrl.substring(0, odbcUrl.lastIndexOf(project) - 1);
 
         logger.debug("Kylin base url " + this.baseUrl + ", project name " + this.project);
 
diff --git a/jdbc/src/test/java/org/apache/kylin/jdbc/DriverTest.java b/jdbc/src/test/java/org/apache/kylin/jdbc/DriverTest.java
index 70978d72e0..9b66f4d2f5 100644
--- a/jdbc/src/test/java/org/apache/kylin/jdbc/DriverTest.java
+++ b/jdbc/src/test/java/org/apache/kylin/jdbc/DriverTest.java
@@ -104,6 +104,29 @@ public void testStatementWithQuestionMask() throws SQLException {
         conn.close();
     }
 
+    @Test
+    public void testMultipathOfDomainForConnection() throws SQLException {
+        Driver driver = new DummyDriver();
+
+        Connection conn = driver.connect("jdbc:kylin://test_url/kylin/test_db/", null);
+        Statement state = conn.createStatement();
+        ResultSet resultSet = state.executeQuery("select * from test_table where url not in ('http://a.b.com/?a=b') limit 1");
+        ResultSetMetaData metadata = resultSet.getMetaData();
+        assertEquals(12, metadata.getColumnType(1));
+        assertEquals("varchar", metadata.getColumnTypeName(1));
+        assertEquals(1, metadata.isNullable(1));
+
+        while (resultSet.next()) {
+            assertEquals("foo", resultSet.getString(1));
+            assertEquals("bar", resultSet.getString(2));
+            assertEquals("tool", resultSet.getString(3));
+        }
+
+        resultSet.close();
+        state.close();
+        conn.close();
+    }
+
     @Test
     public void testPreparedStatementWithMockData() throws SQLException {
         Driver driver = new DummyDriver();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services