Skip to content
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

feat:support Apache Doris database connector #22836

Draft
wants to merge 4 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions plugins/org.jkiss.dbeaver.ext.mysql/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,33 @@
<parameter name="supports-collations" value="false"/>
<parameter name="supportsClients" value="false"/>
</driver>
<driver
id="apache_doris"
label="Apache Doris"
icon="icons/doris_icon.png"
iconBig="icons/doris_icon_big.png"
logoImage="icons/doris_logo.png"
class="com.mysql.cj.jdbc.Driver"
sampleURL="jdbc:mysql://{host}[:{port}]/[{database}]"
defaultPort="9030"
description="Driver for MySQL 8 and Apache Doris"
webURL="https://doris.apache.org/docs/dev/get-starting/quick-start/"
categories="sql">
<file type="jar" path="maven:/com.mysql:mysql-connector-j:RELEASE[8.3.0]" bundle="!drivers.mysql"/>
<file type="license" path="https://www.gnu.org/licenses/old-licenses/lgpl-2.0.txt" bundle="!drivers.mysql"/>
<file type="license" path="drivers/mysql/LICENSE.txt" bundle="drivers.mysql"/>
<file type="jar" path="drivers/mysql/mysql8" bundle="drivers.mysql"/>

<property name="connectTimeout" value="20000"/>
<parameter name="supports-partitions" value="false"/>
<parameter name="supports-references" value="false"/>
<parameter name="supports-triggers" value="false"/>
<parameter name="supports-events" value="false"/>
<parameter name="supports-users" value="false"/>
<parameter name="supports-charsets" value="false"/>
<parameter name="supports-collations" value="false"/>
<parameter name="supportsClients" value="false"/>
</driver>
<provider-properties drivers="*">
<propertyGroup label="Advanced">
<property id="@dbeaver-serverTimezone@" label="Server Time Zone" type="string"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MySQLConstants {
public static final String DRIVER_ID_MYSQL = "mysql5";
public static final String DRIVER_ID_MYSQL8 = "mysql8";
public static final String DRIVER_ID_MARIA_DB = "mariaDB";
public static final String DRIVER_ID_DORIS = "apache_doris";
public static final String DRIVER_CLASS_MARIA_DB = "org.mariadb.jdbc.Driver";
public static final String DRIVER_PARAM_CLIENTS = "supportsClients";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ protected MySQLCatalog createDatabaseObject(DBRProgressMonitor monitor, DBEComma
protected void addObjectCreateActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectCreateCommand command, Map<String, Object> options)
{
final MySQLCatalog catalog = command.getObject();
final StringBuilder script = new StringBuilder("CREATE SCHEMA `" + catalog.getName() + "`");
appendDatabaseModifiers(catalog, script);
final StringBuilder script;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reformat this code please.
Because we are not using quotes anymore, we have a special function.
So, it will be

String catalogName = DBUtils.getQuotedIdentifier(catalog);
...
new StringBuilder("CREATE DATABASE " + catalogName);
...
new StringBuilder("CREATE SCHEMA " + catalogName);

if (catalog.getDataSource().isDoris()) {
script = new StringBuilder("CREATE DATABASE `" + catalog.getName() + "`");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And how about the DROP and ALTER statements in this class?

} else {
script = new StringBuilder("CREATE SCHEMA `" + catalog.getName() + "`");
appendDatabaseModifiers(catalog, script);
}

actions.add(
new SQLDatabasePersistAction("Create schema", script.toString()) //$NON-NLS-2$
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,11 @@ public boolean isMariaDB() {
getContainer().getDriver().getDriverClassName());
}

public boolean isDoris() {
return MySQLConstants.DRIVER_ID_DORIS.equals(
getContainer().getDriver().getId());
}

@Override
public ErrorType discoverErrorType(@NotNull Throwable error) {
if (isMariaDB()) {
Expand Down