-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[feature][jdbc] Jdbc database support identifier #5089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3580756
[feature][jdbc] Jdbc database support identifier
XiaoJiang521 68707cb
[feature][jdbc] Add license
XiaoJiang521 8ef5634
[feature][jdbc] update sqlserver e2e and enum
XiaoJiang521 92af09d
[e2e] jdbc ide add e2e
XiaoJiang521 5d59ce5
[e2e] rename
XiaoJiang521 9ee7953
[e2e] add flink and spark
XiaoJiang521 e93b690
[feature] update e2e
XiaoJiang521 20c6452
[merge] merge dev
XiaoJiang521 ffea0cd
[e2e] update e2e
XiaoJiang521 3a27feb
[e2e] ide
XiaoJiang521 55491a1
[e2e] ide
XiaoJiang521 5830b20
Merge branch 'dev' into dev-jdbc-identifier
XiaoJiang521 9fa4bcd
[e2e] ide
XiaoJiang521 df3ebe9
[e2e] ide
XiaoJiang521 2ffd6c5
Merge branch 'dev' into dev-jdbc-identifier
XiaoJiang521 fb539f5
[bugfix] mvn spotless
XiaoJiang521 b9e2302
[bugfix] update select sql
XiaoJiang521 81f3c59
[bugfix] add docs
XiaoJiang521 d85bd63
Merge branch 'dev' into dev-jdbc-identifier
XiaoJiang521 8bc94cc
[feature] spotless
XiaoJiang521 723fe08
Merge branch 'dev' into dev-jdbc-identifier
XiaoJiang521 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
34 changes: 34 additions & 0 deletions
34
...apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dialectenum/FieldIdeEnum.java
This file contains hidden or 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,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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum; | ||
|
hailin0 marked this conversation as resolved.
|
||
|
|
||
| public enum FieldIdeEnum { | ||
| ORIGINAL("original"), // Original string form | ||
| UPPERCASE("uppercase"), // Convert to uppercase | ||
| LOWERCASE("lowercase"); // Convert to lowercase | ||
|
|
||
| private final String value; | ||
|
|
||
| FieldIdeEnum(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter; | ||
| import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; | ||
| import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; | ||
| import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum; | ||
|
|
||
| import java.sql.Connection; | ||
| import java.sql.PreparedStatement; | ||
|
|
@@ -33,6 +34,14 @@ public class PostgresDialect implements JdbcDialect { | |
|
|
||
| public static final int DEFAULT_POSTGRES_FETCH_SIZE = 128; | ||
|
|
||
| public String fieldIde = FieldIdeEnum.ORIGINAL.getValue(); | ||
|
|
||
| public PostgresDialect() {} | ||
|
|
||
| public PostgresDialect(String fieldIde) { | ||
| this.fieldIde = fieldIde; | ||
| } | ||
|
|
||
| @Override | ||
| public String dialectName() { | ||
| return "PostgreSQL"; | ||
|
|
@@ -88,4 +97,32 @@ public PreparedStatement creatPreparedStatement( | |
| } | ||
| return statement; | ||
| } | ||
|
|
||
| @Override | ||
| public String tableIdentifier(String database, String tableName) { | ||
| // resolve pg database name upper or lower not recognised | ||
| return quoteDatabaseIdentifier(database) + "." + quoteIdentifier(tableName); | ||
| } | ||
|
|
||
| @Override | ||
| public String quoteIdentifier(String identifier) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add test case for this new feature.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! e2e has been added |
||
| if (identifier.contains(".")) { | ||
| String[] parts = identifier.split("\\."); | ||
| StringBuilder sb = new StringBuilder(); | ||
| for (int i = 0; i < parts.length - 1; i++) { | ||
| sb.append("\"").append(parts[i]).append("\"").append("."); | ||
| } | ||
| return sb.append("\"") | ||
| .append(getFieldIde(parts[parts.length - 1], fieldIde)) | ||
| .append("\"") | ||
| .toString(); | ||
| } | ||
|
|
||
| return "\"" + getFieldIde(identifier, fieldIde) + "\""; | ||
| } | ||
|
|
||
| @Override | ||
| public String quoteDatabaseIdentifier(String identifier) { | ||
| return "\"" + identifier + "\""; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.