Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -a
- source variables-2.file
- set +a
- function maptypes(){
- case "$1" in
- "STRING")
- Value=keyword
- ;;
- "INT")
- Value=long
- ;;
- "BIGINT")
- Value=long
- ;;
- "TINYINT")
- Value=integer
- ;;
- "SMALLINT")
- Value=integer
- ;;
- "CHAR")
- Value=keyword
- ;;
- "VARCHAR")
- Value=keyword
- ;;
- "FLOAT")
- Value=double
- ;;
- "DOUBLE")
- Value=double
- ;;
- "TIMESTAMP")
- Value=date
- ;;
- "NUMBER")
- Value=double
- ;;
- "DATETIME")
- Value=date
- ;;
- esac
- }
- TABLES=$(echo $TABLES_ALLOWED | tr "," "\n")
- echo TABLES ARE $TABLES
- append="1"
- for each in ${TABLES}; do
- table=$(echo $each | cut -d. -f2)
- echo Creating index $each$append in ES
- curl -X PUT "10.34.234.112:9200/$each$append" -H 'Content-Type: application/json' -d'{ }'
- echo -e "\n---------------------------------------------------------------------------------------------------------------------------\n"
- ${MASTER_INSTALL_DIR}/${SERVICE_NAME}/tungsten/tungsten-replicator/bin/ddlscan -template ddl-mysql-vertica-staging.vm -user ${MYSQL_EXTRACTOR_USER} -pass ${MYSQL_EXTRACTOR_PASS} -url jdbc:mysql:thin://${MYSQL_SOURCE_IP}:3306/ -db ${MYSQLDUMP_DB} -tables ${table} > /tmp/out
- cat /tmp/out
- sed -e 's/\/\*.*\*\///g' /tmp/out > /tmp/var
- cat /tmp/var
- mappings1=$(sed -n -e '/tungsten_opcode/,/ORDER_BY/p' /tmp/var | sed 's/,//g' | sed 's/(.*)//g')
- echo Mappings is $mappings1
- arr=($mappings1)
- echo -e "\n-------------------------------------------------------------------------------------------------------------------------------\n"
- for i in "${arr[@]}"
- do
- echo "$i"
- done
- echo Creating mappings for table $each$append
- for ((i = 0; i < ${#arr[@]}; ++i)); do
- if [[ ${arr[$i]} == "ORDER" ]]; then
- echo Found ${arr[$i]}.Breaking from loop.
- break
- fi
- rem=$(( $i % 2 ))
- if [ $rem -eq 0 ]
- then
- ColName=$(echo ${arr[$i]} | sed 's/\"//g')
- if [[ $ColName == "tungsten_commit_timestamp" ]]
- then
- echo Changing $ColName to source_commit_timestamp
- ColName="source_commit_timestamp"
- fi
- echo ColName= $ColName
- else
- Value=${arr[$i]}
- echo Value= $Value
- maptypes ${arr[$i]}
- echo Mapping $ColName to $Value
- curl -X PUT "10.34.234.112:9200/$each$append/_mapping/$each" -H 'Content-Type: application/json' -d'
- {
- "properties": {
- "'$ColName'": {
- "type": "'$Value'"
- }
- }
- }'
- fi
- done
- done
Add Comment
Please, Sign In to add comment