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.
- Loading branch information
wangxiangyu
committed
Dec 27, 2023
1 parent
c59dd84
commit 09b5c11
Showing
4 changed files
with
135 additions
and
31 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
46 changes: 46 additions & 0 deletions
46
fe/fe-core/src/test/java/org/apache/doris/plugin/TestHiveDialectPlugin.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,46 @@ | ||
// 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.plugin; | ||
|
||
import org.apache.doris.analysis.StatementBase; | ||
import org.apache.doris.nereids.parser.Dialect; | ||
import org.apache.doris.qe.SessionVariable; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
|
||
import java.util.List; | ||
|
||
public class TestHiveDialectPlugin extends Plugin implements DialectConverterPlugin { | ||
|
||
private static final String TEST_CONVERTED_SQL = "select 1"; | ||
|
||
@Override | ||
public ImmutableSet<Dialect> acceptDialects() { | ||
return ImmutableSet.of(Dialect.HIVE); | ||
} | ||
|
||
@Override | ||
public String convertSql(String originSql, SessionVariable sessionVariable) { | ||
return TEST_CONVERTED_SQL; | ||
} | ||
|
||
@Override | ||
public List<StatementBase> parseSqlWithDialect(String sql, SessionVariable sessionVariable) { | ||
return null; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
fe/fe-core/src/test/java/org/apache/doris/plugin/TestSparkDialectPlugin.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,42 @@ | ||
// 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.plugin; | ||
|
||
import org.apache.doris.analysis.StatementBase; | ||
import org.apache.doris.nereids.parser.Dialect; | ||
import org.apache.doris.nereids.parser.NereidsParser; | ||
import org.apache.doris.qe.SessionVariable; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
|
||
import java.util.List; | ||
|
||
public class TestSparkDialectPlugin extends Plugin implements DialectConverterPlugin { | ||
|
||
private static final String TEST_CONVERTED_SQL = "select 2"; | ||
|
||
@Override | ||
public ImmutableSet<Dialect> acceptDialects() { | ||
return ImmutableSet.of(Dialect.SPARK_SQL); | ||
} | ||
|
||
@Override | ||
public List<StatementBase> parseSqlWithDialect(String sql, SessionVariable sessionVariable) { | ||
return new NereidsParser().parseSQL(TEST_CONVERTED_SQL, sessionVariable); | ||
} | ||
} |