Skip to content

Commit

Permalink
Merge pull request #89 from keboola/zajca-fix-1
Browse files Browse the repository at this point in the history
Fix bug check destination column type (KBC-2303)
  • Loading branch information
zajca authored Dec 15, 2021
2 parents 74db52f + a6e4ccd commit 0e7dc9c
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM php:7.1-cli
ARG COMPOSER_FLAGS="--prefer-dist --no-interaction"
ARG DEBIAN_FRONTEND=noninteractive
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_PROCESS_TIMEOUT 3600
ENV COMPOSER_PROCESS_TIMEOUT 7200

ARG SQLSRV_VERSION=5.6.1
ARG SNOWFLAKE_ODBC_VERSION=2.21.1
Expand Down
9 changes: 4 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ stages:
--principalName $AZURE_SERVICE_PRINCIPAL \
--principalPassword $AZURE_SERVICE_PRINCIPAL_PASSWORD
source ./provisioning/env_export
bash docker/exasol/createDeleteServer.sh -w
source /tmp/env_export_exasol
# bash docker/exasol/createDeleteServer.sh -w
# source /tmp/env_export_exasol
displayName: 'Deploy resources'
env:
ABS_CONTAINER_NAME: $(ABS_CONTAINER_NAME)
Expand Down Expand Up @@ -137,8 +137,7 @@ stages:
tests-synapse-heap4000temp-hash \
tests-synapse-heap4000temp-optimized \
tests-synapse-heap4000temp-optimized-hash \
tests-synapse-next \
tests-exasol
tests-synapse-next
PARALLEL_EXIT_CODE=$?
cat /tmp/parallel-joblog
sleep 1
Expand Down Expand Up @@ -179,7 +178,7 @@ stages:
--principalName $AZURE_SERVICE_PRINCIPAL \
--principalPassword $AZURE_SERVICE_PRINCIPAL_PASSWORD \
--storageAccountName $ABS_ACCOUNT_NAME
bash docker/exasol/createDeleteServer.sh -d
# bash docker/exasol/createDeleteServer.sh -d
displayName: 'Clean up'
condition: 'always()'
env:
Expand Down
11 changes: 6 additions & 5 deletions docker/exasol/createDeleteServer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -o pipefail # Use last non-zero exit code in a pipeline

createDb(){
DATE=`date +%s`
curl -X 'POST' \
curl -s -X 'POST' \
"$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases" \
-H 'accept: application/json' \
-H "Authorization: Bearer $EXA_SAAS_TOKEN" \
Expand All @@ -27,7 +27,7 @@ createDb(){

deleteDb(){
DATE=`date +%s`
curl -X 'DELETE' \
curl -s -X 'DELETE' \
"$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$EXASOL_DB_ID" \
-H 'accept: application/json' \
-H "Authorization: Bearer $EXA_SAAS_TOKEN" \
Expand All @@ -36,13 +36,13 @@ deleteDb(){


getDb(){
curl -X GET "$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$1" -H "accept: application/json" -H "Authorization: Bearer $EXA_SAAS_TOKEN"
curl -s -X GET "$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$1" -H "accept: application/json" -H "Authorization: Bearer $EXA_SAAS_TOKEN"
}
getClusters(){
curl -X GET "$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$1/clusters" -H "accept: application/json" -H "Authorization: Bearer $EXA_SAAS_TOKEN"
curl -s -X GET "$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$1/clusters" -H "accept: application/json" -H "Authorization: Bearer $EXA_SAAS_TOKEN"
}
getConnectionData(){
curl -X GET "$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$1/clusters/$2/connect" -H "accept: application/json" -H "Authorization: Bearer $EXA_SAAS_TOKEN"
curl -s -X GET "$EXA_SAAS_HOST/api/v1/accounts/$EXA_SAAS_USER_ID/databases/$1/clusters/$2/connect" -H "accept: application/json" -H "Authorization: Bearer $EXA_SAAS_TOKEN"
}

getDbStatus(){
Expand Down Expand Up @@ -80,6 +80,7 @@ waitForCreate(){
local runtime="30 minute"
local endtime=$(date -ud "$runtime" +%s)
local newDbId=$(createDbWithId)
echo "Starting new db with id: "${newDbId}
while [[ $(date -u +%s) -le ${endtime} ]]
do
local status=$(getDbStatus $newDbId)
Expand Down
4 changes: 2 additions & 2 deletions src/Backend/Synapse/ToFinalTable/SqlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private function getCTASColumnSetSQLWithConvertEmptyValues(
string $columnTypeDefinition,
SynapseColumn $destinationColumn
): string {
if ($source->getColumnDefinition()->getBasetype() === BaseType::STRING) {
if ($destinationColumn->getColumnDefinition()->getBasetype() === BaseType::STRING) {
// convert nulls only for strings
$colSql = sprintf(
'NULLIF(%s, \'\')',
Expand Down Expand Up @@ -643,7 +643,7 @@ private function getCTASColumnSetSQL(
} else {
$colSql = SynapseQuote::quoteSingleIdentifier($sourceColumn->getColumnName());
}
if ($sourceColumn->getColumnDefinition()->getBasetype() === BaseType::STRING) {
if ($destinationColumn->getColumnDefinition()->getBasetype() === BaseType::STRING) {
if ($destinationColumn->getColumnDefinition()->isNullable()) {
// Columns with coalesce are nullable in CTAS
$colSql = sprintf(
Expand Down
Loading

0 comments on commit 0e7dc9c

Please sign in to comment.