You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/07/16 03:55:49 UTC

[GitHub] [doris] Toms1999 opened a new pull request, #10905: will mysql database export doris

Toms1999 opened a new pull request, #10905:
URL: https://github.com/apache/doris/pull/10905

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem Summary:
   
   Describe the overview of changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (Yes/No/I Don't know)
   2. Has unit tests been added: (Yes/No/No Need)
   3. Has document been added or modified: (Yes/No/No Need)
   4. Does it need to update dependencies: (Yes/No)
   5. Are there any changes that cannot be rolled back: (Yes/No)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r935507013


##########
extension/mysql_to_doris/user_define_tables.sh:
##########
@@ -0,0 +1,144 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql tables import doris by external and by user to define tables
+####################################################################
+
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p user_files
+rm -rf ./user_files/tables
+rm -rf ./user_files/tables.sql
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./conf/tables)
+        do
+        sed -i "/${table}view/d" ./conf/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql_host -uroot -p$mysql_password 2>/dev/null >> ./user_files/tables.sql
+        echo "print ${table} sql to tables.sql in the user_file dir"
+done
+
+echo '==============================start to transform mysql table for doris extral table======================'
+
+#adjust sql
+awk -F '\t' '{print $2}' ./user_files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./user_files/tables1.sql
+sed -i 's/\\n/\n/g' ./user_files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./user_files/tables1.sql > ./user_files/tables2.sql
+
+#delete tables special struct
+sed -i '/^  CON/d' ./user_files/tables2.sql
+sed -i '/^  KEY/d' ./user_files/tables2.sql
+rm -rf ./user_files/tables.sql
+rm -rf ./user_files/tables1.sql
+mv ./user_files/tables2.sql ./user_files/tables.sql
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./user_files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./user_files/tables.sql
+sed -i '/PRIMARY KEY/d' ./user_files/tables.sql
+sed -i '/UNIQUE KEY/d' ./user_files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./user_files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./user_files/tables.sql
+
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./conf/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql_host}/" ./user_files/tables.sql
+        sed -i "0,/ApacheDorisHostPassword/s/ApacheDorisHostPassword/${mysql_password}/" ./user_files/tables.sql
+        sed -i "0,/ApacheDorisDataBases/s/ApacheDorisDataBases/${d_mysql}/" ./user_files/tables.sql
+        sed -i "0,/ApacheDorisTables/s/ApacheDorisTables/${t_name}/" ./user_files/tables.sql
+
+done
+#replace mysql type with doris
+sed -i 's/\<text\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<tinyblob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<blob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<mediumblob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<longblob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<tinystring\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<mediumstring\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<longstring\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<timestamp\>/datetime/g' ./user_files/tables.sql
+sed -i 's/AUTO_INCREMENT//g' ./user_files/tables.sql
+sed -i 's/\<unsigned\>//g' ./user_files/tables.sql
+sed -i 's/\<zerofill\>//g' ./user_files/tables.sql
+sed -i 's/\<json\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/enum([^)]*)/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<set\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<bit\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci//g'  ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8_general_ci//g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_general_ci//g' ./user_files/tables.sql
+sed -i 's/COLLATE utf8mb4_general_ci//g' ./user_files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./user_files/tables.sql
+sed -i 's/DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP//g' ./user_files/tables.sql
+sed -i 's/DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP//g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_bin//g' ./user_files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./user_files/tables.sql
+sed -i 's/datetime([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci//g' ./user_files/tables.sql
+sed -i 's/\<binary\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<varbinary\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/binary([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/varbinary([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<string\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/binary([0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/varbinary([0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/binary([0-9][0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/varbinary([0-9][0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9][0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_bin//g' ./user_files/tables.sql
+
+
+#######################################
+#import doris
+for table in $(awk -F '\n' '{print $1}' ./conf/tables)
+        do
+        echo "use $d_doris; drop table if exists ${table};" |mysql -h$master_host -P$master_port -uroot -p$doris_password 2>/dev/null

