forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor](dialect) Add sql dialect converter plugins (apache#28890)
The current logic for SQL dialect conversion is all in the `fe-core` module, which may lead to the following issues: - Changes to the dialect conversion logic may occur frequently, requiring users to upgrade the Doris version frequently within the fe-core module, leading to a longer change cycle. - The cost of customized development is high, requiring users to replace the fe-core JAR package. Turning it into a plugin can address the above issues properly.
- Loading branch information
Showing
54 changed files
with
1,597 additions
and
485 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
101 changes: 101 additions & 0 deletions
101
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/Dialect.java
This file contains 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,101 @@ | ||
// 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.doris.nereids.parser; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* ParseDialect enum, maybe support other dialect. | ||
*/ | ||
public enum Dialect { | ||
/** | ||
* Doris parser dialect | ||
*/ | ||
DORIS("doris"), | ||
/** | ||
* Trino parser dialect | ||
*/ | ||
TRINO("trino"), | ||
/** | ||
* Presto parser dialect | ||
*/ | ||
PRESTO("presto"), | ||
/** | ||
* Spark sql parser dialect | ||
*/ | ||
SPARK_SQL("spark_sql"), | ||
/** | ||
* Hive parser dialect | ||
*/ | ||
HIVE("hive"), | ||
/** | ||
* Alibaba max compute parser dialect | ||
*/ | ||
MAX_COMPUTE("max_compute"), | ||
/** | ||
* Mysql parser dialect | ||
*/ | ||
MYSQL("mysql"), | ||
/** | ||
* Postgresql parser dialect | ||
*/ | ||
POSTGRESQL("postgresql"), | ||
/** | ||
* Sqlserver parser dialect | ||
*/ | ||
SQLSERVER("sqlserver"), | ||
/** | ||
* Clickhouse parser dialect | ||
*/ | ||
CLICKHOUSE("clickhouse"), | ||
/** | ||
* Sap hana parser dialect | ||
*/ | ||
SAP_HANA("sap_hana"), | ||
/** | ||
* OceanBase parser dialect | ||
*/ | ||
OCEANBASE("oceanbase"); | ||
|
||
public static final int MAX_DIALECT_SIZE = Dialect.values().length; | ||
|
||
private final String dialectName; | ||
|
||
Dialect(String dialectName) { | ||
this.dialectName = dialectName; | ||
} | ||
|
||
public String getDialectName() { | ||
return dialectName; | ||
} | ||
|
||
/** | ||
* Get dialect by name | ||
*/ | ||
public static @Nullable Dialect getByName(String dialectName) { | ||
if (dialectName == null) { | ||
return null; | ||
} | ||
for (Dialect dialect : Dialect.values()) { | ||
if (dialect.getDialectName().equals(dialectName.toLowerCase())) { | ||
return dialect; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains 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 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.