<!--
  ~ 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.
  ~
  -->

<h1 align="center">
   <img src="./images/selectdb.png"
   alt="SelectDB Logo" title="SelectDB Logo" width="600"/>
  <br>
</h1>

<h3 align="center">Cloud-Native Realtime Data Warehouse</h3>

<div align="center">

![](./images/doris-sql-convertor.png)


**[Website](https://selectdb.com)**&nbsp;&nbsp;|&nbsp;&nbsp;
**[Document](https://www.selectdb.com/tools/doris-sql-convertor)**&nbsp;&nbsp;
**[Playgroud](https://play.selectdb.com/sql-convertor?case_sensitive=0)**&nbsp;&nbsp;

</div>


## 🚀 What is doris-sql-converter?


> SQL Converter is a dedicated SQL Converter that allows seamless switching of multi-source SQL dialects to Doris, achieving smooth business migration.


## 🔨 Requirements
- python >= 3.7
- Node >= 16.20.2
- yarn >= 1.22.22

## 🔨 Build

```shell
sh build.sh ${APP_VERSION} ${ARCHITECTURE}

eg:
cd server
sh build.sh 1.0.6 x64
```

## 🔨 How to Use

```shell
cd sql-converter-1.0.6-x64

# start apiserver
vim apiserver/config.conf
sh apiserver/bin/start.sh
# In doris, set global sql_converter_service_url = "http://ip:api-port/api/v1/convert"
# Or access it through the curl command
    curl --location 'http://127.0.0.1:5001/api/v1/convert' \
    --header 'Content-Type: application/json' \
    --data '{
        "version":"v1",
        "sql_query":"select aa,sum(score) filter(where index_name=idx) as avg_score from table group by aa",
        "from":"presto",
        "to":"doris",
        "source": "text",
        "case_sensitive":"0"
    }'

# If you need to access the front-end interface, start webserver, 
# visit http://ip:webserver-port/ to enter the front-end interface
vim webserver/config.conf
sh webserver/bin/start.sh
```