Review Comment:
   the for loop read result set is limited,so it is auto over



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r932160212


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table==========================='
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisHostPassword/s/ApacheDorisHostPassword/${mysql_password}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisDataBases/s/ApacheDorisDataBases/${d_mysql}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisTables/s/ApacheDorisTables/${t_name}/" ./files/tables.sql
+
+done
+######################################################################################################################################################################
+#replace mysql type with doris
+sed -i 's/text/string/g' ./files/tables.sql

Review Comment:
   i will string replace with varchar(65535),but some data type not a good idea,I hope to improve it in the future by issue



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #10905: [extension](feature)Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10905:
URL: https://github.com/apache/doris/pull/10905#issuecomment-1210516536

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] caoliang-web commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
caoliang-web commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r942261910


##########
extension/mysql_to_doris/conf/tables:
##########
@@ -0,0 +1,44 @@
+
+# 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.
+
+
+####################################################################
+# The tables is used to define tables
+####################################################################

Review Comment:
   This file is not a shell script. When the user_define_tables.sh script is used to read ./conf/tables, the above contents will be read, resulting in the wrong table name being obtained and the script execution failing. These contents need to be removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman merged pull request #10905: [extension](feature)Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
morningman merged PR #10905:
URL: https://github.com/apache/doris/pull/10905


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r935358450


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,150 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql_host  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql_host -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table======================'
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql_host}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisHostPassword/s/ApacheDorisHostPassword/${mysql_password}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisDataBases/s/ApacheDorisDataBases/${d_mysql}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisTables/s/ApacheDorisTables/${t_name}/" ./files/tables.sql
+
+done
+######################################################################################################################################################################
+#replace mysql type with doris
+sed -i 's/AUTO_INCREMENT//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_bin//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_bin//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci//g'  ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8_general_ci//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_general_ci//g' ./files/tables.sql
+sed -i 's/DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_bin//g' ./files/tables.sql
+sed -i 's/DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8//g' ./files/tables.sql
+sed -i 's/COLLATE utf8mb4_general_ci//g' ./files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./files/tables.sql
+sed -i 's/\<tinytext\>/varchar(65535)/g' ./files/tables.sql

Review Comment:
   i has fixed ,thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #10905: [extension](feature)Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10905:
URL: https://github.com/apache/doris/pull/10905#issuecomment-1210516487

   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r932158162


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql

Review Comment:
   you are right,I've already fixed it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman commented on pull request #10905: [extension](feature)Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
morningman commented on PR #10905:
URL: https://github.com/apache/doris/pull/10905#issuecomment-1210545113

   hi @Toms1999 , you need to add `extension/mysql_to_doris/conf/tables` to the `.licenserc.yaml` to pass the license check


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r942300960


##########
extension/mysql_to_doris/conf/tables:
##########
@@ -0,0 +1,44 @@
+
+# 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.
+
+
+####################################################################
+# The tables is used to define tables
+####################################################################

Review Comment:
   delete all content



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on PR #10905:
URL: https://github.com/apache/doris/pull/10905#issuecomment-1197586904

   alter chinese 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] caoliang-web commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
caoliang-web commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r935427739


