You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "corgy-w (via GitHub)" <gi...@apache.org> on 2024/08/24 07:58:36 UTC
[PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
corgy-w opened a new pull request, #7484:
URL: https://github.com/apache/seatunnel/pull/7484
### Purpose of this pull request
issue : #7480
### Does this PR introduce _any_ user-facing change?
### How was this patch tested?
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If you are contributing the connector code, please check that the following files are updated:
1. Update change log that in connector document. For more details you can refer to [connector-v2](https://github.com/apache/seatunnel/tree/dev/docs/en/connector-v2)
2. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
3. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
* [ ] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1734048940
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcHiveIT.java:
##########
@@ -43,7 +44,7 @@ public class JdbcHiveIT extends AbstractJdbcIT {
private static final String HIVE_DATABASE = "default";
- private static final String HIVE_SOURCE = "e2e_table_source";
+ private static final String HIVE_SOURCE = "hive_e2e_source_table";
Review Comment:

In this case, the create statement is `hive_e2e_source_table`
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1732336983
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/JdbcCatalogUtilsTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.catalog;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Disabled("Configure your own environment")
+public class JdbcCatalogUtilsTest {
Review Comment:
just put it in `AbstractJdbcIT`
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1729800517
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/JdbcCatalogUtilsTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.catalog;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Disabled("Configure your own environment")
+public class JdbcCatalogUtilsTest {
+
+ @Test
+ public void test() throws SQLException, ClassNotFoundException {
+ List<JdbcSourceTableConfig> tablesConfig = new ArrayList<>();
+ // JdbcSourceTableConfig(tablePath=null, query=select age, name,gender from `dbs`.`user`,
+ // partitionColumn=null, partitionNumber=10, partitionStart=null, partitionEnd=null,
+ // useSelectCount=false, skipAnalyze=false)
+ JdbcSourceTableConfig tableConfig =
+ JdbcSourceTableConfig.builder()
+ .query("SELECT age, user1.name AS name1, gender FROM user1 ; ")
+ .useSelectCount(false)
+ .build();
+ tablesConfig.add(tableConfig);
+ JdbcCatalogUtils.getTables(
+ JdbcConnectionConfig.builder()
+ .url(
+ "jdbc:mysql://xxxx:3306/xxx?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true")
+ .username("root")
+ .password("xxxxxx")
+ .build(),
+ tablesConfig);
Review Comment:
get
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1729824175
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -290,7 +300,11 @@ public static CatalogTable getCatalogTable(
}
String catalogName = "jdbc_catalog";
return CatalogTable.of(
- TableIdentifier.of(catalogName, "default", "default", "default"),
+ TableIdentifier.of(
+ catalogName,
+ StringUtils.isBlank(databaseName) ? null : databaseName,
+ StringUtils.isBlank(schemaName) ? null : schemaName,
+ StringUtils.isBlank(tableName) ? "default" : tableName),
Review Comment:
keep old logic, format will be somewhat unconventional.
eg:mysql-> dbname.default.tablename , ck->default.shname.tablename
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1732295431
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/JdbcCatalogUtilsTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.catalog;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Disabled("Configure your own environment")
+public class JdbcCatalogUtilsTest {
Review Comment:
Please remove this file.
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "wuchunfu (via GitHub)" <gi...@apache.org>.
wuchunfu merged PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "wuchunfu (via GitHub)" <gi...@apache.org>.
wuchunfu commented on PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#issuecomment-2313927360
@corgy-w Please resolve the CI issue, thanks
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1732340611
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/JdbcCatalogUtilsTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.catalog;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Disabled("Configure your own environment")
+public class JdbcCatalogUtilsTest {
Review Comment:
I know
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1729827042
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -290,7 +300,11 @@ public static CatalogTable getCatalogTable(
}
String catalogName = "jdbc_catalog";
return CatalogTable.of(
- TableIdentifier.of(catalogName, "default", "default", "default"),
+ TableIdentifier.of(
+ catalogName,
+ StringUtils.isBlank(databaseName) ? null : databaseName,
+ StringUtils.isBlank(schemaName) ? null : schemaName,
+ StringUtils.isBlank(tableName) ? "default" : tableName),
Review Comment:
How about when `tableName` name is null, set tablepath to `default.default.default`? Otherwise keep as it is.
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1734040673
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcHiveIT.java:
##########
@@ -43,7 +44,7 @@ public class JdbcHiveIT extends AbstractJdbcIT {
private static final String HIVE_DATABASE = "default";
- private static final String HIVE_SOURCE = "e2e_table_source";
+ private static final String HIVE_SOURCE = "hive_e2e_source_table";
Review Comment:
why change this?
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1729825471
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -272,6 +272,16 @@ public static CatalogTable getCatalogTable(
throws SQLException {
TableSchema.Builder schemaBuilder = TableSchema.builder();
Map<String, String> unsupported = new LinkedHashMap<>();
+ String tableName = null;
+ String databaseName = null;
+ String schemaName = null;
+ try {
+ int columnCount = metadata.getColumnCount();
+ tableName = metadata.getTableName(columnCount);
+ databaseName = metadata.getCatalogName(columnCount);
+ schemaName = metadata.getSchemaName(columnCount);
Review Comment:
<img width="647" alt="image" src="https://github.com/user-attachments/assets/fae3bdc1-b0f6-48c7-a79d-680b310b5f97">
`getColumnCount` is like a pre-judgement. If it's not exist on the throw SQLException.of course, can use `getTableName (1)`, which always gets the first element in metadata.
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1734048940
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcHiveIT.java:
##########
@@ -43,7 +44,7 @@ public class JdbcHiveIT extends AbstractJdbcIT {
private static final String HIVE_DATABASE = "default";
- private static final String HIVE_SOURCE = "e2e_table_source";
+ private static final String HIVE_SOURCE = "hive_e2e_source_table";
Review Comment:
In this case, the create statement is `hive_e2e_source_table`
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1729825471
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -272,6 +272,16 @@ public static CatalogTable getCatalogTable(
throws SQLException {
TableSchema.Builder schemaBuilder = TableSchema.builder();
Map<String, String> unsupported = new LinkedHashMap<>();
+ String tableName = null;
+ String databaseName = null;
+ String schemaName = null;
+ try {
+ int columnCount = metadata.getColumnCount();
+ tableName = metadata.getTableName(columnCount);
+ databaseName = metadata.getCatalogName(columnCount);
+ schemaName = metadata.getSchemaName(columnCount);
Review Comment:
<img width="619" alt="image" src="https://github.com/user-attachments/assets/a548ca73-3515-4c6e-bf07-d665c2004984">
`getColumnCount` is like a pre-judgement. If it's not exist on the throw SQLException.of course, can use `getTableName (1)`, which always gets the first element in metadata.
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -272,6 +272,16 @@ public static CatalogTable getCatalogTable(
throws SQLException {
TableSchema.Builder schemaBuilder = TableSchema.builder();
Map<String, String> unsupported = new LinkedHashMap<>();
+ String tableName = null;
+ String databaseName = null;
+ String schemaName = null;
+ try {
+ int columnCount = metadata.getColumnCount();
+ tableName = metadata.getTableName(columnCount);
+ databaseName = metadata.getCatalogName(columnCount);
+ schemaName = metadata.getSchemaName(columnCount);
Review Comment:
`getColumnCount` is like a pre-judgement. If it's not exist on the throw SQLException.of course, can use `getTableName (1)`, which always gets the first element in metadata.
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#issuecomment-2314139717
https://github.com/corgy-w/seatunnel/actions/runs/10589410082/job/29343488028
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] fix part jdbc-multi-metrics bug [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1729797033
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -272,6 +272,16 @@ public static CatalogTable getCatalogTable(
throws SQLException {
TableSchema.Builder schemaBuilder = TableSchema.builder();
Map<String, String> unsupported = new LinkedHashMap<>();
+ String tableName = null;
+ String databaseName = null;
+ String schemaName = null;
+ try {
+ int columnCount = metadata.getColumnCount();
+ tableName = metadata.getTableName(columnCount);
+ databaseName = metadata.getCatalogName(columnCount);
+ schemaName = metadata.getSchemaName(columnCount);
Review Comment:
Why we need `getTableName` with `columnCount`? Is this way of api design?
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/JdbcCatalogUtilsTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.catalog;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Disabled("Configure your own environment")
+public class JdbcCatalogUtilsTest {
+
+ @Test
+ public void test() throws SQLException, ClassNotFoundException {
+ List<JdbcSourceTableConfig> tablesConfig = new ArrayList<>();
+ // JdbcSourceTableConfig(tablePath=null, query=select age, name,gender from `dbs`.`user`,
+ // partitionColumn=null, partitionNumber=10, partitionStart=null, partitionEnd=null,
+ // useSelectCount=false, skipAnalyze=false)
+ JdbcSourceTableConfig tableConfig =
+ JdbcSourceTableConfig.builder()
+ .query("SELECT age, user1.name AS name1, gender FROM user1 ; ")
+ .useSelectCount(false)
+ .build();
+ tablesConfig.add(tableConfig);
+ JdbcCatalogUtils.getTables(
+ JdbcConnectionConfig.builder()
+ .url(
+ "jdbc:mysql://xxxx:3306/xxx?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true")
+ .username("root")
+ .password("xxxxxx")
+ .build(),
+ tablesConfig);
Review Comment:
Please put this test case into https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e and enable it.
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:
##########
@@ -290,7 +300,11 @@ public static CatalogTable getCatalogTable(
}
String catalogName = "jdbc_catalog";
return CatalogTable.of(
- TableIdentifier.of(catalogName, "default", "default", "default"),
+ TableIdentifier.of(
+ catalogName,
+ StringUtils.isBlank(databaseName) ? null : databaseName,
+ StringUtils.isBlank(schemaName) ? null : schemaName,
+ StringUtils.isBlank(tableName) ? "default" : tableName),
Review Comment:
Please keep the old logic. The default TablePath should be `default.default.default`.
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2] Fix jdbc query sql can not get table path [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w commented on code in PR #7484:
URL: https://github.com/apache/seatunnel/pull/7484#discussion_r1732308438
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/JdbcCatalogUtilsTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.catalog;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Disabled("Configure your own environment")
+public class JdbcCatalogUtilsTest {
Review Comment:
get, I think this pr test case is not complete, I have tested it in mysql, but this case should be the common of all jdbc
--
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@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org