You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/04/29 02:27:48 UTC

[GitHub] [incubator-inlong] lucaspeng12138 opened a new pull request, #4004: [INLONG-3883][Manager] Support create table of ClickHouse

lucaspeng12138 opened a new pull request, #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004

   ### Title Name: [INLONG-3883][Manager]Support create table with clickhouse
   Add create table to Manager Group.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869281625


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/ck/ClickHouseJdbcUtils.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.resource.ck;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseColumnInfo;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseTableInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import ru.yandex.clickhouse.ClickHouseDatabaseMetadata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utils for ClickHouse JDBC.
+ */
+public class ClickHouseJdbcUtils {
+
+    private static final String CLICKHOUSE_DRIVER_CLASS = "ru.yandex.clickhouse.ClickHouseDriver";
+    private static final String METADATA_TYPE = "TABLE";
+    private static final String COLUMN_LABEL = "TABLE_NAME";
+    private static final String CLICKHOUSE_JDBC_PREFIX = "jdbc:clickhouse";
+
+    private static final Logger LOG = LoggerFactory.getLogger(ClickHouseJdbcUtils.class);
+
+    /**
+     * Get ClickHouse connection from clickhouse url and user
+     */
+    public static Connection getConnection(String url, String user, String password) throws Exception {
+        if (StringUtils.isBlank(url) || !url.startsWith(CLICKHOUSE_JDBC_PREFIX)) {
+            throw new Exception("ClickHouse server URL was invalid, it should start with jdbc:clickhouse");
+        }
+        Connection conn;
+        try {
+            Class.forName(CLICKHOUSE_DRIVER_CLASS);
+            conn = DriverManager.getConnection(url, user, password);
+        } catch (Exception e) {
+            LOG.error("get clickhouse connection error, please check clickhouse jdbc url, username or password", e);
+            throw new Exception("get clickhouse connection error, please check jdbc url, username or password. "
+                    + "other error msg: " + e.getMessage());
+        }
+
+        if (conn == null) {
+            throw new Exception("get clickhouse connection failed, please contact administrator");
+        }
+
+        LOG.info("get clickhouse connection success, url={}", url);
+        return conn;
+    }
+
+    public static void executeSql(String sql, String url, String user, String password) throws Exception {

Review Comment:
   Please add some brief java docs for each static method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869277215


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/ck/ClickHouseSqlBuilder.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.resource.ck;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseColumnInfo;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseTableInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ClickHouseSqlBuilder<T> {

Review Comment:
   Does this generics `T` needed?
   Add, the builder should be a util class, so it should not declare to `abstract`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow merged pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
healchow merged PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] lucaspeng12138 closed pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
lucaspeng12138 closed pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse
URL: https://github.com/apache/incubator-inlong/pull/4004


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869277215


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/ck/ClickHouseSqlBuilder.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.resource.ck;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseColumnInfo;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseTableInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ClickHouseSqlBuilder<T> {

Review Comment:
   Does this generics `T` needed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869271903


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sink/ck/ClickHouseColumnInfo.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.pojo.sink.ck;
+
+import lombok.Data;
+
+@Data
+public class ClickHouseColumnInfo {
+
+    private String name;
+    private String type;
+    private String desc;
+    private String defaultType;
+    private String defaultExpr;
+
+    private String compressionCode;
+
+    private String tTLExpr;

Review Comment:
   Wouldn't it be better to replace `tTLExpr` with `ttlExpr`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] gong commented on pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
gong commented on PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#issuecomment-1112001087

   `git rebase master` before pull request.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] lucaspeng12138 commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
lucaspeng12138 commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869810203


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/ck/ClickHouseJdbcUtils.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.resource.ck;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseColumnInfo;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseTableInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import ru.yandex.clickhouse.ClickHouseDatabaseMetadata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utils for ClickHouse JDBC.
+ */
+public class ClickHouseJdbcUtils {
+
+    private static final String CLICKHOUSE_DRIVER_CLASS = "ru.yandex.clickhouse.ClickHouseDriver";
+    private static final String METADATA_TYPE = "TABLE";
+    private static final String COLUMN_LABEL = "TABLE_NAME";
+    private static final String CLICKHOUSE_JDBC_PREFIX = "jdbc:clickhouse";
+
+    private static final Logger LOG = LoggerFactory.getLogger(ClickHouseJdbcUtils.class);
+
+    /**
+     * Get ClickHouse connection from clickhouse url and user
+     */
+    public static Connection getConnection(String url, String user, String password) throws Exception {
+        if (StringUtils.isBlank(url) || !url.startsWith(CLICKHOUSE_JDBC_PREFIX)) {
+            throw new Exception("ClickHouse server URL was invalid, it should start with jdbc:clickhouse");
+        }
+        Connection conn;
+        try {
+            Class.forName(CLICKHOUSE_DRIVER_CLASS);
+            conn = DriverManager.getConnection(url, user, password);
+        } catch (Exception e) {
+            LOG.error("get clickhouse connection error, please check clickhouse jdbc url, username or password", e);
+            throw new Exception("get clickhouse connection error, please check jdbc url, username or password. "
+                    + "other error msg: " + e.getMessage());
+        }
+
+        if (conn == null) {
+            throw new Exception("get clickhouse connection failed, please contact administrator");
+        }
+
+        LOG.info("get clickhouse connection success, url={}", url);
+        return conn;
+    }
+
+    public static void executeSql(String sql, String url, String user, String password) throws Exception {

Review Comment:
   OK, I have add description.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] lucaspeng12138 commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
lucaspeng12138 commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869809996


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/ck/ClickHouseSqlBuilder.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.resource.ck;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseColumnInfo;
+import org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseTableInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ClickHouseSqlBuilder<T> {

Review Comment:
   You are right, I should fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] lucaspeng12138 commented on a diff in pull request #4004: [INLONG-3883][Manager] Support create table of ClickHouse

Posted by GitBox <gi...@apache.org>.
lucaspeng12138 commented on code in PR #4004:
URL: https://github.com/apache/incubator-inlong/pull/4004#discussion_r869809848


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sink/ck/ClickHouseColumnInfo.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.pojo.sink.ck;
+
+import lombok.Data;
+
+@Data
+public class ClickHouseColumnInfo {
+
+    private String name;
+    private String type;
+    private String desc;
+    private String defaultType;
+    private String defaultExpr;
+
+    private String compressionCode;
+
+    private String tTLExpr;

Review Comment:
   Good idea, I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org