##########
extension/mysql_to_doris/user_define_tables.sh:
##########
@@ -0,0 +1,144 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql tables import doris by external and by user to define tables
+####################################################################
+
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p user_files
+rm -rf ./user_files/tables
+rm -rf ./user_files/tables.sql
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./conf/tables)
+        do
+        sed -i "/${table}view/d" ./conf/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql_host -uroot -p$mysql_password 2>/dev/null >> ./user_files/tables.sql
+        echo "print ${table} sql to tables.sql in the user_file dir"
+done
+
+echo '==============================start to transform mysql table for doris extral table======================'
+
+#adjust sql
+awk -F '\t' '{print $2}' ./user_files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./user_files/tables1.sql
+sed -i 's/\\n/\n/g' ./user_files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./user_files/tables1.sql > ./user_files/tables2.sql
+
+#delete tables special struct
+sed -i '/^  CON/d' ./user_files/tables2.sql
+sed -i '/^  KEY/d' ./user_files/tables2.sql
+rm -rf ./user_files/tables.sql
+rm -rf ./user_files/tables1.sql
+mv ./user_files/tables2.sql ./user_files/tables.sql
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./user_files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./user_files/tables.sql
+sed -i '/PRIMARY KEY/d' ./user_files/tables.sql
+sed -i '/UNIQUE KEY/d' ./user_files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./user_files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./user_files/tables.sql
+
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./conf/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql_host}/" ./user_files/tables.sql
+        sed -i "0,/ApacheDorisHostPassword/s/ApacheDorisHostPassword/${mysql_password}/" ./user_files/tables.sql
+        sed -i "0,/ApacheDorisDataBases/s/ApacheDorisDataBases/${d_mysql}/" ./user_files/tables.sql
+        sed -i "0,/ApacheDorisTables/s/ApacheDorisTables/${t_name}/" ./user_files/tables.sql
+
+done
+#replace mysql type with doris
+sed -i 's/\<text\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<tinyblob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<blob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<mediumblob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<longblob\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<tinystring\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<mediumstring\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<longstring\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<timestamp\>/datetime/g' ./user_files/tables.sql
+sed -i 's/AUTO_INCREMENT//g' ./user_files/tables.sql
+sed -i 's/\<unsigned\>//g' ./user_files/tables.sql
+sed -i 's/\<zerofill\>//g' ./user_files/tables.sql
+sed -i 's/\<json\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/enum([^)]*)/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<set\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<bit\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci//g'  ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8_general_ci//g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_general_ci//g' ./user_files/tables.sql
+sed -i 's/COLLATE utf8mb4_general_ci//g' ./user_files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./user_files/tables.sql
+sed -i 's/DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP//g' ./user_files/tables.sql
+sed -i 's/DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP//g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_bin//g' ./user_files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./user_files/tables.sql
+sed -i 's/datetime([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci//g' ./user_files/tables.sql
+sed -i 's/\<binary\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<varbinary\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/binary([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/varbinary([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/\<string\>/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/binary([0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/varbinary([0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/binary([0-9][0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/varbinary([0-9][0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/string([0-9][0-9][0-9])/varchar(65533)/g' ./user_files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_bin//g' ./user_files/tables.sql
+
+
+#######################################
+#import doris
+for table in $(awk -F '\n' '{print $1}' ./conf/tables)
+        do
+        echo "use $d_doris; drop table if exists ${table};" |mysql -h$master_host -P$master_port -uroot -p$doris_password 2>/dev/null

Review Comment:
   for loop not ending



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] caoliang-web commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
caoliang-web commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r935347149


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,150 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql_host  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql_host -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table======================'
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql_host}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisHostPassword/s/ApacheDorisHostPassword/${mysql_password}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisDataBases/s/ApacheDorisDataBases/${d_mysql}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisTables/s/ApacheDorisTables/${t_name}/" ./files/tables.sql
+
+done
+######################################################################################################################################################################
+#replace mysql type with doris
+sed -i 's/AUTO_INCREMENT//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_bin//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_bin//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci//g'  ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8_general_ci//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8 COLLATE utf8_general_ci//g' ./files/tables.sql
+sed -i 's/DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8mb4 COLLATE utf8mb4_bin//g' ./files/tables.sql
+sed -i 's/DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP//g' ./files/tables.sql
+sed -i 's/CHARACTER SET utf8//g' ./files/tables.sql
+sed -i 's/COLLATE utf8mb4_general_ci//g' ./files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./files/tables.sql
+sed -i 's/COLLATE utf8_general_ci//g'  ./files/tables.sql
+sed -i 's/\<tinytext\>/varchar(65535)/g' ./files/tables.sql

Review Comment:
   The range of doris varchar is 1-65533, which needs to be modified to 65533



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Toms1999 commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
Toms1999 commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r935293300


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql_host -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table==========================='
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql}/" ./files/tables.sql

Review Comment:
   I have completed the repair and test once



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] caoliang-web commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
caoliang-web commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r934299295


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql_host -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table==========================='
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql}/" ./files/tables.sql

Review Comment:
   It is incorrect to use ${mysql} here, it should be ${mysql_host}



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] caoliang-web commented on a diff in pull request #10905: [extension] Mysql database import doris by external tables

Posted by GitBox <gi...@apache.org>.
caoliang-web commented on code in PR #10905:
URL: https://github.com/apache/doris/pull/10905#discussion_r931830581


