keboola / php-db-import-export

[READ-ONLY] - see https://github.com/keboola/storage-backend
MIT License
1 stars 0 forks source link

Collect query templates 2 #146

Closed martinjunger closed 2 years ago

martinjunger commented 2 years ago

Jira: KBC-2929

martinjunger commented 2 years ago

Varianta 1 - FullImportCustomQueryTest - vsechno pres mocky:

'=== queries'
'CREATE TEMPORARY TABLE "stageSchemaName"."stageTableName"\n
 (\n
 "sourceCol1" INT\n
 );'
'---------'
'CREATE TABLE "destSchemaName"."destTableName"\n
 (\n
 "destCol1" INT,\n
 "destColTimestamp" TIMESTAMP\n
 );'
'---------'
'COPY INTO "stageSchemaName"."stageTableName" \n
 FROM 'sourceContainerUrl'\n
 CREDENTIALS=(AZURE_SAS_TOKEN='sourceSasToken')\n
 FILE_FORMAT = (TYPE=CSV FIELD_DELIMITER = ',' SKIP_HEADER = 1 FIELD_OPTIONALLY_ENCLOSED_BY = '\"' ESCAPE_UNENCLOSED_FIELD = NONE)\n
 FILES = ('sourceFile1')'
'---------'
'BEGIN TRANSACTION'
'---------'
'TRUNCATE TABLE "destSchemaName"."destTableName"'
'---------'
'INSERT INTO "destSchemaName"."destTableName" ("sourceCol1") (SELECT "sourceCol1" FROM "stageSchemaName"."stageTableName" AS "src")'
'---------'
'COMMIT'
'---------'

Varianta 2 - FullImportCustomQueryFakeTest - fake driver + ostatni pres mocky:

'=== queries'
'CREATE TEMPORARY TABLE "stageSchemaName"."stageTableName"\n
 (\n
 "sourceCol1" INT\n
 );'
'---------'
'CREATE TABLE "destSchemaName"."destTableName"\n
 (\n
 "destCol1" INT,\n
 "destColTimestamp" TIMESTAMP\n
 );'
'---------'
'COPY INTO "stageSchemaName"."stageTableName" \n
 FROM 'sourceContainerUrl'\n
 CREDENTIALS=(AZURE_SAS_TOKEN='sourceSasToken')\n
 FILE_FORMAT = (TYPE=CSV FIELD_DELIMITER = ',' SKIP_HEADER = 1 FIELD_OPTIONALLY_ENCLOSED_BY = '\"' ESCAPE_UNENCLOSED_FIELD = NONE)\n
 FILES = ('sourceFile1')'
'---------'
'SELECT COUNT(*) AS NumberOfRows FROM "stageSchemaName"."stageTableName"'
'---------'
'BEGIN TRANSACTION'
'---------'
'TRUNCATE TABLE "destSchemaName"."destTableName"'
'---------'
'INSERT INTO "destSchemaName"."destTableName" ("sourceCol1") (SELECT "sourceCol1" FROM "stageSchemaName"."stageTableName" AS "src")'
'---------'
'COMMIT'
'---------'
martinjunger commented 2 years ago

V obou pripadech je potreba pritahnout jako zavislost PhpUnit. Potom by melo stacit nadefinovat tridy napr. FullImportFlow, IncrementalImportFlow a dalsi, a logiku presunout do nich. Tyhle flow tridy by se potom volaly z komponenty.

martinjunger commented 2 years ago

Moved to CustomQuery component: https://github.com/keboola/app-custom-query-manager/pull/1