##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql

Review Comment:
   The variable name in mysql.conf is mysql_host, and $mysql is used here, which should be $mysql_host



##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table==========================='
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisHostPassword/s/ApacheDorisHostPassword/${mysql_password}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisDataBases/s/ApacheDorisDataBases/${d_mysql}/" ./files/tables.sql
+        sed -i "0,/ApacheDorisTables/s/ApacheDorisTables/${t_name}/" ./files/tables.sql
+
+done
+######################################################################################################################################################################
+#replace mysql type with doris
+sed -i 's/text/string/g' ./files/tables.sql

Review Comment:
   mysql external table currently does not support string type,Will cause the creation of the doris odbc table to fail



##########
extension/mysql_to_doris/all_tables.sh:
##########
@@ -0,0 +1,142 @@
+#!/bin/bash
+# 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.
+
+
+####################################################################
+# This script is used to will mysql databases import doris by external
+####################################################################
+
+#reference configuration file
+source ./conf/mysql.conf
+source ./conf/doris.conf
+
+#define mysql database and doris database
+d_mysql=$1
+d_doris=$2
+
+#check args
+if [ ! -n "$1" ];then
+        echo "please check source database"
+        exit
+fi
+if [ ! -n "$2" ];then
+        echo "please check sink database"
+        exit
+fi
+
+#mkdir files to store tables and tables.sql
+mkdir -p files
+rm -rf ./files/tables
+rm -rf ./files/tables.sql
+
+#get tables from mysql databases
+echo "use $d_mysql; show tables;" |mysql -h$mysql  -uroot -p$mysql_password 2>/dev/null >> ./files/tables
+
+#delete tables first line
+sed -i '1d' ./files/tables
+
+#reference tables to create tables.sql
+for table in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "/${table}view/d" ./files/tables
+        echo "use $d_mysql; show create table ${table};" |mysql -h$mysql -uroot -p$mysql_password 2>/dev/null >> ./files/tables.sql
+        echo "print ${table} sql to tables.sql in the file dir"
+
+done
+
+echo '==============================start to transform mysql table for doris extral table==========================='
+#adjust sql
+awk -F '\t' '{print $2}' ./files/tables.sql |awk '!(NR%2)' |awk '{print $0 ";"}' > ./files/tables1.sql
+sed -i 's/\\n/\n/g' ./files/tables1.sql
+sed -n '/CREATE TABLE/,/ENGINE\=/p' ./files/tables1.sql > ./files/tables2.sql
+#delete tables special struct
+sed -i '/^  CON/d' ./files/tables2.sql
+sed -i '/^  KEY/d' ./files/tables2.sql
+rm -rf ./files/tables.sql
+rm -rf ./files/tables1.sql
+mv ./files/tables2.sql ./files/tables.sql
+
+#start transform tables struct
+sed -i '/ENGINE=/a) ENGINE=MYSQL\n COMMENT "MYSQL"\nPROPERTIES (\n"host" = "ApacheDorisHostIp",\n"port" = "3306",\n"user" = "root",\n"password" = "ApacheDorisHostPassword",\n"database" = "ApacheDorisDataBases",\n"table" = "ApacheDorisTables");' ./files/tables.sql
+
+#delete match line
+sed -i '/ENGINT=/d' ./files/tables.sql
+sed -i '/PRIMARY KEY/d' ./files/tables.sql
+sed -i '/UNIQUE KEY/d' ./files/tables.sql
+#delete , at the beginning (
+sed -i '/,\s*$/{:loop; N; /,\(\s*\|\n\))/! bloop; s/,\s*[\n]\?\s*)/\n)/}' ./files/tables.sql
+
+#delete a line on keyword
+sed -i -e '$!N;/\n.*ENGINE=MYSQL/!P;D' ./files/tables.sql
+#replace mysql password、database、table、host
+for t_name in $(awk -F '\n' '{print $1}' ./files/tables)
+        do
+        sed -i "0,/ApacheDorisHostIp/s/ApacheDorisHostIp/${mysql}/" ./files/tables.sql

Review Comment:
   The variable name in mysql.conf is mysql_host, and $mysql is used here, which should be $mysql_host



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org