diff --git a/composer.json b/composer.json index cbe01f372..fccfb0b59 100755 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/process": "^4.4|^5.0|^6.0" }, "require-dev": { - "keboola/coding-standard": "^14", + "keboola/coding-standard": "^15", "keboola/phpunit-retry-annotations": "^0.3.0", "php-parallel-lint/php-parallel-lint": "^1.3", "phpstan/extension-installer": "^1.1", diff --git a/packages/php-datatypes/composer.json b/packages/php-datatypes/composer.json index 5a4eac0d0..f52dc6368 100644 --- a/packages/php-datatypes/composer.json +++ b/packages/php-datatypes/composer.json @@ -16,7 +16,7 @@ "squizlabs/php_codesniffer": "^3", "phpstan/phpstan": "^1.4", "php-parallel-lint/php-parallel-lint": "^1.3", - "keboola/coding-standard": "^14", + "keboola/coding-standard": "^15", "phpstan/phpdoc-parser": "^1.6" }, "autoload": { diff --git a/packages/php-datatypes/src/Definition/Bigquery.php b/packages/php-datatypes/src/Definition/Bigquery.php index d0e3f6076..e0fd6ce30 100644 --- a/packages/php-datatypes/src/Definition/Bigquery.php +++ b/packages/php-datatypes/src/Definition/Bigquery.php @@ -108,6 +108,8 @@ class Bigquery extends Common public const MAX_LENGTH = 9223372036854775807; + public const METADATA_BACKEND = 'bigquery'; + /** @phpstan-var BigqueryTableFieldSchema|null */ private ?array $fieldAsArray = null; @@ -319,7 +321,7 @@ private function validateLength(string $type, $length = null): void protected function validateBigqueryNumericLength( $length, int $firstMax, - int $secondMax + int $secondMax, ): bool { if ($this->isEmpty($length)) { return true; @@ -340,7 +342,7 @@ protected function validateBigqueryNumericLength( protected function validateBigNumericLength( $length, int $firstMax, - int $secondMax + int $secondMax, ): bool { if ($this->isEmpty($length)) { return true; diff --git a/packages/php-datatypes/src/Definition/Common.php b/packages/php-datatypes/src/Definition/Common.php index f4fce923b..ddfe1968c 100644 --- a/packages/php-datatypes/src/Definition/Common.php +++ b/packages/php-datatypes/src/Definition/Common.php @@ -126,7 +126,7 @@ protected function validateNumericLength( $length, int $firstMax, int $secondMax, - bool $firstMustBeBigger = true + bool $firstMustBeBigger = true, ): bool { if ($this->isEmpty($length)) { return true; diff --git a/packages/php-datatypes/src/Definition/Oracle.php b/packages/php-datatypes/src/Definition/Oracle.php index ee4ec8bfc..af77e25ba 100644 --- a/packages/php-datatypes/src/Definition/Oracle.php +++ b/packages/php-datatypes/src/Definition/Oracle.php @@ -124,7 +124,7 @@ public static function getTypeByBasetype(string $basetype): string BaseType::NUMERIC, BaseType::FLOAT, BaseType::BOOLEAN, BaseType::INTEGER => self::TYPE_NUMBER, BaseType::TIMESTAMP, BaseType::DATE => self::TYPE_DATE, default => throw new InvalidTypeException( - sprintf('No Oracle type mapped for base type "%s"', $basetype) + sprintf('No Oracle type mapped for base type "%s"', $basetype), ), }; } diff --git a/packages/php-datatypes/src/Definition/Redshift.php b/packages/php-datatypes/src/Definition/Redshift.php index fcce5d847..4cbcf2c7c 100644 --- a/packages/php-datatypes/src/Definition/Redshift.php +++ b/packages/php-datatypes/src/Definition/Redshift.php @@ -24,6 +24,8 @@ class Redshift extends Common 'TIMESTAMPTZ', 'TIMESTAMP WITH TIME ZONE', ]; + public const METADATA_BACKEND = 'redshift'; + protected ?string $compression = null; /** diff --git a/packages/php-datatypes/src/Definition/Teradata.php b/packages/php-datatypes/src/Definition/Teradata.php index dc8159cbd..127d925c2 100644 --- a/packages/php-datatypes/src/Definition/Teradata.php +++ b/packages/php-datatypes/src/Definition/Teradata.php @@ -315,6 +315,8 @@ class Teradata extends Common self::TYPE_NUMBER => '-128,-128', ]; + public const METADATA_BACKEND = 'teradata'; + private bool $isLatin = false; // depends on Char Type column in HELP TABLE column @@ -592,7 +594,7 @@ private function validateLength(string $type, $length = null): void 'K' => $isLatin ? 2_047_937 : 1_023_968, 'M' => $isLatin ? 1999 : 999, 'G' => $isLatin ? 1 : 0, - ] + ], ); break; case self::TYPE_BLOB: @@ -604,7 +606,7 @@ private function validateLength(string $type, $length = null): void 'K' => 2_047_937, 'M' => 1999, 'G' => 1, - ] + ], ); break; } diff --git a/packages/php-datatypes/tests/CommonDatatypeTest.php b/packages/php-datatypes/tests/CommonDatatypeTest.php index 09db0b80e..a0222b2c4 100644 --- a/packages/php-datatypes/tests/CommonDatatypeTest.php +++ b/packages/php-datatypes/tests/CommonDatatypeTest.php @@ -19,7 +19,7 @@ public function testConstructor(): void $datatype = $this->getMockForAbstractClass( Common::class, - ['VARCHAR', ['length' => '50', 'nullable' => false, 'default' => '']] + ['VARCHAR', ['length' => '50', 'nullable' => false, 'default' => '']], ); $this->assertTrue($datatype->getLength() === '50'); $this->assertTrue(!$datatype->isNullable()); @@ -27,7 +27,7 @@ public function testConstructor(): void $datatype = $this->getMockForAbstractClass( Common::class, - ['VARCHAR', ['length' => 50, 'nullable' => false, 'default' => 123]] + ['VARCHAR', ['length' => 50, 'nullable' => false, 'default' => 123]], ); $this->assertTrue($datatype->getLength() === '50'); $this->assertTrue(!$datatype->isNullable()); diff --git a/packages/php-datatypes/tests/ExasolDatatypeTest.php b/packages/php-datatypes/tests/ExasolDatatypeTest.php index d6cab8d8c..829ea3e0e 100644 --- a/packages/php-datatypes/tests/ExasolDatatypeTest.php +++ b/packages/php-datatypes/tests/ExasolDatatypeTest.php @@ -67,11 +67,11 @@ public function testDefaultTypeForNumberBasedOnLength(): void { self::assertSame( BaseType::NUMERIC, - (new Exasol('NUMBER', ['length' => '10,5']))->getBasetype() + (new Exasol('NUMBER', ['length' => '10,5']))->getBasetype(), ); self::assertSame( BaseType::FLOAT, - (new Exasol('NUMBER', ['length' => null]))->getBasetype() + (new Exasol('NUMBER', ['length' => null]))->getBasetype(), ); } @@ -202,7 +202,7 @@ public function expectedSqlDefinitions(): array ['length' => '20,20', 'default' => 10, 'nullable' => true], 'NUMBER (20,20) DEFAULT 10', ], - ] + ], ); } diff --git a/packages/php-datatypes/tests/RedshiftDatatypeTest.php b/packages/php-datatypes/tests/RedshiftDatatypeTest.php index c00702bc3..0a7dc9442 100644 --- a/packages/php-datatypes/tests/RedshiftDatatypeTest.php +++ b/packages/php-datatypes/tests/RedshiftDatatypeTest.php @@ -98,13 +98,13 @@ public function testToArray(): void $datatype = new Redshift('VARCHAR'); $this->assertEquals( ['type' => 'VARCHAR', 'length' => null, 'nullable' => true, 'compression' => null], - $datatype->toArray() + $datatype->toArray(), ); $datatype = new Redshift('VARCHAR', ['length' => '50', 'nullable' => false, 'compression' => 'ZSTD']); $this->assertEquals( ['type' => 'VARCHAR', 'length' => '50', 'nullable' => false, 'compression' => 'ZSTD'], - $datatype->toArray() + $datatype->toArray(), ); } @@ -112,7 +112,7 @@ public function testToMetadata(): void { $datatype = new Redshift( 'VARCHAR', - ['length' => '50', 'nullable' => false, 'default' => '', 'compression' => 'ZSTD'] + ['length' => '50', 'nullable' => false, 'default' => '', 'compression' => 'ZSTD'], ); $md = $datatype->toMetadata(); @@ -142,7 +142,7 @@ public function testBasetypes(): void { $types = array_merge( Redshift::TYPES, - array_map(fn($v) => strtolower($v), Redshift::TYPES) + array_map(fn($v) => strtolower($v), Redshift::TYPES), ); foreach ($types as $type) { $basetype = (new Redshift($type))->getBasetype(); diff --git a/packages/php-db-import-export/composer.json b/packages/php-db-import-export/composer.json index 1c2cac445..8c4714235 100644 --- a/packages/php-db-import-export/composer.json +++ b/packages/php-db-import-export/composer.json @@ -25,7 +25,7 @@ "symfony/process": "^4.4|^5.0|^6.0" }, "require-dev": { - "keboola/coding-standard": "^14", + "keboola/coding-standard": "^15", "php-parallel-lint/php-parallel-lint": "^1.3", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.4", diff --git a/packages/php-db-import-export/provisioning/src/Azure/AzCli.php b/packages/php-db-import-export/provisioning/src/Azure/AzCli.php index b29d79985..48737a9f8 100644 --- a/packages/php-db-import-export/provisioning/src/Azure/AzCli.php +++ b/packages/php-db-import-export/provisioning/src/Azure/AzCli.php @@ -18,7 +18,7 @@ final class AzCli public function __construct( string $azureServicePrincipalTenant, string $azureServicePrincipal, - string $azureServicePrincipalPassword + string $azureServicePrincipalPassword, ) { $this->azureServicePrincipalTenant = $azureServicePrincipalTenant; $this->azureServicePrincipal = $azureServicePrincipal; @@ -28,7 +28,7 @@ public function __construct( public function runAuthorizedSingleLineOutputCmd(string $cmd): string { $out = $this->runAuthorizedCmd( - $cmd + $cmd, ); return explode(PHP_EOL, $out)[0]; } diff --git a/packages/php-db-import-export/provisioning/src/BaseCmd.php b/packages/php-db-import-export/provisioning/src/BaseCmd.php index ecfc3fb13..a953b74b3 100644 --- a/packages/php-db-import-export/provisioning/src/BaseCmd.php +++ b/packages/php-db-import-export/provisioning/src/BaseCmd.php @@ -24,21 +24,21 @@ protected function configure(): void ->addOption( self::OPTION_AZURE_SERVICE_PRINCIPAL_TENANT, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_AZURE_SERVICE_PRINCIPAL, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_AZURE_SERVICE_PRINCIPAL_PASSWORD, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); } diff --git a/packages/php-db-import-export/provisioning/src/Delete.php b/packages/php-db-import-export/provisioning/src/Delete.php index 86061a2cc..6f52c80aa 100644 --- a/packages/php-db-import-export/provisioning/src/Delete.php +++ b/packages/php-db-import-export/provisioning/src/Delete.php @@ -27,37 +27,37 @@ protected function configure(): void ->addOption( self::OPTION_AZURE_RESOURCE_GROUP, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_SYNAPSE_DW_SERVER_NAME, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_SYNAPSE_SQL_SERVER_NAME, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_FILE_STORAGE_RESOURCE_ID, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_SYNAPSE_SERVICE_PRINCIPAL_OBJECT_ID, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_STORAGE_ACCOUNT_NAME, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); parent::configure(); } @@ -86,8 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int --assignee $servicePrincipalObjetId \ --role "Storage Blob Data Contributor" \ --scope $fileStorageResourceId -EOT - ); +EOT,); $output->writeln([ 'Managed identity role removed', ]); @@ -100,8 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int --resource-group $resourceGroup \ --name $synapseDwServerName \ --server $synapseSqlServerName -EOT - ); +EOT,); $output->writeln([ 'Synapse pool removed', ]); @@ -113,8 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int az sql server delete -y \ --resource-group $resourceGroup \ --name $synapseSqlServerName -EOT - ); +EOT,); $output->writeln([ 'Synapse logical sql server removed', ]); @@ -126,8 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int az storage account delete -y \ --resource-group $resourceGroup \ --name $storageAccountName -EOT - ); +EOT,); $output->writeln([ 'Blob storage account removed', ]); diff --git a/packages/php-db-import-export/provisioning/src/Deploy.php b/packages/php-db-import-export/provisioning/src/Deploy.php index 338313c33..67cb46cd8 100644 --- a/packages/php-db-import-export/provisioning/src/Deploy.php +++ b/packages/php-db-import-export/provisioning/src/Deploy.php @@ -24,13 +24,13 @@ protected function configure(): void ->addOption( self::OPTION_SERVER_NAME, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); $this ->addOption( self::OPTION_AZURE_RESOURCE_GROUP, null, - InputOption::VALUE_REQUIRED + InputOption::VALUE_REQUIRED, ); parent::configure(); } @@ -60,8 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int --output json \ --parameters \ suffix=$suffix -EOT - ); +EOT,); $outBlobDeploy = $this->getDeploymentResult($outBlobDeploy); $storageAccountName = $outBlobDeploy['properties']['outputs']['storageAccountName']['value']; $storageAccountKey = $outBlobDeploy['properties']['outputs']['storageAccountKey']['value']; @@ -89,8 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int warehouseName=$serverName \ suffix=$suffix \ warehouseCapacity=900 -EOT - ); +EOT,); $outSynapseDeploy = $this->getDeploymentResult($outSynapseDeploy); $synapseSqlServerName = $outSynapseDeploy['properties']['outputs']['sqlServerName']['value']; @@ -123,8 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int --name all \ --start-ip-address 0.0.0.0 \ --end-ip-address 255.255.255.255 -EOT - ); +EOT,); $output->writeln([ 'Firewall rule set done', @@ -136,8 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int --display-name $synapseSqlServerName \ --query "[].objectId" \ --output tsv -EOT - ); +EOT,); $output->writeln([ 'SYNAPSE_SERVICE_PRINCIPAL_OBJECT_ID: ' . $principalObjectId, @@ -150,8 +146,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int -n $storageAccountName \ --query "id" \ --output tsv -EOT - ); +EOT,); $output->writeln([ 'FILE_STORAGE_RESOURCE_ID: ' . $fileStorageResourceId, @@ -162,8 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int --assignee $principalObjectId \ --role "Storage Blob Data Contributor" \ --scope $fileStorageResourceId -EOT - ); +EOT,); $output->writeln([ 'Managed identity role created', diff --git a/packages/php-db-import-export/provisioning/src/EnvCollector.php b/packages/php-db-import-export/provisioning/src/EnvCollector.php index c7267a555..bbefe20c6 100644 --- a/packages/php-db-import-export/provisioning/src/EnvCollector.php +++ b/packages/php-db-import-export/provisioning/src/EnvCollector.php @@ -24,7 +24,7 @@ public function addEnv(string $name, string $value): void $fs->appendToFile($this->envFile, sprintf( 'echo "##vso[task.setvariable variable=%s]%s"' . PHP_EOL, $name, - $value + $value, )); } } diff --git a/packages/php-db-import-export/src/Backend/Assert.php b/packages/php-db-import-export/src/Backend/Assert.php index 389746a22..2ce5356d5 100644 --- a/packages/php-db-import-export/src/Backend/Assert.php +++ b/packages/php-db-import-export/src/Backend/Assert.php @@ -55,7 +55,7 @@ public static function assertSameColumns( $sourceCol, $destCol, $simpleLengthTypes, - $complexLengthTypes + $complexLengthTypes, ); } else { throw ColumnsMismatchException::createColumnsCountMismatch($source, $destination); @@ -84,7 +84,7 @@ private static function isLengthMismatchComplexLength( int $sourcePrecision, int $sourceScale, int $destinationPrecision, - int $destinationScale + int $destinationScale, ): bool { return $sourcePrecision > $destinationPrecision || $sourceScale > $destinationScale; } @@ -102,12 +102,12 @@ private static function isMismatchComplexLength(Common $sourceDef, Common $destD sourcePrecision: (int) $sourceLength[0], sourceScale: (int) $sourceLength[1], destinationPrecision: (int) $destLength[0], - destinationScale: (int) $destLength[1] + destinationScale: (int) $destLength[1], ), $isSourceComplex !== $isDestComplex => false, default => self::isLengthMismatchSimpleLength( $sourceDef, - $destDef + $destDef, ), }; } diff --git a/packages/php-db-import-export/src/Backend/BackendExportAdapterInterface.php b/packages/php-db-import-export/src/Backend/BackendExportAdapterInterface.php index 637f2e151..7f3775be4 100644 --- a/packages/php-db-import-export/src/Backend/BackendExportAdapterInterface.php +++ b/packages/php-db-import-export/src/Backend/BackendExportAdapterInterface.php @@ -11,7 +11,7 @@ interface BackendExportAdapterInterface { public static function isSupported( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): bool; /** @@ -20,6 +20,6 @@ public static function isSupported( public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array; } diff --git a/packages/php-db-import-export/src/Backend/BackendImportAdapterInterface.php b/packages/php-db-import-export/src/Backend/BackendImportAdapterInterface.php index ab4a19924..dde4a9d59 100644 --- a/packages/php-db-import-export/src/Backend/BackendImportAdapterInterface.php +++ b/packages/php-db-import-export/src/Backend/BackendImportAdapterInterface.php @@ -14,7 +14,7 @@ interface BackendImportAdapterInterface { public static function isSupported( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): bool; /** @@ -24,6 +24,6 @@ public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): int; } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/BigqueryException.php b/packages/php-db-import-export/src/Backend/Bigquery/BigqueryException.php index 81c80bc1e..2af0d23c3 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/BigqueryException.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/BigqueryException.php @@ -11,7 +11,7 @@ class BigqueryException extends Exception { - const MAX_MESSAGES_IN_ERROR_MESSAGE = 10; + private const MAX_MESSAGES_IN_ERROR_MESSAGE = 10; public static function covertException(JobException|ServiceException $e): Throwable { @@ -24,6 +24,7 @@ public static function covertException(JobException|ServiceException $e): Throwa return $e; } + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint public static function createExceptionFromJobResult(array $jobInfo): Throwable { $errorMessage = $jobInfo['status']['errorResult']['message'] ?? 'Unknown error'; @@ -49,7 +50,9 @@ public static function createExceptionFromJobResult(array $jobInfo): Throwable if (count($parsingErrors) > 0) { // filter parsing errors $areExtraErrors = count($parsingErrors) !== $countOfErrors; - return new BigqueryInputDataException(self::getErrorMessageForErrorList($parsingErrors, $areExtraErrors, $jobInfo['jobReference']['jobId'])); + return new BigqueryInputDataException( + self::getErrorMessageForErrorList($parsingErrors, $areExtraErrors, $jobInfo['jobReference']['jobId']), + ); } return new self($errorMessage); @@ -66,18 +69,27 @@ private static function isUserError(string $message, string $reason): bool return false; } + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint private static function getErrorMessageForErrorList(array $parsingErrors, bool $areExtraErrors, string $jobId) { $count = count($parsingErrors); if ($count > self::MAX_MESSAGES_IN_ERROR_MESSAGE) { - return sprintf('There were too many errors during the import. For more information check job "%s" in Google Cloud Console.', $jobId); + return sprintf( + 'There were too many errors during the import. For more information check job "%s"' + . 'in Google Cloud Console.', + $jobId, + ); } $message = implode(PHP_EOL, array_map(function ($error) { return $error['message']; }, $parsingErrors)); if ($areExtraErrors) { - $message .= PHP_EOL . sprintf('There were additional errors during the import. For more information check job "%s" in Google Cloud Console.', $jobId); + $message .= PHP_EOL . sprintf( + 'There were additional errors during the import. For more information check job "%s"' + . 'in Google Cloud Console.', + $jobId, + ); } return $message; diff --git a/packages/php-db-import-export/src/Backend/Bigquery/BigqueryImportOptions.php b/packages/php-db-import-export/src/Backend/Bigquery/BigqueryImportOptions.php index dc757314a..8484515cb 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/BigqueryImportOptions.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/BigqueryImportOptions.php @@ -21,14 +21,14 @@ public function __construct( bool $useTimestamp = false, int $numberOfIgnoredLines = self::SKIP_NO_LINE, string $usingTypes = self::USING_TYPES_STRING, - ?Session $session = null + ?Session $session = null, ) { parent::__construct( $convertEmptyValuesToNull, $isIncremental, $useTimestamp, $numberOfIgnoredLines, - $usingTypes + $usingTypes, ); $this->session = $session; } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/BigqueryInputDataException.php b/packages/php-db-import-export/src/Backend/Bigquery/BigqueryInputDataException.php index 55b20059d..f936a26fe 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/BigqueryInputDataException.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/BigqueryInputDataException.php @@ -10,5 +10,3 @@ class BigqueryInputDataException extends BigqueryException { } - - diff --git a/packages/php-db-import-export/src/Backend/Bigquery/Export/Exporter.php b/packages/php-db-import-export/src/Backend/Bigquery/Export/Exporter.php index e93a70652..0754e7374 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/Export/Exporter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/Export/Exporter.php @@ -35,7 +35,7 @@ public function __construct(BigQueryClient $bqClient) public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array { return $this->getAdapter($source, $destination) ->runCopyCommand($source, $destination, $options); @@ -43,7 +43,7 @@ public function exportTable( private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): BackendExportAdapterInterface { $adapterForUse = null; /** @var class-string $adapter */ @@ -55,8 +55,8 @@ private function getAdapter( 'More than one suitable adapter found for Bigquery exporter with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->bqClient); @@ -67,8 +67,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Bigquery exporter with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/Export/GcsExportAdapter.php b/packages/php-db-import-export/src/Backend/Bigquery/Export/GcsExportAdapter.php index 716778489..7accf97e6 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/Export/GcsExportAdapter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/Export/GcsExportAdapter.php @@ -40,7 +40,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( 'EXPORT DATA @@ -62,12 +62,12 @@ public function runCopyCommand( ); $this->bqClient->runQuery( $this->bqClient->query($sql) - ->parameters($source->getQueryBindings()) + ->parameters($source->getQueryBindings()), ); if ($exportOptions->generateManifest()) { (new Storage\GCS\ManifestGenerator\GcsSlicedManifestFromFolderGenerator( - $destination->getClient() + $destination->getClient(), )) ->generateAndSaveManifest($destination->getRelativePath()); } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelper.php b/packages/php-db-import-export/src/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelper.php index 570b78b51..a844a7e84 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelper.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelper.php @@ -15,7 +15,7 @@ final class CopyCommandCsvOptionsHelper */ public static function getCsvCopyCommandOptions( ImportOptionsInterface $importOptions, - CsvOptions $csvOptions + CsvOptions $csvOptions, ): array { $options = [ sprintf('field_delimiter=%s', BigqueryQuote::quote($csvOptions->getDelimiter())), diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/FullImporter.php b/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/FullImporter.php index b594ad736..2ff1a514c 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/FullImporter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/FullImporter.php @@ -42,15 +42,15 @@ private function doLoadFullWithoutDedup( BigqueryTableDefinition $destinationTableDefinition, BigqueryImportOptions $options, ImportState $state, - Session $session + Session $session, ): void { // truncate destination table $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getTruncateTable( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() + $destinationTableDefinition->getTableName(), ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->startTimer(self::TIMER_COPY_TO_TARGET); @@ -59,11 +59,11 @@ private function doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() + DateTimeHelper::getNowFormatted(), ); $this->bqClient->runQuery($this->bqClient->query( $sql, - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->stopTimer(self::TIMER_COPY_TO_TARGET); } @@ -72,7 +72,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof BigqueryTableDefinition); assert($destinationTableDefinition instanceof BigqueryTableDefinition); @@ -92,7 +92,7 @@ public function importToTable( $destinationTableDefinition, $options, $state, - $session + $session, ); } else { $this->doLoadFullWithoutDedup( @@ -100,7 +100,7 @@ public function importToTable( $destinationTableDefinition, $options, $state, - $session + $session, ); } } catch (JobException|ServiceException $e) { @@ -118,7 +118,7 @@ private function doFullLoadWithDedup( BigqueryTableDefinition $destinationTableDefinition, BigqueryImportOptions $options, ImportState $state, - Session $session + Session $session, ): void { $state->startTimer(self::TIMER_DEDUP); @@ -132,29 +132,29 @@ private function doFullLoadWithDedup( $this->sqlBuilder->getCreateDedupTable( $stagingTableDefinition, $deduplicationTableName, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); /** @var BigqueryTableDefinition $deduplicationTableDefinition */ $deduplicationTableDefinition = (new BigqueryTableReflection( $this->bqClient, $stagingTableDefinition->getSchemaName(), - $deduplicationTableName + $deduplicationTableName, ))->getTableDefinition(); // 3 truncate destination table $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getTruncateTable( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() + $destinationTableDefinition->getTableName(), ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getBeginTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $transactionStarted = true; @@ -164,21 +164,21 @@ private function doFullLoadWithDedup( $deduplicationTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() + DateTimeHelper::getNowFormatted(), ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->stopTimer(self::TIMER_DEDUP); $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getCommitTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); } catch (Throwable $e) { if ($transactionStarted) { $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getRollbackTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); } throw $e; @@ -188,9 +188,9 @@ private function doFullLoadWithDedup( $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getDropTableIfExistsCommand( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() + $deduplicationTableDefinition->getTableName(), ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); } } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/IncrementalImporter.php b/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/IncrementalImporter.php index d2e179846..67c5014cc 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/IncrementalImporter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/IncrementalImporter.php @@ -43,7 +43,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof BigqueryTableDefinition); assert($destinationTableDefinition instanceof BigqueryTableDefinition); @@ -67,15 +67,15 @@ public function importToTable( $this->sqlBuilder->getCreateDedupTable( $stagingTableDefinition, $deduplicationTableName, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); /** @var BigqueryTableDefinition $deduplicationTableDefinition */ $deduplicationTableDefinition = (new BigqueryTableReflection( $this->bqClient, $stagingTableDefinition->getSchemaName(), - $deduplicationTableName + $deduplicationTableName, ))->getTableDefinition(); $tableToCopyFrom = $deduplicationTableDefinition; @@ -83,7 +83,7 @@ public function importToTable( $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getBeginTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $transactionStarted = true; @@ -94,9 +94,9 @@ public function importToTable( $deduplicationTableDefinition, $destinationTableDefinition, $options, - $timestampValue + $timestampValue, ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->stopTimer(self::TIMER_UPDATE_TARGET_TABLE); @@ -106,15 +106,15 @@ public function importToTable( $this->sqlBuilder->getDeleteOldItemsCommand( $deduplicationTableDefinition, $destinationTableDefinition, - $options + $options, ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->stopTimer(self::TIMER_DELETE_UPDATED_ROWS); } else { $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getBeginTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $transactionStarted = true; } @@ -126,15 +126,15 @@ public function importToTable( $tableToCopyFrom, $destinationTableDefinition, $options, - $timestampValue + $timestampValue, ), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->stopTimer(self::TIMER_INSERT_INTO_TARGET); $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getCommitTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); $state->setImportedColumns($stagingTableDefinition->getColumnsNames()); @@ -142,7 +142,7 @@ public function importToTable( if ($transactionStarted) { $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getRollbackTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); } throw BigqueryException::covertException($e); @@ -150,7 +150,7 @@ public function importToTable( if ($transactionStarted) { $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getRollbackTransaction(), - $session->getAsQueryOptions() + $session->getAsQueryOptions(), )); } throw $e; @@ -160,8 +160,8 @@ public function importToTable( $this->bqClient->runQuery($this->bqClient->query( $this->sqlBuilder->getDropTableIfExistsCommand( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() - ) + $deduplicationTableDefinition->getTableName(), + ), )); } } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/SqlBuilder.php b/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/SqlBuilder.php index b09e66dd6..b3c9efccb 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/SqlBuilder.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToFinalTable/SqlBuilder.php @@ -19,7 +19,7 @@ class SqlBuilder private function assertColumnExist( BigqueryTableDefinition $tableDefinition, - BigqueryColumn $columnDefinition + BigqueryColumn $columnDefinition, ): BigqueryColumn { $destinationColumn = null; // case sensitive search @@ -35,9 +35,9 @@ private function assertColumnExist( sprintf( 'Columns "%s" can be imported as it was not found between columns "%s" of destination table.', $columnDefinition->getColumnName(), - implode(', ', $tableDefinition->getColumnsNames()) + implode(', ', $tableDefinition->getColumnsNames()), ), - Exception::UNKNOWN_ERROR + Exception::UNKNOWN_ERROR, ); } @@ -68,18 +68,18 @@ public function getDropTableUnsafe(string $dbName, string $tableName): string return sprintf( 'DROP TABLE %s.%s', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ); } public function getDropTableIfExistsCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DROP TABLE IF EXISTS %s.%s', BigqueryQuote::quoteSingleIdentifier($schema), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ); } @@ -89,7 +89,7 @@ public function getDropTableIfExistsCommand( private function getColumnSetSqlPartForStringTable( BigqueryTableDefinition $sourceTableDefinition, BigqueryTableDefinition $destinationTableDefinition, - BigqueryImportOptions $importOptions + BigqueryImportOptions $importOptions, ): array { $columnsSetSql = []; /** @var BigqueryColumn $columnDefinition */ @@ -100,7 +100,7 @@ private function getColumnSetSqlPartForStringTable( if ($columnDefinition->getColumnDefinition()->getBasetype() === BaseType::STRING) { $columnsSetSql[] = sprintf( 'NULLIF(%s, \'\')', - BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { $columnsSetSql[] = BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()); @@ -110,7 +110,7 @@ private function getColumnSetSqlPartForStringTable( 'CAST(COALESCE(%s, \'\') as %s) AS %s', BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $destinationColumn->getColumnDefinition()->getType(), - BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { // on columns other than string dont use COALESCE, use direct cast @@ -119,7 +119,7 @@ private function getColumnSetSqlPartForStringTable( 'CAST(%s as %s) AS %s', BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $destinationColumn->getColumnDefinition()->getType(), - BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } } @@ -133,7 +133,7 @@ public function getTableExistsCommand(string $dbName, string $tableName): string SELECT COUNT(*) AS count FROM %s.INFORMATION_SCHEMA.TABLES WHERE `table_type` != 'VIEW' AND table_name = %s; SQL, BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quote($tableName) + BigqueryQuote::quote($tableName), ); } @@ -141,12 +141,12 @@ public function getInsertAllIntoTargetTableCommand( BigqueryTableDefinition $sourceTableDefinition, BigqueryTableDefinition $destinationTableDefinition, BigqueryImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $destinationTable = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); $columnsToInsert = $sourceTableDefinition->getColumnsNames(); @@ -156,7 +156,7 @@ public function getInsertAllIntoTargetTableCommand( if ($useTimestamp) { $columnsToInsert = array_merge( $sourceTableDefinition->getColumnsNames(), - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); } @@ -171,7 +171,7 @@ public function getInsertAllIntoTargetTableCommand( $columnsSetSql = $this->getColumnSetSqlPartForStringTable( $sourceTableDefinition, $destinationTableDefinition, - $importOptions + $importOptions, ); } @@ -186,7 +186,7 @@ public function getInsertAllIntoTargetTableCommand( implode(',', $columnsSetSql), BigqueryQuote::quoteSingleIdentifier($sourceTableDefinition->getSchemaName()), BigqueryQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()), - BigqueryQuote::quoteSingleIdentifier(self::SRC_ALIAS) + BigqueryQuote::quoteSingleIdentifier(self::SRC_ALIAS), ); } @@ -195,7 +195,7 @@ public function getTruncateTable(string $schema, string $tableName): string return sprintf( 'TRUNCATE TABLE %s.%s', BigqueryQuote::quoteSingleIdentifier($schema), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ); } @@ -205,10 +205,10 @@ public function getTruncateTable(string $schema, string $tableName): string public function getColumnsString( array $columns, string $delimiter = ', ', - ?string $tableAlias = null + ?string $tableAlias = null, ): string { return implode($delimiter, array_map(static function ($columns) use ( - $tableAlias + $tableAlias, ) { $alias = $tableAlias === null ? '' : $tableAlias . '.'; return $alias . BigqueryQuote::quoteSingleIdentifier($columns); @@ -218,18 +218,18 @@ public function getColumnsString( public function getDeleteOldItemsCommand( BigqueryTableDefinition $stagingTableDefinition, BigqueryTableDefinition $destinationTableDefinition, - BigqueryImportOptions $importOptions + BigqueryImportOptions $importOptions, ): string { $stagingTable = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $destinationTable = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); return sprintf( @@ -238,8 +238,8 @@ public function getDeleteOldItemsCommand( $destinationTable, $this->getPrimaryKeyWhereConditions( $destinationTableDefinition->getPrimaryKeysNames(), - $importOptions - ) + $importOptions, + ), ); } @@ -249,7 +249,7 @@ public function getDeleteOldItemsCommand( public function getCreateDedupTable( BigqueryTableDefinition $stagingTableDefinition, string $dedupTableName, - array $primaryKeys + array $primaryKeys, ): string { return sprintf( <<< SQL @@ -261,7 +261,7 @@ public function getCreateDedupTable( $this->getDedupSelect( $stagingTableDefinition, $stagingTableDefinition->getColumnsNames(), - $primaryKeys + $primaryKeys, ), ); } @@ -270,7 +270,7 @@ public function getUpdateWithPkCommand( BigqueryTableDefinition $stagingTableDefinition, BigqueryTableDefinition $destinationTableDefinition, BigqueryImportOptions $importOptions, - string $timestampValue + string $timestampValue, ): string { $columnsSet = []; @@ -289,13 +289,13 @@ public function getUpdateWithPkCommand( '%s = IF(`src`.%s = \'\', NULL, `src`.%s)', BigqueryQuote::quoteSingleIdentifier($columnName), BigqueryQuote::quoteSingleIdentifier($columnName), - BigqueryQuote::quoteSingleIdentifier($columnName) + BigqueryQuote::quoteSingleIdentifier($columnName), ); } else { $columnsSet[] = sprintf( '%s = COALESCE(`src`.%s, \'\')', BigqueryQuote::quoteSingleIdentifier($columnName), - BigqueryQuote::quoteSingleIdentifier($columnName) + BigqueryQuote::quoteSingleIdentifier($columnName), ); } } @@ -304,14 +304,14 @@ public function getUpdateWithPkCommand( $columnsSet[] = sprintf( '%s = \'%s\'', BigqueryQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), - $timestampValue + $timestampValue, ); } $dest = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); return sprintf( 'UPDATE %s AS `dest` SET %s FROM %s.%s AS `src` WHERE %s', @@ -328,7 +328,7 @@ public function getUpdateWithPkCommand( */ private function getPrimaryKeyWhereConditions( array $primaryKeys, - BigqueryImportOptions $importOptions + BigqueryImportOptions $importOptions, ): string { $pkWhereSql = array_map(function (string $col) use ($importOptions) { $str = '`dest`.%s = COALESCE(`src`.%s, \'\')'; @@ -338,7 +338,7 @@ private function getPrimaryKeyWhereConditions( return sprintf( $str, BigqueryQuote::quoteSingleIdentifier($col), - BigqueryQuote::quoteSingleIdentifier($col) + BigqueryQuote::quoteSingleIdentifier($col), ); }, $primaryKeys); @@ -351,7 +351,7 @@ private function getPrimaryKeyWhereConditions( public function getDedupCommand( BigqueryTableDefinition $stagingTableDefinition, BigqueryTableDefinition $deduplicationTableDefinition, - array $primaryKeysNames + array $primaryKeysNames, ): string { if (empty($primaryKeysNames)) { return ''; @@ -360,20 +360,20 @@ public function getDedupCommand( $depudeSql = $this->getDedupSelect( $stagingTableDefinition, $deduplicationTableDefinition->getColumnsNames(), - $primaryKeysNames + $primaryKeysNames, ); $deduplication = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($deduplicationTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()), ); return sprintf( 'INSERT INTO %s (%s) %s', $deduplication, $this->getColumnsString($deduplicationTableDefinition->getColumnsNames()), - $depudeSql + $depudeSql, ); } @@ -384,17 +384,17 @@ public function getDedupCommand( private function getDedupSelect( BigqueryTableDefinition $stagingTableDefinition, array $columns, - array $primaryKeysNames + array $primaryKeysNames, ): string { $pkSql = $this->getColumnsString( $primaryKeysNames, - ',' + ',', ); $stage = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); return sprintf( @@ -407,7 +407,7 @@ private function getDedupSelect( $this->getColumnsString($columns, ', '), $pkSql, $pkSql, - $stage + $stage, ); } } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromGCSCopyIntoAdapter.php b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromGCSCopyIntoAdapter.php index a00870d14..9bd246c29 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromGCSCopyIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromGCSCopyIntoAdapter.php @@ -27,7 +27,7 @@ public function __construct(BigQueryClient $bqClient) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof Storage\GCS\SourceFile); assert($destination instanceof BigqueryTableDefinition); @@ -83,7 +83,7 @@ public function runCopyCommand( $ref = new BigqueryTableReflection( $this->bqClient, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromTableInsertIntoAdapter.php b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromTableInsertIntoAdapter.php index fd43e9f14..76b015e90 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromTableInsertIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/FromTableInsertIntoAdapter.php @@ -33,7 +33,7 @@ public function __construct(BigQueryClient $bqClient) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SelectSource || $source instanceof Table); assert($destination instanceof BigqueryTableDefinition); @@ -48,9 +48,9 @@ public function runCopyCommand( (new BigqueryTableReflection( $this->bqClient, $source->getSchema(), - $source->getTableName() + $source->getTableName(), ))->getColumnsDefinitions(), - $destination->getColumnsDefinitions() + $destination->getColumnsDefinitions(), ); } @@ -65,12 +65,12 @@ public function runCopyCommand( BigqueryQuote::quoteSingleIdentifier($destination->getSchemaName()), BigqueryQuote::quoteSingleIdentifier($destination->getTableName()), implode(', ', $quotedColumns), - $select + $select, ); if ($source instanceof SelectSource) { $this->bqClient->runQuery($this->bqClient->query($sql)->parameters( - $source->getQueryBindings() + $source->getQueryBindings(), )); } else { $this->bqClient->runQuery($this->bqClient->query($sql)); @@ -79,7 +79,7 @@ public function runCopyCommand( $ref = new BigqueryTableReflection( $this->bqClient, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/StageTableDefinitionFactory.php b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/StageTableDefinitionFactory.php index b3cc2f7a9..19a303e72 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/StageTableDefinitionFactory.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/StageTableDefinitionFactory.php @@ -17,7 +17,7 @@ final class StageTableDefinitionFactory */ public static function createStagingTableDefinition( BigqueryTableDefinition $destination, - array $sourceColumnsNames + array $sourceColumnsNames, ): BigqueryTableDefinition { $newDefinitions = []; // create staging table for source columns in order @@ -36,8 +36,8 @@ public static function createStagingTableDefinition( 'length' => $definition->getColumnDefinition()->getLength(), 'nullable' => true, 'default' => $definition->getColumnDefinition()->getDefault(), - ] - ) + ], + ), ); continue 2; } @@ -51,7 +51,7 @@ public static function createStagingTableDefinition( BackendHelper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - $destination->getPrimaryKeysNames() + $destination->getPrimaryKeysNames(), ); } @@ -63,8 +63,8 @@ private static function createVarcharColumn(string $columnName): BigqueryColumn Bigquery::TYPE_STRING, [ 'nullable' => true, - ] - ) + ], + ), ); } @@ -73,7 +73,7 @@ private static function createVarcharColumn(string $columnName): BigqueryColumn */ public static function createStagingTableDefinitionWithText( BigqueryTableDefinition $destination, - array $sourceColumnsNames + array $sourceColumnsNames, ): BigqueryTableDefinition { $newDefinitions = []; foreach ($sourceColumnsNames as $columnName) { @@ -85,7 +85,7 @@ public static function createStagingTableDefinitionWithText( BackendHelper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - $destination->getPrimaryKeysNames() + $destination->getPrimaryKeysNames(), ); } } diff --git a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/ToStageImporter.php b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/ToStageImporter.php index 95a369dd0..c2e5c6c4c 100644 --- a/packages/php-db-import-export/src/Backend/Bigquery/ToStage/ToStageImporter.php +++ b/packages/php-db-import-export/src/Backend/Bigquery/ToStage/ToStageImporter.php @@ -32,7 +32,7 @@ public function __construct(BigQueryClient $bqClient) public function importToStagingTable( Storage\SourceInterface $source, TableDefinitionInterface $destinationDefinition, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): ImportState { assert($destinationDefinition instanceof BigqueryTableDefinition); assert($options instanceof ImportOptions); @@ -46,8 +46,8 @@ public function importToStagingTable( $adapter->runCopyCommand( $source, $destinationDefinition, - $options - ) + $options, + ), ); } catch (JobException|ServiceException $e) { throw BigqueryException::covertException($e); @@ -58,7 +58,7 @@ public function importToStagingTable( } private function getAdapter( - Storage\SourceInterface $source + Storage\SourceInterface $source, ): CopyAdapterInterface { switch (true) { case $source instanceof Storage\GCS\SourceFile: @@ -69,8 +69,8 @@ private function getAdapter( throw new LogicException( sprintf( 'No suitable adapter found for source: "%s".', - get_class($source) - ) + get_class($source), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/CopyAdapterInterface.php b/packages/php-db-import-export/src/Backend/CopyAdapterInterface.php index c1e964d95..1580e7ca9 100644 --- a/packages/php-db-import-export/src/Backend/CopyAdapterInterface.php +++ b/packages/php-db-import-export/src/Backend/CopyAdapterInterface.php @@ -16,6 +16,6 @@ interface CopyAdapterInterface public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int; } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ExasolException.php b/packages/php-db-import-export/src/Backend/Exasol/ExasolException.php index 971805433..2df42a67d 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ExasolException.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ExasolException.php @@ -34,7 +34,7 @@ public static function covertException(DBALAlias $e): Throwable preg_match( '/^(An exception occurred.*?)\[EXASOL\]\[EXASolution driver\]ETL-2105: (.+)?.\(Session.*/ms', $e->getMessage(), - $matches + $matches, ); return InvalidSourceDataException::createFromDbalException($e, $matches[2]); @@ -45,12 +45,12 @@ public static function covertException(DBALAlias $e): Throwable preg_match( '/^(An exception occurred.*?)(constraint violation - not null.*)=?.in table.*/ms', $e->getMessage(), - $matches + $matches, ); return new Exception( 'Load error: ' . ucfirst($matches[2]) . ').', - Exception::UNKNOWN_ERROR + Exception::UNKNOWN_ERROR, ); } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ExasolImportOptions.php b/packages/php-db-import-export/src/Backend/Exasol/ExasolImportOptions.php index f26f3d105..be8f42231 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ExasolImportOptions.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ExasolImportOptions.php @@ -23,13 +23,13 @@ public function __construct( bool $isIncremental = false, bool $useTimestamp = false, int $numberOfIgnoredLines = 0, - string $castValueTypes = self::TABLE_TYPES_PRESERVE + string $castValueTypes = self::TABLE_TYPES_PRESERVE, ) { parent::__construct( $convertEmptyValuesToNull, $isIncremental, $useTimestamp, - $numberOfIgnoredLines + $numberOfIgnoredLines, ); $this->castValueTypes = $castValueTypes; } diff --git a/packages/php-db-import-export/src/Backend/Exasol/Exporter.php b/packages/php-db-import-export/src/Backend/Exasol/Exporter.php index 5df2fc7a0..6744a42d0 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/Exporter.php +++ b/packages/php-db-import-export/src/Backend/Exasol/Exporter.php @@ -23,7 +23,7 @@ class Exporter implements ExporterInterface private Connection $connection; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; } @@ -43,7 +43,7 @@ public function setAdapters(array $adapters): void public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array { $adapter = $this->getAdapter($source, $destination); return $adapter->runCopyCommand($source, $destination, $options); @@ -51,7 +51,7 @@ public function exportTable( private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): BackendExportAdapterInterface { $adapterForUse = null; foreach ($this->adapters as $adapter) { @@ -62,8 +62,8 @@ private function getAdapter( 'More than one suitable adapter found for Export exporter with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->connection); @@ -74,8 +74,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Exasol exporter with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/FullImporter.php b/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/FullImporter.php index 665d88959..0b77f4524 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/FullImporter.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/FullImporter.php @@ -28,7 +28,7 @@ final class FullImporter implements ToFinalTableImporterInterface private SqlBuilder $sqlBuilder; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -38,7 +38,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof ExasolTableDefinition); assert($destinationTableDefinition instanceof ExasolTableDefinition); @@ -51,14 +51,14 @@ public function importToTable( $stagingTableDefinition, $destinationTableDefinition, $options, - $state + $state, ); } else { $this->doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - $state + $state, ); } } catch (Exception $e) { @@ -74,14 +74,14 @@ private function doFullLoadWithDedup( ExasolTableDefinition $stagingTableDefinition, ExasolTableDefinition $destinationTableDefinition, ExasolImportOptions $options, - ImportState $state + ImportState $state, ): void { $state->startTimer(self::TIMER_DEDUP); // 1. Create table for deduplication $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupTableDefinition( $stagingTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ); try { @@ -94,16 +94,16 @@ private function doFullLoadWithDedup( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); // 3 truncate destination table $this->connection->executeStatement( $this->sqlBuilder->getTruncateTableWithDeleteCommand( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); // 4 move data with INSERT INTO @@ -112,8 +112,8 @@ private function doFullLoadWithDedup( $deduplicationTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_DEDUP); } finally { @@ -121,13 +121,13 @@ private function doFullLoadWithDedup( $this->connection->executeStatement( $this->sqlBuilder->getDropTableIfExistsCommand( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() - ) + $deduplicationTableDefinition->getTableName(), + ), ); } $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); } @@ -135,14 +135,14 @@ private function doLoadFullWithoutDedup( ExasolTableDefinition $stagingTableDefinition, ExasolTableDefinition $destinationTableDefinition, ExasolImportOptions $options, - ImportState $state + ImportState $state, ): void { // truncate destination table $this->connection->executeStatement( $this->sqlBuilder->getTruncateTableWithDeleteCommand( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); $state->startTimer(self::TIMER_COPY_TO_TARGET); @@ -152,13 +152,13 @@ private function doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_COPY_TO_TARGET); $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); } } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/IncrementalImporter.php b/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/IncrementalImporter.php index 6e11bc35a..dbe0741f2 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/IncrementalImporter.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/IncrementalImporter.php @@ -31,7 +31,7 @@ final class IncrementalImporter implements ToFinalTableImporterInterface private SqlBuilder $sqlBuilder; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -41,7 +41,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof ExasolTableDefinition); assert($destinationTableDefinition instanceof ExasolTableDefinition); @@ -59,7 +59,7 @@ public function importToTable( // 0. Create table for deduplication $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupTableDefinition( $stagingTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ); $tableToCopyFrom = $deduplicationTableDefinition; $qb = new ExasolTableQueryBuilder(); @@ -75,8 +75,8 @@ public function importToTable( $stagingTableDefinition, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_UPDATE_TARGET_TABLE); @@ -85,8 +85,8 @@ public function importToTable( $this->connection->executeStatement( $this->sqlBuilder->getDeleteOldItemsCommand( $stagingTableDefinition, - $destinationTableDefinition - ) + $destinationTableDefinition, + ), ); $state->stopTimer(self::TIMER_DELETE_UPDATED_ROWS); @@ -96,14 +96,14 @@ public function importToTable( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); $this->connection->executeStatement( $this->sqlBuilder->getTruncateTableWithDeleteCommand( $stagingTableDefinition->getSchemaName(), - $stagingTableDefinition->getTableName() - ) + $stagingTableDefinition->getTableName(), + ), ); $state->stopTimer(self::TIMER_DEDUP_STAGING); } @@ -115,13 +115,13 @@ public function importToTable( $tableToCopyFrom, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_INSERT_INTO_TARGET); $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); $state->setImportedColumns($stagingTableDefinition->getColumnsNames()); @@ -133,8 +133,8 @@ public function importToTable( $this->connection->executeStatement( $this->sqlBuilder->getDropTableIfExistsCommand( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() - ) + $deduplicationTableDefinition->getTableName(), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/SqlBuilder.php b/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/SqlBuilder.php index 9e80b2ff3..5a9d98066 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/SqlBuilder.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToFinalTable/SqlBuilder.php @@ -27,7 +27,7 @@ public function getCommitTransaction(): string public function getDedupCommand( ExasolTableDefinition $stagingTableDefinition, ExasolTableDefinition $deduplicationTableDefinition, - array $primaryKeys + array $primaryKeys, ): string { if (empty($primaryKeys)) { return ''; @@ -35,13 +35,13 @@ public function getDedupCommand( $pkSql = $this->getColumnsString( $primaryKeys, - ',' + ',', ); $stage = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $depudeSql = sprintf( @@ -54,20 +54,20 @@ public function getDedupCommand( $this->getColumnsString($deduplicationTableDefinition->getColumnsNames(), ', '), $pkSql, $pkSql, - $stage + $stage, ); $deduplication = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($deduplicationTableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()), ); return sprintf( 'INSERT INTO %s (%s) %s', $deduplication, $this->getColumnsString($deduplicationTableDefinition->getColumnsNames()), - $depudeSql + $depudeSql, ); } @@ -77,10 +77,10 @@ public function getDedupCommand( public function getColumnsString( array $columns, string $delimiter = ', ', - ?string $tableAlias = null + ?string $tableAlias = null, ): string { return implode($delimiter, array_map(static function ($columns) use ( - $tableAlias + $tableAlias, ) { $alias = $tableAlias === null ? '' : $tableAlias . '.'; return $alias . ExasolQuote::quoteSingleIdentifier($columns); @@ -89,18 +89,18 @@ public function getColumnsString( public function getDeleteOldItemsCommand( ExasolTableDefinition $stagingTableDefinition, - ExasolTableDefinition $destinationTableDefinition + ExasolTableDefinition $destinationTableDefinition, ): string { $stagingTable = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $destinationTable = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); return sprintf( @@ -110,8 +110,8 @@ public function getDeleteOldItemsCommand( $this->getPrimaryKeyWhereConditionsSubstitute( $destinationTableDefinition->getPrimaryKeysNames(), $stagingTable, - $destinationTable - ) + $destinationTable, + ), ); } @@ -121,7 +121,7 @@ public function getDeleteOldItemsCommand( private function getPrimaryKeyWhereConditionsSubstitute( array $primaryKeys, string $sourceTable, - string $destinationTable + string $destinationTable, ): string { $pkWhereSql = array_map(function (string $col) use ($sourceTable, $destinationTable) { return sprintf( @@ -129,7 +129,7 @@ private function getPrimaryKeyWhereConditionsSubstitute( $destinationTable, ExasolQuote::quoteSingleIdentifier($col), $sourceTable, - ExasolQuote::quoteSingleIdentifier($col) + ExasolQuote::quoteSingleIdentifier($col), ); }, $primaryKeys); @@ -142,7 +142,7 @@ private function getPrimaryKeyWhereConditionsSubstitute( private function getPrimaryKeyWhereConditionsNull( array $primaryKeys, string $sourceTable, - string $destinationTable + string $destinationTable, ): string { $pkWhereSql = array_map(function (string $col) use ($sourceTable, $destinationTable) { return sprintf( @@ -154,7 +154,7 @@ private function getPrimaryKeyWhereConditionsNull( $destinationTable, ExasolQuote::quoteSingleIdentifier($col), $sourceTable, - ExasolQuote::quoteSingleIdentifier($col) + ExasolQuote::quoteSingleIdentifier($col), ); }, $primaryKeys); @@ -163,12 +163,12 @@ private function getPrimaryKeyWhereConditionsNull( public function getDropTableIfExistsCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DROP TABLE IF EXISTS %s.%s', ExasolQuote::quoteSingleIdentifier($schema), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), ); } @@ -176,12 +176,12 @@ public function getInsertAllIntoTargetTableCommand( ExasolTableDefinition $sourceTableDefinition, ExasolTableDefinition $destinationTableDefinition, ExasolImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $destinationTable = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); $insColumns = $sourceTableDefinition->getColumnsNames(); @@ -191,7 +191,7 @@ public function getInsertAllIntoTargetTableCommand( if ($useTimestamp) { $insColumns = array_merge( $sourceTableDefinition->getColumnsNames(), - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); } @@ -204,7 +204,7 @@ public function getInsertAllIntoTargetTableCommand( if ($columnDefinition->getColumnDefinition()->getBasetype() === BaseType::STRING) { $columnsSetSql[] = sprintf( 'NULLIF(%s, \'\')', - ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { $columnsSetSql[] = ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()); @@ -214,7 +214,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(COALESCE(%s, \'\') AS %s) AS %s', ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $columnDefinition->getColumnDefinition()->getTypeOnlySQLDefinition(), - ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } } @@ -230,18 +230,18 @@ public function getInsertAllIntoTargetTableCommand( implode(',', $columnsSetSql), ExasolQuote::quoteSingleIdentifier($sourceTableDefinition->getSchemaName()), ExasolQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()), - ExasolQuote::quoteSingleIdentifier(self::SRC_ALIAS) + ExasolQuote::quoteSingleIdentifier(self::SRC_ALIAS), ); } public function getTruncateTableWithDeleteCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DELETE FROM %s.%s', ExasolQuote::quoteSingleIdentifier($schema), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), ); } @@ -249,12 +249,12 @@ public function getUpdateWithPkCommandSubstitute( ExasolTableDefinition $stagingTableDefinition, ExasolTableDefinition $destinationDefinition, ExasolImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $dest = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($destinationDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($destinationDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($destinationDefinition->getTableName()), ); $columnsSet = []; @@ -267,7 +267,7 @@ public function getUpdateWithPkCommandSubstitute( $columnsSet[] = sprintf( '%s = "src".%s', ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } @@ -275,7 +275,7 @@ public function getUpdateWithPkCommandSubstitute( $columnsSet[] = sprintf( '%s = \'%s\'', ExasolQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), - $timestamp + $timestamp, ); } @@ -288,10 +288,10 @@ function (ExasolColumn $columnDefinition) { 'COALESCE(CAST("dest".%s AS %s), \'KBC_$#\') != COALESCE("src".%s, \'KBC_$#\')', ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $columnDefinition->getColumnDefinition()->getTypeOnlySQLDefinition(), - ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); }, - $columnsList + $columnsList, ); return sprintf( @@ -304,9 +304,9 @@ function (ExasolColumn $columnDefinition) { $this->getPrimaryKeyWhereConditionsSubstitute( $destinationDefinition->getPrimaryKeysNames(), '"src"', - '"dest"' + '"dest"', ), - implode(' OR ', $columnsComparisonSql) + implode(' OR ', $columnsComparisonSql), ); } @@ -315,12 +315,12 @@ public function getUpdateWithPkCommandNull( ExasolTableDefinition $stagingTableDefinition, ExasolTableDefinition $destinationDefinition, ExasolImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $dest = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($destinationDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($destinationDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($destinationDefinition->getTableName()), ); $columnsSet = []; @@ -333,7 +333,7 @@ public function getUpdateWithPkCommandNull( $columnsSet[] = sprintf( '%s = "src".%s', ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } @@ -341,7 +341,7 @@ public function getUpdateWithPkCommandNull( $columnsSet[] = sprintf( '%s = \'%s\'', ExasolQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), - $timestamp + $timestamp, ); } @@ -358,10 +358,10 @@ function (ExasolColumn $columnDefinition) { ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + ExasolQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); }, - $columnsList + $columnsList, ); return sprintf( @@ -374,9 +374,9 @@ function (ExasolColumn $columnDefinition) { $this->getPrimaryKeyWhereConditionsNull( $destinationDefinition->getPrimaryKeysNames(), '"src"', - '"dest"' + '"dest"', ), - implode(' OR ', $columnsComparisonSql) + implode(' OR ', $columnsComparisonSql), ); } } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromS3CopyIntoAdapter.php b/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromS3CopyIntoAdapter.php index 4a3847625..9dafccfc2 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromS3CopyIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromS3CopyIntoAdapter.php @@ -42,7 +42,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SourceFile); assert($destination instanceof ExasolTableDefinition); @@ -62,7 +62,7 @@ public function runCopyCommand( $ref = new ExasolTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -74,7 +74,7 @@ public function runCopyCommand( private function getCopyCommand( Storage\S3\SourceFile $source, ExasolTableDefinition $destination, - ExasolImportOptions $importOptions + ExasolImportOptions $importOptions, ): Generator { $destinationSchema = ExasolQuote::quoteSingleIdentifier($destination->getSchemaName()); $destinationTable = ExasolQuote::quoteSingleIdentifier($destination->getTableName()); @@ -99,7 +99,7 @@ private function getCopyCommand( static function ($entry) use ($s3Prefix) { return 'FILE ' . ExasolQuote::quote(strtr($entry, [$s3Prefix => ''])); }, - $entries + $entries, ); // EXA COLUMN SEPARATOR = string between values @@ -123,7 +123,7 @@ static function ($entry) use ($s3Prefix) { implode("\n", $entries), $firstRow, ExasolQuote::quote($source->getCsvOptions()->getDelimiter()), - ExasolQuote::quote($source->getCsvOptions()->getEnclosure()) + ExasolQuote::quote($source->getCsvOptions()->getEnclosure()), ); } } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromTableInsertIntoAdapter.php b/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromTableInsertIntoAdapter.php index b8f997152..dc51cb5e2 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromTableInsertIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToStage/FromTableInsertIntoAdapter.php @@ -28,7 +28,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SelectSource || $source instanceof Table); assert($destination instanceof ExasolTableDefinition); @@ -43,7 +43,7 @@ public function runCopyCommand( ExasolQuote::quoteSingleIdentifier($destination->getSchemaName()), ExasolQuote::quoteSingleIdentifier($destination->getTableName()), implode(', ', $quotedColumns), - $source->getFromStatement() + $source->getFromStatement(), ); if ($source instanceof SelectSource) { @@ -55,7 +55,7 @@ public function runCopyCommand( $ref = new ExasolTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToStage/StageTableDefinitionFactory.php b/packages/php-db-import-export/src/Backend/Exasol/ToStage/StageTableDefinitionFactory.php index 68773ccb8..a435ecd66 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToStage/StageTableDefinitionFactory.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToStage/StageTableDefinitionFactory.php @@ -18,7 +18,7 @@ final class StageTableDefinitionFactory */ public static function createStagingTableDefinition( TableDefinitionInterface $destination, - array $sourceColumnsNames + array $sourceColumnsNames, ): ExasolTableDefinition { /** @var ExasolTableDefinition $destination */ $newDefinitions = []; @@ -38,8 +38,8 @@ public static function createStagingTableDefinition( 'length' => $definition->getColumnDefinition()->getLength(), 'nullable' => true, // set all columns to be nullable 'default' => $definition->getColumnDefinition()->getDefault(), - ] - ) + ], + ), ); continue 2; } @@ -53,7 +53,7 @@ public static function createStagingTableDefinition( BackendHelper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - $destination->getPrimaryKeysNames() + $destination->getPrimaryKeysNames(), ); } @@ -66,8 +66,8 @@ private static function createNvarcharColumn(string $columnName): ExasolColumn [ 'length' => (string) Exasol::MAX_VARCHAR_LENGTH, 'nullable' => true, // set all columns to be nullable - ] - ) + ], + ), ); } @@ -76,7 +76,7 @@ private static function createNvarcharColumn(string $columnName): ExasolColumn */ public static function createDedupTableDefinition( ExasolTableDefinition $destination, - array $pkNames + array $pkNames, ): ExasolTableDefinition { // ensure that PK on dedup table are not null $dedupTableColumns = []; @@ -90,8 +90,8 @@ public static function createDedupTableDefinition( [ 'length' => $definition->getColumnDefinition()->getLength(), 'nullable' => false, - ] - ) + ], + ), ); } else { $dedupTableColumns[] = $definition; @@ -103,7 +103,7 @@ public static function createDedupTableDefinition( BackendHelper::generateTempDedupTableName(), true, new ColumnCollection($dedupTableColumns), - $pkNames + $pkNames, ); } } diff --git a/packages/php-db-import-export/src/Backend/Exasol/ToStage/ToStageImporter.php b/packages/php-db-import-export/src/Backend/Exasol/ToStage/ToStageImporter.php index aeee31682..3a80725df 100644 --- a/packages/php-db-import-export/src/Backend/Exasol/ToStage/ToStageImporter.php +++ b/packages/php-db-import-export/src/Backend/Exasol/ToStage/ToStageImporter.php @@ -28,7 +28,7 @@ final class ToStageImporter implements ToStageImporterInterface public function __construct( Connection $connection, - ?CopyAdapterInterface $adapter = null + ?CopyAdapterInterface $adapter = null, ) { $this->connection = $connection; $this->adapter = $adapter; @@ -37,7 +37,7 @@ public function __construct( public function importToStagingTable( Storage\SourceInterface $source, TableDefinitionInterface $destinationDefinition, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): ImportState { assert($options instanceof ExasolImportOptions); assert($destinationDefinition instanceof ExasolTableDefinition); @@ -52,8 +52,8 @@ public function importToStagingTable( $adapter->runCopyCommand( $source, $destinationDefinition, - $options - ) + $options, + ), ); } catch (Exception $e) { throw $e; @@ -81,8 +81,8 @@ private function getAdapter(Storage\SourceInterface $source): CopyAdapterInterfa throw new LogicException( sprintf( 'No suitable adapter found for source: "%s".', - get_class($source) - ) + get_class($source), + ), ); } return $adapter; diff --git a/packages/php-db-import-export/src/Backend/ExporterInterface.php b/packages/php-db-import-export/src/Backend/ExporterInterface.php index 4c4f7a729..0b8ad4a9d 100644 --- a/packages/php-db-import-export/src/Backend/ExporterInterface.php +++ b/packages/php-db-import-export/src/Backend/ExporterInterface.php @@ -15,7 +15,7 @@ interface ExporterInterface public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array; /** diff --git a/packages/php-db-import-export/src/Backend/Helper/Assert.php b/packages/php-db-import-export/src/Backend/Helper/Assert.php index 3fdbebf89..fe46bb9cc 100644 --- a/packages/php-db-import-export/src/Backend/Helper/Assert.php +++ b/packages/php-db-import-export/src/Backend/Helper/Assert.php @@ -12,12 +12,12 @@ class Assert { public static function assertColumnsOnTableDefinition( SourceInterface $source, - TableDefinitionInterface $destinationDefinition + TableDefinitionInterface $destinationDefinition, ): void { if (count($source->getColumnsNames()) === 0) { throw new Exception( 'No columns found in CSV file.', - Exception::NO_COLUMNS + Exception::NO_COLUMNS, ); } @@ -25,7 +25,7 @@ public static function assertColumnsOnTableDefinition( if (!empty($moreColumns)) { throw new Exception( 'Columns doest not match. Non existing columns: ' . implode(', ', $moreColumns), - Exception::COLUMNS_COUNT_NOT_MATCH + Exception::COLUMNS_COUNT_NOT_MATCH, ); } } diff --git a/packages/php-db-import-export/src/Backend/ImporterInterface.php b/packages/php-db-import-export/src/Backend/ImporterInterface.php index dc599d0de..9beb01ad3 100644 --- a/packages/php-db-import-export/src/Backend/ImporterInterface.php +++ b/packages/php-db-import-export/src/Backend/ImporterInterface.php @@ -19,7 +19,7 @@ interface ImporterInterface public function importTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): Result; /** diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Export/AbsExportAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/Export/AbsExportAdapter.php index 1edb5ed7f..adfea3ada 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Export/AbsExportAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Export/AbsExportAdapter.php @@ -37,7 +37,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( 'COPY INTO \'%s%s\' @@ -57,7 +57,7 @@ public function runCopyCommand( $destination->getFilePath(), $source->getFromStatement(), $destination->getSasToken(), - $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'" + $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'", ); /** @var array $unloadedFiles */ diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Export/Exporter.php b/packages/php-db-import-export/src/Backend/Snowflake/Export/Exporter.php index 10bda4a15..6748709f1 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Export/Exporter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Export/Exporter.php @@ -25,7 +25,7 @@ class Exporter implements ExporterInterface private Connection $connection; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; } @@ -37,7 +37,7 @@ public function __construct( public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array { return $this->getAdapter($source, $destination) ->runCopyCommand($source, $destination, $options); @@ -45,7 +45,7 @@ public function exportTable( private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): BackendExportAdapterInterface { $adapterForUse = null; foreach ($this->adapters as $adapter) { @@ -56,8 +56,8 @@ private function getAdapter( 'More than one suitable adapter found for Snowflake exporter with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->connection); @@ -68,8 +68,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Snowflake exporter with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Export/GcsExportAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/Export/GcsExportAdapter.php index cfa68a4f5..11dd81980 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Export/GcsExportAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Export/GcsExportAdapter.php @@ -39,7 +39,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( 'COPY INTO \'%s/%s\' @@ -59,7 +59,7 @@ public function runCopyCommand( $destination->getFilePath(), $source->getFromStatement(), $destination->getStorageIntegrationName(), - $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'" + $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'", ); /** @var array $unloadedFiles */ @@ -67,7 +67,7 @@ public function runCopyCommand( if ($exportOptions->generateManifest()) { (new Storage\GCS\ManifestGenerator\GcsSlicedManifestFromUnloadQueryResultGenerator( - $destination->getClient() + $destination->getClient(), )) ->generateAndSaveManifest($destination->getRelativePath(), $unloadedFiles); } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Export/S3ExportAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/Export/S3ExportAdapter.php index 2ede4a720..b6dfeebe9 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Export/S3ExportAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Export/S3ExportAdapter.php @@ -39,7 +39,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( <<connection = $connection; } @@ -41,7 +41,7 @@ public function __construct( public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array { $adapter = $this->getAdapter($source, $destination); return $adapter->runCopyCommand($source, $destination, $options); @@ -49,7 +49,7 @@ public function exportTable( private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): SnowflakeExportAdapterInterface { $adapterForUse = null; foreach ($this->adapters as $adapter) { @@ -58,8 +58,8 @@ private function getAdapter( throw new Exception( sprintf( 'Each Snowflake export adapter must implement "%s".', - SnowflakeExportAdapterInterface::class - ) + SnowflakeExportAdapterInterface::class, + ), ); } if ($adapter::isSupported($source, $destination)) { @@ -69,8 +69,8 @@ private function getAdapter( 'More than one suitable adapter found for Snowflake exporter with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->connection); @@ -81,8 +81,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Snowflake exporter with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Helper/ColumnsHelper.php b/packages/php-db-import-export/src/Backend/Snowflake/Helper/ColumnsHelper.php index 199ad8e22..9e68b4f1e 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Helper/ColumnsHelper.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Helper/ColumnsHelper.php @@ -14,10 +14,10 @@ final class ColumnsHelper public static function getColumnsString( array $columns, string $delimiter = ', ', - ?string $tableAlias = null + ?string $tableAlias = null, ): string { return implode($delimiter, array_map(function ($columns) use ( - $tableAlias + $tableAlias, ) { $alias = $tableAlias === null ? '' : $tableAlias . '.'; return $alias . QuoteHelper::quoteIdentifier($columns); diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelper.php b/packages/php-db-import-export/src/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelper.php index beefd73cf..ebd32fbd1 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelper.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelper.php @@ -14,7 +14,7 @@ final class CopyCommandCsvOptionsHelper */ public static function getCsvCopyCommandOptions( ImportOptionsInterface $importOptions, - CsvOptions $csvOptions + CsvOptions $csvOptions, ): array { $options = [ sprintf('FIELD_DELIMITER = %s', QuoteHelper::quote($csvOptions->getDelimiter())), diff --git a/packages/php-db-import-export/src/Backend/Snowflake/Importer.php b/packages/php-db-import-export/src/Backend/Snowflake/Importer.php index d9ba16017..aeffbc3d9 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/Importer.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/Importer.php @@ -39,7 +39,7 @@ class Importer implements ImporterInterface private ImportState $importState; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlCommandBuilder(); @@ -51,7 +51,7 @@ public function __construct( public function importTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): Result { $adapter = $this->getAdapter($source, $destination); @@ -61,7 +61,7 @@ public function importTable( $this->runQuery($this->sqlBuilder->getCreateStagingTableCommand( $destination->getSchema(), $this->importState->getStagingTableName(), - $source->getColumnsNames() + $source->getColumnsNames(), )); try { @@ -70,11 +70,11 @@ public function importTable( $source, $destination, $options, - $adapter + $adapter, ); $primaryKeys = $this->connection->getTablePrimaryKey( $destination->getSchema(), - $destination->getTableName() + $destination->getTableName(), ); if ($options->isIncremental()) { $this->doIncrementalLoad($options, $source, $destination, $primaryKeys); @@ -84,7 +84,7 @@ public function importTable( $this->importState->setImportedColumns($source->getColumnsNames()); } finally { $this->runQuery( - $this->sqlBuilder->getDropCommand($destination->getSchema(), $this->importState->getStagingTableName()) + $this->sqlBuilder->getDropCommand($destination->getSchema(), $this->importState->getStagingTableName()), ); } @@ -93,25 +93,25 @@ public function importTable( private function validateColumns( Storage\SourceInterface $source, - Storage\Snowflake\Table $destination + Storage\Snowflake\Table $destination, ): void { if (count($source->getColumnsNames()) === 0) { throw new Exception( 'No columns found in CSV file.', - Exception::NO_COLUMNS + Exception::NO_COLUMNS, ); } $tableColumns = $this->connection->getTableColumns( $destination->getSchema(), - $destination->getTableName() + $destination->getTableName(), ); $moreColumns = array_diff($source->getColumnsNames(), $tableColumns); if (!empty($moreColumns)) { throw new Exception( 'Columns doest not match. Non existing columns: ' . implode(', ', $moreColumns), - Exception::COLUMNS_COUNT_NOT_MATCH + Exception::COLUMNS_COUNT_NOT_MATCH, ); } } @@ -133,7 +133,7 @@ private function importToStagingTable( Storage\SourceInterface $source, Storage\Snowflake\Table $destination, ImportOptionsInterface $importOptions, - SnowflakeImportAdapterInterface $adapter + SnowflakeImportAdapterInterface $adapter, ): void { try { $this->importState->startTimer('copyToStaging'); @@ -141,7 +141,7 @@ private function importToStagingTable( $source, $destination, $importOptions, - $this->importState->getStagingTableName() + $this->importState->getStagingTableName(), ); $this->importState->stopTimer('copyToStaging'); $this->importState->addImportedRowsCount($rowsCount); @@ -160,11 +160,11 @@ private function doIncrementalLoad( ImportOptionsInterface $importOptions, Storage\SourceInterface $source, Storage\Snowflake\Table $destination, - array $primaryKeys + array $primaryKeys, ): void { $timestampValue = DateTimeHelper::getNowFormatted(); $this->runQuery( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); if (!empty($primaryKeys)) { $this->runQuery( @@ -174,17 +174,17 @@ private function doIncrementalLoad( $importOptions, $this->importState->getStagingTableName(), $primaryKeys, - $timestampValue + $timestampValue, ), - 'updateTargetTable' + 'updateTargetTable', ); $this->runQuery( $this->sqlBuilder->getDeleteOldItemsCommand( $destination, $this->importState->getStagingTableName(), - $primaryKeys + $primaryKeys, ), - 'deleteUpdatedRowsFromStaging' + 'deleteUpdatedRowsFromStaging', ); $this->importState->startTimer('dedupStaging'); $this->dedup($source, $destination, $primaryKeys); @@ -196,12 +196,12 @@ private function doIncrementalLoad( $destination, $importOptions, $this->importState->getStagingTableName(), - $timestampValue + $timestampValue, ), - 'insertIntoTargetFromStaging' + 'insertIntoTargetFromStaging', ); $this->runQuery( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); } @@ -211,13 +211,13 @@ private function doIncrementalLoad( private function dedup( Storage\SourceInterface $source, Storage\Snowflake\Table $destination, - array $primaryKeys + array $primaryKeys, ): void { $tempTableName = BackendHelper::generateStagingTableName(); $this->runQuery($this->sqlBuilder->getCreateStagingTableCommand( $destination->getSchema(), $tempTableName, - $source->getColumnsNames() + $source->getColumnsNames(), )); $this->runQuery( @@ -226,21 +226,21 @@ private function dedup( $destination, $primaryKeys, $this->importState->getStagingTableName(), - $tempTableName - ) + $tempTableName, + ), ); $this->runQuery( $this->sqlBuilder->getDropCommand( $destination->getSchema(), - $this->importState->getStagingTableName() - ) + $this->importState->getStagingTableName(), + ), ); $this->runQuery( $this->sqlBuilder->getRenameTableCommand( $destination->getSchema(), $tempTableName, - $this->importState->getStagingTableName() - ) + $this->importState->getStagingTableName(), + ), ); } @@ -251,7 +251,7 @@ private function doNonIncrementalLoad( ImportOptionsInterface $importOptions, Storage\SourceInterface $source, Storage\Snowflake\Table $destination, - array $primaryKeys + array $primaryKeys, ): void { if (!empty($primaryKeys)) { $this->importState->startTimer('dedup'); @@ -259,25 +259,25 @@ private function doNonIncrementalLoad( $this->importState->stopTimer('dedup'); } $this->runQuery( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); $this->runQuery( $this->sqlBuilder->getTruncateTableCommand( $destination->getSchema(), - $destination->getTableName() - ) + $destination->getTableName(), + ), ); $this->runQuery( $this->sqlBuilder->getInsertAllIntoTargetTableCommand( $source, $destination, $importOptions, - $this->importState->getStagingTableName() + $this->importState->getStagingTableName(), ), - 'copyFromStagingToTarget' + 'copyFromStagingToTarget', ); $this->runQuery( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); } @@ -291,7 +291,7 @@ public function setAdapters(array $adapters): void private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): SnowflakeImportAdapterInterface { $adapterForUse = null; foreach ($this->adapters as $adapter) { @@ -300,8 +300,8 @@ private function getAdapter( throw new InternalException( sprintf( 'Each snowflake import adapter must implement "%s".', - SnowflakeImportAdapterInterface::class - ) + SnowflakeImportAdapterInterface::class, + ), ); } if ($adapter::isSupported($source, $destination)) { @@ -311,8 +311,8 @@ private function getAdapter( 'More than one suitable adapter found for Snowflake importer with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->connection); @@ -323,8 +323,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Snowflake importer with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeException.php b/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeException.php index ea7006f1e..943d8d8d3 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeException.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeException.php @@ -26,7 +26,7 @@ public static function covertException(Throwable $e): Throwable return new Exception( 'Load error: ' . $e->getMessage(), Exception::UNKNOWN_ERROR, - $e + $e, ); } @@ -50,7 +50,7 @@ public static function covertException(Throwable $e): Throwable return new Exception( 'Load error: ' . $message, Exception::VALUE_CONVERSION, - $e + $e, ); } @@ -62,7 +62,7 @@ public static function covertException(Throwable $e): Throwable return new Exception( 'Load error: ' . $e->getMessage(), Exception::ROW_SIZE_TOO_LARGE, - $e + $e, ); } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeImportOptions.php b/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeImportOptions.php index 58ecc7bb8..baed8991d 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeImportOptions.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/SnowflakeImportOptions.php @@ -35,7 +35,7 @@ public function __construct( $useTimestamp, $numberOfIgnoredLines, $requireSameTables === self::SAME_TABLES_REQUIRED ? self::USING_TYPES_USER : self::USING_TYPES_STRING, - $ignoreColumns + $ignoreColumns, ); $this->requireSameTables = $requireSameTables; $this->nullManipulation = $nullManipulation; diff --git a/packages/php-db-import-export/src/Backend/Snowflake/SqlCommandBuilder.php b/packages/php-db-import-export/src/Backend/Snowflake/SqlCommandBuilder.php index 2c633ae7d..de2a4c9a8 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/SqlCommandBuilder.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/SqlCommandBuilder.php @@ -29,7 +29,7 @@ public function getCommitTransaction(): string public function getCreateStagingTableCommand( string $schema, string $tableName, - array $columns + array $columns, ): string { $columnsSql = array_map(function ($column) { return sprintf('%s varchar', QuoteHelper::quoteIdentifier($column)); @@ -38,7 +38,7 @@ public function getCreateStagingTableCommand( 'CREATE TEMPORARY TABLE %s.%s (%s)', QuoteHelper::quoteIdentifier($schema), QuoteHelper::quoteIdentifier($tableName), - implode(', ', $columnsSql) + implode(', ', $columnsSql), ); } @@ -50,7 +50,7 @@ public function getDedupCommand( Table $destination, array $primaryKeys, string $stagingTableName, - string $tempTableName + string $tempTableName, ): string { if (empty($primaryKeys)) { return ''; @@ -58,7 +58,7 @@ public function getDedupCommand( $pkSql = ColumnsHelper::getColumnsString( $primaryKeys, - ',' + ',', ); $depudeSql = sprintf( @@ -72,7 +72,7 @@ public function getDedupCommand( $pkSql, $pkSql, QuoteHelper::quoteIdentifier($destination->getSchema()), - QuoteHelper::quoteIdentifier($stagingTableName) + QuoteHelper::quoteIdentifier($stagingTableName), ); return sprintf( @@ -80,7 +80,7 @@ public function getDedupCommand( QuoteHelper::quoteIdentifier($destination->getSchema()), QuoteHelper::quoteIdentifier($tempTableName), ColumnsHelper::getColumnsString($source->getColumnsNames()), - $depudeSql + $depudeSql, ); } @@ -90,7 +90,7 @@ public function getDedupCommand( public function getDeleteOldItemsCommand( Table $destination, string $stagingTableName, - array $primaryKeys + array $primaryKeys, ): string { // Delete updated rows from staging table return sprintf( @@ -98,7 +98,7 @@ public function getDeleteOldItemsCommand( QuoteHelper::quoteIdentifier($destination->getSchema()), QuoteHelper::quoteIdentifier($stagingTableName), $destination->getQuotedTableWithScheme(), - $this->getPrimayKeyWhereConditions($primaryKeys) + $this->getPrimayKeyWhereConditions($primaryKeys), ); } @@ -106,13 +106,13 @@ public function getDeleteOldItemsCommand( * @param string[] $primaryKeys */ private function getPrimayKeyWhereConditions( - array $primaryKeys + array $primaryKeys, ): string { $pkWhereSql = array_map(function (string $col) { return sprintf( '"dest".%s = COALESCE("src".%s, \'\')', QuoteHelper::quoteIdentifier($col), - QuoteHelper::quoteIdentifier($col) + QuoteHelper::quoteIdentifier($col), ); }, $primaryKeys); @@ -121,12 +121,12 @@ private function getPrimayKeyWhereConditions( public function getDropCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DROP TABLE %s.%s', QuoteHelper::quoteIdentifier($schema), - QuoteHelper::quoteIdentifier($tableName) + QuoteHelper::quoteIdentifier($tableName), ); } @@ -134,23 +134,23 @@ public function getInsertAllIntoTargetTableCommand( SourceInterface $source, Table $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): string { $columnsSetSqlSelect = implode(', ', array_map(function ($column) use ( - $importOptions + $importOptions, ) { if (in_array($column, $importOptions->getConvertEmptyValuesToNull())) { return sprintf( 'IFF(%s = \'\', NULL, %s)', QuoteHelper::quoteIdentifier($column), - QuoteHelper::quoteIdentifier($column) + QuoteHelper::quoteIdentifier($column), ); } return sprintf( "COALESCE(%s, '') AS %s", QuoteHelper::quoteIdentifier($column), - QuoteHelper::quoteIdentifier($column) + QuoteHelper::quoteIdentifier($column), ); }, $source->getColumnsNames())); @@ -163,7 +163,7 @@ public function getInsertAllIntoTargetTableCommand( ColumnsHelper::getColumnsString($source->getColumnsNames()), $columnsSetSqlSelect, QuoteHelper::quoteIdentifier($destination->getSchema()), - QuoteHelper::quoteIdentifier($stagingTableName) + QuoteHelper::quoteIdentifier($stagingTableName), ); } @@ -175,7 +175,7 @@ public function getInsertAllIntoTargetTableCommand( $columnsSetSqlSelect, DateTimeHelper::getNowFormatted(), QuoteHelper::quoteIdentifier($destination->getSchema()), - QuoteHelper::quoteIdentifier($stagingTableName) + QuoteHelper::quoteIdentifier($stagingTableName), ); } @@ -184,7 +184,7 @@ public function getInsertFromStagingToTargetTableCommand( Table $destination, ImportOptionsInterface $importOptions, string $stagingTableName, - string $timestampValue + string $timestampValue, ): string { if ($importOptions->useTimestamp()) { $insColumns = array_merge($source->getColumnsNames(), [Importer::TIMESTAMP_COLUMN_NAME]); @@ -199,12 +199,12 @@ public function getInsertFromStagingToTargetTableCommand( $columnsSetSql[] = sprintf( 'IFF("src".%s = \'\', NULL, %s)', QuoteHelper::quoteIdentifier($columnName), - QuoteHelper::quoteIdentifier($columnName) + QuoteHelper::quoteIdentifier($columnName), ); } else { $columnsSetSql[] = sprintf( 'COALESCE("src".%s, \'\')', - QuoteHelper::quoteIdentifier($columnName) + QuoteHelper::quoteIdentifier($columnName), ); } } @@ -219,21 +219,21 @@ public function getInsertFromStagingToTargetTableCommand( ColumnsHelper::getColumnsString($insColumns), implode(',', $columnsSetSql), QuoteHelper::quoteIdentifier($destination->getSchema()), - QuoteHelper::quoteIdentifier($stagingTableName) + QuoteHelper::quoteIdentifier($stagingTableName), ); } public function getRenameTableCommand( string $schema, string $sourceTableName, - string $targetTable + string $targetTable, ): string { return sprintf( 'ALTER TABLE %s.%s RENAME TO %s.%s', QuoteHelper::quoteIdentifier($schema), QuoteHelper::quoteIdentifier($sourceTableName), QuoteHelper::quoteIdentifier($schema), - QuoteHelper::quoteIdentifier($targetTable) + QuoteHelper::quoteIdentifier($targetTable), ); } @@ -242,18 +242,18 @@ public function getTableItemsCountCommand(string $schema, string $table): string return sprintf( 'SELECT COUNT(*) AS "count" FROM %s.%s', QuoteHelper::quoteIdentifier($schema), - QuoteHelper::quoteIdentifier($table) + QuoteHelper::quoteIdentifier($table), ); } public function getTruncateTableCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'TRUNCATE %s.%s', QuoteHelper::quoteIdentifier($schema), - QuoteHelper::quoteIdentifier($tableName) + QuoteHelper::quoteIdentifier($tableName), ); } @@ -266,7 +266,7 @@ public function getUpdateWithPkCommand( ImportOptionsInterface $importOptions, string $stagingTableName, array $primaryKeys, - string $timestamp + string $timestamp, ): string { $columnsSet = []; foreach ($source->getColumnsNames() as $columnName) { @@ -275,13 +275,13 @@ public function getUpdateWithPkCommand( '%s = IFF("src".%s = \'\', NULL, "src".%s)', QuoteHelper::quoteIdentifier($columnName), QuoteHelper::quoteIdentifier($columnName), - QuoteHelper::quoteIdentifier($columnName) + QuoteHelper::quoteIdentifier($columnName), ); } else { $columnsSet[] = sprintf( '%s = COALESCE("src".%s, \'\')', QuoteHelper::quoteIdentifier($columnName), - QuoteHelper::quoteIdentifier($columnName) + QuoteHelper::quoteIdentifier($columnName), ); } } @@ -290,7 +290,7 @@ public function getUpdateWithPkCommand( $columnsSet[] = sprintf( '%s = \'%s\'', QuoteHelper::quoteIdentifier(Importer::TIMESTAMP_COLUMN_NAME), - $timestamp + $timestamp, ); } @@ -300,10 +300,10 @@ static function ($columnName) { return sprintf( 'COALESCE(TO_VARCHAR("dest".%s), \'\') != COALESCE("src".%s, \'\')', QuoteHelper::quoteIdentifier($columnName), - QuoteHelper::quoteIdentifier($columnName) + QuoteHelper::quoteIdentifier($columnName), ); }, - $source->getColumnsNames() + $source->getColumnsNames(), ); return sprintf( @@ -313,7 +313,7 @@ static function ($columnName) { QuoteHelper::quoteIdentifier($destination->getSchema()), QuoteHelper::quoteIdentifier($stagingTableName), $this->getPrimayKeyWhereConditions($primaryKeys), - implode(' OR ', $columnsComparisionSql) + implode(' OR ', $columnsComparisionSql), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/FullImporter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/FullImporter.php index 12875659c..909eb6bbd 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/FullImporter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/FullImporter.php @@ -28,7 +28,7 @@ final class FullImporter implements ToFinalTableImporterInterface private SqlBuilder $sqlBuilder; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -38,7 +38,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof SnowflakeTableDefinition); assert($destinationTableDefinition instanceof SnowflakeTableDefinition); @@ -51,14 +51,14 @@ public function importToTable( $stagingTableDefinition, $destinationTableDefinition, $options, - $state + $state, ); } else { $this->doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - $state + $state, ); } } catch (Exception $e) { @@ -74,14 +74,14 @@ private function doFullLoadWithDedup( SnowflakeTableDefinition $stagingTableDefinition, SnowflakeTableDefinition $destinationTableDefinition, SnowflakeImportOptions $options, - ImportState $state + ImportState $state, ): void { $state->startTimer(self::TIMER_DEDUP); // 1. Create table for deduplication $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupTableDefinition( $stagingTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ); try { @@ -94,20 +94,20 @@ private function doFullLoadWithDedup( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); // 3 truncate destination table $this->connection->executeStatement( $this->sqlBuilder->getTruncateTable( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); // 4 move data with INSERT INTO @@ -116,8 +116,8 @@ private function doFullLoadWithDedup( $deduplicationTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_DEDUP); } finally { @@ -125,13 +125,13 @@ private function doFullLoadWithDedup( $this->connection->executeStatement( $this->sqlBuilder->getDropTableIfExistsCommand( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() - ) + $deduplicationTableDefinition->getTableName(), + ), ); } $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); } @@ -139,17 +139,17 @@ private function doLoadFullWithoutDedup( SnowflakeTableDefinition $stagingTableDefinition, SnowflakeTableDefinition $destinationTableDefinition, SnowflakeImportOptions $options, - ImportState $state + ImportState $state, ): void { $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); // truncate destination table $this->connection->executeStatement( $this->sqlBuilder->getTruncateTable( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); $state->startTimer(self::TIMER_COPY_TO_TARGET); @@ -159,13 +159,13 @@ private function doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_COPY_TO_TARGET); $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/IncrementalImporter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/IncrementalImporter.php index 2ec8c624a..a9c2f7b6e 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/IncrementalImporter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/IncrementalImporter.php @@ -31,7 +31,7 @@ final class IncrementalImporter implements ToFinalTableImporterInterface private SqlBuilder $sqlBuilder; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -41,7 +41,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof SnowflakeTableDefinition); assert($destinationTableDefinition instanceof SnowflakeTableDefinition); @@ -53,7 +53,7 @@ public function importToTable( $timestampValue = DateTimeHelper::getNowFormatted(); try { $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); /** @var SnowflakeTableDefinition $destinationTableDefinition */ @@ -63,7 +63,7 @@ public function importToTable( // 0. Create table for deduplication $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupTableDefinition( $stagingTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ); $tableToCopyFrom = $deduplicationTableDefinition; $qb = new SnowflakeTableQueryBuilder(); @@ -79,8 +79,8 @@ public function importToTable( $stagingTableDefinition, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_UPDATE_TARGET_TABLE); @@ -90,8 +90,8 @@ public function importToTable( $this->sqlBuilder->getDeleteOldItemsCommand( $stagingTableDefinition, $destinationTableDefinition, - $options - ) + $options, + ), ); $state->stopTimer(self::TIMER_DELETE_UPDATED_ROWS); @@ -101,14 +101,14 @@ public function importToTable( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); $this->connection->executeStatement( $this->sqlBuilder->getTruncateTable( $stagingTableDefinition->getSchemaName(), - $stagingTableDefinition->getTableName() - ) + $stagingTableDefinition->getTableName(), + ), ); $state->stopTimer(self::TIMER_DEDUP_STAGING); } @@ -120,13 +120,13 @@ public function importToTable( $tableToCopyFrom, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_INSERT_INTO_TARGET); $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); $state->setImportedColumns($stagingTableDefinition->getColumnsNames()); @@ -138,8 +138,8 @@ public function importToTable( $this->connection->executeStatement( $this->sqlBuilder->getDropTableIfExistsCommand( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() - ) + $deduplicationTableDefinition->getTableName(), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/SqlBuilder.php b/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/SqlBuilder.php index 74b05009b..94737b8aa 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/SqlBuilder.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToFinalTable/SqlBuilder.php @@ -39,7 +39,7 @@ public function getCommitTransaction(): string public function getDedupCommand( SnowflakeTableDefinition $stagingTableDefinition, SnowflakeTableDefinition $deduplicationTableDefinition, - array $primaryKeys + array $primaryKeys, ): string { if (empty($primaryKeys)) { return ''; @@ -47,13 +47,13 @@ public function getDedupCommand( $pkSql = $this->getColumnsString( $primaryKeys, - ',' + ',', ); $stage = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $depudeSql = sprintf( @@ -66,20 +66,20 @@ public function getDedupCommand( $this->getColumnsString($deduplicationTableDefinition->getColumnsNames(), ', '), $pkSql, $pkSql, - $stage + $stage, ); $deduplication = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($deduplicationTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()), ); return sprintf( 'INSERT INTO %s (%s) %s', $deduplication, $this->getColumnsString($deduplicationTableDefinition->getColumnsNames()), - $depudeSql + $depudeSql, ); } @@ -89,10 +89,10 @@ public function getDedupCommand( public function getColumnsString( array $columns, string $delimiter = ', ', - ?string $tableAlias = null + ?string $tableAlias = null, ): string { return implode($delimiter, array_map(static function ($columns) use ( - $tableAlias + $tableAlias, ) { $alias = $tableAlias === null ? '' : $tableAlias . '.'; return $alias . SnowflakeQuote::quoteSingleIdentifier($columns); @@ -102,18 +102,18 @@ public function getColumnsString( public function getDeleteOldItemsCommand( SnowflakeTableDefinition $stagingTableDefinition, SnowflakeTableDefinition $destinationTableDefinition, - SnowflakeImportOptions $importOptions + SnowflakeImportOptions $importOptions, ): string { $stagingTable = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $destinationTable = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); return sprintf( @@ -122,8 +122,8 @@ public function getDeleteOldItemsCommand( $destinationTable, $this->getPrimayKeyWhereConditions( $destinationTableDefinition->getPrimaryKeysNames(), - $importOptions - ) + $importOptions, + ), ); } @@ -132,7 +132,7 @@ public function getDeleteOldItemsCommand( */ private function getPrimayKeyWhereConditions( array $primaryKeys, - SnowflakeImportOptions $importOptions + SnowflakeImportOptions $importOptions, ): string { $pkWhereSql = array_map(function (string $col) use ($importOptions) { $str = '"dest".%s = COALESCE("src".%s, \'\')'; @@ -142,7 +142,7 @@ private function getPrimayKeyWhereConditions( return sprintf( $str, QuoteHelper::quoteIdentifier($col), - QuoteHelper::quoteIdentifier($col) + QuoteHelper::quoteIdentifier($col), ); }, $primaryKeys); @@ -152,12 +152,12 @@ private function getPrimayKeyWhereConditions( public function getDropTableIfExistsCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DROP TABLE IF EXISTS %s.%s', SnowflakeQuote::quoteSingleIdentifier($schema), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), ); } @@ -165,18 +165,18 @@ public function getInsertAllIntoTargetTableCommand( SnowflakeTableDefinition $sourceTableDefinition, SnowflakeTableDefinition $destinationTableDefinition, SnowflakeImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $columnMap = SourceDestinationColumnMap::createForTables( $sourceTableDefinition, $destinationTableDefinition, $importOptions->ignoreColumns(), - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); $destinationTable = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); $insColumns = $sourceTableDefinition->getColumnsNames(); @@ -186,7 +186,7 @@ public function getInsertAllIntoTargetTableCommand( if ($useTimestamp) { $insColumns = array_merge( $sourceTableDefinition->getColumnsNames(), - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); } @@ -207,7 +207,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(TO_VARIANT(%s) AS %s) AS %s', SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), $destinationColumn->getColumnDefinition()->getSQLDefinition(), - SnowflakeQuote::quoteSingleIdentifier($destinationColumn->getColumnName()) + SnowflakeQuote::quoteSingleIdentifier($destinationColumn->getColumnName()), ); continue; } @@ -215,7 +215,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(%s AS %s) AS %s', SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), $destinationColumn->getColumnDefinition()->getSQLDefinition(), - SnowflakeQuote::quoteSingleIdentifier($destinationColumn->getColumnName()) + SnowflakeQuote::quoteSingleIdentifier($destinationColumn->getColumnName()), ); continue; } @@ -231,7 +231,7 @@ public function getInsertAllIntoTargetTableCommand( $columnsSetSql[] = sprintf( 'IFF(%s = \'\', NULL, %s)', SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), - SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()) + SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), ); continue; } @@ -246,7 +246,7 @@ public function getInsertAllIntoTargetTableCommand( $columnsSetSql[] = sprintf( 'COALESCE(%s, \'\') AS %s', SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), - SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()) + SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), ); continue; } @@ -266,18 +266,18 @@ public function getInsertAllIntoTargetTableCommand( implode(',', $columnsSetSql), SnowflakeQuote::quoteSingleIdentifier($sourceTableDefinition->getSchemaName()), SnowflakeQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()), - SnowflakeQuote::quoteSingleIdentifier(self::SRC_ALIAS) + SnowflakeQuote::quoteSingleIdentifier(self::SRC_ALIAS), ); } public function getTruncateTable( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'TRUNCATE TABLE %s.%s', SnowflakeQuote::quoteSingleIdentifier($schema), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), ); } @@ -285,13 +285,13 @@ public function getUpdateWithPkCommand( SnowflakeTableDefinition $stagingTableDefinition, SnowflakeTableDefinition $destinationDefinition, SnowflakeImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $columnMap = SourceDestinationColumnMap::createForTables( $stagingTableDefinition, $destinationDefinition, $importOptions->ignoreColumns(), - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); $columnsSet = []; @@ -333,13 +333,13 @@ public function getUpdateWithPkCommand( '%s = IFF("src".%s = \'\', NULL, "src".%s)', SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), - SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()) + SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), ); } else { $columnsSet[] = sprintf( '%s = COALESCE("src".%s, \'\')', SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), - SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()) + SnowflakeQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), ); } } @@ -348,7 +348,7 @@ public function getUpdateWithPkCommand( $columnsSet[] = sprintf( '%s = \'%s\'', SnowflakeQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), - $timestamp + $timestamp, ); } @@ -360,17 +360,17 @@ static function ($columnName) { return sprintf( 'COALESCE(TO_VARCHAR("dest".%s), \'\') != COALESCE("src".%s, \'\')', SnowflakeQuote::quoteSingleIdentifier($columnName), - SnowflakeQuote::quoteSingleIdentifier($columnName) + SnowflakeQuote::quoteSingleIdentifier($columnName), ); }, - $stagingTableDefinition->getColumnsNames() + $stagingTableDefinition->getColumnsNames(), ); } $dest = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($destinationDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($destinationDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($destinationDefinition->getTableName()), ); if (empty($columnsComparisonSql)) { @@ -391,7 +391,7 @@ static function ($columnName) { QuoteHelper::quoteIdentifier($stagingTableDefinition->getSchemaName()), QuoteHelper::quoteIdentifier($stagingTableDefinition->getTableName()), $this->getPrimayKeyWhereConditions($destinationDefinition->getPrimaryKeysNames(), $importOptions), - implode(' OR ', $columnsComparisonSql) + implode(' OR ', $columnsComparisonSql), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromABSCopyIntoAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromABSCopyIntoAdapter.php index c2945d25d..39ebd4cfd 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromABSCopyIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromABSCopyIntoAdapter.php @@ -39,7 +39,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { try { $files = $source->getManifestEntries(); @@ -48,10 +48,10 @@ public function runCopyCommand( $source, $destination, $importOptions, - $files + $files, ); $this->connection->executeStatement( - $cmd + $cmd, ); } } catch (Throwable $e) { @@ -61,7 +61,7 @@ public function runCopyCommand( $ref = new SnowflakeTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -74,18 +74,18 @@ private function getCopyCommand( Storage\ABS\SourceFile $source, SnowflakeTableDefinition $destination, SnowflakeImportOptions $importOptions, - array $files + array $files, ): string { $quotedFiles = array_map( static function ($entry) use ($source) { return QuoteHelper::quote( strtr( $entry, - [$source->getContainerUrl(BaseFile::PROTOCOL_AZURE) => ''] - ) + [$source->getContainerUrl(BaseFile::PROTOCOL_AZURE) => ''], + ), ); }, - $files + $files, ); return sprintf( @@ -102,10 +102,10 @@ static function ($entry) use ($source) { ' ', CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( $importOptions, - $source->getCsvOptions() - ) + $source->getCsvOptions(), + ), ), - implode(', ', $quotedFiles) + implode(', ', $quotedFiles), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapter.php index cbab84c54..628008056 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapter.php @@ -36,7 +36,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { try { $files = $source->getManifestEntries(); @@ -45,10 +45,10 @@ public function runCopyCommand( $source, $destination, $importOptions, - $files + $files, ); $this->connection->executeStatement( - $cmd + $cmd, ); } } catch (Throwable $e) { @@ -58,7 +58,7 @@ public function runCopyCommand( $ref = new SnowflakeTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -71,7 +71,7 @@ private function getCopyCommand( Storage\GCS\SourceFile $source, SnowflakeTableDefinition $destination, SnowflakeImportOptions $importOptions, - array $files + array $files, ): string { $gcsPrefix = $source->getGcsPrefix(); $csvOptions = $source->getCsvOptions(); @@ -102,9 +102,9 @@ private function getCopyCommand( function ($file) use ($gcsPrefix) { return SnowflakeQuote::quote(str_replace($gcsPrefix . '/', '', $file)); }, - $files - ) - ) + $files, + ), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromS3CopyIntoAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromS3CopyIntoAdapter.php index 2418e03d5..380aa4d89 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromS3CopyIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromS3CopyIntoAdapter.php @@ -36,7 +36,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { try { $files = $source->getManifestEntries(); @@ -46,8 +46,8 @@ public function runCopyCommand( $source, $destination, $importOptions, - $files - ) + $files, + ), ); } } catch (Throwable $e) { @@ -57,7 +57,7 @@ public function runCopyCommand( $ref = new SnowflakeTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -70,7 +70,7 @@ private function getCopyCommand( Storage\S3\SourceFile $source, SnowflakeTableDefinition $destination, SnowflakeImportOptions $importOptions, - array $files + array $files, ): string { $s3Prefix = $source->getS3Prefix(); $csvOptions = $source->getCsvOptions(); @@ -104,9 +104,9 @@ private function getCopyCommand( function ($file) use ($s3Prefix) { return SnowflakeQuote::quote(str_replace($s3Prefix . '/', '', $file)); }, - $files - ) - ) + $files, + ), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromTableInsertIntoAdapter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromTableInsertIntoAdapter.php index 3f4dd1ec0..b0066d790 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromTableInsertIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/FromTableInsertIntoAdapter.php @@ -36,7 +36,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SelectSource || $source instanceof Table); assert($destination instanceof SnowflakeTableDefinition); @@ -51,7 +51,7 @@ public function runCopyCommand( SnowflakeQuote::quoteSingleIdentifier($destination->getSchemaName()), SnowflakeQuote::quoteSingleIdentifier($destination->getTableName()), implode(', ', $quotedColumns), - $source->getFromStatement() + $source->getFromStatement(), ); if ($source instanceof Table && $importOptions->isRequireSameTables()) { @@ -59,7 +59,7 @@ public function runCopyCommand( (new SnowflakeTableReflection( $this->connection, $source->getSchema(), - $source->getTableName() + $source->getTableName(), ))->getColumnsDefinitions(), $destination->getColumnsDefinitions(), $importOptions->ignoreColumns(), @@ -90,7 +90,7 @@ public function runCopyCommand( Snowflake::TYPE_NUMBER, Snowflake::TYPE_DECIMAL, Snowflake::TYPE_NUMERIC, - ] + ], ); } @@ -103,7 +103,7 @@ public function runCopyCommand( $ref = new SnowflakeTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/StageTableDefinitionFactory.php b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/StageTableDefinitionFactory.php index a69ab00e2..1ea94e73e 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/StageTableDefinitionFactory.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/StageTableDefinitionFactory.php @@ -19,7 +19,7 @@ final class StageTableDefinitionFactory */ public static function createStagingTableDefinition( TableDefinitionInterface $destination, - array $sourceColumnsNames + array $sourceColumnsNames, ): SnowflakeTableDefinition { /** @var SnowflakeTableDefinition $destination */ $newDefinitions = []; @@ -39,8 +39,8 @@ public static function createStagingTableDefinition( 'length' => $definition->getColumnDefinition()->getLength(), 'nullable' => true, // set all columns to be nullable 'default' => $definition->getColumnDefinition()->getDefault(), - ] - ) + ], + ), ); continue 2; } @@ -54,7 +54,7 @@ public static function createStagingTableDefinition( BackendHelper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - $destination->getPrimaryKeysNames() + $destination->getPrimaryKeysNames(), ); } @@ -63,7 +63,7 @@ public static function createStagingTableDefinition( */ public static function createVarcharStagingTableDefinition( string $schemaName, - array $sourceColumnsNames + array $sourceColumnsNames, ): SnowflakeTableDefinition { $newDefinitions = []; // create staging table for source columns in order @@ -76,7 +76,7 @@ public static function createVarcharStagingTableDefinition( BackendHelper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - [] + [], ); } @@ -89,8 +89,8 @@ private static function createNvarcharColumn(string $columnName): SnowflakeColum [ 'length' => (string) Snowflake::MAX_VARCHAR_LENGTH, 'nullable' => true, // set all columns to be nullable - ] - ) + ], + ), ); } @@ -99,14 +99,14 @@ private static function createNvarcharColumn(string $columnName): SnowflakeColum */ public static function createDedupTableDefinition( SnowflakeTableDefinition $destination, - array $pkNames + array $pkNames, ): SnowflakeTableDefinition { return new SnowflakeTableDefinition( $destination->getSchemaName(), BackendHelper::generateTempDedupTableName(), true, $destination->getColumnsDefinitions(), - $pkNames + $pkNames, ); } } diff --git a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/ToStageImporter.php b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/ToStageImporter.php index 254802d78..4c96f3ca9 100644 --- a/packages/php-db-import-export/src/Backend/Snowflake/ToStage/ToStageImporter.php +++ b/packages/php-db-import-export/src/Backend/Snowflake/ToStage/ToStageImporter.php @@ -27,7 +27,7 @@ final class ToStageImporter implements ToStageImporterInterface public function __construct( Connection $connection, - ?CopyAdapterInterface $adapter = null + ?CopyAdapterInterface $adapter = null, ) { $this->connection = $connection; $this->adapter = $adapter; @@ -36,7 +36,7 @@ public function __construct( public function importToStagingTable( Storage\SourceInterface $source, TableDefinitionInterface $destinationDefinition, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): ImportState { assert($options instanceof SnowflakeImportOptions); assert($destinationDefinition instanceof SnowflakeTableDefinition); @@ -51,8 +51,8 @@ public function importToStagingTable( $adapter->runCopyCommand( $source, $destinationDefinition, - $options - ) + $options, + ), ); } catch (Exception $e) { throw $e; @@ -85,8 +85,8 @@ private function getAdapter(Storage\SourceInterface $source): CopyAdapterInterfa throw new LogicException( sprintf( 'No suitable adapter found for source: "%s".', - get_class($source) - ) + get_class($source), + ), ); } return $adapter; diff --git a/packages/php-db-import-export/src/Backend/SourceDestinationColumnMap.php b/packages/php-db-import-export/src/Backend/SourceDestinationColumnMap.php index 4f52fd6b3..6c9328907 100644 --- a/packages/php-db-import-export/src/Backend/SourceDestinationColumnMap.php +++ b/packages/php-db-import-export/src/Backend/SourceDestinationColumnMap.php @@ -62,7 +62,7 @@ public static function createForTables( $source->getColumnsDefinitions(), $destination->getColumnsDefinitions(), $ignoreColumns, - $mode + $mode, ); } diff --git a/packages/php-db-import-export/src/Backend/Synapse/DestinationTableOptions.php b/packages/php-db-import-export/src/Backend/Synapse/DestinationTableOptions.php index d45220d07..aaca5aee2 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/DestinationTableOptions.php +++ b/packages/php-db-import-export/src/Backend/Synapse/DestinationTableOptions.php @@ -24,7 +24,7 @@ final class DestinationTableOptions public function __construct( array $columnNamesInOrder, array $primaryKeys, - TableDistribution $distribution + TableDistribution $distribution, ) { $this->columnNamesInOrder = $columnNamesInOrder; $this->primaryKeys = $primaryKeys; diff --git a/packages/php-db-import-export/src/Backend/Synapse/Exception/Assert.php b/packages/php-db-import-export/src/Backend/Synapse/Exception/Assert.php index 206ac4d1c..ee8ab497a 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/Exception/Assert.php +++ b/packages/php-db-import-export/src/Backend/Synapse/Exception/Assert.php @@ -25,12 +25,12 @@ final class Assert extends BaseAssert { public static function assertColumns( SourceInterface $source, - DestinationTableOptions $destinationTableOptions + DestinationTableOptions $destinationTableOptions, ): void { if (count($source->getColumnsNames()) === 0) { throw new Exception( 'No columns found in CSV file.', - Exception::NO_COLUMNS + Exception::NO_COLUMNS, ); } @@ -38,7 +38,7 @@ public static function assertColumns( if (!empty($moreColumns)) { throw new Exception( 'Columns doest not match. Non existing columns: ' . implode(', ', $moreColumns), - Exception::COLUMNS_COUNT_NOT_MATCH + Exception::COLUMNS_COUNT_NOT_MATCH, ); } } @@ -49,7 +49,7 @@ public static function assertIsSynapseTableDestination(DestinationInterface $des throw new InternalException(sprintf( 'Only "%s" is supported as destination "%s" provided.', Table::class, - get_class($destination) + get_class($destination), )); } } @@ -60,7 +60,7 @@ public static function assertSynapseImportOptions(ImportOptionsInterface $option throw new InternalException(sprintf( 'Synapse importer expect $options to be instance of "%s", "%s" given.', SynapseImportOptions::class, - get_class($options) + get_class($options), )); } } @@ -71,7 +71,7 @@ public static function assertValidSource(SourceInterface $source): void && $source->getCsvOptions()->getEnclosure() === '' ) { throw new InternalException( - 'CSV property FIELDQUOTE|ECLOSURE must be set when using Synapse analytics.' + 'CSV property FIELDQUOTE|ECLOSURE must be set when using Synapse analytics.', ); } } @@ -81,7 +81,7 @@ public static function assertValidSource(SourceInterface $source): void */ public static function assertValidHashDistribution( string $tableDistributionName, - array $hashDistributionColumnsNames + array $hashDistributionColumnsNames, ): void { if ($tableDistributionName === TableDistribution::TABLE_DISTRIBUTION_HASH && count($hashDistributionColumnsNames) !== 1 @@ -99,7 +99,7 @@ public static function assertTableDistribution(string $tableDistributionName): v ], true)) { throw new LogicException(sprintf( 'Unknown table distribution "%s" specified.', - $tableDistributionName + $tableDistributionName, )); } } @@ -109,14 +109,14 @@ public static function assertStagingTable(string $tableName): void if ($tableName[0] !== '#') { throw new Exception(sprintf( 'Staging table must start with "#" table name "%s" supplied.', - $tableName + $tableName, )); } } public static function assertSameColumns( ColumnCollection $source, - ColumnCollection $destination + ColumnCollection $destination, ): void { $it0 = $source->getIterator(); $it1 = $destination->getIterator(); diff --git a/packages/php-db-import-export/src/Backend/Synapse/Exporter.php b/packages/php-db-import-export/src/Backend/Synapse/Exporter.php index abe1e65e1..149b78b71 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/Exporter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/Exporter.php @@ -24,7 +24,7 @@ class Exporter implements ExporterInterface private Connection $connection; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; } @@ -44,7 +44,7 @@ public function setAdapters(array $adapters): void public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array { $adapter = $this->getAdapter($source, $destination); return $adapter->runCopyCommand($source, $destination, $options); @@ -52,7 +52,7 @@ public function exportTable( private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): SynapseExportAdapterInterface { $adapterForUse = null; foreach ($this->adapters as $adapter) { @@ -61,8 +61,8 @@ private function getAdapter( throw new Exception( sprintf( 'Each Synapse export adapter must implement "%s".', - SynapseExportAdapterInterface::class - ) + SynapseExportAdapterInterface::class, + ), ); } if ($adapter::isSupported($source, $destination)) { @@ -72,8 +72,8 @@ private function getAdapter( 'More than one suitable adapter found for Synapse exporter with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->connection); @@ -84,8 +84,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Synapse exporter with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Synapse/PolyBaseCommandBuilder.php b/packages/php-db-import-export/src/Backend/Synapse/PolyBaseCommandBuilder.php index 95f5904bc..35bcd0982 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/PolyBaseCommandBuilder.php +++ b/packages/php-db-import-export/src/Backend/Synapse/PolyBaseCommandBuilder.php @@ -18,7 +18,7 @@ class PolyBaseCommandBuilder public function getCredentialsQuery( string $credentialsId, string $exportCredentialsType, - ?string $blobMasterKey = null + ?string $blobMasterKey = null, ): string { $credentialsId = SynapseQuote::quoteSingleIdentifier($credentialsId); @@ -43,7 +43,7 @@ public function getCredentialsQuery( default: throw new InvalidArgumentException(sprintf( 'Unknown Synapse export credentials type "%s".', - $exportCredentialsType + $exportCredentialsType, )); } } @@ -51,7 +51,7 @@ public function getCredentialsQuery( public function getDataSourceQuery( string $dataSourceId, string $containerUrl, - string $credentialsId + string $credentialsId, ): string { $dataSourceId = SynapseQuote::quoteSingleIdentifier($dataSourceId); $containerUrl = SynapseQuote::quote($containerUrl); @@ -93,7 +93,7 @@ public function getPolyBaseCleanUpQueries( string $fileFormatId, string $dataSourceId, string $credentialsId, - ?string $tableId + ?string $tableId, ): Generator { if ($tableId !== null) { $tableId = SynapseQuote::quoteSingleIdentifier($tableId); @@ -112,7 +112,7 @@ public function getExternalTableQuery( string $tableId, string $exportPath, string $dataSourceId, - string $fileFormatId + string $fileFormatId, ): string { $tableId = SynapseQuote::quoteSingleIdentifier($tableId); $dataSourceId = SynapseQuote::quoteSingleIdentifier($dataSourceId); diff --git a/packages/php-db-import-export/src/Backend/Synapse/SynapseException.php b/packages/php-db-import-export/src/Backend/Synapse/SynapseException.php index 851cabc13..9fe61024e 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/SynapseException.php +++ b/packages/php-db-import-export/src/Backend/Synapse/SynapseException.php @@ -20,47 +20,47 @@ final class SynapseException extends ImportExportException public static function createColumnsCountMismatch( ColumnCollection $source, - ColumnCollection $destination + ColumnCollection $destination, ): Throwable { $columnsSource = array_map( static fn(ColumnInterface $col) => $col->getColumnName(), - iterator_to_array($source->getIterator()) + iterator_to_array($source->getIterator()), ); $columnsDestination = array_map( static fn(ColumnInterface $col) => $col->getColumnName(), - iterator_to_array($destination->getIterator()) + iterator_to_array($destination->getIterator()), ); return new self( sprintf( 'Tables don\'t have same number of columns. Source columns: "%s", Destination columns: "%s"', implode(',', $columnsSource), - implode(',', $columnsDestination) + implode(',', $columnsDestination), ), - self::CODE_TABLE_COLUMNS_MISMATCH + self::CODE_TABLE_COLUMNS_MISMATCH, ); } public static function createColumnsNamesMismatch( ColumnInterface $sourceDef, - ColumnInterface $destDef + ColumnInterface $destDef, ): Throwable { return new self(sprintf( 'Source destination columns name mismatch. "%s"->"%s"', $sourceDef->getColumnName(), - $destDef->getColumnName() + $destDef->getColumnName(), ), self::CODE_TABLE_COLUMNS_MISMATCH); } public static function createColumnsMismatch( ColumnInterface $sourceDef, - ColumnInterface $destDef + ColumnInterface $destDef, ): Throwable { return new self(sprintf( 'Source destination columns mismatch. "%s %s"->"%s %s"', $sourceDef->getColumnName(), $sourceDef->getColumnDefinition()->getSQLDefinition(), $destDef->getColumnName(), - $destDef->getColumnDefinition()->getSQLDefinition() + $destDef->getColumnDefinition()->getSQLDefinition(), ), self::CODE_TABLE_COLUMNS_MISMATCH); } @@ -76,7 +76,7 @@ public static function covertException(DBALException $e): Throwable $message = (string) strstr($e->getMessage(), self::BULK_LOAD_EXCEPTION_BEGINNING); return new self( $message, - Exception::UNKNOWN_ERROR + Exception::UNKNOWN_ERROR, ); } @@ -85,7 +85,7 @@ public static function covertException(DBALException $e): Throwable $message = (string) strstr($e->getMessage(), self::DATA_TYPE_CONVERSION_EXCEPTION_BEGINNING); return new self( $message, - Exception::UNKNOWN_ERROR + Exception::UNKNOWN_ERROR, ); } diff --git a/packages/php-db-import-export/src/Backend/Synapse/SynapseExportOptions.php b/packages/php-db-import-export/src/Backend/Synapse/SynapseExportOptions.php index e31d3cb25..7fd6647a9 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/SynapseExportOptions.php +++ b/packages/php-db-import-export/src/Backend/Synapse/SynapseExportOptions.php @@ -16,7 +16,7 @@ class SynapseExportOptions extends ExportOptions public function __construct( bool $isCompressed = false, string $exportCredentialsType = self::CREDENTIALS_MASTER_KEY, - bool $generateManifest = self::MANIFEST_SKIP + bool $generateManifest = self::MANIFEST_SKIP, ) { parent::__construct($isCompressed, $generateManifest); $this->exportCredentialsType = $exportCredentialsType; diff --git a/packages/php-db-import-export/src/Backend/Synapse/SynapseImportOptions.php b/packages/php-db-import-export/src/Backend/Synapse/SynapseImportOptions.php index 07d79f667..51f781bdb 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/SynapseImportOptions.php +++ b/packages/php-db-import-export/src/Backend/Synapse/SynapseImportOptions.php @@ -46,14 +46,14 @@ public function __construct( string $importCredentialsType = self::CREDENTIALS_SAS, string $castValueTypes = self::TABLE_TYPES_PRESERVE, bool $requireSameTables = self::SAME_TABLES_NOT_REQUIRED, - string $tableToTableAdapter = self::TABLE_TO_TABLE_ADAPTER_INSERT_INTO + string $tableToTableAdapter = self::TABLE_TO_TABLE_ADAPTER_INSERT_INTO, ) { parent::__construct( $convertEmptyValuesToNull, $isIncremental, $useTimestamp, $numberOfIgnoredLines, - $requireSameTables === self::SAME_TABLES_REQUIRED ? self::USING_TYPES_USER : self::USING_TYPES_STRING + $requireSameTables === self::SAME_TABLES_REQUIRED ? self::USING_TYPES_USER : self::USING_TYPES_STRING, ); $this->importCredentialsType = $importCredentialsType; $this->castValueTypes = $castValueTypes; diff --git a/packages/php-db-import-export/src/Backend/Synapse/TableDistribution.php b/packages/php-db-import-export/src/Backend/Synapse/TableDistribution.php index a3d1b8ba1..906b302d2 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/TableDistribution.php +++ b/packages/php-db-import-export/src/Backend/Synapse/TableDistribution.php @@ -26,7 +26,7 @@ final class TableDistribution */ public function __construct( string $distributionName = self::TABLE_DISTRIBUTION_ROUND_ROBIN, - array $distributionColumnsNames = [] + array $distributionColumnsNames = [], ) { Assert::assertTableDistribution($distributionName); Assert::assertValidHashDistribution($distributionName, $distributionColumnsNames); diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/FullImporter.php b/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/FullImporter.php index b4e5e2ba0..7e54770e9 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/FullImporter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/FullImporter.php @@ -29,7 +29,7 @@ final class FullImporter implements ToFinalTableImporterInterface private SqlBuilder $sqlBuilder; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -39,7 +39,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof SynapseTableDefinition); assert($destinationTableDefinition instanceof SynapseTableDefinition); @@ -54,7 +54,7 @@ public function importToTable( $destinationTableDefinition, $options, $state, - $random + $random, ); } else { $this->doLoadFullWithoutDedup( @@ -62,7 +62,7 @@ public function importToTable( $destinationTableDefinition, $options, $state, - $random + $random, ); } } finally { @@ -70,15 +70,15 @@ public function importToTable( $this->connection->executeStatement( $this->sqlBuilder->getDropTableIfExistsCommand( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() . $random . self::OPTIMIZED_LOAD_TMP_TABLE_SUFFIX - ) + $destinationTableDefinition->getTableName() . $random . self::OPTIMIZED_LOAD_TMP_TABLE_SUFFIX, + ), ); // drop optimized load rename table if exists $this->connection->executeStatement( $this->sqlBuilder->getDropTableIfExistsCommand( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() . $random . self::OPTIMIZED_LOAD_RENAME_TABLE_SUFFIX - ) + $destinationTableDefinition->getTableName() . $random . self::OPTIMIZED_LOAD_RENAME_TABLE_SUFFIX, + ), ); } @@ -92,7 +92,7 @@ private function doFullLoadWithDedup( SynapseTableDefinition $destinationTableDefinition, SynapseImportOptions $options, ImportState $state, - string $random + string $random, ): void { $tmpDestination = new SynapseTableDefinition( $destinationTableDefinition->getSchemaName(), @@ -101,7 +101,7 @@ private function doFullLoadWithDedup( $destinationTableDefinition->getColumnsDefinitions(), $destinationTableDefinition->getPrimaryKeysNames(), $destinationTableDefinition->getTableDistribution(), - $destinationTableDefinition->getTableIndex() + $destinationTableDefinition->getTableIndex(), ); $state->startTimer(self::TIMER_DEDUP_CTAS); @@ -110,8 +110,8 @@ private function doFullLoadWithDedup( $stagingTableDefinition, $tmpDestination, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_DEDUP_CTAS); @@ -123,28 +123,28 @@ private function doFullLoadWithDedup( $this->sqlBuilder->getRenameTableCommand( $destinationTableDefinition->getSchemaName(), $destinationTableDefinition->getTableName(), - $tmpDestinationToRemove - ) + $tmpDestinationToRemove, + ), ); $this->connection->executeStatement( $this->sqlBuilder->getRenameTableCommand( $tmpDestination->getSchemaName(), $tmpDestination->getTableName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); } catch (Throwable $e) { if (!$this->isTableInSchema( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() + $destinationTableDefinition->getTableName(), )) { // in case of error ensure original table is renamed back $this->connection->executeStatement( $this->sqlBuilder->getRenameTableCommand( $destinationTableDefinition->getSchemaName(), $tmpDestinationToRemove, - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); } throw $e; @@ -153,8 +153,8 @@ private function doFullLoadWithDedup( $this->connection->executeStatement( $this->sqlBuilder->getDropCommand( $destinationTableDefinition->getSchemaName(), - $tmpDestinationToRemove - ) + $tmpDestinationToRemove, + ), ); } @@ -163,7 +163,7 @@ private function doLoadFullWithoutDedup( SynapseTableDefinition $destinationTableDefinition, SynapseImportOptions $options, ImportState $state, - string $random + string $random, ): void { $tmpDestination = new SynapseTableDefinition( $destinationTableDefinition->getSchemaName(), @@ -172,7 +172,7 @@ private function doLoadFullWithoutDedup( $destinationTableDefinition->getColumnsDefinitions(), $destinationTableDefinition->getPrimaryKeysNames(), $destinationTableDefinition->getTableDistribution(), - $destinationTableDefinition->getTableIndex() + $destinationTableDefinition->getTableIndex(), ); $state->startTimer(self::TIMER_COPY_TO_TARGET); @@ -181,8 +181,8 @@ private function doLoadFullWithoutDedup( $stagingTableDefinition, $tmpDestination, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_COPY_TO_TARGET); @@ -194,28 +194,28 @@ private function doLoadFullWithoutDedup( $this->sqlBuilder->getRenameTableCommand( $destinationTableDefinition->getSchemaName(), $destinationTableDefinition->getTableName(), - $tmpDestinationToRemove - ) + $tmpDestinationToRemove, + ), ); $this->connection->executeStatement( $this->sqlBuilder->getRenameTableCommand( $tmpDestination->getSchemaName(), $tmpDestination->getTableName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); } catch (Throwable $e) { if (!$this->isTableInSchema( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() + $destinationTableDefinition->getTableName(), )) { // in case of error ensure original table is renamed back $this->connection->executeStatement( $this->sqlBuilder->getRenameTableCommand( $destinationTableDefinition->getSchemaName(), $tmpDestinationToRemove, - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); } throw $e; @@ -224,8 +224,8 @@ private function doLoadFullWithoutDedup( $this->connection->executeStatement( $this->sqlBuilder->getDropCommand( $destinationTableDefinition->getSchemaName(), - $tmpDestinationToRemove - ) + $tmpDestinationToRemove, + ), ); } @@ -234,7 +234,7 @@ private function isTableInSchema(string $schemaName, string $tableName): bool return in_array( $tableName, (new SynapseSchemaReflection($this->connection, $schemaName))->getTablesNames(), - true + true, ); } } diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/IncrementalImporter.php b/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/IncrementalImporter.php index bfe74c6ab..331e8a42c 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/IncrementalImporter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/IncrementalImporter.php @@ -30,7 +30,7 @@ final class IncrementalImporter implements ToFinalTableImporterInterface private SqlBuilder $sqlBuilder; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -40,7 +40,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof SynapseTableDefinition); assert($destinationTableDefinition instanceof SynapseTableDefinition); @@ -55,7 +55,7 @@ public function importToTable( $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupStagingTableDefinition( $stagingTableDefinition, $stagingTableDefinition->getColumnsNames(), - $destinationTableDefinition->getTableIndex() + $destinationTableDefinition->getTableIndex(), ); $tableToCopyFrom = $deduplicationTableDefinition; $qb = new SynapseTableQueryBuilder(); @@ -65,14 +65,14 @@ public function importToTable( $state->stopTimer(self::TIMER_DEDUP_TABLE_CREATE); $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); $sql = $this->sqlBuilder->getUpdateWithPkCommand( $stagingTableDefinition, $destinationTableDefinition, $options, - $timestampValue + $timestampValue, ); if ($sql !== '') { @@ -85,8 +85,8 @@ public function importToTable( $this->connection->executeStatement( $this->sqlBuilder->getDeleteOldItemsCommand( $stagingTableDefinition, - $destinationTableDefinition - ) + $destinationTableDefinition, + ), ); $state->stopTimer(self::TIMER_DELETE_UPDATED_ROWS); @@ -96,14 +96,14 @@ public function importToTable( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); $state->stopTimer(self::TIMER_DEDUP_STAGING); } else { $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); } @@ -113,13 +113,13 @@ public function importToTable( $tableToCopyFrom, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_INSERT_INTO_TARGET); $this->connection->executeStatement( - $this->sqlBuilder->getCommitTransaction() + $this->sqlBuilder->getCommitTransaction(), ); $state->setImportedColumns($stagingTableDefinition->getColumnsNames()); diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/SqlBuilder.php b/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/SqlBuilder.php index ccf63d7f3..b34f08add 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/SqlBuilder.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToFinalTable/SqlBuilder.php @@ -33,7 +33,7 @@ public function getCommitTransaction(): string public function getDedupCommand( SynapseTableDefinition $stagingTableDefinition, SynapseTableDefinition $deduplicationTableDefinition, - array $primaryKeys + array $primaryKeys, ): string { if (empty($primaryKeys)) { return ''; @@ -41,13 +41,13 @@ public function getDedupCommand( $pkSql = $this->getColumnsString( $primaryKeys, - ',' + ',', ); $stage = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $depudeSql = sprintf( @@ -60,20 +60,20 @@ public function getDedupCommand( $this->getColumnsString($deduplicationTableDefinition->getColumnsNames(), ', '), $pkSql, $pkSql, - $stage + $stage, ); $deduplication = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($deduplicationTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()), ); return sprintf( 'INSERT INTO %s (%s) %s', $deduplication, $this->getColumnsString($deduplicationTableDefinition->getColumnsNames()), - $depudeSql + $depudeSql, ); } @@ -81,7 +81,7 @@ public function getCtasDedupCommand( SynapseTableDefinition $stagingTableDefinition, SynapseTableDefinition $destinationTableDefinition, SynapseImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { if (empty($destinationTableDefinition->getPrimaryKeysNames())) { return ''; @@ -91,14 +91,14 @@ public function getCtasDedupCommand( $pkSql = $this->getColumnsString( $destinationTableDefinition->getPrimaryKeysNames(), - ',' + ',', ); $columnsInOrder = $destinationTableDefinition->getColumnsNames(); $timestampColIndex = array_search( ToStageImporterInterface::TIMESTAMP_COLUMN_NAME, $columnsInOrder, - true + true, ); if ($timestampColIndex !== false) { // remove timestamp column if exists in ordered columns @@ -107,7 +107,7 @@ public function getCtasDedupCommand( $timestampNotInColumns = !StringCaseSensitivity::isInArrayCaseInsensitive( ToStageImporterInterface::TIMESTAMP_COLUMN_NAME, - $stagingTableDefinition->getColumnsNames() + $stagingTableDefinition->getColumnsNames(), ); $useTimestamp = $timestampNotInColumns && $importOptions->useTimestamp(); @@ -119,7 +119,7 @@ public function getCtasDedupCommand( $columnsSetSql = $this->getCTASColumnsSetSql( $stagingTableDefinition, $destinationTableDefinition, - $importOptions + $importOptions, ); if ($useTimestamp) { @@ -127,7 +127,7 @@ public function getCtasDedupCommand( 'CAST(%s as %s) AS %s', SynapseQuote::quote($timestamp), Synapse::TYPE_DATETIME2, - SynapseQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME) + SynapseQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), ); } @@ -142,7 +142,7 @@ public function getCtasDedupCommand( $pkSql, $pkSql, SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); return sprintf( @@ -151,7 +151,7 @@ public function getCtasDedupCommand( SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), $distributionSql, $indexSql, - $depudeSql + $depudeSql, ); } @@ -161,10 +161,10 @@ public function getCtasDedupCommand( public function getColumnsString( array $columns, string $delimiter = ', ', - ?string $tableAlias = null + ?string $tableAlias = null, ): string { return implode($delimiter, array_map(function ($columns) use ( - $tableAlias + $tableAlias, ) { $alias = $tableAlias === null ? '' : $tableAlias . '.'; return $alias . SynapseQuote::quoteSingleIdentifier($columns); @@ -173,18 +173,18 @@ public function getColumnsString( public function getDeleteOldItemsCommand( SynapseTableDefinition $stagingTableDefinition, - SynapseTableDefinition $destinationTableDefinition + SynapseTableDefinition $destinationTableDefinition, ): string { $stagingTable = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $destinationTable = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); return sprintf( @@ -194,8 +194,8 @@ public function getDeleteOldItemsCommand( $this->getPrimaryKeyWhereConditions( $destinationTableDefinition->getPrimaryKeysNames(), $stagingTable, - $destinationTable - ) + $destinationTable, + ), ); } @@ -205,7 +205,7 @@ public function getDeleteOldItemsCommand( private function getPrimaryKeyWhereConditions( array $primaryKeys, string $sourceTable, - string $destinationTable + string $destinationTable, ): string { $pkWhereSql = array_map(function (string $col) use ($sourceTable, $destinationTable) { return sprintf( @@ -213,7 +213,7 @@ private function getPrimaryKeyWhereConditions( $destinationTable, SynapseQuote::quoteSingleIdentifier($col), $sourceTable, - SynapseQuote::quoteSingleIdentifier($col) + SynapseQuote::quoteSingleIdentifier($col), ); }, $primaryKeys); @@ -222,28 +222,28 @@ private function getPrimaryKeyWhereConditions( public function getDropCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DROP TABLE %s.%s', SynapseQuote::quoteSingleIdentifier($schema), - SynapseQuote::quoteSingleIdentifier($tableName) + SynapseQuote::quoteSingleIdentifier($tableName), ); } public function getDropTableIfExistsCommand( string $schema, - string $tableName + string $tableName, ): string { $table = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($schema), - SynapseQuote::quoteSingleIdentifier($tableName) + SynapseQuote::quoteSingleIdentifier($tableName), ); return sprintf( 'IF OBJECT_ID (N\'%s\', N\'U\') IS NOT NULL DROP TABLE %s', $table, - $table + $table, ); } @@ -251,25 +251,25 @@ public function getInsertAllIntoTargetTableCommand( SynapseTableDefinition $sourceTableDefinition, SynapseTableDefinition $destinationTableDefinition, SynapseImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $destinationTable = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); $insColumns = $sourceTableDefinition->getColumnsNames(); $includesTimestamp = StringCaseSensitivity::isInArrayCaseInsensitive( ToStageImporterInterface::TIMESTAMP_COLUMN_NAME, - $insColumns + $insColumns, ); $useTimestamp = !$includesTimestamp && $importOptions->useTimestamp(); if ($useTimestamp) { $insColumns = array_merge( $sourceTableDefinition->getColumnsNames(), - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); } @@ -279,14 +279,14 @@ public function getInsertAllIntoTargetTableCommand( foreach ($sourceTableDefinition->getColumnsDefinitions() as $columnDefinition) { $convertEmptyToNull = StringCaseSensitivity::isInArrayCaseInsensitive( $columnDefinition->getColumnName(), - $importOptions->getConvertEmptyValuesToNull() + $importOptions->getConvertEmptyValuesToNull(), ); if ($convertEmptyToNull) { // use nullif only for string base type if ($columnDefinition->getColumnDefinition()->getBasetype() === BaseType::STRING) { $columnsSetSql[] = sprintf( 'NULLIF(%s, \'\')', - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { $columnsSetSql[] = SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()); @@ -296,7 +296,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(COALESCE(%s, \'\') as %s) AS %s', SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $this->getColumnTypeSqlDefinition($columnDefinition), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { // on columns other than string dont use COALESCE, use direct cast @@ -305,7 +305,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(%s as %s) AS %s', SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $this->getColumnTypeSqlDefinition($columnDefinition), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } } @@ -320,7 +320,7 @@ public function getInsertAllIntoTargetTableCommand( $this->getColumnsString($insColumns), implode(',', $columnsSetSql), SynapseQuote::quoteSingleIdentifier($sourceTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()), ); } @@ -328,30 +328,30 @@ public function getCTASInsertAllIntoTargetTableCommand( SynapseTableDefinition $sourceTableDefinition, SynapseTableDefinition $destinationTableDefinition, SynapseImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $destinationTable = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); $useTimestamp = !StringCaseSensitivity::isInArrayCaseInsensitive( ToStageImporterInterface::TIMESTAMP_COLUMN_NAME, - $sourceTableDefinition->getColumnsNames() + $sourceTableDefinition->getColumnsNames(), ) && $importOptions->useTimestamp(); $columnsSetSql = $this->getCTASColumnsSetSql( $sourceTableDefinition, $destinationTableDefinition, - $importOptions + $importOptions, ); if ($useTimestamp) { $columnsSetSql[] = sprintf( '%s AS %s', SynapseQuote::quote($timestamp), - ToStageImporterInterface::TIMESTAMP_COLUMN_NAME + ToStageImporterInterface::TIMESTAMP_COLUMN_NAME, ); } @@ -365,20 +365,20 @@ public function getCTASInsertAllIntoTargetTableCommand( $indexSql, implode(',', $columnsSetSql), SynapseQuote::quoteSingleIdentifier($sourceTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()), ); } public function getRenameTableCommand( string $schema, string $sourceTableName, - string $targetTable + string $targetTable, ): string { return sprintf( 'RENAME OBJECT %s.%s TO %s', SynapseQuote::quoteSingleIdentifier($schema), SynapseQuote::quoteSingleIdentifier($sourceTableName), - SynapseQuote::quoteSingleIdentifier($targetTable) + SynapseQuote::quoteSingleIdentifier($targetTable), ); } @@ -386,7 +386,7 @@ private function getSqlDistributionPart(SynapseTableDefinition $definition): str { $distributionSql = sprintf( 'DISTRIBUTION=%s', - $definition->getTableDistribution()->getDistributionName() + $definition->getTableDistribution()->getDistributionName(), ); if ($definition->getTableDistribution()->isHashDistribution()) { @@ -394,8 +394,8 @@ private function getSqlDistributionPart(SynapseTableDefinition $definition): str '%s(%s)', $distributionSql, SynapseQuote::quoteSingleIdentifier( - $definition->getTableDistribution()->getDistributionColumnsNames()[0] - ) + $definition->getTableDistribution()->getDistributionColumnsNames()[0], + ), ); } return $distributionSql; @@ -410,7 +410,7 @@ private function getSqlIndexPart(SynapseTableDefinition $definition): string $indexSql = sprintf( '%s(%s)', $definition->getTableIndex()->getIndexType(), - implode(',', $quotedColumns) + implode(',', $quotedColumns), ); } else { $indexSql = $definition->getTableIndex()->getIndexType(); @@ -421,12 +421,12 @@ private function getSqlIndexPart(SynapseTableDefinition $definition): string public function getTruncateTableWithDeleteCommand( string $schema, - string $tableName + string $tableName, ): string { return sprintf( 'DELETE FROM %s.%s', SynapseQuote::quoteSingleIdentifier($schema), - SynapseQuote::quoteSingleIdentifier($tableName) + SynapseQuote::quoteSingleIdentifier($tableName), ); } @@ -434,12 +434,12 @@ public function getUpdateWithPkCommand( SynapseTableDefinition $stagingTableDefinition, SynapseTableDefinition $destinationDefinition, SynapseImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $dest = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($destinationDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($destinationDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($destinationDefinition->getTableName()), ); $columnsSet = []; @@ -447,7 +447,7 @@ public function getUpdateWithPkCommand( foreach ($stagingTableDefinition->getColumnsDefinitions() as $columnDefinition) { $isPrimaryKey = StringCaseSensitivity::isInArrayCaseInsensitive( $columnDefinition->getColumnName(), - $destinationDefinition->getPrimaryKeysNames() + $destinationDefinition->getPrimaryKeysNames(), ); if ($isPrimaryKey) { // primary keys are not updated @@ -455,7 +455,7 @@ public function getUpdateWithPkCommand( } $convertEmptyToNull = StringCaseSensitivity::isInArrayCaseInsensitive( $columnDefinition->getColumnName(), - $importOptions->getConvertEmptyValuesToNull() + $importOptions->getConvertEmptyValuesToNull(), ); if ($convertEmptyToNull) { // use nullif only for string base type @@ -463,27 +463,27 @@ public function getUpdateWithPkCommand( $columnsSet[] = sprintf( '%s = NULLIF([src].%s, \'\')', SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { $columnsSet[] = sprintf( '%s = [src].%s', SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } } else { $sql = sprintf( '%s = [src].%s', SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); if ($columnDefinition->getColumnDefinition()->getBasetype() === BaseType::STRING) { $sql = sprintf( '%s = COALESCE([src].%s, \'\')', SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } @@ -495,7 +495,7 @@ public function getUpdateWithPkCommand( $columnsSet[] = sprintf( '%s = \'%s\'', SynapseQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), - $timestamp + $timestamp, ); } @@ -511,7 +511,7 @@ public function getUpdateWithPkCommand( iterator_to_array($stagingTableDefinition->getColumnsDefinitions()), static fn(SynapseColumn $columnDefinition): bool => !StringCaseSensitivity::isInArrayCaseInsensitive( $columnDefinition->getColumnName(), - $destinationDefinition->getPrimaryKeysNames() + $destinationDefinition->getPrimaryKeysNames(), ) ); @@ -531,17 +531,17 @@ function (SynapseColumn $columnDefinition) use ($dest) { $dest, SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $this->getColumnTypeSqlDefinition($columnDefinition), - SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + SynapseQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); }, - $columnsForComparison + $columnsForComparison, ); $and = ''; if (count($columnsComparisonSql) !== 0) { $and = sprintf( 'AND (%s) ', - implode(' OR ', $columnsComparisonSql) + implode(' OR ', $columnsComparisonSql), ); } @@ -552,7 +552,7 @@ function (SynapseColumn $columnDefinition) use ($dest) { SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), $this->getPrimaryKeyWhereConditions($destinationDefinition->getPrimaryKeysNames(), '[src]', $dest), - $and + $and, ); } @@ -572,7 +572,7 @@ private function getColumnTypeSqlDefinition(SynapseColumn $column): string private function getCTASColumnsSetSql( SynapseTableDefinition $sourceTableDefinition, SynapseTableDefinition $destinationTableDefinition, - SynapseImportOptions $importOptions + SynapseImportOptions $importOptions, ): array { $columnsSetSql = []; /** @var SynapseColumn $column */ @@ -591,29 +591,29 @@ private function getCTASColumnsSetSql( sprintf( 'Columns "%s" can be imported as it was not found between columns "%s" of destination table.', $column->getColumnName(), - implode(', ', $destinationTableDefinition->getColumnsNames()) + implode(', ', $destinationTableDefinition->getColumnsNames()), ), - Exception::UNKNOWN_ERROR + Exception::UNKNOWN_ERROR, ); } $columnTypeDefinition = $this->getColumnTypeSqlDefinition($destinationColumn); $convertEmptyToNull = StringCaseSensitivity::isInArrayCaseInsensitive( $column->getColumnName(), - $importOptions->getConvertEmptyValuesToNull() + $importOptions->getConvertEmptyValuesToNull(), ); if ($convertEmptyToNull) { $columnsSetSql[] = $this->getCTASColumnSetSQLWithConvertEmptyValues( $column, $importOptions, $columnTypeDefinition, - $destinationColumn + $destinationColumn, ); } else { $columnsSetSql[] = $this->getCTASColumnSetSQL( $column, $importOptions, $columnTypeDefinition, - $destinationColumn + $destinationColumn, ); } } @@ -624,13 +624,13 @@ private function getCTASColumnSetSQLWithConvertEmptyValues( SynapseColumn $source, SynapseImportOptions $importOptions, string $columnTypeDefinition, - SynapseColumn $destinationColumn + SynapseColumn $destinationColumn, ): string { if ($destinationColumn->getColumnDefinition()->getBasetype() === BaseType::STRING) { // convert nulls only for strings $colSql = sprintf( 'NULLIF(%s, \'\')', - SynapseQuote::quoteSingleIdentifier($source->getColumnName()) + SynapseQuote::quoteSingleIdentifier($source->getColumnName()), ); } else { $colSql = SynapseQuote::quoteSingleIdentifier($source->getColumnName()); @@ -639,13 +639,13 @@ private function getCTASColumnSetSQLWithConvertEmptyValues( $colSql = sprintf( 'CAST(%s as %s)', $colSql, - $columnTypeDefinition + $columnTypeDefinition, ); } return sprintf( '%s AS %s', $colSql, - SynapseQuote::quoteSingleIdentifier($destinationColumn->getColumnName()) + SynapseQuote::quoteSingleIdentifier($destinationColumn->getColumnName()), ); } @@ -653,13 +653,13 @@ private function getCTASColumnSetSQL( SynapseColumn $sourceColumn, SynapseImportOptions $importOptions, string $columnTypeDefinition, - SynapseColumn $destinationColumn + SynapseColumn $destinationColumn, ): string { if ($importOptions->getCastValueTypes()) { $colSql = sprintf( 'CAST(%s as %s)', SynapseQuote::quoteSingleIdentifier($sourceColumn->getColumnName()), - $columnTypeDefinition + $columnTypeDefinition, ); } else { $colSql = SynapseQuote::quoteSingleIdentifier($sourceColumn->getColumnName()); @@ -669,20 +669,20 @@ private function getCTASColumnSetSQL( // Columns with coalesce are nullable in CTAS $colSql = sprintf( 'COALESCE(%s, \'\')', - $colSql + $colSql, ); } else { // Columns with isnull are not null in CTAS $colSql = sprintf( 'ISNULL(%s, \'\')', - $colSql + $colSql, ); } } return sprintf( '%s AS %s', $colSql, - SynapseQuote::quoteSingleIdentifier($destinationColumn->getColumnName()) + SynapseQuote::quoteSingleIdentifier($destinationColumn->getColumnName()), ); } } diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromABSCopyIntoAdapter.php b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromABSCopyIntoAdapter.php index d52f9c570..bd8babd51 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromABSCopyIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromABSCopyIntoAdapter.php @@ -34,7 +34,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SourceFile); assert($destination instanceof SynapseTableDefinition); @@ -49,7 +49,7 @@ public function runCopyCommand( $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -58,7 +58,7 @@ public function runCopyCommand( private function getCopyCommand( Storage\ABS\SourceFile $source, SynapseTableDefinition $destination, - SynapseImportOptions $importOptions + SynapseImportOptions $importOptions, ): ?string { $destinationSchema = SynapseQuote::quoteSingleIdentifier($destination->getSchemaName()); $destinationTable = SynapseQuote::quoteSingleIdentifier($destination->getTableName()); @@ -74,7 +74,7 @@ private function getCopyCommand( default: throw new InvalidArgumentException(sprintf( 'Unknown Synapse import credentials type "%s".', - $importOptions->getImportCredentialsType() + $importOptions->getImportCredentialsType(), )); } diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapter.php b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapter.php index 09df54947..9a65c02cb 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapter.php @@ -33,7 +33,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SelectSource || $source instanceof Table); assert($destination instanceof SynapseTableDefinition); @@ -45,9 +45,9 @@ public function runCopyCommand( (new SynapseTableReflection( $this->connection, $source->getSchema(), - $source->getTableName() + $source->getTableName(), ))->getColumnsDefinitions(), - $destination->getColumnsDefinitions() + $destination->getColumnsDefinitions(), ); } @@ -57,14 +57,14 @@ public function runCopyCommand( (new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $tempTableName + $tempTableName, ))->getObjectId(); // rename table to tmp $this->connection->executeQuery( (new SynapseTableQueryBuilder())->getDropTableCommand( $destination->getSchemaName(), - $tempTableName - ) + $tempTableName, + ), ); } catch (TableNotExistsReflectionException $e) { // ignore if table not exists @@ -76,7 +76,7 @@ public function runCopyCommand( $ref = (new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), )); $ref->getObjectId(); $isMainTableTemporary = $ref->isTemporary(); @@ -85,8 +85,8 @@ public function runCopyCommand( $this->connection->executeQuery( (new SynapseTableQueryBuilder())->getDropTableCommand( $destination->getSchemaName(), - $destination->getTableName() - ) + $destination->getTableName(), + ), ); } else { // rename table to temp @@ -94,8 +94,8 @@ public function runCopyCommand( (new SynapseTableQueryBuilder())->getRenameTableCommand( $destination->getSchemaName(), $destination->getTableName(), - $tempTableName - ) + $tempTableName, + ), ); } } catch (TableNotExistsReflectionException $e) { @@ -118,8 +118,8 @@ public function runCopyCommand( (new SynapseTableQueryBuilder())->getRenameTableCommand( $destination->getSchemaName(), $tempTableName, - $destination->getTableName() - ) + $destination->getTableName(), + ), ); } } @@ -128,15 +128,15 @@ public function runCopyCommand( $this->connection->executeQuery( (new SynapseTableQueryBuilder())->getDropTableCommand( $destination->getSchemaName(), - $tempTableName - ) + $tempTableName, + ), ); } $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapterSqlBuilder.php b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapterSqlBuilder.php index 197964271..66ee18d26 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapterSqlBuilder.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableCTASAdapterSqlBuilder.php @@ -20,7 +20,7 @@ class FromTableCTASAdapterSqlBuilder public static function getCTASCommand( SynapseTableDefinition $destination, Storage\SourceInterface $source, - SynapseImportOptions $importOptions + SynapseImportOptions $importOptions, ): string { if ($destination->getTableDistribution()->isHashDistribution()) { $quotedColumns = array_map(function ($columnName) { @@ -29,12 +29,12 @@ public static function getCTASCommand( $distributionSql = sprintf( 'DISTRIBUTION = %s(%s)', $destination->getTableDistribution()->getDistributionName(), - implode(',', $quotedColumns) + implode(',', $quotedColumns), ); } else { $distributionSql = sprintf( 'DISTRIBUTION = %s', - $destination->getTableDistribution()->getDistributionName() + $destination->getTableDistribution()->getDistributionName(), ); } @@ -45,7 +45,7 @@ public static function getCTASCommand( $indexSql = sprintf( '%s(%s)', $destination->getTableIndex()->getIndexType(), - implode(',', $quotedColumns) + implode(',', $quotedColumns), ); } else { $indexSql = $destination->getTableIndex()->getIndexType(); @@ -54,7 +54,7 @@ public static function getCTASCommand( if ($source instanceof Table) { $from = $source->getFromStatementForStaging( // cast values only if table is not typed (tables are not required to be same) - !$importOptions->areSameTablesRequired() + !$importOptions->areSameTablesRequired(), ); } @@ -64,7 +64,7 @@ public static function getCTASCommand( SynapseQuote::quoteSingleIdentifier($destination->getTableName()), $distributionSql, $indexSql, - $from + $from, ); } } diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableInsertIntoAdapter.php b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableInsertIntoAdapter.php index 24ca26425..ccc34e8ce 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableInsertIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToStage/FromTableInsertIntoAdapter.php @@ -28,7 +28,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SelectSource || $source instanceof Table); assert($destination instanceof SynapseTableDefinition); @@ -43,7 +43,7 @@ public function runCopyCommand( SynapseQuote::quoteSingleIdentifier($destination->getSchemaName()), SynapseQuote::quoteSingleIdentifier($destination->getTableName()), implode(', ', $quotedColumns), - $source->getFromStatement() + $source->getFromStatement(), ); if ($source instanceof SelectSource) { @@ -55,7 +55,7 @@ public function runCopyCommand( $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToStage/StageTableDefinitionFactory.php b/packages/php-db-import-export/src/Backend/Synapse/ToStage/StageTableDefinitionFactory.php index cee97b927..995ebdbcf 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToStage/StageTableDefinitionFactory.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToStage/StageTableDefinitionFactory.php @@ -21,7 +21,7 @@ final class StageTableDefinitionFactory public static function createStagingTableDefinition( SynapseTableDefinition $destination, array $sourceColumnsNames, - ?TableIndexDefinition $indexDefinition = null + ?TableIndexDefinition $indexDefinition = null, ): SynapseTableDefinition { $clusteredIndexColumns = self::getClusteredIndexColumns($indexDefinition); @@ -45,8 +45,8 @@ public static function createStagingTableDefinition( // set all columns to be nullable except in clustered index 'nullable' => $isNullable, 'default' => $definition->getColumnDefinition()->getDefault(), - ] - ) + ], + ), ); continue 2; } @@ -62,7 +62,7 @@ public static function createStagingTableDefinition( new ColumnCollection($newDefinitions), $destination->getPrimaryKeysNames(), self::resolveDistribution($destination->getTableDistribution()), - $indexDefinition ?? new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + $indexDefinition ?? new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); } @@ -72,7 +72,7 @@ public static function createStagingTableDefinition( public static function createDedupStagingTableDefinition( SynapseTableDefinition $destination, array $sourceColumnsNames, - ?TableIndexDefinition $indexDefinition = null + ?TableIndexDefinition $indexDefinition = null, ): SynapseTableDefinition { $newDefinitions = []; // create staging table for source columns in order @@ -91,8 +91,8 @@ public static function createDedupStagingTableDefinition( 'length' => $definition->getColumnDefinition()->getLength(), 'nullable' => true, 'default' => $definition->getColumnDefinition()->getDefault(), - ] - ) + ], + ), ); continue 2; } @@ -113,7 +113,7 @@ public static function createDedupStagingTableDefinition( new ColumnCollection($newDefinitions), $destination->getPrimaryKeysNames(), self::resolveDistribution($destination->getTableDistribution()), - $tableIndex + $tableIndex, ); } @@ -132,8 +132,8 @@ private static function createNvarcharColumn(string $columnName, ?array $cluster 'length' => (string) Synapse::MAX_LENGTH_NVARCHAR, // set all columns to be nullable except in clustered index 'nullable' => $isNullable, - ] - ) + ], + ), ); } @@ -143,7 +143,7 @@ private static function createNvarcharColumn(string $columnName, ?array $cluster public static function createStagingTableDefinitionWithText( SynapseTableDefinition $destination, array $sourceColumnsNames, - ?TableIndexDefinition $indexDefinition = null + ?TableIndexDefinition $indexDefinition = null, ): SynapseTableDefinition { $clusteredIndexColumns = self::getClusteredIndexColumns($indexDefinition); @@ -159,7 +159,7 @@ public static function createStagingTableDefinitionWithText( new ColumnCollection($newDefinitions), $destination->getPrimaryKeysNames(), self::resolveDistribution($destination->getTableDistribution()), - $indexDefinition ?? new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + $indexDefinition ?? new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); } @@ -177,7 +177,7 @@ private static function getClusteredIndexColumns(?TableIndexDefinition $indexDef } private static function resolveDistribution( - TableDistributionDefinition $distribution + TableDistributionDefinition $distribution, ): TableDistributionDefinition { //phpcs:ignore $isReplicateTable = $distribution->getDistributionName() === TableDistributionDefinition::TABLE_DISTRIBUTION_REPLICATE; diff --git a/packages/php-db-import-export/src/Backend/Synapse/ToStage/ToStageImporter.php b/packages/php-db-import-export/src/Backend/Synapse/ToStage/ToStageImporter.php index f723ee7bd..e26071b14 100644 --- a/packages/php-db-import-export/src/Backend/Synapse/ToStage/ToStageImporter.php +++ b/packages/php-db-import-export/src/Backend/Synapse/ToStage/ToStageImporter.php @@ -28,7 +28,7 @@ final class ToStageImporter implements ToStageImporterInterface public function __construct( Connection $connection, - ?CopyAdapterInterface $adapter = null + ?CopyAdapterInterface $adapter = null, ) { $this->connection = $connection; $this->adapter = $adapter; @@ -37,7 +37,7 @@ public function __construct( public function importToStagingTable( Storage\SourceInterface $source, TableDefinitionInterface $destinationDefinition, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): ImportState { assert($options instanceof SynapseImportOptions); assert($destinationDefinition instanceof SynapseTableDefinition); @@ -53,8 +53,8 @@ public function importToStagingTable( $adapter->runCopyCommand( $source, $destinationDefinition, - $options - ) + $options, + ), ); } catch (Exception $e) { throw SynapseException::covertException($e); @@ -66,7 +66,7 @@ public function importToStagingTable( private function getAdapter( Storage\SourceInterface $source, - SynapseImportOptions $importOptions + SynapseImportOptions $importOptions, ): CopyAdapterInterface { if ($this->adapter !== null) { return $this->adapter; @@ -83,8 +83,8 @@ private function getAdapter( throw new LogicException( sprintf( 'No suitable adapter found for source: "%s".', - get_class($source) - ) + get_class($source), + ), ); } return $adapter; @@ -102,8 +102,8 @@ private function getAdapterForSqlSource(SynapseImportOptions $importOptions): Co throw new LogicException( sprintf( 'No suitable table to table adapter "%s".', - $importOptions->getTableToTableAdapter() - ) + $importOptions->getTableToTableAdapter(), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/Exporter.php b/packages/php-db-import-export/src/Backend/Teradata/Exporter.php index 71d375dbe..5d61afbe1 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/Exporter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/Exporter.php @@ -24,7 +24,7 @@ class Exporter implements ExporterInterface private Connection $connection; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; } @@ -44,7 +44,7 @@ public function setAdapters(array $adapters): void public function exportTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $options + ExportOptionsInterface $options, ): array { $adapter = $this->getAdapter($source, $destination); return $adapter->runCopyCommand($source, $destination, $options); @@ -52,7 +52,7 @@ public function exportTable( private function getAdapter( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): BackendExportAdapterInterface { $adapterForUse = null; /** @var BackendExportAdapterInterface $adapter */ @@ -64,8 +64,8 @@ private function getAdapter( 'More than one suitable adapter found for Export exporter with source: ' . '"%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } $adapterForUse = new $adapter($this->connection); @@ -76,8 +76,8 @@ private function getAdapter( sprintf( 'No suitable adapter found for Teradata exporter with source: "%s", destination "%s".', get_class($source), - get_class($destination) - ) + get_class($destination), + ), ); } diff --git a/packages/php-db-import-export/src/Backend/Teradata/Helper/DropTableTrait.php b/packages/php-db-import-export/src/Backend/Teradata/Helper/DropTableTrait.php index e2a9e4f70..aa37773d3 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/Helper/DropTableTrait.php +++ b/packages/php-db-import-export/src/Backend/Teradata/Helper/DropTableTrait.php @@ -13,7 +13,7 @@ public function dropTableIfExists(string $dbName, string $tableName): void if ($this->tableExists($dbName, $tableName) ) { $this->connection->executeStatement( - (new SqlBuilder())->getDropTableUnsafe($dbName, $tableName) + (new SqlBuilder())->getDropTableUnsafe($dbName, $tableName), ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/TeradataImportOptions.php b/packages/php-db-import-export/src/Backend/Teradata/TeradataImportOptions.php index b735db6fd..299da427d 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/TeradataImportOptions.php +++ b/packages/php-db-import-export/src/Backend/Teradata/TeradataImportOptions.php @@ -28,14 +28,14 @@ public function __construct( bool $isIncremental = false, bool $useTimestamp = false, int $numberOfIgnoredLines = 0, - string $usingTypes = self::USING_TYPES_STRING + string $usingTypes = self::USING_TYPES_STRING, ) { parent::__construct( $convertEmptyValuesToNull, $isIncremental, $useTimestamp, $numberOfIgnoredLines, - $usingTypes + $usingTypes, ); $this->teradataHost = $teradataHost; $this->teradataUser = $teradataUser; diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/FullImporter.php b/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/FullImporter.php index 32574e08f..014dfce6c 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/FullImporter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/FullImporter.php @@ -31,7 +31,7 @@ final class FullImporter implements ToFinalTableImporterInterface use DropTableTrait; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -41,14 +41,14 @@ private function doLoadFullWithoutDedup( TeradataTableDefinition $stagingTableDefinition, TeradataTableDefinition $destinationTableDefinition, TeradataImportOptions $options, - ImportState $state + ImportState $state, ): void { // truncate destination table $this->connection->executeStatement( $this->sqlBuilder->getTruncateTableWithDeleteCommand( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); $state->startTimer(self::TIMER_COPY_TO_TARGET); @@ -57,10 +57,10 @@ private function doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() + DateTimeHelper::getNowFormatted(), ); $this->connection->executeStatement( - $sql + $sql, ); $state->stopTimer(self::TIMER_COPY_TO_TARGET); } @@ -69,7 +69,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof TeradataTableDefinition); assert($destinationTableDefinition instanceof TeradataTableDefinition); @@ -83,14 +83,14 @@ public function importToTable( $stagingTableDefinition, $destinationTableDefinition, $options, - $state + $state, ); } else { $this->doLoadFullWithoutDedup( $stagingTableDefinition, $destinationTableDefinition, $options, - $state + $state, ); } } catch (Exception $e) { @@ -106,14 +106,14 @@ private function doFullLoadWithDedup( TeradataTableDefinition $stagingTableDefinition, TeradataTableDefinition $destinationTableDefinition, TeradataImportOptions $options, - ImportState $state + ImportState $state, ): void { $state->startTimer(self::TIMER_DEDUP); // 1. Create table for deduplication $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupTableDefinition( $stagingTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ); try { @@ -126,20 +126,20 @@ private function doFullLoadWithDedup( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); // 3 truncate destination table $this->connection->executeStatement( $this->sqlBuilder->getTruncateTableWithDeleteCommand( $destinationTableDefinition->getSchemaName(), - $destinationTableDefinition->getTableName() - ) + $destinationTableDefinition->getTableName(), + ), ); // 4 move data with INSERT INTO @@ -148,20 +148,20 @@ private function doFullLoadWithDedup( $deduplicationTableDefinition, $destinationTableDefinition, $options, - DateTimeHelper::getNowFormatted() - ) + DateTimeHelper::getNowFormatted(), + ), ); $state->stopTimer(self::TIMER_DEDUP); } finally { // 5 drop dedup table $this->dropTableIfExists( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() + $deduplicationTableDefinition->getTableName(), ); } $this->connection->executeStatement( - $this->sqlBuilder->getEndTransaction() + $this->sqlBuilder->getEndTransaction(), ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/IncrementalImporter.php b/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/IncrementalImporter.php index bbc656275..449d6b21b 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/IncrementalImporter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/IncrementalImporter.php @@ -35,7 +35,7 @@ final class IncrementalImporter implements ToFinalTableImporterInterface use DropTableTrait; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; $this->sqlBuilder = new SqlBuilder(); @@ -45,7 +45,7 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result { assert($stagingTableDefinition instanceof TeradataTableDefinition); assert($destinationTableDefinition instanceof TeradataTableDefinition); @@ -64,7 +64,7 @@ public function importToTable( // 0. Create table for deduplication $deduplicationTableDefinition = StageTableDefinitionFactory::createDedupTableDefinition( $stagingTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() + $destinationTableDefinition->getPrimaryKeysNames(), ); $tableToCopyFrom = $deduplicationTableDefinition; $qb = new TeradataTableQueryBuilder(); @@ -75,7 +75,7 @@ public function importToTable( // transaction has to start here because TD can have DDL at the end of transaction $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); // 1. Run UPDATE command to update rows in final table with updated data based on PKs @@ -85,8 +85,8 @@ public function importToTable( $stagingTableDefinition, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_UPDATE_TARGET_TABLE); @@ -96,8 +96,8 @@ public function importToTable( $this->sqlBuilder->getDeleteOldItemsCommand( $stagingTableDefinition, $destinationTableDefinition, - $options - ) + $options, + ), ); $state->stopTimer(self::TIMER_DELETE_UPDATED_ROWS); @@ -107,19 +107,19 @@ public function importToTable( $this->sqlBuilder->getDedupCommand( $stagingTableDefinition, $deduplicationTableDefinition, - $destinationTableDefinition->getPrimaryKeysNames() - ) + $destinationTableDefinition->getPrimaryKeysNames(), + ), ); $this->connection->executeStatement( $this->sqlBuilder->getTruncateTableWithDeleteCommand( $stagingTableDefinition->getSchemaName(), - $stagingTableDefinition->getTableName() - ) + $stagingTableDefinition->getTableName(), + ), ); $state->stopTimer(self::TIMER_DEDUP_STAGING); } else { $this->connection->executeStatement( - $this->sqlBuilder->getBeginTransaction() + $this->sqlBuilder->getBeginTransaction(), ); } @@ -130,13 +130,13 @@ public function importToTable( $tableToCopyFrom, $destinationTableDefinition, $options, - $timestampValue - ) + $timestampValue, + ), ); $state->stopTimer(self::TIMER_INSERT_INTO_TARGET); $this->connection->executeStatement( - $this->sqlBuilder->getEndTransaction() + $this->sqlBuilder->getEndTransaction(), ); $state->setImportedColumns($stagingTableDefinition->getColumnsNames()); @@ -147,7 +147,7 @@ public function importToTable( // 5 drop dedup table $this->dropTableIfExists( $deduplicationTableDefinition->getSchemaName(), - $deduplicationTableDefinition->getTableName() + $deduplicationTableDefinition->getTableName(), ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/SqlBuilder.php b/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/SqlBuilder.php index 284f178a2..b85c0c212 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/SqlBuilder.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToFinalTable/SqlBuilder.php @@ -35,7 +35,7 @@ public function getDropTableUnsafe(string $dbName, string $tableName): string return sprintf( 'DROP TABLE %s.%s', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), ); } @@ -44,7 +44,7 @@ public function getTableExistsCommand(string $dbName, string $tableName): string return sprintf( 'SELECT COUNT(*) FROM DBC.TablesVX WHERE DatabaseName = %s AND TableName = %s;', TeradataQuote::quote($dbName), - TeradataQuote::quote($tableName) + TeradataQuote::quote($tableName), ); } @@ -52,12 +52,12 @@ public function getInsertAllIntoTargetTableCommand( TeradataTableDefinition $sourceTableDefinition, TeradataTableDefinition $destinationTableDefinition, TeradataImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $destinationTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); $columnsToInsert = $sourceTableDefinition->getColumnsNames(); @@ -67,7 +67,7 @@ public function getInsertAllIntoTargetTableCommand( if ($useTimestamp) { $columnsToInsert = array_merge( $sourceTableDefinition->getColumnsNames(), - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); } @@ -89,9 +89,9 @@ public function getInsertAllIntoTargetTableCommand( sprintf( 'Columns "%s" can be imported as it was not found between columns "%s" of destination table.', $columnDefinition->getColumnName(), - implode(', ', $destinationTableDefinition->getColumnsNames()) + implode(', ', $destinationTableDefinition->getColumnsNames()), ), - Exception::UNKNOWN_ERROR + Exception::UNKNOWN_ERROR, ); } if ($importOptions->usingUserDefinedTypes()) { @@ -99,14 +99,14 @@ public function getInsertAllIntoTargetTableCommand( } elseif (in_array( $columnDefinition->getColumnName(), $importOptions->getConvertEmptyValuesToNull(), - true + true, ) ) { // use nullif only for string base type -> OM if ($columnDefinition->getColumnDefinition()->getBasetype() === BaseType::STRING) { $columnsSetSql[] = sprintf( 'NULLIF(%s, \'\')', - TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { $columnsSetSql[] = TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()); @@ -116,7 +116,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(COALESCE(%s, \'\') as %s) AS %s', TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $destinationColumn->getColumnDefinition()->buildTypeWithLength(), - TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } else { // on columns other than string dont use COALESCE, use direct cast @@ -125,7 +125,7 @@ public function getInsertAllIntoTargetTableCommand( 'CAST(%s as %s) AS %s', TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), $destinationColumn->getColumnDefinition()->buildTypeWithLength(), - TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()) + TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), ); } } @@ -141,7 +141,7 @@ public function getInsertAllIntoTargetTableCommand( implode(',', $columnsSetSql), TeradataQuote::quoteSingleIdentifier($sourceTableDefinition->getSchemaName()), TeradataQuote::quoteSingleIdentifier($sourceTableDefinition->getTableName()), - TeradataQuote::quoteSingleIdentifier(self::SRC_ALIAS) + TeradataQuote::quoteSingleIdentifier(self::SRC_ALIAS), ); } @@ -151,7 +151,7 @@ public function getInsertAllIntoTargetTableCommand( public function getDedupCommand( TeradataTableDefinition $stagingTableDefinition, TeradataTableDefinition $deduplicationTableDefinition, - array $primaryKeys + array $primaryKeys, ): string { if (empty($primaryKeys)) { return ''; @@ -160,14 +160,14 @@ public function getDedupCommand( $deduplication = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($deduplicationTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($deduplicationTableDefinition->getTableName()), ); return sprintf( 'INSERT INTO %s (%s) %s', $deduplication, $this->getColumnsString($deduplicationTableDefinition->getColumnsNames()), - $this->getDedupSql($stagingTableDefinition, $deduplicationTableDefinition, $primaryKeys) + $this->getDedupSql($stagingTableDefinition, $deduplicationTableDefinition, $primaryKeys), ); } @@ -177,17 +177,17 @@ public function getDedupCommand( public function getDedupSql( TeradataTableDefinition $stagingTableDefinition, TeradataTableDefinition $deduplicationTableDefinition, - array $primaryKeys + array $primaryKeys, ): string { $pkSql = $this->getColumnsString( $primaryKeys, - ',' + ',', ); $stage = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); return sprintf( @@ -200,19 +200,19 @@ public function getDedupSql( $this->getColumnsString($deduplicationTableDefinition->getColumnsNames(), ', '), $pkSql, $pkSql, - $stage + $stage, ); } public function getTruncateTableWithDeleteCommand( string $schema, - string $tableName + string $tableName, ): string { // TD has no TRUNCATE command - DELETE ALL has to be used return sprintf( 'DELETE %s.%s ALL', TeradataQuote::quoteSingleIdentifier($schema), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), ); } @@ -222,10 +222,10 @@ public function getTruncateTableWithDeleteCommand( public function getColumnsString( array $columns, string $delimiter = ', ', - ?string $tableAlias = null + ?string $tableAlias = null, ): string { return implode($delimiter, array_map(static function ($columns) use ( - $tableAlias + $tableAlias, ) { $alias = $tableAlias === null ? '' : $tableAlias . '.'; return $alias . TeradataQuote::quoteSingleIdentifier($columns); @@ -235,18 +235,18 @@ public function getColumnsString( public function getDeleteOldItemsCommand( TeradataTableDefinition $stagingTableDefinition, TeradataTableDefinition $destinationTableDefinition, - TeradataImportOptions $importOptions + TeradataImportOptions $importOptions, ): string { $stagingTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $destinationTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($destinationTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($destinationTableDefinition->getTableName()), ); return sprintf( @@ -257,8 +257,8 @@ public function getDeleteOldItemsCommand( $destinationTableDefinition->getPrimaryKeysNames(), $importOptions, $stagingTable, - TeradataQuote::quoteSingleIdentifier('joined') - ) + TeradataQuote::quoteSingleIdentifier('joined'), + ), ); } @@ -266,13 +266,13 @@ public function getUpdateWithPkCommand( TeradataTableDefinition $stagingTableDefinition, TeradataTableDefinition $destinationDefinition, TeradataImportOptions $importOptions, - string $timestamp + string $timestamp, ): string { $columnsSet = []; $dest = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($destinationDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($destinationDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($destinationDefinition->getTableName()), ); foreach ($stagingTableDefinition->getColumnsNames() as $columnName) { @@ -290,13 +290,13 @@ public function getUpdateWithPkCommand( '%s = CASE WHEN "src".%s = \'\' THEN NULL ELSE "src".%s END', TeradataQuote::quoteSingleIdentifier($columnName), TeradataQuote::quoteSingleIdentifier($columnName), - TeradataQuote::quoteSingleIdentifier($columnName) + TeradataQuote::quoteSingleIdentifier($columnName), ); } else { $columnsSet[] = sprintf( '%s = COALESCE("src".%s, \'\')', TeradataQuote::quoteSingleIdentifier($columnName), - TeradataQuote::quoteSingleIdentifier($columnName) + TeradataQuote::quoteSingleIdentifier($columnName), ); } } @@ -305,7 +305,7 @@ public function getUpdateWithPkCommand( $columnsSet[] = sprintf( '%s = %s', TeradataQuote::quoteSingleIdentifier(ToStageImporterInterface::TIMESTAMP_COLUMN_NAME), - TeradataQuote::quote($timestamp) + TeradataQuote::quote($timestamp), ); } @@ -315,15 +315,15 @@ public function getUpdateWithPkCommand( $this->getDedupSql( $stagingTableDefinition, $stagingTableDefinition, - $destinationDefinition->getPrimaryKeysNames() + $destinationDefinition->getPrimaryKeysNames(), ), implode(', ', $columnsSet), $this->getPrimayKeyWhereConditions( $destinationDefinition->getPrimaryKeysNames(), $importOptions, TeradataQuote::quoteSingleIdentifier('src'), - $dest - ) + $dest, + ), ); } @@ -334,7 +334,7 @@ private function getPrimayKeyWhereConditions( array $primaryKeys, TeradataImportOptions $importOptions, string $coalescedTable, - string $leftTable + string $leftTable, ): string { $pkWhereSql = array_map(function (string $col) use ($importOptions, $coalescedTable, $leftTable) { if ($importOptions->usingUserDefinedTypes()) { @@ -347,7 +347,7 @@ private function getPrimayKeyWhereConditions( $leftTable, TeradataQuote::quoteSingleIdentifier($col), $coalescedTable, - TeradataQuote::quoteSingleIdentifier($col) + TeradataQuote::quoteSingleIdentifier($col), ); }, $primaryKeys); diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/FailedTPTLoadException.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/FailedTPTLoadException.php index dfbb5100d..00dad32e6 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/FailedTPTLoadException.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/FailedTPTLoadException.php @@ -27,7 +27,7 @@ public function __construct( string $stdOut, ?int $exitCode = null, ?string $logContent = null, - ?array $logTableContent = null + ?array $logTableContent = null, ) { parent::__construct( "Teradata TPT load ended with Error. \n\n @@ -36,7 +36,7 @@ public function __construct( logContent :$logContent \n\n logTableContent : " . ($logTableContent ? json_encode($logTableContent, JSON_THROW_ON_ERROR) : 'no data') . " \n\n", - $exitCode ?? 0 + $exitCode ?? 0, ); $this->stdErr = $stdErr; $this->stdOut = $stdOut; diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/NoMoreRoomInTDException.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/NoMoreRoomInTDException.php index 516097458..2ef2c43bc 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/NoMoreRoomInTDException.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/Exception/NoMoreRoomInTDException.php @@ -12,7 +12,7 @@ class NoMoreRoomInTDException extends Exception public function __construct(string $dbName) { parent::__construct( - sprintf('No more room in Teradata database %s', $dbName) + sprintf('No more room in Teradata database %s', $dbName), ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromABSTPTAdapter.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromABSTPTAdapter.php index 71133fbac..4512adf0f 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromABSTPTAdapter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromABSTPTAdapter.php @@ -48,7 +48,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof Storage\ABS\SourceFile); assert($destination instanceof TeradataTableDefinition); @@ -97,8 +97,8 @@ public function runCopyCommand( sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($destination->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($logTable) - ) + TeradataQuote::quoteSingleIdentifier($logTable), + ), ); $this->connection->executeStatement($qb->getDropTableUnsafe($destination->getSchemaName(), $logTable)); } @@ -121,7 +121,7 @@ public function runCopyCommand( // drop destination table it's not usable $this->connection->executeStatement($qb->getDropTableCommand( $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), )); $stdOut = $process->getOutput(); @@ -134,7 +134,7 @@ public function runCopyCommand( $stdOut, $process->getExitCode(), $this->getLogData($temp), - $logContent + $logContent, ); } @@ -144,7 +144,7 @@ public function runCopyCommand( $ref = new TeradataTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -168,7 +168,7 @@ private function getLogData(Temp $temp): string private function generateTPTScript( Storage\ABS\SourceFile $source, TeradataTableDefinition $destination, - TeradataImportOptions $importOptions + TeradataImportOptions $importOptions, ): array { $temp = new Temp(); $folder = $temp->getTmpFolder(); diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromS3TPTAdapter.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromS3TPTAdapter.php index 0a2f1c1de..9178165a9 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromS3TPTAdapter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromS3TPTAdapter.php @@ -46,7 +46,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof Storage\S3\SourceFile); assert($destination instanceof TeradataTableDefinition); @@ -74,7 +74,7 @@ public function runCopyCommand( [ 'AWS_ACCESS_KEY_ID' => $source->getKey(), 'AWS_SECRET_ACCESS_KEY' => $source->getSecret(), - ] + ], ); $process->setTimeout(self::TPT_TIMEOUT); $process->start(); @@ -100,8 +100,8 @@ public function runCopyCommand( sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($destination->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($logTable) - ) + TeradataQuote::quoteSingleIdentifier($logTable), + ), ); $this->connection->executeStatement($qb->getDropTableUnsafe($destination->getSchemaName(), $logTable)); } @@ -124,7 +124,7 @@ public function runCopyCommand( // drop destination table it's not usable $this->connection->executeStatement($qb->getDropTableCommand( $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), )); $stdOut = $process->getOutput(); @@ -137,7 +137,7 @@ public function runCopyCommand( $stdOut, $process->getExitCode(), $this->getLogData($temp), - $logContent + $logContent, ); } @@ -147,7 +147,7 @@ public function runCopyCommand( $ref = new TeradataTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); @@ -171,7 +171,7 @@ private function getLogData(Temp $temp): string private function generateTPTScript( Storage\S3\SourceFile $source, TeradataTableDefinition $destination, - TeradataImportOptions $importOptions + TeradataImportOptions $importOptions, ): array { $temp = new Temp(); $folder = $temp->getTmpFolder(); @@ -205,7 +205,7 @@ private function generateTPTScript( $source->getBucket(), $prefix, $object, - $s3ConfigDir + $s3ConfigDir, ); } else { if ($source->isSliced()) { @@ -221,7 +221,7 @@ private function generateTPTScript( $path->getRoot(), $path->getPathWithoutRoot() . '/', $path->getFileName(), - $s3ConfigDir + $s3ConfigDir, ); } else { // direct load with @@ -234,7 +234,7 @@ private function generateTPTScript( $source->getBucket(), $source->getPrefix(), $source->getFileName(), - $s3ConfigDir + $s3ConfigDir, ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromTableInsertIntoAdapter.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromTableInsertIntoAdapter.php index c59fad299..e4a94d176 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromTableInsertIntoAdapter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/FromTableInsertIntoAdapter.php @@ -29,7 +29,7 @@ public function __construct(Connection $connection) public function runCopyCommand( Storage\SourceInterface $source, TableDefinitionInterface $destination, - ImportOptionsInterface $importOptions + ImportOptionsInterface $importOptions, ): int { assert($source instanceof SelectSource || $source instanceof Table); assert($destination instanceof TeradataTableDefinition); @@ -44,7 +44,7 @@ public function runCopyCommand( TeradataQuote::quoteSingleIdentifier($destination->getSchemaName()), TeradataQuote::quoteSingleIdentifier($destination->getTableName()), implode(', ', $quotedColumns), - $source->getFromStatement() + $source->getFromStatement(), ); if ($source instanceof Table && $importOptions->usingUserDefinedTypes()) { @@ -52,9 +52,9 @@ public function runCopyCommand( (new TeradataTableReflection( $this->connection, $source->getSchema(), - $source->getTableName() + $source->getTableName(), ))->getColumnsDefinitions(), - $destination->getColumnsDefinitions() + $destination->getColumnsDefinitions(), ); } @@ -67,7 +67,7 @@ public function runCopyCommand( $ref = new TeradataTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); return $ref->getRowsCount(); diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/StageTableDefinitionFactory.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/StageTableDefinitionFactory.php index b4f60a655..235af764a 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/StageTableDefinitionFactory.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/StageTableDefinitionFactory.php @@ -17,7 +17,7 @@ final class StageTableDefinitionFactory */ public static function createStagingTableDefinition( TeradataTableDefinition $destination, - array $sourceColumnsNames + array $sourceColumnsNames, ): TeradataTableDefinition { $newDefinitions = []; // create staging table for source columns in order @@ -36,8 +36,8 @@ public static function createStagingTableDefinition( 'length' => $definition->getColumnDefinition()->getLength(), 'nullable' => true, 'default' => $definition->getColumnDefinition()->getDefault(), - ] - ) + ], + ), ); continue 2; } @@ -51,7 +51,7 @@ public static function createStagingTableDefinition( StorageS3Helper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - $destination->getPrimaryKeysNames() + $destination->getPrimaryKeysNames(), ); } @@ -64,8 +64,8 @@ private static function createVarcharColumn(string $columnName): TeradataColumn [ 'length' => (string) Teradata::DEFAULT_NON_LATIN_CHAR_LENGTH, 'nullable' => true, - ] - ) + ], + ), ); } @@ -74,7 +74,7 @@ private static function createVarcharColumn(string $columnName): TeradataColumn */ public static function createStagingTableDefinitionWithText( TeradataTableDefinition $destination, - array $sourceColumnsNames + array $sourceColumnsNames, ): TeradataTableDefinition { $newDefinitions = []; foreach ($sourceColumnsNames as $columnName) { @@ -86,7 +86,7 @@ public static function createStagingTableDefinitionWithText( StorageS3Helper::generateStagingTableName(), true, new ColumnCollection($newDefinitions), - $destination->getPrimaryKeysNames() + $destination->getPrimaryKeysNames(), ); } @@ -95,14 +95,14 @@ public static function createStagingTableDefinitionWithText( */ public static function createDedupTableDefinition( TeradataTableDefinition $destination, - array $pkNames + array $pkNames, ): TeradataTableDefinition { return new TeradataTableDefinition( $destination->getSchemaName(), StorageS3Helper::generateTempDedupTableName(), true, $destination->getColumnsDefinitions(), - $pkNames + $pkNames, ); } } diff --git a/packages/php-db-import-export/src/Backend/Teradata/ToStage/ToStageImporter.php b/packages/php-db-import-export/src/Backend/Teradata/ToStage/ToStageImporter.php index c7346d5c5..c39f3ca51 100644 --- a/packages/php-db-import-export/src/Backend/Teradata/ToStage/ToStageImporter.php +++ b/packages/php-db-import-export/src/Backend/Teradata/ToStage/ToStageImporter.php @@ -24,7 +24,7 @@ final class ToStageImporter implements ToStageImporterInterface private Connection $connection; public function __construct( - Connection $connection + Connection $connection, ) { $this->connection = $connection; } @@ -32,7 +32,7 @@ public function __construct( public function importToStagingTable( Storage\SourceInterface $source, TableDefinitionInterface $destinationDefinition, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): ImportState { assert($destinationDefinition instanceof TeradataTableDefinition); assert($options instanceof TeradataImportOptions); @@ -46,8 +46,8 @@ public function importToStagingTable( $adapter->runCopyCommand( $source, $destinationDefinition, - $options - ) + $options, + ), ); } catch (Exception $e) { throw TeradataException::covertException($e); @@ -58,7 +58,7 @@ public function importToStagingTable( } private function getAdapter( - Storage\SourceInterface $source + Storage\SourceInterface $source, ): CopyAdapterInterface { switch (true) { case $source instanceof Storage\S3\SourceFile: @@ -71,8 +71,8 @@ private function getAdapter( throw new LogicException( sprintf( 'No suitable adapter found for source: "%s".', - get_class($source) - ) + get_class($source), + ), ); } } diff --git a/packages/php-db-import-export/src/Backend/ToFinalTableImporterInterface.php b/packages/php-db-import-export/src/Backend/ToFinalTableImporterInterface.php index 0375d4978..39d556ff3 100644 --- a/packages/php-db-import-export/src/Backend/ToFinalTableImporterInterface.php +++ b/packages/php-db-import-export/src/Backend/ToFinalTableImporterInterface.php @@ -14,6 +14,6 @@ public function importToTable( TableDefinitionInterface $stagingTableDefinition, TableDefinitionInterface $destinationTableDefinition, ImportOptionsInterface $options, - ImportState $state + ImportState $state, ): Result; } diff --git a/packages/php-db-import-export/src/Backend/ToStageImporterInterface.php b/packages/php-db-import-export/src/Backend/ToStageImporterInterface.php index d6fc0cf3b..e5f33cb1a 100644 --- a/packages/php-db-import-export/src/Backend/ToStageImporterInterface.php +++ b/packages/php-db-import-export/src/Backend/ToStageImporterInterface.php @@ -16,6 +16,6 @@ interface ToStageImporterInterface public function importToStagingTable( Storage\SourceInterface $source, TableDefinitionInterface $destinationDefinition, - ImportOptionsInterface $options + ImportOptionsInterface $options, ): ImportState; } diff --git a/packages/php-db-import-export/src/Exception/ColumnsMismatchException.php b/packages/php-db-import-export/src/Exception/ColumnsMismatchException.php index 054b5c2ce..ac20deb00 100644 --- a/packages/php-db-import-export/src/Exception/ColumnsMismatchException.php +++ b/packages/php-db-import-export/src/Exception/ColumnsMismatchException.php @@ -11,30 +11,30 @@ class ColumnsMismatchException extends ImportExportException { public static function createColumnsNamesMismatch( ColumnInterface $sourceDef, - ColumnInterface $destDef + ColumnInterface $destDef, ): ColumnsMismatchException { return new self(sprintf( 'Source destination columns name mismatch. "%s"->"%s"', $sourceDef->getColumnName(), - $destDef->getColumnName() + $destDef->getColumnName(), )); } public static function createColumnsMismatch( ColumnInterface $sourceDef, - ColumnInterface $destDef + ColumnInterface $destDef, ): ColumnsMismatchException { return new self(sprintf( 'Source destination columns mismatch. "%s %s"->"%s %s"', $sourceDef->getColumnName(), $sourceDef->getColumnDefinition()->getSQLDefinition(), $destDef->getColumnName(), - $destDef->getColumnDefinition()->getSQLDefinition() + $destDef->getColumnDefinition()->getSQLDefinition(), )); } public static function createColumnByNameMissing( - ColumnInterface $sourceDef + ColumnInterface $sourceDef, ): ColumnsMismatchException { return new self(sprintf( 'Source column "%s" not found in destination table', @@ -44,22 +44,22 @@ public static function createColumnByNameMissing( public static function createColumnsCountMismatch( ColumnCollection $source, - ColumnCollection $destination + ColumnCollection $destination, ): ColumnsMismatchException { $columnsSource = array_map( static fn(ColumnInterface $col) => $col->getColumnName(), - iterator_to_array($source->getIterator()) + iterator_to_array($source->getIterator()), ); $columnsDestination = array_map( static fn(ColumnInterface $col) => $col->getColumnName(), - iterator_to_array($destination->getIterator()) + iterator_to_array($destination->getIterator()), ); return new self( sprintf( 'Tables don\'t have same number of columns. Source columns: "%s", Destination columns: "%s"', implode(',', $columnsSource), - implode(',', $columnsDestination) - ) + implode(',', $columnsDestination), + ), ); } } diff --git a/packages/php-db-import-export/src/ExportOptions.php b/packages/php-db-import-export/src/ExportOptions.php index d16e8c3da..4f936d74c 100644 --- a/packages/php-db-import-export/src/ExportOptions.php +++ b/packages/php-db-import-export/src/ExportOptions.php @@ -19,7 +19,7 @@ class ExportOptions implements ExportOptionsInterface public function __construct( bool $isCompressed = false, - bool $generateManifest = self::MANIFEST_SKIP + bool $generateManifest = self::MANIFEST_SKIP, ) { $this->isCompressed = $isCompressed; $this->exportId = BackendHelper::generateRandomExportPrefix(); diff --git a/packages/php-db-import-export/src/ImportOptions.php b/packages/php-db-import-export/src/ImportOptions.php index 83760fb36..75c9cacb4 100644 --- a/packages/php-db-import-export/src/ImportOptions.php +++ b/packages/php-db-import-export/src/ImportOptions.php @@ -37,7 +37,7 @@ public function __construct( bool $useTimestamp = false, int $numberOfIgnoredLines = self::SKIP_NO_LINE, string $usingTypes = self::USING_TYPES_STRING, - array $ignoreColumns = [] + array $ignoreColumns = [], ) { $this->useTimestamp = $useTimestamp; $this->convertEmptyValuesToNull = $convertEmptyValuesToNull; diff --git a/packages/php-db-import-export/src/Storage/ABS/BaseFile.php b/packages/php-db-import-export/src/Storage/ABS/BaseFile.php index 70da0d952..425d2d45c 100644 --- a/packages/php-db-import-export/src/Storage/ABS/BaseFile.php +++ b/packages/php-db-import-export/src/Storage/ABS/BaseFile.php @@ -23,7 +23,7 @@ public function __construct( string $container, string $filePath, string $sasToken, - string $accountName + string $accountName, ) { $this->container = $container; $this->sasToken = $sasToken; @@ -46,7 +46,7 @@ public function getContainerUrl(string $protocol): string '%s://%s.blob.core.windows.net/%s/', $protocol, $this->accountName, - $this->container + $this->container, ); } @@ -56,13 +56,13 @@ public function getPolyBaseUrl(string $credentialsType): string return sprintf( 'abfss://%s@%s.dfs.core.windows.net/', $this->container, - $this->accountName + $this->accountName, ); } return sprintf( 'wasbs://%s@%s.blob.core.windows.net/', $this->container, - $this->accountName + $this->accountName, ); } public function getContainer(): string diff --git a/packages/php-db-import-export/src/Storage/ABS/BlobIterator.php b/packages/php-db-import-export/src/Storage/ABS/BlobIterator.php index e1b69093f..fc45a8aed 100644 --- a/packages/php-db-import-export/src/Storage/ABS/BlobIterator.php +++ b/packages/php-db-import-export/src/Storage/ABS/BlobIterator.php @@ -33,7 +33,7 @@ final class BlobIterator implements Iterator public function __construct( BlobRestProxy $blobRestProxy, string $container, - ?ListBlobsOptions $options = null + ?ListBlobsOptions $options = null, ) { $this->client = $blobRestProxy; if ($options === null) { diff --git a/packages/php-db-import-export/src/Storage/ABS/DestinationFile.php b/packages/php-db-import-export/src/Storage/ABS/DestinationFile.php index 4df8fd8b6..39dbf0001 100644 --- a/packages/php-db-import-export/src/Storage/ABS/DestinationFile.php +++ b/packages/php-db-import-export/src/Storage/ABS/DestinationFile.php @@ -21,7 +21,7 @@ public function __construct( string $filePath, string $sasToken, string $accountName, - ?string $blobMasterKey = null + ?string $blobMasterKey = null, ) { parent::__construct($container, $filePath, $sasToken, $accountName); $this->blobMasterKey = $blobMasterKey; @@ -49,11 +49,11 @@ public function getClient(): BlobRestProxy $this->accountName, Resources::BLOB_BASE_DNS_NAME, Resources::SAS_TOKEN_NAME, - $this->sasToken + $this->sasToken, ); return ClientFactory::createClientFromConnectionString( - $SASConnectionString + $SASConnectionString, ); } } diff --git a/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGenerator.php b/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGenerator.php index ba6aebb85..217fde53e 100644 --- a/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGenerator.php +++ b/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGenerator.php @@ -25,7 +25,7 @@ class AbsSlicedManifestFromFolderGenerator implements SlicedManifestGeneratorInt public function __construct( BlobRestProxy $absClient, - bool $usingPolyBaseExport = self::GENERATE_MANIFEST_DEFAULT + bool $usingPolyBaseExport = self::GENERATE_MANIFEST_DEFAULT, ) { $this->absClient = $absClient; $this->usingPolyBaseExport = $usingPolyBaseExport; @@ -65,7 +65,7 @@ public function generateAndSaveManifest(RelativePathInterface $path): void $this->absClient->createBlockBlob( $path->getRoot(), $path->getPathnameWithoutRoot() . 'manifest', - $encodedManifest + $encodedManifest, ); } } diff --git a/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromUnloadQueryResultGenerator.php b/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromUnloadQueryResultGenerator.php index 3aeb916af..487f292da 100644 --- a/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromUnloadQueryResultGenerator.php +++ b/packages/php-db-import-export/src/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromUnloadQueryResultGenerator.php @@ -22,7 +22,7 @@ class AbsSlicedManifestFromUnloadQueryResultGenerator implements SlicedManifestG public function __construct( BlobRestProxy $absClient, - string $accountName + string $accountName, ) { $this->absClient = $absClient; $this->accountName = $accountName; @@ -42,9 +42,9 @@ public function generateAndSaveManifest(RelativePathInterface $path, array $list $path->getProvider(), $path->getRoot(), '', - $object['FILE_NAME'] + $object['FILE_NAME'], ), - $this->accountName + $this->accountName, ))->getAbsoluteUrl(), 'mandatory' => true, ]; @@ -59,7 +59,7 @@ public function generateAndSaveManifest(RelativePathInterface $path, array $list $this->absClient->createBlockBlob( $path->getRoot(), $path->getPathnameWithoutRoot() . 'manifest', - $encodedManifest + $encodedManifest, ); } } diff --git a/packages/php-db-import-export/src/Storage/ABS/SnowflakeExportAdapter.php b/packages/php-db-import-export/src/Storage/ABS/SnowflakeExportAdapter.php index e0232f2c3..c38aacb64 100644 --- a/packages/php-db-import-export/src/Storage/ABS/SnowflakeExportAdapter.php +++ b/packages/php-db-import-export/src/Storage/ABS/SnowflakeExportAdapter.php @@ -40,7 +40,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( 'COPY INTO \'%s%s\' @@ -59,7 +59,7 @@ public function runCopyCommand( $destination->getFilePath(), $source->getFromStatement(), $destination->getSasToken(), - $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'" + $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'", ); $unloadedFiles = $this->connection->fetchAll($sql, $source->getQueryBindings()); @@ -67,7 +67,7 @@ public function runCopyCommand( if ($exportOptions->generateManifest()) { (new Storage\ABS\ManifestGenerator\AbsSlicedManifestFromUnloadQueryResultGenerator( $destination->getClient(), - $destination->getAccountName() + $destination->getAccountName(), ))->generateAndSaveManifest($destination->getRelativePath(), $unloadedFiles); } diff --git a/packages/php-db-import-export/src/Storage/ABS/SnowflakeImportAdapter.php b/packages/php-db-import-export/src/Storage/ABS/SnowflakeImportAdapter.php index edd1dc669..3431d37f0 100644 --- a/packages/php-db-import-export/src/Storage/ABS/SnowflakeImportAdapter.php +++ b/packages/php-db-import-export/src/Storage/ABS/SnowflakeImportAdapter.php @@ -44,7 +44,7 @@ public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): int { $commands = $this->getCommands($source, $destination, $importOptions, $stagingTableName); @@ -54,7 +54,7 @@ public function runCopyCommand( $rows = $this->connection->fetchAll($this->sqlBuilder->getTableItemsCountCommand( $destination->getSchema(), - $stagingTableName + $stagingTableName, )); return (int) $rows[0]['count']; @@ -67,7 +67,7 @@ private function getCommands( Storage\ABS\SourceFile $source, Storage\Snowflake\Table $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): array { $filesToImport = $source->getManifestEntries(); $commands = []; @@ -77,11 +77,11 @@ static function ($entry) use ($source) { return QuoteHelper::quote( strtr( $entry, - [$source->getContainerUrl(BaseFile::PROTOCOL_AZURE) => ''] - ) + [$source->getContainerUrl(BaseFile::PROTOCOL_AZURE) => ''], + ), ); }, - $entries + $entries, ); $commands[] = sprintf( @@ -98,10 +98,10 @@ static function ($entry) use ($source) { ' ', CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( $importOptions, - $source->getCsvOptions() - ) + $source->getCsvOptions(), + ), ), - implode(', ', $quotedFiles) + implode(', ', $quotedFiles), ); } return $commands; diff --git a/packages/php-db-import-export/src/Storage/ABS/SourceDirectory.php b/packages/php-db-import-export/src/Storage/ABS/SourceDirectory.php index b607f2de8..3826867a4 100644 --- a/packages/php-db-import-export/src/Storage/ABS/SourceDirectory.php +++ b/packages/php-db-import-export/src/Storage/ABS/SourceDirectory.php @@ -31,7 +31,7 @@ public function getLineEnding(): string $file = RelativePath::createFromRootAndPath( new AbsProvider(), $this->container, - $this->getBlobPath($blob->getUrl()) + $this->getBlobPath($blob->getUrl()), ); try { @@ -57,7 +57,7 @@ private function getEntriesInFolder(BlobRestProxy $blobClient): BlobIterator * @return string[] */ public function getManifestEntries( - string $protocol = self::PROTOCOL_AZURE + string $protocol = self::PROTOCOL_AZURE, ): array { $blobClient = $this->getBlobClient(); diff --git a/packages/php-db-import-export/src/Storage/ABS/SourceFile.php b/packages/php-db-import-export/src/Storage/ABS/SourceFile.php index e3b6dd74b..2c1513e91 100644 --- a/packages/php-db-import-export/src/Storage/ABS/SourceFile.php +++ b/packages/php-db-import-export/src/Storage/ABS/SourceFile.php @@ -48,7 +48,7 @@ public function __construct( bool $isSliced, array $columnsNames = [], ?array $primaryKeysNames = null, - ?string $blobMasterKey = null + ?string $blobMasterKey = null, ) { parent::__construct($container, $filePath, $sasToken, $accountName); $this->isSliced = $isSliced; @@ -94,7 +94,7 @@ public function getCsvOptions(): CsvOptions * @return string[] */ public function getManifestEntries( - string $protocol = self::PROTOCOL_AZURE + string $protocol = self::PROTOCOL_AZURE, ): array { $blobClient = $this->getBlobClient(); @@ -130,11 +130,11 @@ protected function getBlobClient(): BlobRestProxy $this->accountName, Resources::BLOB_BASE_DNS_NAME, Resources::SAS_TOKEN_NAME, - $this->sasToken + $this->sasToken, ); return ClientFactory::createClientFromConnectionString( - $SASConnectionString + $SASConnectionString, ); } @@ -145,7 +145,7 @@ protected function getBlobClient(): BlobRestProxy protected function transformManifestEntries( array $entries, string $protocol, - BlobRestProxy $blobClient + BlobRestProxy $blobClient, ): array { return array_map(function ($entryUrl) use ($protocol, $blobClient) { // this is temporary solution copy into is not failing when blob not exists diff --git a/packages/php-db-import-export/src/Storage/ABS/SynapseExportAdapter.php b/packages/php-db-import-export/src/Storage/ABS/SynapseExportAdapter.php index 77e0356b4..1478af563 100644 --- a/packages/php-db-import-export/src/Storage/ABS/SynapseExportAdapter.php +++ b/packages/php-db-import-export/src/Storage/ABS/SynapseExportAdapter.php @@ -44,7 +44,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $compression = $exportOptions->isCompressed() ? ',DATA_COMPRESSION = \'org.apache.hadoop.io.compress.GzipCodec\'' : @@ -65,7 +65,7 @@ public function runCopyCommand( $sql = $this->polyBase->getCredentialsQuery( $credentialsId, $exportOptions->getExportCredentialsType(), - $blobMasterKey + $blobMasterKey, ); $this->connection->exec($sql); @@ -92,7 +92,7 @@ public function runCopyCommand( $fileFormatId, $dataSourceId, $credentialsId, - $tableId + $tableId, ) as $sql ) { try { diff --git a/packages/php-db-import-export/src/Storage/ABS/TeradataExportTPTAdapter.php b/packages/php-db-import-export/src/Storage/ABS/TeradataExportTPTAdapter.php index 72daa27c5..e8d2fc8a7 100644 --- a/packages/php-db-import-export/src/Storage/ABS/TeradataExportTPTAdapter.php +++ b/packages/php-db-import-export/src/Storage/ABS/TeradataExportTPTAdapter.php @@ -36,7 +36,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { assert($source instanceof Storage\SqlSourceInterface); assert($destination instanceof DestinationFile); @@ -95,7 +95,7 @@ public function runCopyCommand( private function generateTPTExportScript( SqlSourceInterface $source, DestinationFile $destination, - TeradataExportOptions $exportOptions + TeradataExportOptions $exportOptions, ): array { $temp = new Temp(); $folder = $temp->getTmpFolder(); @@ -145,7 +145,7 @@ private function generateTPTExportScript( $path->getPathWithoutRoot() ? ($path->getPathWithoutRoot() . '/') : '', $path->getFileName() . ($exportOptions->isCompressed() ? '.gz' : ''), $exportOptions->generateABSSizeOptions(), - $source->getFromStatement() + $source->getFromStatement(), ); $jobVariableFile = sprintf( diff --git a/packages/php-db-import-export/src/Storage/Bigquery/SelectSource.php b/packages/php-db-import-export/src/Storage/Bigquery/SelectSource.php index 3867ab359..d2c7a38fd 100644 --- a/packages/php-db-import-export/src/Storage/Bigquery/SelectSource.php +++ b/packages/php-db-import-export/src/Storage/Bigquery/SelectSource.php @@ -34,7 +34,7 @@ public function __construct( array $queryBindings = [], array $columnsNames = [], array $dataTypes = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->query = $query; $this->queryBindings = $queryBindings; diff --git a/packages/php-db-import-export/src/Storage/Bigquery/Table.php b/packages/php-db-import-export/src/Storage/Bigquery/Table.php index 7b7ec2e0f..e086500b2 100644 --- a/packages/php-db-import-export/src/Storage/Bigquery/Table.php +++ b/packages/php-db-import-export/src/Storage/Bigquery/Table.php @@ -29,7 +29,7 @@ public function __construct( string $schema, string $tableName, array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->schema = $schema; $this->tableName = $tableName; @@ -52,7 +52,7 @@ public function getFromStatement(): string 'SELECT %s FROM %s.%s', $select, BigqueryQuote::quoteSingleIdentifier($this->getSchema()), - BigqueryQuote::quoteSingleIdentifier($this->getTableName()) + BigqueryQuote::quoteSingleIdentifier($this->getTableName()), ); } @@ -91,7 +91,7 @@ public function getQuotedTableWithScheme(): string return sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($this->schema), - BigqueryQuote::quoteSingleIdentifier($this->tableName) + BigqueryQuote::quoteSingleIdentifier($this->tableName), ); } @@ -110,7 +110,7 @@ public function getFromStatementWithStringCasting(): string 'SELECT %s FROM %s.%s', $select, BigqueryQuote::quoteSingleIdentifier($this->getSchema()), - BigqueryQuote::quoteSingleIdentifier($this->getTableName()) + BigqueryQuote::quoteSingleIdentifier($this->getTableName()), ); } } diff --git a/packages/php-db-import-export/src/Storage/Exasol/SelectSource.php b/packages/php-db-import-export/src/Storage/Exasol/SelectSource.php index 9101637a1..3346cb192 100644 --- a/packages/php-db-import-export/src/Storage/Exasol/SelectSource.php +++ b/packages/php-db-import-export/src/Storage/Exasol/SelectSource.php @@ -34,7 +34,7 @@ public function __construct( array $queryBindings = [], array $dataTypes = [], array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->query = $query; $this->queryBindings = $queryBindings; diff --git a/packages/php-db-import-export/src/Storage/Exasol/Table.php b/packages/php-db-import-export/src/Storage/Exasol/Table.php index 7daf2817e..6d05669e0 100644 --- a/packages/php-db-import-export/src/Storage/Exasol/Table.php +++ b/packages/php-db-import-export/src/Storage/Exasol/Table.php @@ -29,7 +29,7 @@ public function __construct( string $schema, string $tableName, array $columns = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->schema = $schema; $this->tableName = $tableName; @@ -64,7 +64,7 @@ public function getQuotedTableWithScheme(): string return sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($this->getSchema()), - ExasolQuote::quoteSingleIdentifier($this->getTableName()) + ExasolQuote::quoteSingleIdentifier($this->getTableName()), ); } diff --git a/packages/php-db-import-export/src/Storage/FileNotFoundException.php b/packages/php-db-import-export/src/Storage/FileNotFoundException.php index 6fbff1721..3f78b7101 100644 --- a/packages/php-db-import-export/src/Storage/FileNotFoundException.php +++ b/packages/php-db-import-export/src/Storage/FileNotFoundException.php @@ -18,7 +18,7 @@ public function __construct(string $message = '', ?Throwable $previous = null) } public static function createFromFileNotFoundException( - FileStorageFileNotFoundException $e + FileStorageFileNotFoundException $e, ): FileNotFoundException { return new self($e->getMessage(), $e); } diff --git a/packages/php-db-import-export/src/Storage/GCS/BaseFile.php b/packages/php-db-import-export/src/Storage/GCS/BaseFile.php index 7493f0cf7..b377490a2 100644 --- a/packages/php-db-import-export/src/Storage/GCS/BaseFile.php +++ b/packages/php-db-import-export/src/Storage/GCS/BaseFile.php @@ -17,7 +17,7 @@ abstract class BaseFile public function __construct( string $bucket, string $filePath, - string $storageIntegrationName + string $storageIntegrationName, ) { $this->filePath = $filePath; $this->bucket = $bucket; diff --git a/packages/php-db-import-export/src/Storage/GCS/DestinationFile.php b/packages/php-db-import-export/src/Storage/GCS/DestinationFile.php index ced5def2a..52b18b0df 100644 --- a/packages/php-db-import-export/src/Storage/GCS/DestinationFile.php +++ b/packages/php-db-import-export/src/Storage/GCS/DestinationFile.php @@ -45,7 +45,7 @@ public function __construct( string $bucket, string $filePath, string $storageIntegrationName, - array $credentials + array $credentials, ) { parent::__construct($bucket, $filePath, $storageIntegrationName); $this->credentials = $credentials; diff --git a/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromFolderGenerator.php b/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromFolderGenerator.php index 834020223..8aebbeabc 100644 --- a/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromFolderGenerator.php +++ b/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromFolderGenerator.php @@ -19,7 +19,7 @@ class GcsSlicedManifestFromFolderGenerator implements SlicedManifestGeneratorInt private StorageClient $client; public function __construct( - StorageClient $client + StorageClient $client, ) { $this->client = $client; } @@ -47,7 +47,7 @@ public function generateAndSaveManifest(RelativePathInterface $path): void ], JSON_THROW_ON_ERROR); $writeStream = new WriteStream(null, [ - 'chunkSize' => self::CHUNK_SIZE_256_KB + 'chunkSize' => self::CHUNK_SIZE_256_KB, ]); $uploader = $bucket->getStreamableUploader($writeStream, [ 'name' => $path->getPathnameWithoutRoot() . 'manifest', diff --git a/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGenerator.php b/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGenerator.php index 6867a7a2a..a0bceb9bc 100644 --- a/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGenerator.php +++ b/packages/php-db-import-export/src/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGenerator.php @@ -40,7 +40,7 @@ public function generateAndSaveManifest(RelativePathInterface $path, array $list 'entries' => $entries, ]; $writeStream = new WriteStream(null, [ - 'chunkSize' => self::CHUNK_SIZE_256_KB + 'chunkSize' => self::CHUNK_SIZE_256_KB, ]); $uploader = $bucket->getStreamableUploader($writeStream, [ 'name' => $path->getPathnameWithoutRoot() . 'manifest', diff --git a/packages/php-db-import-export/src/Storage/GCS/SnowflakeExportAdapter.php b/packages/php-db-import-export/src/Storage/GCS/SnowflakeExportAdapter.php index cfced9b8c..dc42351c6 100644 --- a/packages/php-db-import-export/src/Storage/GCS/SnowflakeExportAdapter.php +++ b/packages/php-db-import-export/src/Storage/GCS/SnowflakeExportAdapter.php @@ -42,7 +42,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( 'COPY INTO \'%s/%s\' @@ -61,14 +61,14 @@ public function runCopyCommand( $destination->getFilePath(), $source->getFromStatement(), $destination->getStorageIntegrationName(), - $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'" + $exportOptions->isCompressed() ? "COMPRESSION='GZIP'" : "COMPRESSION='NONE'", ); $unloadedFiles = $this->connection->fetchAll($sql, $source->getQueryBindings()); if ($exportOptions->generateManifest()) { (new Storage\GCS\ManifestGenerator\GcsSlicedManifestFromUnloadQueryResultGenerator( - $destination->getClient() + $destination->getClient(), )) ->generateAndSaveManifest($destination->getRelativePath(), $unloadedFiles); } diff --git a/packages/php-db-import-export/src/Storage/GCS/SourceFile.php b/packages/php-db-import-export/src/Storage/GCS/SourceFile.php index 946b43ca5..25e46071e 100644 --- a/packages/php-db-import-export/src/Storage/GCS/SourceFile.php +++ b/packages/php-db-import-export/src/Storage/GCS/SourceFile.php @@ -66,12 +66,12 @@ public function __construct( CsvOptions $csvOptions, bool $isSliced, array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { parent::__construct( $bucket, $filePath, - $storageIntegrationName + $storageIntegrationName, ); $this->isSliced = $isSliced; $this->csvOptions = $csvOptions; @@ -180,7 +180,7 @@ public function getPrefix(): string */ protected function transformManifestEntries( array $entries, - string $protocol + string $protocol, ): array { return array_map(static function ($entryUrl) use ($protocol): string { switch ($protocol) { diff --git a/packages/php-db-import-export/src/Storage/ManifestNotFoundException.php b/packages/php-db-import-export/src/Storage/ManifestNotFoundException.php index 1589b9eb6..17f8afeba 100644 --- a/packages/php-db-import-export/src/Storage/ManifestNotFoundException.php +++ b/packages/php-db-import-export/src/Storage/ManifestNotFoundException.php @@ -14,7 +14,7 @@ public function __construct(?Throwable $previous = null) parent::__construct( 'Load error: manifest file was not found.', Exception::MANDATORY_FILE_NOT_FOUND, - $previous + $previous, ); } } diff --git a/packages/php-db-import-export/src/Storage/S3/BaseFile.php b/packages/php-db-import-export/src/Storage/S3/BaseFile.php index 54ea5c6b9..3c05001d7 100644 --- a/packages/php-db-import-export/src/Storage/S3/BaseFile.php +++ b/packages/php-db-import-export/src/Storage/S3/BaseFile.php @@ -23,7 +23,7 @@ public function __construct( string $secret, string $region, string $bucket, - string $filePath + string $filePath, ) { $this->key = $key; $this->secret = $secret; diff --git a/packages/php-db-import-export/src/Storage/S3/ExasolExportAdapter.php b/packages/php-db-import-export/src/Storage/S3/ExasolExportAdapter.php index 59aee4f1f..f27150613 100644 --- a/packages/php-db-import-export/src/Storage/S3/ExasolExportAdapter.php +++ b/packages/php-db-import-export/src/Storage/S3/ExasolExportAdapter.php @@ -36,7 +36,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { assert($source instanceof Storage\SqlSourceInterface); assert($destination instanceof DestinationFile); @@ -47,7 +47,7 @@ public function runCopyCommand( static function ($entry) use ($suffix) { return 'FILE ' . ExasolQuote::quote($entry . $suffix); }, - $files + $files, ); $sql = sprintf( @@ -63,7 +63,7 @@ static function ($entry) use ($suffix) { $destination->getBucketURL(), $destination->getKey(), $destination->getSecret(), - implode("\n", $entries) + implode("\n", $entries), ); $this->connection->executeStatement($sql, $source->getQueryBindings()); diff --git a/packages/php-db-import-export/src/Storage/S3/SnowflakeExportAdapter.php b/packages/php-db-import-export/src/Storage/S3/SnowflakeExportAdapter.php index a6b482d0a..0c8973894 100644 --- a/packages/php-db-import-export/src/Storage/S3/SnowflakeExportAdapter.php +++ b/packages/php-db-import-export/src/Storage/S3/SnowflakeExportAdapter.php @@ -42,7 +42,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { $sql = sprintf( <<getCommands($source, $destination, $importOptions, $stagingTableName); @@ -55,7 +55,7 @@ public function runCopyCommand( $rows = $this->connection->fetchAll($this->sqlBuilder->getTableItemsCountCommand( $destination->getSchema(), - $stagingTableName + $stagingTableName, )); return (int) $rows[0]['count']; @@ -68,7 +68,7 @@ private function getCommands( Storage\S3\SourceFile $source, Storage\Snowflake\Table $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): array { $filesToImport = $source->getManifestEntries(); $commands = []; @@ -78,7 +78,7 @@ private function getCommands( static function ($entry) use ($s3Prefix) { return QuoteHelper::quote(strtr($entry, [$s3Prefix => ''])); }, - $entries + $entries, ); $commands[] = sprintf( @@ -96,9 +96,9 @@ static function ($entry) use ($s3Prefix) { QuoteHelper::quote($source->getRegion()), implode(' ', CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( $importOptions, - $source->getCsvOptions() + $source->getCsvOptions(), )), - implode(', ', $quotedFiles) + implode(', ', $quotedFiles), ); } return $commands; diff --git a/packages/php-db-import-export/src/Storage/S3/SourceFile.php b/packages/php-db-import-export/src/Storage/S3/SourceFile.php index 8c8ee0e6a..6400441b6 100644 --- a/packages/php-db-import-export/src/Storage/S3/SourceFile.php +++ b/packages/php-db-import-export/src/Storage/S3/SourceFile.php @@ -35,14 +35,14 @@ public function __construct( CsvOptions $csvOptions, bool $isSliced, array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { parent::__construct( $key, $secret, $region, $bucket, - $filePath + $filePath, ); $this->isSliced = $isSliced; $this->csvOptions = $csvOptions; diff --git a/packages/php-db-import-export/src/Storage/S3/TeradataExportTPTAdapter.php b/packages/php-db-import-export/src/Storage/S3/TeradataExportTPTAdapter.php index eaa001a7e..e6e3d0b57 100644 --- a/packages/php-db-import-export/src/Storage/S3/TeradataExportTPTAdapter.php +++ b/packages/php-db-import-export/src/Storage/S3/TeradataExportTPTAdapter.php @@ -34,7 +34,7 @@ public static function isSupported(Storage\SourceInterface $source, Storage\Dest public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ExportOptionsInterface $exportOptions + ExportOptionsInterface $exportOptions, ): array { assert($source instanceof Storage\SqlSourceInterface); assert($destination instanceof DestinationFile); @@ -54,7 +54,7 @@ public function runCopyCommand( [ 'AWS_ACCESS_KEY_ID' => $destination->getKey(), 'AWS_SECRET_ACCESS_KEY' => $destination->getSecret(), - ] + ], ); $process->setTimeout(self::TPT_TIMEOUT); $process->start(); @@ -98,7 +98,7 @@ public function runCopyCommand( private function generateTPTExportScript( SqlSourceInterface $source, DestinationFile $destination, - TeradataExportOptions $exportOptions + TeradataExportOptions $exportOptions, ): array { $temp = new Temp(); $folder = $temp->getTmpFolder(); @@ -134,7 +134,7 @@ private function generateTPTExportScript( $destination->getRegion(), $s3ConfigDir, $exportOptions->generateS3SizeOptions(), - $source->getFromStatement() + $source->getFromStatement(), ); $jobVariableFile = sprintf( diff --git a/packages/php-db-import-export/src/Storage/Snowflake/SelectSource.php b/packages/php-db-import-export/src/Storage/Snowflake/SelectSource.php index 88ae1f6f7..6ccc52c53 100644 --- a/packages/php-db-import-export/src/Storage/Snowflake/SelectSource.php +++ b/packages/php-db-import-export/src/Storage/Snowflake/SelectSource.php @@ -34,7 +34,7 @@ public function __construct( array $queryBindings = [], array $columnsNames = [], ?array $primaryKeysNames = null, - array $dataTypes = [] + array $dataTypes = [], // TODO when doing major update - this parametr should be on 3rd position as EXA/TD does ) { $this->query = $query; diff --git a/packages/php-db-import-export/src/Storage/Snowflake/SnowflakeImportAdapter.php b/packages/php-db-import-export/src/Storage/Snowflake/SnowflakeImportAdapter.php index a1e096a0f..2a6a0657e 100644 --- a/packages/php-db-import-export/src/Storage/Snowflake/SnowflakeImportAdapter.php +++ b/packages/php-db-import-export/src/Storage/Snowflake/SnowflakeImportAdapter.php @@ -43,7 +43,7 @@ public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): int { $quotedColumns = array_map(function ($column) { return $this->connection->quoteIdentifier($column); @@ -54,17 +54,17 @@ public function runCopyCommand( $this->connection->quoteIdentifier($destination->getSchema()), $this->connection->quoteIdentifier($stagingTableName), implode(', ', $quotedColumns), - $source->getFromStatement() + $source->getFromStatement(), ); $this->connection->query( $sql, - $source instanceof SelectSource ? $source->getQueryBindings() : [] + $source instanceof SelectSource ? $source->getQueryBindings() : [], ); $rows = $this->connection->fetchAll($this->sqlBuilder->getTableItemsCountCommand( $destination->getSchema(), - $stagingTableName + $stagingTableName, )); return (int) $rows[0]['count']; diff --git a/packages/php-db-import-export/src/Storage/Snowflake/Table.php b/packages/php-db-import-export/src/Storage/Snowflake/Table.php index eb37ed09e..a2a822296 100644 --- a/packages/php-db-import-export/src/Storage/Snowflake/Table.php +++ b/packages/php-db-import-export/src/Storage/Snowflake/Table.php @@ -29,7 +29,7 @@ public function __construct( string $schema, string $tableName, array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->schema = $schema; $this->tableName = $tableName; @@ -52,7 +52,7 @@ public function getFromStatement(): string 'SELECT %s FROM %s.%s', $select, QuoteHelper::quoteIdentifier($this->getSchema()), - QuoteHelper::quoteIdentifier($this->getTableName()) + QuoteHelper::quoteIdentifier($this->getTableName()), ); } @@ -91,7 +91,7 @@ public function getQuotedTableWithScheme(): string return sprintf( '%s.%s', QuoteHelper::quoteIdentifier($this->schema), - QuoteHelper::quoteIdentifier($this->tableName) + QuoteHelper::quoteIdentifier($this->tableName), ); } diff --git a/packages/php-db-import-export/src/Storage/Synapse/SelectSource.php b/packages/php-db-import-export/src/Storage/Synapse/SelectSource.php index eb31ce43a..4f7e9014f 100644 --- a/packages/php-db-import-export/src/Storage/Synapse/SelectSource.php +++ b/packages/php-db-import-export/src/Storage/Synapse/SelectSource.php @@ -35,7 +35,7 @@ public function __construct( array $queryBindings = [], array $dataTypes = [], array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->query = $query; $this->queryBindings = $queryBindings; diff --git a/packages/php-db-import-export/src/Storage/Synapse/Table.php b/packages/php-db-import-export/src/Storage/Synapse/Table.php index ed2f4b4b2..877471b59 100644 --- a/packages/php-db-import-export/src/Storage/Synapse/Table.php +++ b/packages/php-db-import-export/src/Storage/Synapse/Table.php @@ -30,7 +30,7 @@ public function __construct( string $schema, string $tableName, array $columns = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->schema = $schema; $this->tableName = $tableName; @@ -61,7 +61,7 @@ public function getFromStatementForStaging(bool $castValues): string { $quotedColumns = array_map( static fn(string $column) => SynapseQuote::quoteSingleIdentifier($column), - $this->getColumnsNames() + $this->getColumnsNames(), ); $castedColumns = []; @@ -70,9 +70,9 @@ public function getFromStatementForStaging(bool $castValues): string static fn(string $column): string => sprintf( 'CAST(%s as NVARCHAR(4000)) AS %s', $column, - $column + $column, ), - $quotedColumns + $quotedColumns, ); } @@ -83,13 +83,13 @@ public function getFromStatementForStaging(bool $castValues): string if ($castValues === true) { $quotedColumns = array_map( static fn(string $column) => sprintf('a.%s', $column), - $quotedColumns + $quotedColumns, ); $select = implode(', ', $quotedColumns); $from = sprintf( '(SELECT %s FROM %s) AS a', implode(', ', $castedColumns), - $from + $from, ); } } @@ -109,7 +109,7 @@ public function getQuotedTableWithScheme(): string return sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($this->schema), - SynapseQuote::quoteSingleIdentifier($this->tableName) + SynapseQuote::quoteSingleIdentifier($this->tableName), ); } diff --git a/packages/php-db-import-export/src/Storage/Teradata/SelectSource.php b/packages/php-db-import-export/src/Storage/Teradata/SelectSource.php index 5b087f2d9..be2124cb2 100644 --- a/packages/php-db-import-export/src/Storage/Teradata/SelectSource.php +++ b/packages/php-db-import-export/src/Storage/Teradata/SelectSource.php @@ -34,7 +34,7 @@ public function __construct( array $queryBindings = [], array $dataTypes = [], array $columnsNames = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->query = $query; $this->queryBindings = $queryBindings; diff --git a/packages/php-db-import-export/src/Storage/Teradata/Table.php b/packages/php-db-import-export/src/Storage/Teradata/Table.php index 860c73376..688a0a2ac 100644 --- a/packages/php-db-import-export/src/Storage/Teradata/Table.php +++ b/packages/php-db-import-export/src/Storage/Teradata/Table.php @@ -29,7 +29,7 @@ public function __construct( string $schema, string $tableName, array $columns = [], - ?array $primaryKeysNames = null + ?array $primaryKeysNames = null, ) { $this->schema = $schema; $this->tableName = $tableName; @@ -62,7 +62,7 @@ public function getQuotedTableWithScheme(): string return sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($this->getSchema()), - TeradataQuote::quoteSingleIdentifier($this->getTableName()) + TeradataQuote::quoteSingleIdentifier($this->getTableName()), ); } diff --git a/packages/php-db-import-export/src/Storage/Teradata/TeradataExportOptions.php b/packages/php-db-import-export/src/Storage/Teradata/TeradataExportOptions.php index 341467fcb..b1882e55a 100644 --- a/packages/php-db-import-export/src/Storage/Teradata/TeradataExportOptions.php +++ b/packages/php-db-import-export/src/Storage/Teradata/TeradataExportOptions.php @@ -40,11 +40,11 @@ public function __construct( string $maxObjectSize = self::DEFAULT_MAX_OBJECT_SIZE, bool $dontSplitRows = self::DEFAULT_SPLIT_ROWS, bool $singlePartFile = self::DEFAULT_SINGLE_PART_FILE, - bool $generateManifest = self::MANIFEST_SKIP + bool $generateManifest = self::MANIFEST_SKIP, ) { parent::__construct( $isCompressed, - $generateManifest + $generateManifest, ); $this->teradataHost = $teradataHost; $this->teradataUser = $teradataUser; @@ -109,7 +109,7 @@ public function generateS3SizeOptions(): string $this->dontSplitRows ? 'True' : 'False', $this->singlePartFile ? 'True' : 'False', $this->singlePartFile ? '' : (sprintf('S3MaxObjectSize=%s', $this->getMaxObjectSize())), - $this->bufferSize + $this->bufferSize, ); // !Error! Setting S3MaxObjectSize when S3SinglePartFile=True is unsupported } @@ -124,7 +124,7 @@ public function generateABSSizeOptions(): string $this->dontSplitRows ? 'True' : 'False', $this->singlePartFile ? 'True' : 'False', $this->singlePartFile ? '' : (sprintf('-MaxObjectSize %s', $this->getMaxObjectSize())), - $this->bufferSize + $this->bufferSize, ); // !Error! Setting S3MaxObjectSize when S3SinglePartFile=True is unsupported } diff --git a/packages/php-db-import-export/tests/Common/ABSSourceTrait.php b/packages/php-db-import-export/tests/Common/ABSSourceTrait.php index 6041b5f84..bd2e3ff8d 100644 --- a/packages/php-db-import-export/tests/Common/ABSSourceTrait.php +++ b/packages/php-db-import-export/tests/Common/ABSSourceTrait.php @@ -14,7 +14,7 @@ trait ABSSourceTrait { protected function createDummyABSSourceInstance( string $file, - bool $isSliced = false + bool $isSliced = false, ): Storage\ABS\SourceFile { return new Storage\ABS\SourceFile( 'absContainer', @@ -23,19 +23,19 @@ protected function createDummyABSSourceInstance( 'absAccount', new CsvOptions(), $isSliced, - [] + [], ); } protected function createABSSourceDestinationInstance( - string $filePath + string $filePath, ): Storage\ABS\DestinationFile { return new Storage\ABS\DestinationFile( (string) getenv('ABS_CONTAINER_NAME'), $filePath, $this->getCredentialsForAzureContainer((string) getenv('ABS_CONTAINER_NAME'), 'rwla'), (string) getenv('ABS_ACCOUNT_NAME'), - (string) getenv('ABS_ACCOUNT_KEY') + (string) getenv('ABS_ACCOUNT_KEY'), ); } @@ -48,7 +48,7 @@ protected function createABSSourceInstance( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ): Storage\ABS\SourceFile { return $this->createABSSourceInstanceFromCsv( $filePath, @@ -56,7 +56,7 @@ protected function createABSSourceInstance( $columns, $isSliced, $isDirectory, - $primaryKeys + $primaryKeys, ); } @@ -70,7 +70,7 @@ protected function createABSSourceInstanceFromCsv( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ): Storage\ABS\SourceFile { if ($isDirectory) { $class = Storage\ABS\SourceDirectory::class; @@ -92,11 +92,11 @@ protected function createABSSourceInstanceFromCsv( protected function getCredentialsForAzureContainer( string $container, - string $permissions = 'rwl' + string $permissions = 'rwl', ): string { $sasHelper = new BlobSharedAccessSignatureHelper( (string) getenv('ABS_ACCOUNT_NAME'), - (string) getenv('ABS_ACCOUNT_KEY') + (string) getenv('ABS_ACCOUNT_KEY'), ); $expirationDate = (new DateTime())->modify('+1hour'); return $sasHelper->generateBlobServiceSharedAccessSignatureToken( @@ -104,7 +104,7 @@ protected function getCredentialsForAzureContainer( $container, $permissions, $expirationDate, - (new DateTime()) + (new DateTime()), ); } } diff --git a/packages/php-db-import-export/tests/Common/GCSSourceTrait.php b/packages/php-db-import-export/tests/Common/GCSSourceTrait.php index a48c95d55..01a48e15d 100644 --- a/packages/php-db-import-export/tests/Common/GCSSourceTrait.php +++ b/packages/php-db-import-export/tests/Common/GCSSourceTrait.php @@ -17,7 +17,7 @@ protected function getGCSBucketEnvName(): string protected function createDummyGCSSourceInstance( string $file, - bool $isSliced = false + bool $isSliced = false, ): Storage\GCS\SourceFile { return new Storage\GCS\SourceFile( 'gcsBucket', @@ -37,7 +37,7 @@ protected function createDummyGCSSourceInstance( ], new CsvOptions(), $isSliced, - [] + [], ); } @@ -50,7 +50,7 @@ protected function createGCSSourceInstance( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ): Storage\GCS\SourceFile { return $this->createGCSSourceInstanceFromCsv( $filePath, @@ -58,7 +58,7 @@ protected function createGCSSourceInstance( $columns, $isSliced, $isDirectory, - $primaryKeys + $primaryKeys, ); } @@ -74,7 +74,7 @@ protected function createGCSSourceInstanceFromCsv( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ): Storage\GCS\SourceFile { if ($isDirectory) { throw new Exception('Directory not supported for GCS'); @@ -88,7 +88,7 @@ protected function createGCSSourceInstanceFromCsv( $options, $isSliced, $columns, - $primaryKeys + $primaryKeys, ); } diff --git a/packages/php-db-import-export/tests/Common/S3SourceTrait.php b/packages/php-db-import-export/tests/Common/S3SourceTrait.php index 69e689bcc..40e2ecd0d 100644 --- a/packages/php-db-import-export/tests/Common/S3SourceTrait.php +++ b/packages/php-db-import-export/tests/Common/S3SourceTrait.php @@ -11,7 +11,7 @@ trait S3SourceTrait { protected function createDummyS3SourceInstance( string $file, - bool $isSliced = false + bool $isSliced = false, ): Storage\S3\SourceFile { return new Storage\S3\SourceFile( 's3Key', @@ -21,7 +21,7 @@ protected function createDummyS3SourceInstance( $file, new CsvOptions(), $isSliced, - [] + [], ); } @@ -34,7 +34,7 @@ protected function createS3SourceInstance( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ): Storage\S3\SourceFile { return $this->createS3SourceInstanceFromCsv( $filePath, @@ -42,7 +42,7 @@ protected function createS3SourceInstance( $columns, $isSliced, $isDirectory, - $primaryKeys + $primaryKeys, ); } @@ -57,7 +57,7 @@ protected function createS3SourceInstanceFromCsv( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ): Storage\S3\SourceFile { if ($isDirectory) { $class = Storage\S3\SourceDirectory::class; @@ -74,7 +74,7 @@ protected function createS3SourceInstanceFromCsv( $options, $isSliced, $columns, - $primaryKeys + $primaryKeys, ); } } diff --git a/packages/php-db-import-export/tests/Common/StorageTrait.php b/packages/php-db-import-export/tests/Common/StorageTrait.php index 4113eab49..1033f0936 100644 --- a/packages/php-db-import-export/tests/Common/StorageTrait.php +++ b/packages/php-db-import-export/tests/Common/StorageTrait.php @@ -54,7 +54,7 @@ protected function getExportBlobDir(): string } protected function getDestinationInstance( - string $filePath + string $filePath, ): DestinationInterface { switch (getenv('STORAGE_TYPE')) { case StorageType::STORAGE_S3: @@ -63,7 +63,7 @@ protected function getDestinationInstance( (string) getenv('AWS_SECRET_ACCESS_KEY'), (string) getenv('AWS_REGION'), (string) getenv('AWS_S3_BUCKET'), - $filePath + $filePath, ); case StorageType::STORAGE_ABS: return new Storage\ABS\DestinationFile( @@ -71,14 +71,14 @@ protected function getDestinationInstance( $filePath, $this->getCredentialsForAzureContainer((string) getenv('ABS_CONTAINER_NAME'), 'rwla'), (string) getenv('ABS_ACCOUNT_NAME'), - (string) getenv('ABS_ACCOUNT_KEY') + (string) getenv('ABS_ACCOUNT_KEY'), ); case StorageType::STORAGE_GCS: return new Storage\GCS\DestinationFile( (string) getenv($this->getGCSBucketEnvName()), $filePath, (string) getenv('GCS_INTEGRATION_NAME'), - $this->getGCSCredentials() + $this->getGCSCredentials(), ); default: throw new Exception(sprintf('Unknown STORAGE_TYPE "%s".', getenv('STORAGE_TYPE'))); @@ -95,7 +95,7 @@ public function getSourceInstance( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ) { switch (getenv('STORAGE_TYPE')) { case StorageType::STORAGE_S3: @@ -123,7 +123,7 @@ public function getSourceInstance( $columns, $isSliced, $isDirectory, - $primaryKeys + $primaryKeys, ); } @@ -138,7 +138,7 @@ public function getSourceInstanceFromCsv( array $columns = [], bool $isSliced = false, bool $isDirectory = false, - ?array $primaryKeys = null + ?array $primaryKeys = null, ) { switch (getenv('STORAGE_TYPE')) { case StorageType::STORAGE_S3: @@ -164,7 +164,7 @@ public function getSourceInstanceFromCsv( $columns, $isSliced, $isDirectory, - $primaryKeys + $primaryKeys, ); } @@ -176,7 +176,7 @@ public function clearDestination(string $dirToClear): void $client = $this->createClient(); $client->deleteMatchingObjects( (string) getenv('AWS_S3_BUCKET'), - $dirToClear + $dirToClear, ); return; case StorageType::STORAGE_ABS: @@ -224,10 +224,10 @@ public function createClient() $connectionString = sprintf( 'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net', (string) getenv('ABS_ACCOUNT_NAME'), - (string) getenv('ABS_ACCOUNT_KEY') + (string) getenv('ABS_ACCOUNT_KEY'), ); return ClientFactory::createClientFromConnectionString( - $connectionString + $connectionString, ); case StorageType::STORAGE_GCS: return new StorageClient([ @@ -319,7 +319,7 @@ public function listFiles(string $dir, bool $excludeManifest = true): array */ public function getCsvFileFromStorage( array $files, - string $tmpName = 'tmp.csv' + string $tmpName = 'tmp.csv', ): CsvFile { $tmp = new Temp(); $tmpFolder = $tmp->getTmpFolder(); @@ -384,7 +384,7 @@ private function concatCsv(array $tmpFiles, string $finalFile): void } private function getAbsBlobContent( - string $blob + string $blob, ): string { $client = $this->createClient(); assert($client instanceof BlobRestProxy); diff --git a/packages/php-db-import-export/tests/Common/StubLoader/AbsLoader.php b/packages/php-db-import-export/tests/Common/StubLoader/AbsLoader.php index 1d822e3e2..f79d4fc12 100644 --- a/packages/php-db-import-export/tests/Common/StubLoader/AbsLoader.php +++ b/packages/php-db-import-export/tests/Common/StubLoader/AbsLoader.php @@ -26,14 +26,14 @@ class AbsLoader extends BaseStubLoader public function __construct( string $accountName, - string $containerName + string $containerName, ) { $this->accountName = $accountName; $this->containerName = $containerName; $this->connectionString = sprintf( 'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net', $accountName, - getenv('ABS_ACCOUNT_KEY') + getenv('ABS_ACCOUNT_KEY'), ); } @@ -62,7 +62,7 @@ public function getBlobService(): BlobRestProxy if ($this->blobService === null) { echo "Creating blob service \n"; $this->blobService = ClientFactory::createClientFromConnectionString( - $this->connectionString + $this->connectionString, ); } return $this->blobService; @@ -98,7 +98,7 @@ public function load(): void $promises[] = $this->getBlobService()->createBlockBlobAsync( $this->containerName, strtr($file->getPathname(), [self::BASE_DIR => '']), - $file->getContents() + $file->getContents(), ); } @@ -113,12 +113,12 @@ public function load(): void 'azure://%s.%s/%s/not-exists.csv', $this->accountName, Resources::BLOB_BASE_DNS_NAME, - $this->containerName + $this->containerName, ), 'mandatory' => true, ], ], - ], JSON_THROW_ON_ERROR) + ], JSON_THROW_ON_ERROR), ); foreach ($promises as $promise) { @@ -150,7 +150,7 @@ private function generateManifests(): void Resources::BLOB_BASE_DNS_NAME, $this->containerName, $directory->getBasename(), - $file->getFilename() + $file->getFilename(), ), 'mandatory' => true, ]; @@ -160,7 +160,7 @@ private function generateManifests(): void '%s/%s.%s.csvmanifest', $directory->getPathname(), self::MANIFEST_SUFFIX, - $directory->getBasename() + $directory->getBasename(), ); file_put_contents($manifestFilePath, guzzle_json_encode($manifest)); } diff --git a/packages/php-db-import-export/tests/Common/StubLoader/BaseStubLoader.php b/packages/php-db-import-export/tests/Common/StubLoader/BaseStubLoader.php index 7b827354b..d7bfe413e 100644 --- a/packages/php-db-import-export/tests/Common/StubLoader/BaseStubLoader.php +++ b/packages/php-db-import-export/tests/Common/StubLoader/BaseStubLoader.php @@ -22,7 +22,7 @@ public function generateLargeSliced(): void $sliceName = sprintf('sliced.csv_%d', $i); file_put_contents( self::BASE_DIR . 'sliced/2cols-large/' . $sliceName, - "\"a\",\"b\"\n" + "\"a\",\"b\"\n", ); } } @@ -34,7 +34,7 @@ public function generateLongCol(): void $file = BaseStubLoader::BASE_DIR . 'long_col_6k.csv'; file_put_contents( $file, - "\"col1\",\"col2\"\n" + "\"col1\",\"col2\"\n", ); $fp = fopen($file, 'ab'); assert($fp !== false); @@ -48,7 +48,7 @@ public function generateLongCol(): void $file = BaseStubLoader::BASE_DIR . 'long_col_10k.csv'; file_put_contents( $file, - "\"col1\",\"col2\"\n" + "\"col1\",\"col2\"\n", ); $fp = fopen($file, 'ab'); assert($fp !== false); diff --git a/packages/php-db-import-export/tests/Common/StubLoader/GCSLoader.php b/packages/php-db-import-export/tests/Common/StubLoader/GCSLoader.php index 38a3a5fb1..0970ee26e 100644 --- a/packages/php-db-import-export/tests/Common/StubLoader/GCSLoader.php +++ b/packages/php-db-import-export/tests/Common/StubLoader/GCSLoader.php @@ -36,7 +36,7 @@ class GCSLoader extends BaseStubLoader */ public function __construct( array $credentials, - string $bucketName + string $bucketName, ) { $this->client = new StorageClient([ 'keyFile' => $credentials, @@ -52,7 +52,7 @@ public function __construct( 'activate-service-account', '--key-file', '/tmp/gcs-credentials.json', - ] + ], ); $p->run(); echo $p->getOutput(); @@ -70,7 +70,7 @@ public function clearBucket(): void 'rm', '-r', 'gs://' . $this->bucketName . '/*', - ] + ], ); $p->setTimeout(60 * 10 * 1000); $p->run(); @@ -104,7 +104,7 @@ public function load(): void null, [ 'GOOGLE_APPLICATION_CREDENTIALS' => '/tmp/gcs-credentials.json', - ] + ], ); $p->setTimeout(60 * 10 * 1000); $p->run(); @@ -121,7 +121,7 @@ public function load(): void [ 'url' => sprintf( 'gs://%s/not-exists.csv', - $this->bucketName + $this->bucketName, ), 'mandatory' => true, ], @@ -129,7 +129,7 @@ public function load(): void ], JSON_THROW_ON_ERROR), [ 'name' => $blobName, - ] + ], ); return $resolve([$blobName, $res]); }); @@ -163,7 +163,7 @@ private function generateManifests(): void 'gs://%s/sliced/%s/%s', $this->bucketName, $directory->getBasename(), - $file->getFilename() + $file->getFilename(), ), 'mandatory' => true, ]; @@ -173,7 +173,7 @@ private function generateManifests(): void '%s/%s.%s.csvmanifest', $directory->getPathname(), self::MANIFEST_SUFFIX, - $directory->getBasename() + $directory->getBasename(), ); file_put_contents($manifestFilePath, json_encode($manifest, JSON_THROW_ON_ERROR)); } diff --git a/packages/php-db-import-export/tests/Common/StubLoader/S3Loader.php b/packages/php-db-import-export/tests/Common/StubLoader/S3Loader.php index bbac91b7d..e34b09cf7 100644 --- a/packages/php-db-import-export/tests/Common/StubLoader/S3Loader.php +++ b/packages/php-db-import-export/tests/Common/StubLoader/S3Loader.php @@ -25,7 +25,7 @@ class S3Loader extends BaseStubLoader public function __construct( string $region, string $bucket, - string $key + string $key, ) { $this->client = new S3Client([ 'region' => $region, @@ -74,7 +74,7 @@ public function load(): void 's3://' . $this->path, [ 'debug' => true, - ] + ], ); // Perform the transfer synchronously. @@ -88,7 +88,7 @@ public function load(): void [ 'url' => sprintf( 's3://%snot-exists.csv', - $this->path + $this->path, ), 'mandatory' => true, ], @@ -119,7 +119,7 @@ private function generateManifests(): void 's3://%ssliced/%s/%s', $this->path, $directory->getBasename(), - $file->getFilename() + $file->getFilename(), ), 'mandatory' => true, ]; @@ -129,7 +129,7 @@ private function generateManifests(): void '%s/%s.%s.csvmanifest', $directory->getPathname(), self::MANIFEST_SUFFIX, - $directory->getBasename() + $directory->getBasename(), ); file_put_contents($manifestFilePath, guzzle_json_encode($manifest)); } diff --git a/packages/php-db-import-export/tests/Common/StubLoader/loader.php b/packages/php-db-import-export/tests/Common/StubLoader/loader.php index 81be4977d..2c9b1e644 100644 --- a/packages/php-db-import-export/tests/Common/StubLoader/loader.php +++ b/packages/php-db-import-export/tests/Common/StubLoader/loader.php @@ -24,7 +24,7 @@ $loader = new AbsLoader( (string) getenv('ABS_ACCOUNT_NAME'), - (string) getenv('ABS_CONTAINER_NAME') + (string) getenv('ABS_CONTAINER_NAME'), ); $loader->deleteContainer(); $loader->createContainer(); @@ -36,7 +36,7 @@ $loader = new S3Loader( (string) getenv('AWS_REGION'), (string) getenv('AWS_S3_BUCKET'), - (string) getenv('AWS_S3_KEY') + (string) getenv('AWS_S3_KEY'), ); $loader->clearBucket(); $loader->load(); diff --git a/packages/php-db-import-export/tests/functional/Backend/Snowflake/SnowflakeExceptionTest.php b/packages/php-db-import-export/tests/functional/Backend/Snowflake/SnowflakeExceptionTest.php index 6157a661c..0935beeee 100644 --- a/packages/php-db-import-export/tests/functional/Backend/Snowflake/SnowflakeExceptionTest.php +++ b/packages/php-db-import-export/tests/functional/Backend/Snowflake/SnowflakeExceptionTest.php @@ -22,7 +22,7 @@ public function testCovertException( string $expectedException, string $expectedMessage, int $expectedCode, - bool $hasPrevious + bool $hasPrevious, ): void { $inputException = new RuntimeException($inputMessage); $convertedException = SnowflakeException::covertException($inputException); diff --git a/packages/php-db-import-export/tests/functional/Bigquery/BigqueryBaseTestCase.php b/packages/php-db-import-export/tests/functional/Bigquery/BigqueryBaseTestCase.php index 53831b239..d01204423 100644 --- a/packages/php-db-import-export/tests/functional/Bigquery/BigqueryBaseTestCase.php +++ b/packages/php-db-import-export/tests/functional/Bigquery/BigqueryBaseTestCase.php @@ -67,7 +67,7 @@ protected function getImportOptions( array $convertEmptyValuesToNull = [], bool $isIncremental = false, bool $useTimestamp = false, - int $numberOfIgnoredLines = 0 + int $numberOfIgnoredLines = 0, ): BigqueryImportOptions { return new BigqueryImportOptions( @@ -113,7 +113,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `isDeleted` INT64 )', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_OUT_CSV_2COLS: @@ -125,14 +125,14 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) - ) + BigqueryQuote::quoteSingleIdentifier($tableName), + ), )); $this->bqClient->runQuery($this->bqClient->query(sprintf( 'INSERT INTO %s.%s VALUES (\'x\', \'y\', CURRENT_TIMESTAMP());', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); $this->bqClient->runQuery($this->bqClient->query(sprintf( @@ -141,19 +141,19 @@ protected function initTable(string $tableName, string $dbName = ''): void `col2` STRING(50) );', BigqueryQuote::quoteSingleIdentifier($this->getSourceDbName()), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); $this->bqClient->runQuery($this->bqClient->query(sprintf( 'INSERT INTO %s.%s VALUES (\'a\', \'b\');', BigqueryQuote::quoteSingleIdentifier($this->getSourceDbName()), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); $this->bqClient->runQuery($this->bqClient->query(sprintf( 'INSERT INTO %s.%s VALUES (\'c\', \'d\');', BigqueryQuote::quoteSingleIdentifier($this->getSourceDbName()), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_OUT_LEMMA: @@ -165,7 +165,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_ACCOUNTS_3: @@ -186,7 +186,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP )', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_TABLE: @@ -198,7 +198,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_OUT_NO_TIMESTAMP_TABLE: @@ -208,7 +208,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `col2` STRING(50) );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_TYPES: @@ -221,7 +221,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); $this->bqClient->runQuery($this->bqClient->query(sprintf( @@ -232,14 +232,14 @@ protected function initTable(string $tableName, string $dbName = ''): void `boolCol` BOOL );', BigqueryQuote::quoteSingleIdentifier($this->getSourceDbName()), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); $this->bqClient->runQuery($this->bqClient->query(sprintf( 'INSERT INTO %s.%s VALUES (\'a\', 10.5, 0.3, TRUE) ;', BigqueryQuote::quoteSingleIdentifier($this->getSourceDbName()), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_ACCOUNTS_WITHOUT_TS: @@ -259,7 +259,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `idApp` STRING(2000000) ) ', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_COLUMN_NAME_ROW_NUMBER: @@ -270,7 +270,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP )', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_SINGLE_PK: @@ -283,7 +283,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `Other` STRING(2000000) );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_MULTI_PK: @@ -296,7 +296,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `Other` STRING(2000000) );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; case self::TABLE_MULTI_PK_WITH_TS: @@ -310,7 +310,7 @@ protected function initTable(string $tableName, string $dbName = ''): void `_timestamp` TIMESTAMP, );', BigqueryQuote::quoteSingleIdentifier($dbName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); break; default: @@ -319,20 +319,20 @@ protected function initTable(string $tableName, string $dbName = ''): void } protected function getSimpleImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): BigqueryImportOptions { return new BigqueryImportOptions( [], false, true, $skipLines, - BigqueryImportOptions::USING_TYPES_STRING + BigqueryImportOptions::USING_TYPES_STRING, ); } protected function initSingleTable( string $db = self::BIGQUERY_SOURCE_DATABASE_NAME, - string $table = self::TABLE_TABLE + string $table = self::TABLE_TABLE, ): void { if (!$this->datasetExists($db)) { $this->createDatabase($db); @@ -345,8 +345,8 @@ protected function initSingleTable( `Other` STRING(50) );', BigqueryQuote::quoteSingleIdentifier($db), - BigqueryQuote::quoteSingleIdentifier($table) - ) + BigqueryQuote::quoteSingleIdentifier($table), + ), )); } @@ -428,12 +428,12 @@ protected function assertBigqueryTableEqualsExpected( BigqueryImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = (new BigqueryTableReflection( $this->bqClient, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ))->getColumnsNames(); if ($options->useTimestamp()) { @@ -459,7 +459,7 @@ protected function assertBigqueryTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } @@ -473,7 +473,7 @@ public function fetchTable(string $schemaName, string $tableName, array $columns $result = $this->bqClient->runQuery($this->bqClient->query(sprintf( 'SELECT * FROM %s.%s', $schemaName, - $tableName + $tableName, ))); } else { $result = $this->bqClient->runQuery($this->bqClient->query(sprintf( @@ -482,7 +482,7 @@ public function fetchTable(string $schemaName, string $tableName, array $columns return BigqueryQuote::quoteSingleIdentifier($item); }, $columns)), BigqueryQuote::quoteSingleIdentifier($schemaName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ))); } @@ -504,14 +504,14 @@ public function fetchTable(string $schemaName, string $tableName, array $columns */ protected function cloneDefinitionWithDedupCol( BigqueryTableDefinition $destination, - array $dedupCols + array $dedupCols, ): BigqueryTableDefinition { return new BigqueryTableDefinition( $destination->getSchemaName(), $destination->getTableName(), $destination->isTemporary(), $destination->getColumnsDefinitions(), - $dedupCols + $dedupCols, ); } } diff --git a/packages/php-db-import-export/tests/functional/Bigquery/Exporter/ExportTest.php b/packages/php-db-import-export/tests/functional/Bigquery/Exporter/ExportTest.php index f0238c3b6..03ac20aeb 100644 --- a/packages/php-db-import-export/tests/functional/Bigquery/Exporter/ExportTest.php +++ b/packages/php-db-import-export/tests/functional/Bigquery/Exporter/ExportTest.php @@ -44,7 +44,7 @@ public function testExportGzip(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Bigquery\Table( $this->getDestinationDbName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->importTable($source, $destination); @@ -57,7 +57,7 @@ public function testExportGzip(): void (new Exporter($this->bqClient))->exportTable( $source, $destination, - $options + $options, ); $files = $this->getFileNames($this->getExportDir() . '/gz_test', false); @@ -79,7 +79,7 @@ public function testExportSimple(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Bigquery\Table( $this->getDestinationDbName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->importTable($source, $destination); @@ -91,7 +91,7 @@ public function testExportSimple(): void (new Exporter($this->bqClient))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -101,7 +101,7 @@ public function testExportSimple(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -115,7 +115,7 @@ public function assertCsvFilesSame(CsvFile $expected, CsvFile $actual): void iterator_to_array($expected), iterator_to_array($actual), 0, - 'Csv files are not same' + 'Csv files are not same', ); } @@ -127,7 +127,7 @@ public function testExportSimpleWithQuery(): void $source = $this->getSourceInstance('tw_accounts.csv', $file->getHeader()); $destination = new Storage\Bigquery\Table( $this->getDestinationDbName(), - self::TABLE_ACCOUNTS_3 + self::TABLE_ACCOUNTS_3, ); $this->importTable($source, $destination); @@ -137,7 +137,7 @@ public function testExportSimpleWithQuery(): void $query = sprintf( 'SELECT %s FROM %s', implode(',', $file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Bigquery\SelectSource($query); $options = new ExportOptions(false, ExportOptions::MANIFEST_AUTOGENERATED); @@ -146,7 +146,7 @@ public function testExportSimpleWithQuery(): void (new Exporter($this->bqClient))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -156,7 +156,7 @@ public function testExportSimpleWithQuery(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -166,29 +166,29 @@ public function testExportSimpleWithQuery(): void private function importTable( Storage\SourceInterface $source, - Storage\Bigquery\Table $destination + Storage\Bigquery\Table $destination, ): void { $options = $this->getSimpleImportOptions(ImportOptions::SKIP_FIRST_LINE); $importer = new ToStageImporter($this->bqClient); $destinationRef = new BigqueryTableReflection( $this->bqClient, $destination->getSchema(), - $destination->getTableName() + $destination->getTableName(), ); /** @var BigqueryTableDefinition $importDestination */ $importDestination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $importDestination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), )); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->bqClient); @@ -196,7 +196,7 @@ private function importTable( $stagingTable, $importDestination, $options, - $importState + $importState, ); } } diff --git a/packages/php-db-import-export/tests/functional/Bigquery/SqlBuildTest.php b/packages/php-db-import-export/tests/functional/Bigquery/SqlBuildTest.php index c04f882d8..21b1863a1 100644 --- a/packages/php-db-import-export/tests/functional/Bigquery/SqlBuildTest.php +++ b/packages/php-db-import-export/tests/functional/Bigquery/SqlBuildTest.php @@ -66,22 +66,22 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): B sprintf( 'INSERT INTO %s.%s(`pk1`,`pk2`,`col1`,`col2`) VALUES (\'1\',\'1\',\'1\',\'1\')', self::TEST_DB_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), )); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s.%s(`pk1`,`pk2`,`col1`,`col2`) VALUES (\'1\',\'1\',\'1\',\'1\')', self::TEST_DB_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), )); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s.%s(`pk1`,`pk2`,`col1`,`col2`) VALUES (\'2\',\'2\',\'2\',\'2\')', self::TEST_DB_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), )); if ($includeEmptyValues) { @@ -89,8 +89,8 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): B sprintf( 'INSERT INTO %s.%s(`pk1`,`pk2`,`col1`,`col2`) VALUES (\'2\',\'2\',\'\',NULL)', self::TEST_DB_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), )); } @@ -104,7 +104,7 @@ private function assertTableNotExists(string $schemaName, string $tableName): vo self::fail(sprintf( 'Table "%s.%s" is expected to not exist.', $schemaName, - $tableName + $tableName, )); } catch (Throwable $e) { } @@ -131,7 +131,7 @@ public function testGetDropTableIfExistsCommand(): void self::assertEquals( // phpcs:ignore 'DROP TABLE `import_export_test_schema`.`import_export_test_test`', - $sql + $sql, ); $this->bqClient->runQuery($this->bqClient->query($sql)); } catch (NotFoundException $e) { @@ -192,7 +192,7 @@ public function testGetInsertAllIntoTargetTableCommand(string $usingTypes, strin $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // no convert values no timestamp @@ -204,9 +204,9 @@ public function testGetInsertAllIntoTargetTableCommand(string $usingTypes, strin false, false, BigqueryImportOptions::SKIP_NO_LINE, - $usingTypes + $usingTypes, ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals($expectedSql, $sql); @@ -251,7 +251,7 @@ public function testGetInsertAllIntoTargetTableCommand(string $usingTypes, strin protected function createTestTableWithColumns( bool $includeTimestamp = false, - bool $includePrimaryKey = false + bool $includePrimaryKey = false, ): BigqueryTableDefinition { $columns = []; $pks = []; @@ -259,7 +259,7 @@ protected function createTestTableWithColumns( $pks[] = 'id'; $columns[] = new BigqueryColumn( 'id', - new Bigquery(Bigquery::TYPE_INT) + new Bigquery(Bigquery::TYPE_INT), ); } else { $columns[] = $this->createNullableGenericColumn('id'); @@ -270,7 +270,7 @@ protected function createTestTableWithColumns( if ($includeTimestamp) { $columns[] = new BigqueryColumn( '_timestamp', - new Bigquery(Bigquery::TYPE_TIMESTAMP) + new Bigquery(Bigquery::TYPE_TIMESTAMP), ); } @@ -279,10 +279,10 @@ protected function createTestTableWithColumns( self::TEST_TABLE, false, new ColumnCollection($columns), - $pks + $pks, ); $this->bqClient->runQuery($this->bqClient->query( - (new BigqueryTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition) + (new BigqueryTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition), )); return $tableDefinition; @@ -295,12 +295,12 @@ private function createNullableGenericColumn(string $columnName): BigqueryColumn [ 'length' => '50', // should be changed to max in future 'nullable' => true, - ] + ], ); return new BigqueryColumn( $columnName, - $definition + $definition, ); } @@ -343,7 +343,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(string $usin $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $sql = $this->getBuilder()->getInsertAllIntoTargetTableCommand( @@ -354,9 +354,9 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(string $usin false, false, BigqueryImportOptions::SKIP_NO_LINE, - $usingTypes + $usingTypes, ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals($expectedSql, $sql); $out = $this->bqClient->runQuery($this->bqClient->query($sql)); @@ -364,7 +364,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(string $usin $result = $this->bqClient->runQuery($this->bqClient->query(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_DB + self::TEST_TABLE_IN_DB, ))); $queryResult = array_map(static function (array $row) { @@ -422,7 +422,7 @@ public function getInsertAllIntoTargetTableCommandConvertToNullWithTimestampProv */ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp( string $usingTypes, - string $expectedSql + string $expectedSql, ): void { $this->createTestDb(); $destination = $this->createTestTableWithColumns(true); @@ -436,7 +436,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $sql = $this->getBuilder()->getInsertAllIntoTargetTableCommand( @@ -447,9 +447,9 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp false, true, // use timestamp BigqueryImportOptions::SKIP_NO_LINE, - $usingTypes + $usingTypes, ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals($expectedSql, $sql); $out = $this->bqClient->runQuery($this->bqClient->query($sql)); @@ -457,7 +457,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $result = $this->bqClient->runQuery($this->bqClient->query(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_DB + self::TEST_TABLE_IN_DB, ))); /** @var array $item */ @@ -480,7 +480,7 @@ public function testGetTruncateTableCommand(): void $sql = $this->getBuilder()->getTruncateTable(self::TEST_DB, self::TEST_STAGING_TABLE); self::assertEquals( 'TRUNCATE TABLE `import_export_test_schema`.`stagingTable`', - $sql + $sql, ); $this->bqClient->runQuery($this->bqClient->query($sql)); $ref->refresh(); @@ -525,7 +525,7 @@ public function testGetUpdateWithPkCommand(string $usingTypes, string $expectedS $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new BigqueryTableDefinition( @@ -536,15 +536,15 @@ public function testGetUpdateWithPkCommand(string $usingTypes, string $expectedS $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s.%s(`id`,`col1`,`col2`) VALUES (\'1\',\'2\',\'1\')', self::TEST_DB_QUOTED, - self::TEST_TABLE_QUOTED - ) + self::TEST_TABLE_QUOTED, + ), )); $result = $this->fetchTable(self::TEST_DB_QUOTED, self::TEST_TABLE_QUOTED); @@ -565,9 +565,9 @@ public function testGetUpdateWithPkCommand(string $usingTypes, string $expectedS false, false, BigqueryImportOptions::SKIP_NO_LINE, - $usingTypes + $usingTypes, ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals($expectedSql, $sql); $this->bqClient->runQuery($this->bqClient->query($sql)); @@ -620,7 +620,7 @@ public function testGetUpdateWithPkCommandConvertValues(string $usingTypes, stri $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new BigqueryTableDefinition( @@ -631,22 +631,22 @@ public function testGetUpdateWithPkCommandConvertValues(string $usingTypes, stri $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s.%s(`id`,`col1`,`col2`) VALUES (\'1\',\'\',\'1\')', self::TEST_DB_QUOTED, - self::TEST_TABLE_QUOTED - ) + self::TEST_TABLE_QUOTED, + ), )); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s.%s(`id`,`col1`,`col2`) VALUES (\'1\',\'2\',\'\')', self::TEST_DB_QUOTED, - self::TEST_TABLE_QUOTED - ) + self::TEST_TABLE_QUOTED, + ), )); $result = $this->fetchTable(self::TEST_DB_QUOTED, self::TEST_TABLE_QUOTED); @@ -671,7 +671,7 @@ public function testGetUpdateWithPkCommandConvertValues(string $usingTypes, stri $fakeStage, $fakeDestination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals($expectedSql, $sql); $this->bqClient->runQuery($this->bqClient->query($sql)); @@ -733,7 +733,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(string $usi $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new BigqueryTableDefinition( @@ -744,7 +744,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(string $usi $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->bqClient->runQuery($this->bqClient->query( @@ -752,16 +752,16 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(string $usi 'INSERT INTO %s.%s(`id`,`col1`,`col2`,`_timestamp`) VALUES (\'1\',\'\',\'1\',\'%s\')', self::TEST_DB_QUOTED, self::TEST_TABLE_QUOTED, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), )); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s.%s(`id`,`col1`,`col2`,`_timestamp`) VALUES (\'1\',\'2\',\'\',\'%s\')', self::TEST_DB_QUOTED, self::TEST_TABLE_QUOTED, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), )); self::assertEqualsCanonicalizing([ @@ -785,13 +785,13 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(string $usi false, true, BigqueryImportOptions::SKIP_NO_LINE, - $usingTypes + $usingTypes, ); $sql = $this->getBuilder()->getUpdateWithPkCommand( $fakeStage, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) + $timestampSet->format(DateTimeHelper::FORMAT), ); self::assertEquals($expectedSql, $sql); @@ -806,7 +806,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(string $usi self::assertIsString($item['_timestamp']); self::assertSame( $timestampSet->format(DateTimeHelper::FORMAT), - (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT) + (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT), ); } } @@ -848,28 +848,28 @@ public function testGetDeleteOldItemsCommand(string $usingTypes, string $expecte new BigqueryColumn( 'id', new Bigquery( - Bigquery::TYPE_INT - ) + Bigquery::TYPE_INT, + ), ), BigqueryColumn::createGenericColumn('pk1'), BigqueryColumn::createGenericColumn('pk2'), BigqueryColumn::createGenericColumn('col1'), BigqueryColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $tableSql = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query($qb->getCreateTableCommandFromDefinition($tableDefinition))); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s(`id`,`pk1`,`pk2`,`col1`,`col2`) VALUES (1,\'1\',\'1\',\'1\',\'1\')', - $tableSql - ) + $tableSql, + ), )); $stagingTableDefinition = new BigqueryTableDefinition( self::TEST_DB, @@ -881,33 +881,33 @@ public function testGetDeleteOldItemsCommand(string $usingTypes, string $expecte BigqueryColumn::createGenericColumn('col1'), BigqueryColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTableDefinition) + $qb->getCreateTableCommandFromDefinition($stagingTableDefinition), )); $stagingTableSql = sprintf( '%s.%s', BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + BigqueryQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s(`pk1`,`pk2`,`col1`,`col2`) VALUES (\'1\',\'1\',\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), )); $this->bqClient->runQuery($this->bqClient->query( sprintf( 'INSERT INTO %s(`pk1`,`pk2`,`col1`,`col2`) VALUES (\'2\',\'1\',\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), )); $sql = $this->getBuilder()->getDeleteOldItemsCommand( $stagingTableDefinition, $tableDefinition, - $this->getSimpleImportOptions() + $this->getSimpleImportOptions(), ); self::assertEquals($expectedSql, $sql); @@ -938,7 +938,7 @@ private function getStagingTableDefinition(): BigqueryTableDefinition $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); } } diff --git a/packages/php-db-import-export/tests/functional/Bigquery/StageImportTest.php b/packages/php-db-import-export/tests/functional/Bigquery/StageImportTest.php index 9e451057a..7659d473a 100644 --- a/packages/php-db-import-export/tests/functional/Bigquery/StageImportTest.php +++ b/packages/php-db-import-export/tests/functional/Bigquery/StageImportTest.php @@ -33,8 +33,8 @@ public function testSimpleStageImport(): void `last_name` STRING(100) );', BigqueryQuote::quoteSingleIdentifier(self::TEST_DATABASE), - BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $this->bqClient->runQuery($query); @@ -42,7 +42,7 @@ public function testSimpleStageImport(): void $ref = new BigqueryTableReflection( $this->bqClient, self::TEST_DATABASE, - self::TABLE_GENERIC + self::TABLE_GENERIC, ); $state = $importer->importToStagingTable( @@ -52,8 +52,8 @@ public function testSimpleStageImport(): void [], false, false, - 1 - ) + 1, + ), ); self::assertEquals(1, $state->getResult()->getImportedRowsCount()); @@ -100,8 +100,8 @@ public function testAsciiZeroImport(): void `CREDITS_USED_CLOUD_SERVICES` STRING(4000), );', BigqueryQuote::quoteSingleIdentifier(self::TEST_DATABASE), - BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $this->bqClient->runQuery($query); @@ -109,7 +109,7 @@ public function testAsciiZeroImport(): void $ref = new BigqueryTableReflection( $this->bqClient, self::TEST_DATABASE, - self::TABLE_GENERIC + self::TABLE_GENERIC, ); $state = $importer->importToStagingTable( @@ -119,8 +119,8 @@ public function testAsciiZeroImport(): void [], false, false, - 1 - ) + 1, + ), ); self::assertEquals(3, $state->getResult()->getImportedRowsCount()); @@ -137,8 +137,8 @@ public function testFailingImport(): void `first_name` STRING(1) );', BigqueryQuote::quoteSingleIdentifier(self::TEST_DATABASE), - BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $this->bqClient->runQuery($query); @@ -146,7 +146,7 @@ public function testFailingImport(): void $ref = new BigqueryTableReflection( $this->bqClient, self::TEST_DATABASE, - self::TABLE_GENERIC + self::TABLE_GENERIC, ); try { @@ -157,8 +157,8 @@ public function testFailingImport(): void [], false, false, - 1 - ) + 1, + ), ); self::fail('should fail'); } catch (BigqueryException $e) { @@ -181,8 +181,8 @@ public function testLoadFromFileWithNullValueToRequiredColumn(): void `price` STRING(100) );', BigqueryQuote::quoteSingleIdentifier(self::TEST_DATABASE), - BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $this->bqClient->runQuery($query); @@ -190,7 +190,7 @@ public function testLoadFromFileWithNullValueToRequiredColumn(): void $ref = new BigqueryTableReflection( $this->bqClient, self::TEST_DATABASE, - self::TABLE_GENERIC + self::TABLE_GENERIC, ); try { @@ -201,8 +201,8 @@ public function testLoadFromFileWithNullValueToRequiredColumn(): void [], false, false, - 1 - ) + 1, + ), ); self::fail('should fail'); } catch (Throwable $e) { @@ -233,8 +233,8 @@ public function testLoadFromTableWithNullValueToRequiredColumn(): void `name` STRING(100) NOT NULL, `price` STRING(100) );', - ...$destinationPath - ) + ...$destinationPath, + ), ); $this->bqClient->runQuery($query); @@ -248,8 +248,8 @@ public function testLoadFromTableWithNullValueToRequiredColumn(): void `name` STRING(100), `price` STRING(100) );', - ...$sourcePath - ) + ...$sourcePath, + ), ); $this->bqClient->runQuery($query); @@ -257,8 +257,8 @@ public function testLoadFromTableWithNullValueToRequiredColumn(): void $query = $this->bqClient->query( sprintf( 'INSERT INTO %s.%s VALUES (1, NULL, \'1000\');', - ...$sourcePath - ) + ...$sourcePath, + ), ); $this->bqClient->runQuery($query); @@ -266,7 +266,7 @@ public function testLoadFromTableWithNullValueToRequiredColumn(): void $ref = new BigqueryTableReflection( $this->bqClient, self::TEST_DATABASE, - $destinationTable + $destinationTable, ); try { @@ -283,8 +283,8 @@ public function testLoadFromTableWithNullValueToRequiredColumn(): void [], false, false, - 1 - ) + 1, + ), ); self::fail('should fail'); } catch (Throwable $e) { diff --git a/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/FullImportTest.php b/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/FullImportTest.php index 89a672410..2ae81cd60 100644 --- a/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/FullImportTest.php +++ b/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/FullImportTest.php @@ -42,7 +42,7 @@ public function testLoadToTableWithNullValuesShouldPass(): void false, false, BigqueryImportOptions::SKIP_FIRST_LINE, - BigqueryImportOptions::USING_TYPES_STRING + BigqueryImportOptions::USING_TYPES_STRING, ); $source = $this->getSourceInstance( 'multi-pk_null.csv', @@ -55,14 +55,14 @@ public function testLoadToTableWithNullValuesShouldPass(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->bqClient); $destinationRef = new BigqueryTableReflection( $this->bqClient, $this->getDestinationDbName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); /** @var BigqueryTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -76,12 +76,12 @@ public function testLoadToTableWithNullValuesShouldPass(): void ]); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), )); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->bqClient); @@ -89,7 +89,7 @@ public function testLoadToTableWithNullValuesShouldPass(): void $stagingTable, $destination, $options, - $importState + $importState, ); $destinationRef->refresh(); @@ -106,7 +106,7 @@ public function testLoadToFinalTableWithoutDedup(): void false, false, BigqueryImportOptions::SKIP_FIRST_LINE, - BigqueryImportOptions::USING_TYPES_STRING + BigqueryImportOptions::USING_TYPES_STRING, ); $source = $this->getSourceInstance( 'column-name-row-number.csv', @@ -116,14 +116,14 @@ public function testLoadToFinalTableWithoutDedup(): void ], false, false, - [] + [], ); $importer = new ToStageImporter($this->bqClient); $destinationRef = new BigqueryTableReflection( $this->bqClient, $this->getDestinationDbName(), - self::TABLE_COLUMN_NAME_ROW_NUMBER + self::TABLE_COLUMN_NAME_ROW_NUMBER, ); /** @var BigqueryTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -133,19 +133,19 @@ public function testLoadToFinalTableWithoutDedup(): void ]); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), )); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->bqClient); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $destinationRef->refresh(); @@ -162,7 +162,7 @@ public function testLoadToTableWithDedupWithSinglePK(): void false, false, BigqueryImportOptions::SKIP_FIRST_LINE, - BigqueryImportOptions::USING_TYPES_STRING + BigqueryImportOptions::USING_TYPES_STRING, ); $source = $this->getSourceInstance( 'multi-pk.csv', @@ -175,14 +175,14 @@ public function testLoadToTableWithDedupWithSinglePK(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->bqClient); $destinationRef = new BigqueryTableReflection( $this->bqClient, $this->getDestinationDbName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); /** @var BigqueryTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -196,19 +196,19 @@ public function testLoadToTableWithDedupWithSinglePK(): void ]); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), )); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->bqClient); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $destinationRef->refresh(); @@ -225,7 +225,7 @@ public function testLoadToTableWithDedupWithMultiPK(): void false, false, BigqueryImportOptions::SKIP_FIRST_LINE, - BigqueryImportOptions::USING_TYPES_STRING + BigqueryImportOptions::USING_TYPES_STRING, ); $source = $this->getSourceInstance( 'multi-pk.csv', @@ -238,14 +238,14 @@ public function testLoadToTableWithDedupWithMultiPK(): void ], false, false, - ['VisitID', 'Something'] + ['VisitID', 'Something'], ); $importer = new ToStageImporter($this->bqClient); $destinationRef = new BigqueryTableReflection( $this->bqClient, $this->getDestinationDbName(), - self::TABLE_MULTI_PK + self::TABLE_MULTI_PK, ); /** @var BigqueryTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -259,12 +259,12 @@ public function testLoadToTableWithDedupWithMultiPK(): void ]); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), )); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); // now 6 lines. Add one with same VisitId and Something as an existing line has @@ -273,15 +273,15 @@ public function testLoadToTableWithDedupWithMultiPK(): void sprintf( "INSERT INTO %s.%s VALUES ('134', 'xx', 'yy', 'abc', 'def');", BigqueryQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - BigqueryQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + BigqueryQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), )); $toFinalTableImporter = new FullImporter($this->bqClient); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $destinationRef->refresh(); @@ -310,7 +310,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), true, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -325,7 +325,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), true, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -340,7 +340,7 @@ public function fullImportData(): Generator $lemmaStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_LEMMA], $this->getSimpleImportOptions(), @@ -355,7 +355,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -370,7 +370,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -386,7 +386,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -401,7 +401,7 @@ public function fullImportData(): Generator $accountsChangedColumnsOrderStub->getColumns(), false, false, - ['id'] + ['id'], ), [ $this->getDestinationDbName(), @@ -418,7 +418,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(), @@ -434,7 +434,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(), @@ -450,7 +450,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), true, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -465,7 +465,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), true, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -481,7 +481,7 @@ public function fullImportData(): Generator ['column', 'table'], false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_TABLE], $this->getSimpleImportOptions(), @@ -500,7 +500,7 @@ public function fullImportData(): Generator ], false, false, - [] + [], ), [ $this->getDestinationDbName(), @@ -521,7 +521,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [ $this->getDestinationDbName(), @@ -531,7 +531,7 @@ public function fullImportData(): Generator [], false, false, // don't use timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), $escapingStub->getRows(), 7, @@ -555,7 +555,7 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationDbName(), @@ -579,7 +579,7 @@ public function testFullImportWithDataSet( BigqueryImportOptions $options, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { $this->initTable($tablesToInit); @@ -588,17 +588,17 @@ public function testFullImportWithDataSet( $destination = (new BigqueryTableReflection( $this->bqClient, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), )); $toStageImporter = new ToStageImporter($this->bqClient); $toFinalTableImporter = new FullImporter($this->bqClient); @@ -606,18 +606,18 @@ public function testFullImportWithDataSet( $importState = $toStageImporter->importToStagingTable( $source, $stagingTable, - $options + $options, ); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } finally { $sql = (new SqlBuilder())->getTableExistsCommand( $stagingTable->getSchemaName(), - $stagingTable->getTableName() + $stagingTable->getTableName(), ); $current = (array) $this->bqClient->runQuery($this->bqClient->query($sql))->getIterator()->current(); $count = $current['count']; @@ -625,7 +625,7 @@ public function testFullImportWithDataSet( if ($count > 0) { $this->bqClient->runQuery($this->bqClient->query((new SqlBuilder())->getDropTableUnsafe( $stagingTable->getSchemaName(), - $stagingTable->getTableName() + $stagingTable->getTableName(), ))); } } @@ -637,7 +637,7 @@ public function testFullImportWithDataSet( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/IncrementalImportTest.php b/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/IncrementalImportTest.php index 24a4cbab3..0f730d6ef 100644 --- a/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/IncrementalImportTest.php +++ b/packages/php-db-import-export/tests/functional/Bigquery/ToFinal/IncrementalImportTest.php @@ -22,14 +22,14 @@ class IncrementalImportTest extends BigqueryBaseTestCase { protected function getBigqueryIncrementalImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): BigqueryImportOptions { return new BigqueryImportOptions( [], true, true, $skipLines, - BigqueryImportOptions::USING_TYPES_STRING + BigqueryImportOptions::USING_TYPES_STRING, ); } @@ -58,7 +58,7 @@ public function incrementalImportData(): Generator $accountsNoDedupStub->getColumns(), false, false, - ['id'] + ['id'], ), $this->getSimpleImportOptions(), $this->getSourceInstance( @@ -66,7 +66,7 @@ public function incrementalImportData(): Generator $accountsNoDedupStub->getColumns(), false, false, - ['id'] + ['id'], ), $this->getBigqueryIncrementalImportOptions(), [$this->getDestinationDbName(), 'accounts-3'], @@ -81,7 +81,7 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), $this->getSimpleImportOptions(), $this->getSourceInstance( @@ -89,7 +89,7 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), $this->getBigqueryIncrementalImportOptions(), [$this->getDestinationDbName(), 'accounts-3'], @@ -104,26 +104,26 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), new BigqueryImportOptions( [], false, false, // disable timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), $this->getSourceInstance( 'tw_accounts.increment.csv', $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), new BigqueryImportOptions( [], true, // incremental false, // disable timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_WITHOUT_TS], $accountsStub->getRows(), @@ -137,7 +137,7 @@ public function incrementalImportData(): Generator $multiPKStub->getColumns(), false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSimpleImportOptions(), $this->getSourceInstance( @@ -145,7 +145,7 @@ public function incrementalImportData(): Generator $multiPKStub->getColumns(), false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getBigqueryIncrementalImportOptions(), [$this->getDestinationDbName(), self::TABLE_MULTI_PK_WITH_TS], @@ -171,7 +171,7 @@ public function testIncrementalImport( array $expected, int $expectedImportedRowCount, string $tablesToInit, - array $dedupCols + array $dedupCols, ): void { $this->initTable($tablesToInit); @@ -180,7 +180,7 @@ public function testIncrementalImport( $destination = (new BigqueryTableReflection( $this->bqClient, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); // update PK $destination = $this->cloneDefinitionWithDedupCol($destination, $dedupCols); @@ -191,59 +191,59 @@ public function testIncrementalImport( $fullLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $fullLoadSource->getColumnsNames() + $fullLoadSource->getColumnsNames(), ); $incrementalLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $incrementalSource->getColumnsNames() + $incrementalSource->getColumnsNames(), ); try { // full load $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable), )); $importState = $toStageImporter->importToStagingTable( $fullLoadSource, $fullLoadStagingTable, - $fullLoadOptions + $fullLoadOptions, ); $fullImporter->importToTable( $fullLoadStagingTable, $destination, $fullLoadOptions, - $importState + $importState, ); // incremental load $qb = new BigqueryTableQueryBuilder(); $this->bqClient->runQuery($this->bqClient->query( - $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable), )); $importState = $toStageImporter->importToStagingTable( $incrementalSource, $incrementalLoadStagingTable, - $incrementalOptions + $incrementalOptions, ); $result = $incrementalImporter->importToTable( $incrementalLoadStagingTable, $destination, $incrementalOptions, - $importState + $importState, ); } finally { $this->bqClient->runQuery($this->bqClient->query( (new SqlBuilder())->getDropTableIfExistsCommand( $fullLoadStagingTable->getSchemaName(), - $fullLoadStagingTable->getTableName() - ) + $fullLoadStagingTable->getTableName(), + ), )); $this->bqClient->runQuery($this->bqClient->query( (new SqlBuilder())->getDropTableIfExistsCommand( $incrementalLoadStagingTable->getSchemaName(), - $incrementalLoadStagingTable->getTableName() - ) + $incrementalLoadStagingTable->getTableName(), + ), )); } @@ -255,7 +255,7 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/DebugLogger.php b/packages/php-db-import-export/tests/functional/DebugLogger.php index 1dd68e40c..2600d25d8 100644 --- a/packages/php-db-import-export/tests/functional/DebugLogger.php +++ b/packages/php-db-import-export/tests/functional/DebugLogger.php @@ -27,8 +27,8 @@ public static function logMsg(string $message, string $level = LogLevel::INFO, a sprintf( '%s: %s', strtoupper($level), - self::interpolate($message, $context) - ) + self::interpolate($message, $context), + ), ); } diff --git a/packages/php-db-import-export/tests/functional/Exasol/ExasolBaseTestCase.php b/packages/php-db-import-export/tests/functional/Exasol/ExasolBaseTestCase.php index 3c1aa869e..c0376df1c 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/ExasolBaseTestCase.php +++ b/packages/php-db-import-export/tests/functional/Exasol/ExasolBaseTestCase.php @@ -43,7 +43,7 @@ private function getExasolConnection(): Connection (string) getenv('EXASOL_HOST'), (string) getenv('EXASOL_USERNAME'), (string) getenv('EXASOL_PASSWORD'), - $this->getDoctrineLogger() + $this->getDoctrineLogger(), ); } @@ -52,7 +52,7 @@ protected function insertRowToTable( string $tableName, int $id, string $firstName, - string $lastName + string $lastName, ): void { $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (%d, %s, %s)', @@ -60,13 +60,13 @@ protected function insertRowToTable( ExasolQuote::quoteSingleIdentifier($tableName), $id, ExasolQuote::quote($firstName), - ExasolQuote::quote($lastName) + ExasolQuote::quote($lastName), )); } protected function initSingleTable( string $schema = self::EXASOL_SOURCE_SCHEMA_NAME, - string $table = self::TABLE_TABLE + string $table = self::TABLE_TABLE, ): void { if (!$this->schemaExists($schema)) { $this->createSchema($schema); @@ -80,8 +80,8 @@ protected function initSingleTable( "last_name" VARCHAR(100) );', ExasolQuote::quoteSingleIdentifier($schema), - ExasolQuote::quoteSingleIdentifier($table) - ) + ExasolQuote::quoteSingleIdentifier($table), + ), ); } @@ -96,8 +96,8 @@ protected function initTable(string $tableName): void "col2" VARCHAR(20000) );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) - ) + ExasolQuote::quoteSingleIdentifier($tableName), + ), ); break; case self::TABLE_OUT_CSV_2COLS: @@ -109,14 +109,14 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) - ) + ExasolQuote::quoteSingleIdentifier($tableName), + ), ); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'x\', \'y\', NOW());', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( @@ -125,19 +125,19 @@ protected function initTable(string $tableName): void "col2" VARCHAR(2000000) );', ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'a\', \'b\');', ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'c\', \'d\');', ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_ACCOUNTS_WITHOUT_TS: @@ -158,7 +158,7 @@ protected function initTable(string $tableName): void CONSTRAINT PRIMARY KEY ("id") ) ', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_NULLIFY: @@ -169,7 +169,7 @@ protected function initTable(string $tableName): void "col2" VARCHAR(2000000) ) ', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_TYPES: @@ -181,7 +181,7 @@ protected function initTable(string $tableName): void "boolCol" VARCHAR(2000000) , "_timestamp" TIMESTAMP );', - ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()) + ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), )); $this->connection->executeQuery(sprintf( @@ -191,13 +191,13 @@ protected function initTable(string $tableName): void "floatCol" float , "boolCol" tinyint );', - ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()) + ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s."types" VALUES (\'a\', \'10.5\', \'0.3\', 1) ;', - ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()) + ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()), )); break; case self::TABLE_COLUMN_NAME_ROW_NUMBER: @@ -208,7 +208,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP )', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_SINGLE_PK: @@ -222,7 +222,7 @@ protected function initTable(string $tableName): void CONSTRAINT PRIMARY KEY ("VisitID") );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_MULTI_PK: @@ -236,7 +236,7 @@ protected function initTable(string $tableName): void CONSTRAINT PRIMARY KEY ("VisitID", "Something") );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; // table just for EXA because PK cannot have null nor '' @@ -252,7 +252,7 @@ protected function initTable(string $tableName): void CONSTRAINT PRIMARY KEY ("VisitID", "Value", "MenuItem") );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_ACCOUNTS_3: @@ -274,7 +274,7 @@ protected function initTable(string $tableName): void CONSTRAINT PRIMARY KEY ("id") );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_LEMMA: @@ -286,7 +286,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_TABLE: @@ -298,7 +298,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_NO_TIMESTAMP_TABLE: @@ -308,7 +308,7 @@ protected function initTable(string $tableName): void "col2" VARCHAR(2000000) );', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), )); break; default: @@ -339,8 +339,8 @@ protected function cleanSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'DROP SCHEMA %s CASCADE', - ExasolQuote::quoteSingleIdentifier($schemaName) - ) + ExasolQuote::quoteSingleIdentifier($schemaName), + ), ); } @@ -349,8 +349,8 @@ protected function schemaExists(string $schemaName): bool return (bool) $this->connection->fetchOne( sprintf( 'SELECT "SCHEMA_NAME" FROM "SYS"."EXA_ALL_SCHEMAS" WHERE "SCHEMA_NAME" = %s', - ExasolQuote::quote($schemaName) - ) + ExasolQuote::quote($schemaName), + ), ); } @@ -359,20 +359,20 @@ public function createSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'CREATE SCHEMA %s;', - ExasolQuote::quoteSingleIdentifier($schemaName) - ) + ExasolQuote::quoteSingleIdentifier($schemaName), + ), ); } protected function getExasolImportOptions( int $skipLines = 1, - bool $useTimeStamp = true + bool $useTimeStamp = true, ): ExasolImportOptions { return new ExasolImportOptions( [], false, $useTimeStamp, - $skipLines + $skipLines, ); } @@ -387,12 +387,12 @@ protected function assertExasolTableEqualsExpected( ExasolImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = (new ExasolTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ))->getColumnsNames(); if ($options->useTimestamp()) { @@ -417,7 +417,7 @@ protected function assertExasolTableEqualsExpected( return ExasolQuote::quoteSingleIdentifier($item); }, $tableColumns)), ExasolQuote::quoteSingleIdentifier($destination->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($destination->getTableName()) + ExasolQuote::quoteSingleIdentifier($destination->getTableName()), ); $queryResult = array_map(static function ($row) { @@ -430,7 +430,7 @@ protected function assertExasolTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } } diff --git a/packages/php-db-import-export/tests/functional/Exasol/ExportTest.php b/packages/php-db-import-export/tests/functional/Exasol/ExportTest.php index 762c49a9f..cf4133c18 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/ExportTest.php +++ b/packages/php-db-import-export/tests/functional/Exasol/ExportTest.php @@ -48,7 +48,7 @@ public function testExportGzip(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Exasol\Table( $schema, - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $options = $this->getSimpleImportOptions(); @@ -62,7 +62,7 @@ public function testExportGzip(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -77,13 +77,13 @@ public function testExportGzip(): void * @return ExasolImportOptions */ protected function getSimpleImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): ImportOptions { return new ExasolImportOptions( [], false, true, - $skipLines + $skipLines, ); } @@ -96,34 +96,34 @@ protected function getSimpleImportOptions( private function importTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ImportOptions $options + ImportOptions $options, ): void { $importer = new ToStageImporter($this->connection); $destinationRef = new ExasolTableReflection( $this->connection, $destination->getSchema(), - $destination->getTableName() + $destination->getTableName(), ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } @@ -135,7 +135,7 @@ public function testExportSimple(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Exasol\Table( $this->getDestinationSchemaName(), - 'out_csv_2Cols' + 'out_csv_2Cols', ); $options = $this->getSimpleImportOptions(); $this->importTable($source, $destination, $options); @@ -148,7 +148,7 @@ public function testExportSimple(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -160,7 +160,7 @@ public function testExportSimple(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -176,7 +176,7 @@ public function testExportSimpleWithQuery(): void $source = $this->getSourceInstance('tw_accounts.csv', $file->getHeader()); $destination = new Storage\Exasol\Table( $this->getDestinationSchemaName(), - 'accounts-3' + 'accounts-3', ); $options = $this->getSimpleImportOptions(); @@ -187,7 +187,7 @@ public function testExportSimpleWithQuery(): void $query = sprintf( 'SELECT %s FROM %s', (new SqlBuilder)->getColumnsString($file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Exasol\SelectSource($query); $options = new ExportOptions(false, ExportOptions::MANIFEST_AUTOGENERATED); @@ -196,7 +196,7 @@ public function testExportSimpleWithQuery(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -208,7 +208,7 @@ public function testExportSimpleWithQuery(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); diff --git a/packages/php-db-import-export/tests/functional/Exasol/FullImportTest.php b/packages/php-db-import-export/tests/functional/Exasol/FullImportTest.php index f55770a31..d07d41d32 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/FullImportTest.php +++ b/packages/php-db-import-export/tests/functional/Exasol/FullImportTest.php @@ -52,14 +52,14 @@ public function testLoadToTableFailOnNullConstraint(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -71,12 +71,12 @@ public function testLoadToTableFailOnNullConstraint(): void ]); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); @@ -86,7 +86,7 @@ public function testLoadToTableFailOnNullConstraint(): void $stagingTable, $destination, $options, - $importState + $importState, ); } @@ -104,14 +104,14 @@ public function testLoadToFinalTableWithoutDedup(): void ], false, false, - [] + [], ); $importer = new ToStageImporter($this->connection); $destinationRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_COLUMN_NAME_ROW_NUMBER + self::TABLE_COLUMN_NAME_ROW_NUMBER, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -120,19 +120,19 @@ public function testLoadToFinalTableWithoutDedup(): void ]); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(2, $destinationRef->getRowsCount()); @@ -155,14 +155,14 @@ public function testLoadToTableWithDedupWithSinglePK(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -174,19 +174,19 @@ public function testLoadToTableWithDedupWithSinglePK(): void ]); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(4, $destinationRef->getRowsCount()); @@ -209,14 +209,14 @@ public function testLoadToTableWithDedupWithMultiPK(): void ], false, false, - ['VisitID', 'Something'] + ['VisitID', 'Something'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_MULTI_PK + self::TABLE_MULTI_PK, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -228,12 +228,12 @@ public function testLoadToTableWithDedupWithMultiPK(): void ]); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); // now 6 lines. Add one with same VisitId and Something as an existing line has @@ -242,15 +242,15 @@ public function testLoadToTableWithDedupWithMultiPK(): void sprintf( "INSERT INTO %s.%s VALUES ('134', 'xx', 'yy', 'abc', 'def');", ExasolQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + ExasolQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(6, $destinationRef->getRowsCount()); @@ -300,7 +300,7 @@ public function fullImportData(): Generator $escapingHeader, true, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getExasolImportOptions(ImportOptions::SKIP_NO_LINE), @@ -315,7 +315,7 @@ public function fullImportData(): Generator $escapingHeader, true, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getExasolImportOptions(ImportOptions::SKIP_NO_LINE), @@ -330,7 +330,7 @@ public function fullImportData(): Generator $lemmaHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_LEMMA], $this->getExasolImportOptions(), @@ -345,7 +345,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getExasolImportOptions(), @@ -360,7 +360,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getExasolImportOptions(), @@ -376,7 +376,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getExasolImportOptions(), @@ -391,7 +391,7 @@ public function fullImportData(): Generator $accountChangedColumnsOrderHeader, false, false, - ['id'] + ['id'], ), [ $this->getDestinationSchemaName(), @@ -408,7 +408,7 @@ public function fullImportData(): Generator $accountsHeader, false, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getExasolImportOptions(), @@ -440,7 +440,7 @@ public function fullImportData(): Generator $accountsHeader, true, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getExasolImportOptions(ImportOptions::SKIP_NO_LINE), @@ -455,7 +455,7 @@ public function fullImportData(): Generator $accountsHeader, true, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getExasolImportOptions(ImportOptions::SKIP_NO_LINE), @@ -471,7 +471,7 @@ public function fullImportData(): Generator $accountsHeader, true, true, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getExasolImportOptions(ImportOptions::SKIP_NO_LINE), @@ -487,7 +487,7 @@ public function fullImportData(): Generator ['column', 'table'], false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_TABLE], $this->getExasolImportOptions(), @@ -506,7 +506,7 @@ public function fullImportData(): Generator ], false, false, - [] + [], ), [ $this->getDestinationSchemaName(), @@ -527,7 +527,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [ $this->getDestinationSchemaName(), @@ -537,7 +537,7 @@ public function fullImportData(): Generator [], false, false, // don't use timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), $expectedEscaping, 7, @@ -561,7 +561,7 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationSchemaName(), @@ -585,7 +585,7 @@ public function testFullImportWithDataSet( ExasolImportOptions $options, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { $this->initTable($tablesToInit); @@ -594,16 +594,16 @@ public function testFullImportWithDataSet( $destination = (new ExasolTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $toStageImporter = new ToStageImporter($this->connection); $toFinalTableImporter = new FullImporter($this->connection); @@ -611,20 +611,20 @@ public function testFullImportWithDataSet( $importState = $toStageImporter->importToStagingTable( $source, $stagingTable, - $options + $options, ); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $stagingTable->getSchemaName(), - $stagingTable->getTableName() - ) + $stagingTable->getTableName(), + ), ); } @@ -635,7 +635,7 @@ public function testFullImportWithDataSet( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Exasol/IncrementalImportTest.php b/packages/php-db-import-export/tests/functional/Exasol/IncrementalImportTest.php index 6ef418e01..727bdf1cc 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/IncrementalImportTest.php +++ b/packages/php-db-import-export/tests/functional/Exasol/IncrementalImportTest.php @@ -24,13 +24,13 @@ class IncrementalImportTest extends ExasolBaseTestCase use S3SourceTrait; protected function getExasolIncrementalImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): ExasolImportOptions { return new ExasolImportOptions( [], true, true, - $skipLines + $skipLines, ); } @@ -73,7 +73,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getExasolImportOptions(), $this->createS3SourceInstance( @@ -81,7 +81,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getExasolIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'accounts-3'], @@ -95,26 +95,26 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), new ExasolImportOptions( [], false, false, // disable timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), $this->createS3SourceInstance( 'tw_accounts.increment.csv', $accountColumns, false, false, - ['id'] + ['id'], ), new ExasolImportOptions( [], true, // incremental false, // disable timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_WITHOUT_TS], $expectedAccountsRows, @@ -127,7 +127,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getExasolImportOptions(), $this->createS3SourceInstance( @@ -135,7 +135,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getExasolIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'multi-pk_ts'], @@ -159,7 +159,7 @@ public function testIncrementalImport( array $table, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { $this->initTable($tablesToInit); @@ -167,7 +167,7 @@ public function testIncrementalImport( $destination = (new ExasolTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $toStageImporter = new ToStageImporter($this->connection); @@ -176,59 +176,59 @@ public function testIncrementalImport( $fullLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $fullLoadSource->getColumnsNames() + $fullLoadSource->getColumnsNames(), ); $incrementalLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $incrementalSource->getColumnsNames() + $incrementalSource->getColumnsNames(), ); try { // full load $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $fullLoadSource, $fullLoadStagingTable, - $fullLoadOptions + $fullLoadOptions, ); $fullImporter->importToTable( $fullLoadStagingTable, $destination, $fullLoadOptions, - $importState + $importState, ); // incremental load $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $incrementalSource, $incrementalLoadStagingTable, - $incrementalOptions + $incrementalOptions, ); $result = $incrementalImporter->importToTable( $incrementalLoadStagingTable, $destination, $incrementalOptions, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $fullLoadStagingTable->getSchemaName(), - $fullLoadStagingTable->getTableName() - ) + $fullLoadStagingTable->getTableName(), + ), ); $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $incrementalLoadStagingTable->getSchemaName(), - $incrementalLoadStagingTable->getTableName() - ) + $incrementalLoadStagingTable->getTableName(), + ), ); } @@ -240,7 +240,7 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Exasol/SqlBuilderTest.php b/packages/php-db-import-export/tests/functional/Exasol/SqlBuilderTest.php index 93d4f23d5..e291078d2 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/SqlBuilderTest.php +++ b/packages/php-db-import-export/tests/functional/Exasol/SqlBuilderTest.php @@ -65,7 +65,7 @@ public function testGetDedupCommand(): void [ 'pk1', 'pk2', - ] + ], ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($deduplicationDef)); @@ -73,18 +73,18 @@ public function testGetDedupCommand(): void $sql = $this->getBuilder()->getDedupCommand( $stageDef, $deduplicationDef, - $deduplicationDef->getPrimaryKeysNames() + $deduplicationDef->getPrimaryKeysNames(), ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import-export-test_schema"."tempTable" ("col1", "col2") SELECT a."col1",a."col2" FROM (SELECT "col1", "col2", ROW_NUMBER() OVER (PARTITION BY "pk1","pk2" ORDER BY "pk1","pk2") AS "_row_number_" FROM "import-export-test_schema"."stagingTable") AS a WHERE a."_row_number_" = 1', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', ExasolQuote::quoteSingleIdentifier($deduplicationDef->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($deduplicationDef->getTableName()) + ExasolQuote::quoteSingleIdentifier($deduplicationDef->getTableName()), )); self::assertCount(2, $result); @@ -100,22 +100,22 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): E sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (2,2,\'2\',\'2\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); if ($includeEmptyValues) { @@ -123,8 +123,8 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): E sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (2,2,\'\',NULL)', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); } @@ -148,28 +148,28 @@ public function testGetDeleteOldItemsCommand(): void new ExasolColumn( 'id', new Exasol( - Exasol::TYPE_INT - ) + Exasol::TYPE_INT, + ), ), ExasolColumn::createGenericColumn('pk1'), ExasolColumn::createGenericColumn('pk2'), ExasolColumn::createGenericColumn('col1'), ExasolColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $tableSql = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($tableDefinition)); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","pk1","pk2","col1","col2") VALUES (1,1,1,\'1\',\'1\')', - $tableSql - ) + $tableSql, + ), ); $stagingTableDefinition = new ExasolTableDefinition( self::TEST_SCHEMA, @@ -181,42 +181,42 @@ public function testGetDeleteOldItemsCommand(): void ExasolColumn::createGenericColumn('col1'), ExasolColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stagingTableDefinition)); $stagingTableSql = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + ExasolQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (2,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $sql = $this->getBuilder()->getDeleteOldItemsCommand( $stagingTableDefinition, - $tableDefinition + $tableDefinition, ); self::assertEquals( // phpcs:ignore 'DELETE FROM "import-export-test_schema"."stagingTable" WHERE EXISTS (SELECT * FROM "import-export-test_schema"."import-export-test_test" WHERE COALESCE("import-export-test_schema"."import-export-test_test"."pk1", \'KBC_$#\') = COALESCE("import-export-test_schema"."stagingTable"."pk1", \'KBC_$#\') AND COALESCE("import-export-test_schema"."import-export-test_test"."pk2", \'KBC_$#\') = COALESCE("import-export-test_schema"."stagingTable"."pk2", \'KBC_$#\'))', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - $stagingTableSql + $stagingTableSql, )); self::assertCount(1, $result); @@ -237,7 +237,7 @@ private function assertTableNotExists(string $schemaName, string $tableName): vo self::fail(sprintf( 'Table "%s.%s" is expected to not exist.', $schemaName, - $tableName + $tableName, )); } catch (Exception $e) { } @@ -253,7 +253,7 @@ public function testGetDropTableIfExistsCommand(): void self::assertEquals( // phpcs:ignore 'DROP TABLE IF EXISTS "import-export-test_schema"."import-export-test_test"', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -265,7 +265,7 @@ public function testGetDropTableIfExistsCommand(): void self::assertEquals( // phpcs:ignore 'DROP TABLE IF EXISTS "import-export-test_schema"."import-export-test_test"', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -279,8 +279,7 @@ protected function createTestTable(): void CREATE TABLE $table ( id int NOT NULL ) -EOT - ); +EOT,); } public function testGetInsertAllIntoTargetTableCommand(): void @@ -298,7 +297,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // no convert values no timestamp @@ -306,13 +305,13 @@ public function testGetInsertAllIntoTargetTableCommand(): void $fakeStage, $destination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import-export-test_schema"."import-export-test_test" ("col1", "col2") (SELECT CAST(COALESCE("col1", \'\') AS NVARCHAR (4000)) AS "col1",CAST(COALESCE("col2", \'\') AS NVARCHAR (4000)) AS "col2" FROM "import-export-test_schema"."stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); @@ -320,7 +319,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -349,7 +348,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void protected function createTestTableWithColumns( bool $includeTimestamp = false, - bool $includePrimaryKey = false + bool $includePrimaryKey = false, ): ExasolTableDefinition { $columns = []; $pks = []; @@ -357,7 +356,7 @@ protected function createTestTableWithColumns( $pks[] = 'id'; $columns[] = new ExasolColumn( 'id', - new Exasol(Exasol::TYPE_INT) + new Exasol(Exasol::TYPE_INT), ); } else { $columns[] = $this->createNullableGenericColumn('id'); @@ -368,7 +367,7 @@ protected function createTestTableWithColumns( if ($includeTimestamp) { $columns[] = new ExasolColumn( '_timestamp', - new Exasol(Exasol::TYPE_TIMESTAMP) + new Exasol(Exasol::TYPE_TIMESTAMP), ); } @@ -377,10 +376,10 @@ protected function createTestTableWithColumns( self::TEST_TABLE, false, new ColumnCollection($columns), - $pks + $pks, ); $this->connection->executeStatement( - (new ExasolTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition) + (new ExasolTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition), ); return $tableDefinition; @@ -393,12 +392,12 @@ private function createNullableGenericColumn(string $columnName): ExasolColumn [ 'length' => '4000', // should be changed to max in future 'nullable' => true, - ] + ], ); return new ExasolColumn( $columnName, - $definition + $definition, ); } @@ -416,7 +415,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // convert col1 to null @@ -425,19 +424,19 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import-export-test_schema"."import-export-test_test" ("col1", "col2") (SELECT NULLIF("col1", \'\'),CAST(COALESCE("col2", \'\') AS NVARCHAR (4000)) AS "col2" FROM "import-export-test_schema"."stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); self::assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -478,7 +477,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // use timestamp @@ -487,19 +486,19 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import-export-test_schema"."import-export-test_test" ("col1", "col2", "_timestamp") (SELECT NULLIF("col1", \'\'),CAST(COALESCE("col2", \'\') AS NVARCHAR (4000)) AS "col2",\'2020-01-01 00:00:00\' FROM "import-export-test_schema"."stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); self::assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -521,7 +520,7 @@ public function testGetTruncateTableWithDeleteCommand(): void $sql = $this->getBuilder()->getTruncateTableWithDeleteCommand(self::TEST_SCHEMA, self::TEST_STAGING_TABLE); self::assertEquals( 'DELETE FROM "import-export-test_schema"."stagingTable"', - $sql + $sql, ); $this->connection->executeStatement($sql); self::assertEquals(0, $ref->getRowsCount()); @@ -541,7 +540,7 @@ public function testGetUpdateWithPkCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new ExasolTableDefinition( @@ -552,19 +551,19 @@ public function testGetUpdateWithPkCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'2\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -580,18 +579,18 @@ public function testGetUpdateWithPkCommand(): void $fakeStage, $fakeDestination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "import-export-test_schema"."import-export-test_test" AS "dest" SET "col2" = "src"."col2" FROM (SELECT DISTINCT * FROM "import-export-test_schema"."stagingTable") AS "src","import-export-test_schema"."import-export-test_test" AS "dest" WHERE COALESCE("dest"."col1", \'KBC_$#\') = COALESCE("src"."col1", \'KBC_$#\') AND (COALESCE(CAST("dest"."col1" AS NVARCHAR (4000)), \'KBC_$#\') != COALESCE("src"."col1", \'KBC_$#\') OR COALESCE(CAST("dest"."col2" AS NVARCHAR (4000)), \'KBC_$#\') != COALESCE("src"."col2", \'KBC_$#\')) ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -617,7 +616,7 @@ public function testGetUpdateWithPkCommandConvertValues(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new ExasolTableDefinition( @@ -628,25 +627,25 @@ public function testGetUpdateWithPkCommandConvertValues(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'2\',\'\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -669,18 +668,18 @@ public function testGetUpdateWithPkCommandConvertValues(): void $fakeStage, $fakeDestination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "import-export-test_schema"."import-export-test_test" AS "dest" SET "col2" = "src"."col2" FROM (SELECT DISTINCT * FROM "import-export-test_schema"."stagingTable") AS "src","import-export-test_schema"."import-export-test_test" AS "dest" WHERE COALESCE("dest"."col1", \'KBC_$#\') = COALESCE("src"."col1", \'KBC_$#\') AND (COALESCE(CAST("dest"."col1" AS NVARCHAR (4000)), \'KBC_$#\') != COALESCE("src"."col1", \'KBC_$#\') OR COALESCE(CAST("dest"."col2" AS NVARCHAR (4000)), \'KBC_$#\') != COALESCE("src"."col2", \'KBC_$#\')) ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -714,7 +713,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new ExasolTableDefinition( @@ -725,27 +724,27 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2","_timestamp") VALUES (1,\'\',\'1\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2","_timestamp") VALUES (1,\'2\',\'\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -769,19 +768,19 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $fakeStage, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) . '.000' + $timestampSet->format(DateTimeHelper::FORMAT) . '.000', ); self::assertEquals( // phpcs:ignore 'UPDATE "import-export-test_schema"."import-export-test_test" AS "dest" SET "col2" = "src"."col2", "_timestamp" = \'2020-01-01 01:01:01.000\' FROM (SELECT DISTINCT * FROM "import-export-test_schema"."stagingTable") AS "src","import-export-test_schema"."import-export-test_test" AS "dest" WHERE COALESCE("dest"."col1", \'KBC_$#\') = COALESCE("src"."col1", \'KBC_$#\') AND (COALESCE(CAST("dest"."col1" AS NVARCHAR (4000)), \'KBC_$#\') != COALESCE("src"."col1", \'KBC_$#\') OR COALESCE(CAST("dest"."col2" AS NVARCHAR (4000)), \'KBC_$#\') != COALESCE("src"."col2", \'KBC_$#\')) ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -791,7 +790,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void self::assertArrayHasKey('_timestamp', $item); self::assertSame( $timestampSet->format(DateTimeHelper::FORMAT), - (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT) + (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT), ); } } @@ -808,7 +807,7 @@ private function getStagingTableDefinition(): ExasolTableDefinition $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); } } diff --git a/packages/php-db-import-export/tests/functional/Exasol/StageImportS3Test.php b/packages/php-db-import-export/tests/functional/Exasol/StageImportS3Test.php index ddecda801..16edba2a3 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/StageImportS3Test.php +++ b/packages/php-db-import-export/tests/functional/Exasol/StageImportS3Test.php @@ -53,7 +53,7 @@ public function testImportS3( array $s3Setting, int $expectedRowsNumber, int $expectedFirstLine, - int $skippedLines = 0 + int $skippedLines = 0, ): void { $this->initTable($table); @@ -61,30 +61,30 @@ public function testImportS3( $ref = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - $table + $table, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer->importToStagingTable( $this->createS3SourceInstanceFromCsv( - ...$s3Setting + ...$s3Setting, ), $stagingTable, - $this->getExasolImportOptions($skippedLines) + $this->getExasolImportOptions($skippedLines), ); $importedData = $this->connection->fetchAllAssociative( sprintf( 'SELECT * FROM %s.%s', ExasolQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + ExasolQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), ); self::assertCount($expectedRowsNumber, $importedData); self::assertCount($expectedFirstLine, $importedData[0]); @@ -189,15 +189,15 @@ public function testWithNullifyValue(): void $ref = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_NULLIFY + self::TABLE_NULLIFY, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer->importToStagingTable( $this->createS3SourceInstanceFromCsv( @@ -209,10 +209,10 @@ public function testWithNullifyValue(): void 'col2', ], false, - false + false, ), $stagingTable, - $this->getExasolImportOptions() + $this->getExasolImportOptions(), ); self::assertEquals([ @@ -223,8 +223,8 @@ public function testWithNullifyValue(): void sprintf( 'SELECT * FROM %s.%s', ExasolQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - ExasolQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + ExasolQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), )); } @@ -237,15 +237,15 @@ public function testInvalidManifestImport(): void $ref = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_ACCOUNTS_WITHOUT_TS + self::TABLE_ACCOUNTS_WITHOUT_TS, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); // fails on SQL, no parsing/checking entries before @@ -257,10 +257,10 @@ public function testInvalidManifestImport(): void new CsvOptions(), self::TWITTER_COLUMNS, true, - false + false, ), $stagingTable, - $this->getExasolImportOptions() + $this->getExasolImportOptions(), ); } @@ -272,15 +272,15 @@ public function testCopyIntoInvalidTypes(): void $ref = new ExasolTableReflection( $this->connection, $this->getSourceSchemaName(), - self::TABLE_TYPES + self::TABLE_TYPES, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new ExasolTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->expectException(Exception::class); @@ -296,10 +296,10 @@ public function testCopyIntoInvalidTypes(): void 'boolCol', ], false, - false + false, ), $stagingTable, - $this->getExasolImportOptions() + $this->getExasolImportOptions(), ); } } diff --git a/packages/php-db-import-export/tests/functional/Exasol/StageImportTest.php b/packages/php-db-import-export/tests/functional/Exasol/StageImportTest.php index 87b949497..1131b4eda 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/StageImportTest.php +++ b/packages/php-db-import-export/tests/functional/Exasol/StageImportTest.php @@ -31,14 +31,14 @@ public function testMoveDataFromAToB(): void $targetTableRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -47,22 +47,22 @@ public function testMoveDataFromAToB(): void $importer->importToStagingTable( $source, $targetTableRef->getTableDefinition(), - $this->getExasolImportOptions() + $this->getExasolImportOptions(), ); $dataSource = $this->connection->fetchAllAssociative( sprintf( 'SELECT * FROM %s.%s', ExasolQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - ExasolQuote::quoteSingleIdentifier('sourceTable') - ) + ExasolQuote::quoteSingleIdentifier('sourceTable'), + ), ); $dataDest = $this->connection->fetchAllAssociative( sprintf( 'SELECT * FROM %s.%s', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - ExasolQuote::quoteSingleIdentifier('targetTable') - ) + ExasolQuote::quoteSingleIdentifier('targetTable'), + ), ); self::assertSame($dataSource, $dataDest); @@ -76,14 +76,14 @@ public function testMoveDataFromAToTableWithWrongSourceStructure(): void $targetTableRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'XXXX', 'last_name'], - [] + [], ); $this->expectException(Exception::class); @@ -92,7 +92,7 @@ public function testMoveDataFromAToTableWithWrongSourceStructure(): void $importer->importToStagingTable( $source, $targetTableRef->getTableDefinition(), - $this->getExasolImportOptions() + $this->getExasolImportOptions(), ); } @@ -106,8 +106,8 @@ public function testMoveDataFromBetweenDifferentTables(): void 'ALTER TABLE %s.%s DROP COLUMN %s', ExasolQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), ExasolQuote::quoteSingleIdentifier('targetTable'), - ExasolQuote::quoteSingleIdentifier('first_name') - ) + ExasolQuote::quoteSingleIdentifier('first_name'), + ), ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -116,14 +116,14 @@ public function testMoveDataFromBetweenDifferentTables(): void $targetTableRef = new ExasolTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->expectException(Exception::class); @@ -132,7 +132,7 @@ public function testMoveDataFromBetweenDifferentTables(): void $importer->importToStagingTable( $source, $targetTableRef->getTableDefinition(), - $this->getExasolImportOptions() + $this->getExasolImportOptions(), ); } } diff --git a/packages/php-db-import-export/tests/functional/Exasol/TestConnectionTest.php b/packages/php-db-import-export/tests/functional/Exasol/TestConnectionTest.php index 8d8aade9e..3784f4b39 100644 --- a/packages/php-db-import-export/tests/functional/Exasol/TestConnectionTest.php +++ b/packages/php-db-import-export/tests/functional/Exasol/TestConnectionTest.php @@ -10,7 +10,7 @@ public function test(): void { self::assertEquals( 1, - $this->connection->fetchOne('SELECT 1') + $this->connection->fetchOne('SELECT 1'), ); } } diff --git a/packages/php-db-import-export/tests/functional/ImportExportBaseTest.php b/packages/php-db-import-export/tests/functional/ImportExportBaseTest.php index ad18dc6e9..c75081db8 100644 --- a/packages/php-db-import-export/tests/functional/ImportExportBaseTest.php +++ b/packages/php-db-import-export/tests/functional/ImportExportBaseTest.php @@ -67,7 +67,7 @@ public function assertCsvFilesCountSliced(array $expected, array $actual): void $this->assertCount( count($expectedContent), $actualContent, - 'Csv dont have equals count of items.' + 'Csv dont have equals count of items.', ); } @@ -77,7 +77,7 @@ public function assertCsvFilesSame(CsvFile $expected, CsvFile $actual): void iterator_to_array($expected), iterator_to_array($actual), 0, - 'Csv files are not same' + 'Csv files are not same', ); } @@ -90,7 +90,7 @@ protected function assertArrayEqualsSorted( array $expected, array $actual, $sortKey, - string $message = '' + string $message = '', ): void { $comparsion = function ($attrLeft, $attrRight) use ($sortKey) { if ($attrLeft[$sortKey] === $attrRight[$sortKey]) { @@ -129,29 +129,29 @@ public function assertCsvFilesSameSliced(array $expected, array $actual): void $expectedContent, $actualContent, 0, - 'Csv files are not same' + 'Csv files are not same', ); } protected function getSimpleImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): ImportOptions { return new ImportOptions( [], false, true, - $skipLines + $skipLines, ); } protected function getSimpleIncrementalImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): ImportOptions { return new ImportOptions( [], true, true, - $skipLines + $skipLines, ); } @@ -163,7 +163,7 @@ protected function getSimpleIncrementalImportOptions( */ protected function getExpectationFileData( string $filePathInDataDir, - bool $convertNullsString = self::EXPECTATION_FILE_DATA_KEEP_AS_IS + bool $convertNullsString = self::EXPECTATION_FILE_DATA_KEEP_AS_IS, ): array { $expectedRows = []; $expectationFile = new CsvFile(self::DATA_DIR . $filePathInDataDir); @@ -208,7 +208,7 @@ protected function getParseCsvStub(string $filePathInDataDir): CsvStub return new CsvStub( $columns, - $rows + $rows, ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ExportLegacyTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ExportLegacyTest.php index c859f3c5c..d5a5e1e55 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ExportLegacyTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ExportLegacyTest.php @@ -32,14 +32,14 @@ public function testExportGzip(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'out.csv_2Cols' + 'out.csv_2Cols', ); $options = $this->getSimpleImportOptions(); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); // export @@ -50,7 +50,7 @@ public function testExportGzip(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -82,14 +82,14 @@ public function testExportSimple(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'out.csv_2Cols' + 'out.csv_2Cols', ); $options = $this->getSimpleImportOptions(); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); // export @@ -100,7 +100,7 @@ public function testExportSimple(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -122,7 +122,7 @@ public function testExportSimple(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -136,7 +136,7 @@ public function assertCsvFilesSame(CsvFile $expected, CsvFile $actual): void iterator_to_array($expected), iterator_to_array($actual), 0, - 'Csv files are not same' + 'Csv files are not same', ); } @@ -147,14 +147,14 @@ public function testExportSimpleWithQuery(): void $source = $this->getSourceInstance('tw_accounts.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'accounts-3' + 'accounts-3', ); $options = $this->getSimpleImportOptions(); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); // export @@ -162,7 +162,7 @@ public function testExportSimpleWithQuery(): void $query = sprintf( 'SELECT %s FROM %s', ColumnsHelper::getColumnsString($file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Snowflake\SelectSource($query); $options = new ExportOptions(false, ExportOptions::MANIFEST_AUTOGENERATED); @@ -171,7 +171,7 @@ public function testExportSimpleWithQuery(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -193,7 +193,7 @@ public function testExportSimpleWithQuery(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); diff --git a/packages/php-db-import-export/tests/functional/Snowflake/Exporter/ExportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/Exporter/ExportTest.php index 71a8b48a1..6cb231c0b 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/Exporter/ExportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/Exporter/ExportTest.php @@ -43,7 +43,7 @@ public function testExportNulls(): void $source = $this->getSourceInstance('null-and-empty-string.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - self::TABLE_NULL_EMPTY_STRING + self::TABLE_NULL_EMPTY_STRING, ); $this->importTable($source, $destination); @@ -53,7 +53,7 @@ public function testExportNulls(): void $query = sprintf( 'SELECT %s FROM %s', ColumnsHelper::getColumnsString($file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Snowflake\SelectSource($query); $options = new ExportOptions(false, ExportOptions::MANIFEST_AUTOGENERATED); @@ -62,7 +62,7 @@ public function testExportNulls(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -84,7 +84,7 @@ public function testExportNulls(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -100,7 +100,7 @@ public function testExportGzip(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->importTable($source, $destination); @@ -113,7 +113,7 @@ public function testExportGzip(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -146,7 +146,7 @@ public function testExportSimple(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->importTable($source, $destination); @@ -158,7 +158,7 @@ public function testExportSimple(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -180,7 +180,7 @@ public function testExportSimple(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -194,7 +194,7 @@ public function assertCsvFilesSame(CsvFile $expected, CsvFile $actual): void iterator_to_array($expected), iterator_to_array($actual), 0, - 'Csv files are not same' + 'Csv files are not same', ); } @@ -206,7 +206,7 @@ public function testExportSimpleWithQuery(): void $source = $this->getSourceInstance('tw_accounts.csv', $file->getHeader()); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - self::TABLE_ACCOUNTS_3 + self::TABLE_ACCOUNTS_3, ); $this->importTable($source, $destination); @@ -216,7 +216,7 @@ public function testExportSimpleWithQuery(): void $query = sprintf( 'SELECT %s FROM %s', ColumnsHelper::getColumnsString($file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Snowflake\SelectSource($query); $options = new ExportOptions(false, ExportOptions::MANIFEST_AUTOGENERATED); @@ -225,7 +225,7 @@ public function testExportSimpleWithQuery(): void $result = (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $this->assertCount(1, $result); @@ -247,7 +247,7 @@ public function testExportSimpleWithQuery(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -257,28 +257,28 @@ public function testExportSimpleWithQuery(): void private function importTable( Storage\SourceInterface $source, - Storage\Snowflake\Table $destination + Storage\Snowflake\Table $destination, ): void { $options = $this->getSimpleImportOptions(ImportOptions::SKIP_FIRST_LINE); $importer = new ToStageImporter($this->connection); $destinationRef = new SnowflakeTableReflection( $this->connection, $destination->getSchema(), - $destination->getTableName() + $destination->getTableName(), ); $importDestination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $importDestination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); @@ -286,7 +286,7 @@ private function importTable( $stagingTable, $importDestination, $options, - $importState + $importState, ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/FullImportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/FullImportTest.php index 8eeb18a61..5476027dd 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/FullImportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/FullImportTest.php @@ -57,7 +57,7 @@ public function fullImportData(): array $this->getSourceInstance( 'sliced/2cols-large/%MANIFEST_PREFIX%2cols-large.csvmanifest', $escapingHeader, - true + true, ), new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'out.csv_2Cols'), $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -101,7 +101,7 @@ public function fullImportData(): array $this->getSourceInstanceFromCsv( 'standard-with-enclosures.tabs.csv', new CsvOptions("\t"), - $escapingHeader + $escapingHeader, ), new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'out.csv_2Cols'), $this->getSimpleImportOptions(), @@ -121,7 +121,7 @@ public function fullImportData(): array $this->getSourceInstance('tw_accounts.changedColumnsOrder.csv', $accountChangedColumnsOrderHeader), new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'accounts-3' + 'accounts-3', ), $this->getSimpleImportOptions(), $expectedAccounts, @@ -147,7 +147,7 @@ public function fullImportData(): array $this->getSourceInstance( 'sliced/accounts-gzip/%MANIFEST_PREFIX%accounts-gzip.csvmanifest', $accountsHeader, - true + true, ), new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'accounts-3'), $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -161,7 +161,7 @@ public function fullImportData(): array 'sliced_accounts_no_manifest/', $accountsHeader, true, - true + true, ), new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'accounts-3'), $this->getSimpleImportOptions(ImportOptions::SKIP_NO_LINE), @@ -186,11 +186,11 @@ public function fullImportData(): array 'col2', '_timestamp', ], - false + false, ), new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'out.csv_2Cols' + 'out.csv_2Cols', ), $this->getSimpleImportOptions(), [ @@ -207,7 +207,7 @@ public function fullImportData(): array [], false, false, // don't use timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), $expectedEscaping, 7, @@ -229,7 +229,7 @@ public function fullImportData(): array ]), new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'types' + 'types', ), $this->getSimpleImportOptions(), [['a', '10.5', '0.3', 'true']], @@ -249,12 +249,12 @@ public function testFullImport( Storage\DestinationInterface $destination, ImportOptions $options, array $expected, - int $expectedImportedRowCount + int $expectedImportedRowCount, ): void { $result = (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); self::assertEquals($expectedImportedRowCount, $result->getImportedRowsCount()); @@ -263,7 +263,7 @@ public function testFullImport( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/IncrementalImportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/IncrementalImportTest.php index 434eb83aa..e4919c03f 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/IncrementalImportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/IncrementalImportTest.php @@ -50,14 +50,14 @@ public function incrementalImportData(): array [], false, false, // disable timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), $this->getSourceInstance('tw_accounts.increment.csv', $accountColumns, false), new ImportOptions( [], true, // incremental false, // disable timestamp - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'accounts-without-ts'), $expectedAccountsRows, @@ -87,18 +87,18 @@ public function testIncrementalImport( ImportOptions $incrementalOptions, Storage\DestinationInterface $destination, array $expected, - int $expectedImportedRowCount + int $expectedImportedRowCount, ): void { (new Importer($this->connection))->importTable( $initialSource, $destination, - $initialOptions + $initialOptions, ); $result = (new Importer($this->connection))->importTable( $incrementalSource, $destination, - $incrementalOptions + $incrementalOptions, ); self::assertEquals($expectedImportedRowCount, $result->getImportedRowsCount()); @@ -107,7 +107,7 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/OtherImportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/OtherImportTest.php index 0ff15c626..88bf4fbda 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/OtherImportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/OtherImportTest.php @@ -24,7 +24,7 @@ public function testCopyInvalidSourceDataShouldThrowException(): void (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); } @@ -36,17 +36,17 @@ public function testImportShouldNotFailOnColumnNameRowNumber(): void [ 'id', 'row_number', - ] + ], ); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'column-name-row-number' + 'column-name-row-number', ); $result = (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); self::assertEquals(2, $result->getImportedRowsCount()); } @@ -58,11 +58,11 @@ public function testInvalidManifestImport(): void $source = $this->getSourceInstance( '02_tw_accounts.csv.invalid.manifest', $initialFile->getHeader(), - true + true, ); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'accounts-3' + 'accounts-3', ); $this->expectException(Exception::class); @@ -74,7 +74,7 @@ public function testInvalidManifestImport(): void (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); } @@ -87,11 +87,11 @@ public function testMoreColumnsShouldThrowException(): void 'first', 'second', ], - false + false, ); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'out.csv_2Cols' + 'out.csv_2Cols', ); self::expectException(Exception::class); @@ -101,7 +101,7 @@ public function testMoreColumnsShouldThrowException(): void (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); } @@ -110,7 +110,7 @@ public function testIncrementalImportFromTable(): void $fetchSQL = sprintf( 'SELECT "col1", "col2" FROM "%s"."%s"', $this->getDestinationSchemaName(), - 'out.csv_2Cols' + 'out.csv_2Cols', ); $source = new Storage\Snowflake\SelectSource( @@ -120,7 +120,7 @@ public function testIncrementalImportFromTable(): void 'col1', 'col2', ], - [] + [], ); $destination = new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'out.csv_2Cols'); $options = $this->getSimpleImportOptions(); @@ -128,7 +128,7 @@ public function testIncrementalImportFromTable(): void (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll($fetchSQL); @@ -142,7 +142,7 @@ public function testIncrementalImportFromTable(): void (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll($fetchSQL); @@ -154,30 +154,30 @@ public function testNullifyCopy(): void { $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify"', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify_src" ', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify_src" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify_src" VALUES(\'1\', \'\', NULL), (\'2\', NULL, 500)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new ImportOptions( ['name', 'price'], //convert empty values false, false, - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ); $source = new Storage\Snowflake\Table( $this->getSourceSchemaName(), @@ -186,19 +186,19 @@ public function testNullifyCopy(): void 'id', 'name', 'price', - ] + ], ); $destination = new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'nullify'); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll(sprintf( 'SELECT "id", "name", "price" FROM "%s"."nullify" ORDER BY "id" ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->assertCount(2, $importedData); $this->assertTrue($importedData[0]['name'] === null); @@ -210,34 +210,34 @@ public function testNullifyCopyIncremental(): void { $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify" ', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify" VALUES(\'4\', NULL, 50)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify_src" ', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify_src" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify_src" VALUES(\'1\', \'\', NULL), (\'2\', NULL, 500)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new ImportOptions( ['name', 'price'], //convert empty values true, // incremetal false, - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ); $source = new Storage\Snowflake\Table( $this->getSourceSchemaName(), @@ -246,19 +246,19 @@ public function testNullifyCopyIncremental(): void 'id', 'name', 'price', - ] + ], ); $destination = new Storage\Snowflake\Table($this->getDestinationSchemaName(), 'nullify'); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll(sprintf( 'SELECT "id", "name", "price" FROM "%s"."nullify" ORDER BY "id" ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->assertCount(3, $importedData); $this->assertTrue($importedData[0]['name'] === null); @@ -271,55 +271,55 @@ public function testNullifyCopyIncrementalWithPk(): void { $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify" ', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC, PRIMARY KEY("id"))', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify" VALUES(\'4\', \'3\', 2)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify_src" ', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( // phpcs:ignore 'CREATE TABLE "%s"."nullify_src" ("id" VARCHAR NOT NULL, "name" VARCHAR NOT NULL, "price" VARCHAR NOT NULL, PRIMARY KEY("id"))', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify_src" VALUES(\'1\', \'\', \'\'), (\'2\', \'\', \'500\'), (\'4\', \'\', \'\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new ImportOptions( ['name', 'price'], //convert empty values true, // incremetal false, - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ); $source = new Storage\Snowflake\Table( $this->getSourceSchemaName(), 'nullify_src', - ['id', 'name', 'price'] + ['id', 'name', 'price'], ); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll(sprintf( 'SELECT "id", "name", "price" FROM "%s"."nullify"', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $expectedData = [ [ @@ -347,55 +347,55 @@ public function testNullifyCopyIncrementalWithPkDestinationWithNull(): void { $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify" ', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC, PRIMARY KEY("id"))', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify" VALUES(\'4\', NULL, NULL)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify_src" ', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( // phpcs:ignore 'CREATE TABLE "%s"."nullify_src" ("id" VARCHAR NOT NULL, "name" VARCHAR NOT NULL, "price" VARCHAR NOT NULL, PRIMARY KEY("id"))', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify_src" VALUES(\'1\', \'\', \'\'), (\'2\', \'\', \'500\'), (\'4\', \'\', \'500\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new ImportOptions( ['name', 'price'], //convert empty values true, // incremetal false, - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ); $source = new Storage\Snowflake\Table( $this->getSourceSchemaName(), 'nullify_src', - ['id', 'name', 'price'] + ['id', 'name', 'price'], ); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll(sprintf( 'SELECT "id", "name", "price" FROM "%s"."nullify"', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $expectedData = [ [ @@ -423,34 +423,34 @@ public function testNullifyCsv(): void { $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify" ', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $options = new ImportOptions( ['name', 'price'], //convert empty values false, false, - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ); $source = $this->getSourceInstance('nullify.csv', ['id', 'name', 'price']); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll(sprintf( 'SELECT "id", "name", "price" FROM "%s"."nullify" ORDER BY "id" ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->assertCount(3, $importedData); $this->assertTrue($importedData[1]['name'] === null); @@ -461,37 +461,37 @@ public function testNullifyCsvIncremental(): void { $this->connection->query(sprintf( 'DROP TABLE IF EXISTS "%s"."nullify" ', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE "%s"."nullify" ("id" VARCHAR, "name" VARCHAR, "price" NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."nullify" VALUES(\'4\', NULL, 50)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $options = new ImportOptions( ['name', 'price'], //convert empty values true, // incremetal false, - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ); $source = $this->getSourceInstance('nullify.csv', ['id', 'name', 'price']); $destination = new Storage\Snowflake\Table( $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); (new Importer($this->connection))->importTable( $source, $destination, - $options + $options, ); $importedData = $this->connection->fetchAll(sprintf( 'SELECT "id", "name", "price" FROM "%s"."nullify" ORDER BY "id" ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->assertCount(4, $importedData); $this->assertTrue($importedData[1]['name'] === null); diff --git a/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeBaseTestCase.php b/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeBaseTestCase.php index 166b7fa5b..ee71fe86d 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeBaseTestCase.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeBaseTestCase.php @@ -67,7 +67,7 @@ protected function getSnowflakeConnection(): Connection 'warehouse' => (string) getenv('SNOWFLAKE_WAREHOUSE'), 'database' => (string) getenv('SNOWFLAKE_DATABASE'), ], - $this->getDoctrineLogger() + $this->getDoctrineLogger(), ); } @@ -76,7 +76,7 @@ protected function insertRowToTable( string $tableName, int $id, string $firstName, - string $lastName + string $lastName, ): void { $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (%d, %s, %s)', @@ -84,14 +84,14 @@ protected function insertRowToTable( SnowflakeQuote::quoteSingleIdentifier($tableName), $id, SnowflakeQuote::quote($firstName), - SnowflakeQuote::quote($lastName) + SnowflakeQuote::quote($lastName), )); } protected function initSingleTable( string $schema = self::SNFLK_SOURCE_SCHEMA_NAME, string $table = self::TABLE_TABLE, - ?string $tableTemplate = null + ?string $tableTemplate = null, ): void { if (!$this->schemaExists($schema)) { $this->createSchema($schema); @@ -109,8 +109,8 @@ protected function initSingleTable( sprintf( $tableTemplate, SnowflakeQuote::quoteSingleIdentifier($schema), - SnowflakeQuote::quoteSingleIdentifier($table) - ) + SnowflakeQuote::quoteSingleIdentifier($table), + ), ); } @@ -126,8 +126,8 @@ protected function initTable(string $tableName): void "col2" VARCHAR(20000) );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) - ) + SnowflakeQuote::quoteSingleIdentifier($tableName), + ), ); break; case self::TABLE_OUT_CSV_2COLS: @@ -139,14 +139,14 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) - ) + SnowflakeQuote::quoteSingleIdentifier($tableName), + ), ); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'x\', \'y\', CURRENT_TIMESTAMP());', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( @@ -155,19 +155,19 @@ protected function initTable(string $tableName): void "col2" VARCHAR(2000000) );', SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'a\', \'b\');', SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'c\', \'d\');', SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_ACCOUNTS_WITHOUT_TS: @@ -187,7 +187,7 @@ protected function initTable(string $tableName): void "idApp" VARCHAR(2000000) ) ', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_NULLIFY: @@ -198,7 +198,7 @@ protected function initTable(string $tableName): void "col2" VARCHAR(2000000) ) ', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_TYPES: @@ -210,7 +210,7 @@ protected function initTable(string $tableName): void "boolCol" VARCHAR(2000000) , "_timestamp" TIMESTAMP );', - SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()) + SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), )); $this->connection->executeQuery(sprintf( @@ -220,13 +220,13 @@ protected function initTable(string $tableName): void "floatCol" float , "boolCol" tinyint );', - SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()) + SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s."types" VALUES (\'a\', \'10.5\', \'0.3\', 1) ;', - SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()) + SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()), )); break; case self::TABLE_COLUMN_NAME_ROW_NUMBER: @@ -237,7 +237,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP )', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_SINGLE_PK: @@ -251,7 +251,7 @@ protected function initTable(string $tableName): void CONSTRAINT "visitidpk" PRIMARY KEY ("VisitID") );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_MULTI_PK: @@ -265,7 +265,7 @@ protected function initTable(string $tableName): void CONSTRAINT "visit_something_pk" PRIMARY KEY ("VisitID", "Something") );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_MULTI_PK_WITH_TS: @@ -280,7 +280,7 @@ protected function initTable(string $tableName): void CONSTRAINT "triple_pk" PRIMARY KEY ("VisitID", "Value", "MenuItem") );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_ACCOUNTS_3: @@ -302,7 +302,7 @@ protected function initTable(string $tableName): void CONSTRAINT "accounts_id_pk" PRIMARY KEY ("id") );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_LEMMA: @@ -314,7 +314,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_TABLE: @@ -326,7 +326,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_NO_TIMESTAMP_TABLE: @@ -336,7 +336,7 @@ protected function initTable(string $tableName): void "col2" VARCHAR(2000000) );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_NULL_EMPTY_STRING: @@ -347,7 +347,7 @@ protected function initTable(string $tableName): void "_timestamp" TIMESTAMP );', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), )); break; default: @@ -374,8 +374,8 @@ protected function cleanSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'DROP SCHEMA IF EXISTS %s CASCADE', - SnowflakeQuote::quoteSingleIdentifier($schemaName) - ) + SnowflakeQuote::quoteSingleIdentifier($schemaName), + ), ); } @@ -384,8 +384,8 @@ protected function schemaExists(string $schemaName): bool return (bool) $this->connection->fetchOne( sprintf( 'SHOW SCHEMAS LIKE %s;', - SnowflakeQuote::quote($schemaName) - ) + SnowflakeQuote::quote($schemaName), + ), ); } @@ -394,21 +394,21 @@ public function createSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'CREATE SCHEMA %s;', - SnowflakeQuote::quoteSingleIdentifier($schemaName) - ) + SnowflakeQuote::quoteSingleIdentifier($schemaName), + ), ); } protected function getSnowflakeImportOptions( int $skipLines = 1, - bool $useTimeStamp = true + bool $useTimeStamp = true, ): SnowflakeImportOptions { return new SnowflakeImportOptions( convertEmptyValuesToNull: [], isIncremental: false, useTimestamp: $useTimeStamp, numberOfIgnoredLines: $skipLines, - ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); } @@ -423,12 +423,12 @@ protected function assertSnowflakeTableEqualsExpected( SnowflakeImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = (new SnowflakeTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ))->getColumnsNames(); if ($options->useTimestamp()) { @@ -453,7 +453,7 @@ protected function assertSnowflakeTableEqualsExpected( return SnowflakeQuote::quoteSingleIdentifier($item); }, $tableColumns)), SnowflakeQuote::quoteSingleIdentifier($destination->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($destination->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($destination->getTableName()), ); $queryResult = array_map(static function ($row) { @@ -466,12 +466,12 @@ protected function assertSnowflakeTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } protected function getSimpleImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): SnowflakeImportOptions { return new SnowflakeImportOptions( convertEmptyValuesToNull: [], diff --git a/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeImportExportBaseTest.php b/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeImportExportBaseTest.php index 3fd8e2c14..3df447416 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeImportExportBaseTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/SnowflakeImportExportBaseTest.php @@ -33,7 +33,7 @@ protected function assertTableEqualsExpected( ImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = $this->connection->getTableColumns($table->getSchema(), $table->getTableName()); @@ -57,7 +57,7 @@ protected function assertTableEqualsExpected( $sql = sprintf( 'SELECT %s FROM %s', implode(', ', $columnsSql), - $table->getQuotedTableWithScheme() + $table->getQuotedTableWithScheme(), ); $queryResult = array_map(function ($row) { @@ -70,7 +70,7 @@ protected function assertTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } @@ -81,7 +81,7 @@ protected function assertTableEqualsFiles( string $tableName, array $files, string $sortKey, - string $message + string $message, ): void { $filesContent = []; $filesHeader = []; @@ -99,7 +99,7 @@ protected function assertTableEqualsFiles( $this->assertSame( $filesHeader, array_shift($csvFileRows), - 'Provided files have incosistent headers' + 'Provided files have incosistent headers', ); } foreach ($csvFileRows as $fileRow) { @@ -110,15 +110,15 @@ protected function assertTableEqualsFiles( $queryResult = $this->connection->fetchAll( sprintf( 'SELECT * FROM %s', - $this->connection->quoteIdentifier($tableName) - ) + $this->connection->quoteIdentifier($tableName), + ), ); $this->assertArrayEqualsSorted( $filesContent, $queryResult, $sortKey, - $message + $message, ); if (!empty($filesHeader)) { @@ -164,7 +164,7 @@ private function initData(): void 'INSERT INTO "%s"."out.csv_2Cols" VALUES (\'x\', \'y\', \'%s\');', $this->getDestinationSchemaName(), - $now + $now, )); $this->connection->query(sprintf('CREATE TABLE "%s"."out.csv_2Cols" ( @@ -193,7 +193,7 @@ private function initData(): void "_timestamp" TIMESTAMP_NTZ, PRIMARY KEY("id") )', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( @@ -212,7 +212,7 @@ private function initData(): void "idApp" varchar(65535) NOT NULL, PRIMARY KEY("id") )', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( @@ -221,7 +221,7 @@ private function initData(): void "table" varchar(65535) NOT NULL DEFAULT \'\', "_timestamp" TIMESTAMP_NTZ );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( @@ -232,7 +232,7 @@ private function initData(): void "boolCol" varchar NOT NULL, "_timestamp" TIMESTAMP_NTZ );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( @@ -242,14 +242,14 @@ private function initData(): void "floatCol" float NOT NULL, "boolCol" boolean NOT NULL );', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO "%s"."types" VALUES (\'a\', \'10.5\', \'0.3\', TRUE) ;', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( @@ -257,7 +257,7 @@ private function initData(): void "col1" VARCHAR NOT NULL DEFAULT \'\', "col2" VARCHAR NOT NULL DEFAULT \'\' );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( @@ -267,7 +267,7 @@ private function initData(): void "_timestamp" TIMESTAMP_NTZ, PRIMARY KEY("id") );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( @@ -280,7 +280,7 @@ private function initData(): void "_timestamp" TIMESTAMP_NTZ, PRIMARY KEY("VisitID","Value","MenuItem") );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); } @@ -296,14 +296,14 @@ private function getSnowflakeConnection(): Connection $connection->query( sprintf( 'USE DATABASE %s', - $connection->quoteIdentifier((string) getenv('SNOWFLAKE_DATABASE')) - ) + $connection->quoteIdentifier((string) getenv('SNOWFLAKE_DATABASE')), + ), ); $connection->query( sprintf( 'USE WAREHOUSE %s', - $connection->quoteIdentifier((string) getenv('SNOWFLAKE_WAREHOUSE')) - ) + $connection->quoteIdentifier((string) getenv('SNOWFLAKE_WAREHOUSE')), + ), ); return $connection; } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/FullImportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/FullImportTest.php index 3bebf9dfb..29ee8a75b 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/FullImportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/FullImportTest.php @@ -56,7 +56,7 @@ public function testLoadTypedTableWithCastingValues(): void "GEOMETRY" GEOMETRY, "_timestamp" TIMESTAMP );', - SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()) + SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), )); // skipping header @@ -67,13 +67,13 @@ public function testLoadTypedTableWithCastingValues(): void 1, SnowflakeImportOptions::SAME_TABLES_NOT_REQUIRED, SnowflakeImportOptions::NULL_MANIPULATION_SKIP, - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'types' + 'types', ); /** @var SnowflakeTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -88,12 +88,12 @@ public function testLoadTypedTableWithCastingValues(): void 'ARRAY', 'GEOGRAPHY', 'GEOMETRY', - ] + ], ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->connection->executeQuery(sprintf( /** @lang Snowflake */ @@ -108,7 +108,7 @@ public function testLoadTypedTableWithCastingValues(): void \'POINT(1820.12 890.56)\' ;', $stagingTable->getSchemaName(), - $stagingTable->getTableName() + $stagingTable->getTableName(), )); $toFinalTableImporter = new FullImporter($this->connection); @@ -116,7 +116,7 @@ public function testLoadTypedTableWithCastingValues(): void $stagingTable, $destination, $options, - new ImportState($stagingTable->getTableName()) + new ImportState($stagingTable->getTableName()), ); self::assertEquals(1, $destinationRef->getRowsCount()); @@ -139,14 +139,14 @@ public function testLoadToTableWithNullValuesShouldPass(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -158,12 +158,12 @@ public function testLoadToTableWithNullValuesShouldPass(): void ]); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); @@ -171,7 +171,7 @@ public function testLoadToTableWithNullValuesShouldPass(): void $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(5, $destinationRef->getRowsCount()); @@ -191,14 +191,14 @@ public function testLoadToFinalTableWithoutDedup(): void ], false, false, - [] + [], ); $importer = new ToStageImporter($this->connection); $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_COLUMN_NAME_ROW_NUMBER + self::TABLE_COLUMN_NAME_ROW_NUMBER, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -207,19 +207,19 @@ public function testLoadToFinalTableWithoutDedup(): void ]); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(2, $destinationRef->getRowsCount()); @@ -242,14 +242,14 @@ public function testLoadToTableWithDedupWithSinglePK(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -261,19 +261,19 @@ public function testLoadToTableWithDedupWithSinglePK(): void ]); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(4, $destinationRef->getRowsCount()); @@ -296,14 +296,14 @@ public function testLoadToTableWithDedupWithMultiPK(): void ], false, false, - ['VisitID', 'Something'] + ['VisitID', 'Something'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_MULTI_PK + self::TABLE_MULTI_PK, ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -315,12 +315,12 @@ public function testLoadToTableWithDedupWithMultiPK(): void ]); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); // now 6 lines. Add one with same VisitId and Something as an existing line has @@ -329,15 +329,15 @@ public function testLoadToTableWithDedupWithMultiPK(): void sprintf( "INSERT INTO %s.%s VALUES ('134', 'xx', 'yy', 'abc', 'def');", SnowflakeQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + SnowflakeQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(6, $destinationRef->getRowsCount()); @@ -365,7 +365,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), true, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSnowflakeImportOptions(ImportOptions::SKIP_NO_LINE), @@ -380,7 +380,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), true, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSnowflakeImportOptions(ImportOptions::SKIP_NO_LINE), @@ -395,7 +395,7 @@ public function fullImportData(): Generator $lemmaStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_LEMMA], $this->getSnowflakeImportOptions(), @@ -410,7 +410,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSnowflakeImportOptions(), @@ -425,7 +425,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSnowflakeImportOptions(), @@ -441,7 +441,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSnowflakeImportOptions(), @@ -456,7 +456,7 @@ public function fullImportData(): Generator $accountsChangedColumnsOrderStub->getColumns(), false, false, - ['id'] + ['id'], ), [ $this->getDestinationSchemaName(), @@ -473,7 +473,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSnowflakeImportOptions(), @@ -489,7 +489,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSnowflakeImportOptions(), @@ -505,7 +505,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), true, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSnowflakeImportOptions(ImportOptions::SKIP_NO_LINE), @@ -520,7 +520,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), true, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSnowflakeImportOptions(ImportOptions::SKIP_NO_LINE), @@ -536,7 +536,7 @@ public function fullImportData(): Generator $accountsStub->getColumns(), true, true, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSnowflakeImportOptions(ImportOptions::SKIP_NO_LINE), @@ -552,7 +552,7 @@ public function fullImportData(): Generator ['column', 'table'], false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_TABLE], new SnowflakeImportOptions( @@ -563,7 +563,7 @@ public function fullImportData(): Generator ignoreColumns: [ ToStageImporterInterface::TIMESTAMP_COLUMN_NAME, 'lemmaIndex', - ] + ], ), [['table', 'column', null]], 1, @@ -580,7 +580,7 @@ public function fullImportData(): Generator ], false, false, - [] + [], ), [ $this->getDestinationSchemaName(), @@ -601,7 +601,7 @@ public function fullImportData(): Generator $escapingStub->getColumns(), false, false, - [] + [], ), [ $this->getDestinationSchemaName(), @@ -636,7 +636,7 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationSchemaName(), @@ -660,7 +660,7 @@ public function testFullImportWithDataSet( SnowflakeImportOptions $options, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { $this->initTable($tablesToInit); @@ -669,16 +669,16 @@ public function testFullImportWithDataSet( $destination = (new SnowflakeTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $toStageImporter = new ToStageImporter($this->connection); $toFinalTableImporter = new FullImporter($this->connection); @@ -686,20 +686,20 @@ public function testFullImportWithDataSet( $importState = $toStageImporter->importToStagingTable( $source, $stagingTable, - $options + $options, ); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $stagingTable->getSchemaName(), - $stagingTable->getTableName() - ) + $stagingTable->getTableName(), + ), ); } @@ -710,7 +710,7 @@ public function testFullImportWithDataSet( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/IncrementalImportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/IncrementalImportTest.php index 0e139d042..e523590eb 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/IncrementalImportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/IncrementalImportTest.php @@ -27,7 +27,7 @@ class IncrementalImportTest extends SnowflakeBaseTestCase { protected function getSnowflakeIncrementalImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): SnowflakeImportOptions { return new SnowflakeImportOptions( convertEmptyValuesToNull: [], @@ -68,7 +68,7 @@ public function testLoadTypedTableWithCastingValues(): void "_timestamp" TIMESTAMP, PRIMARY KEY ("id") );', - SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()) + SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), )); $this->connection->executeQuery(sprintf( /** @lang Snowflake */ @@ -83,7 +83,7 @@ public function testLoadTypedTableWithCastingValues(): void \'POINT(1820.12 890.56)\' ;', $this->getDestinationSchemaName(), - 'types' + 'types', )); // skipping header @@ -100,7 +100,7 @@ public function testLoadTypedTableWithCastingValues(): void $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'types' + 'types', ); /** @var SnowflakeTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -115,12 +115,12 @@ public function testLoadTypedTableWithCastingValues(): void 'ARRAY', 'GEOGRAPHY', 'GEOMETRY', - ] + ], ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->connection->executeQuery(sprintf( /** @lang Snowflake */ @@ -135,7 +135,7 @@ public function testLoadTypedTableWithCastingValues(): void \'POINT(1820.12 890.56)\' ;', $stagingTable->getSchemaName(), - $stagingTable->getTableName() + $stagingTable->getTableName(), )); $this->connection->executeQuery(sprintf( /** @lang Snowflake */ @@ -150,7 +150,7 @@ public function testLoadTypedTableWithCastingValues(): void \'POINT(1820.12 890.56)\' ;', $stagingTable->getSchemaName(), - $stagingTable->getTableName() + $stagingTable->getTableName(), )); $toFinalTableImporter = new IncrementalImporter($this->connection); @@ -158,7 +158,7 @@ public function testLoadTypedTableWithCastingValues(): void $stagingTable, $destination, $options, - new ImportState($stagingTable->getTableName()) + new ImportState($stagingTable->getTableName()), ); self::assertEquals(2, $destinationRef->getRowsCount()); @@ -180,7 +180,7 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), $this->getSnowflakeImportOptions(), $this->getSourceInstance( @@ -188,7 +188,7 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), $this->getSnowflakeIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'accounts_3'], @@ -202,7 +202,7 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), new SnowflakeImportOptions( convertEmptyValuesToNull: [], @@ -216,7 +216,7 @@ public function incrementalImportData(): Generator $accountsStub->getColumns(), false, false, - ['id'] + ['id'], ), new SnowflakeImportOptions( convertEmptyValuesToNull: [], @@ -236,7 +236,7 @@ public function incrementalImportData(): Generator $multiPKStub->getColumns(), false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSnowflakeImportOptions(), $this->getSourceInstance( @@ -244,7 +244,7 @@ public function incrementalImportData(): Generator $multiPKStub->getColumns(), false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSnowflakeIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'multi_pk_ts'], @@ -259,7 +259,7 @@ public function incrementalImportData(): Generator $multiPKWithNullStub->getColumns(), false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), new SnowflakeImportOptions( convertEmptyValuesToNull: [], @@ -273,7 +273,7 @@ public function incrementalImportData(): Generator $multiPKWithNullStub->getColumns(), false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSnowflakeIncrementalImportOptions(), [$this->getDestinationSchemaName(), self::TABLE_MULTI_PK_WITH_TS], @@ -298,7 +298,7 @@ public function testIncrementalImport( array $table, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { $this->initTable($tablesToInit); @@ -306,7 +306,7 @@ public function testIncrementalImport( $destination = (new SnowflakeTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $toStageImporter = new ToStageImporter($this->connection); @@ -315,59 +315,59 @@ public function testIncrementalImport( $fullLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $fullLoadSource->getColumnsNames() + $fullLoadSource->getColumnsNames(), ); $incrementalLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $incrementalSource->getColumnsNames() + $incrementalSource->getColumnsNames(), ); try { // full load $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $fullLoadSource, $fullLoadStagingTable, - $fullLoadOptions + $fullLoadOptions, ); $fullImporter->importToTable( $fullLoadStagingTable, $destination, $fullLoadOptions, - $importState + $importState, ); // incremental load $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $incrementalSource, $incrementalLoadStagingTable, - $incrementalOptions + $incrementalOptions, ); $result = $incrementalImporter->importToTable( $incrementalLoadStagingTable, $destination, $incrementalOptions, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $fullLoadStagingTable->getSchemaName(), - $fullLoadStagingTable->getTableName() - ) + $fullLoadStagingTable->getTableName(), + ), ); $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $incrementalLoadStagingTable->getSchemaName(), - $incrementalLoadStagingTable->getTableName() - ) + $incrementalLoadStagingTable->getTableName(), + ), ); } @@ -379,7 +379,7 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/SqlBuilderTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/SqlBuilderTest.php index dbc468193..02c4b189a 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/SqlBuilderTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/SqlBuilderTest.php @@ -68,7 +68,7 @@ public function testGetDedupCommand(): void [ 'pk1', 'pk2', - ] + ], ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($deduplicationDef)); @@ -76,18 +76,18 @@ public function testGetDedupCommand(): void $sql = $this->getBuilder()->getDedupCommand( $stageDef, $deduplicationDef, - $deduplicationDef->getPrimaryKeysNames() + $deduplicationDef->getPrimaryKeysNames(), ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import_export_test_schema"."__temp_tempTable" ("col1", "col2") SELECT a."col1",a."col2" FROM (SELECT "col1", "col2", ROW_NUMBER() OVER (PARTITION BY "pk1","pk2" ORDER BY "pk1","pk2") AS "_row_number_" FROM "import_export_test_schema"."__temp_stagingTable") AS a WHERE a."_row_number_" = 1', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', SnowflakeQuote::quoteSingleIdentifier($deduplicationDef->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($deduplicationDef->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($deduplicationDef->getTableName()), )); self::assertCount(2, $result); @@ -103,22 +103,22 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): S sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (2,2,\'2\',\'2\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); if ($includeEmptyValues) { @@ -126,8 +126,8 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): S sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (2,2,\'\',NULL)', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE_QUOTED - ) + self::TEST_STAGING_TABLE_QUOTED, + ), ); } @@ -151,28 +151,28 @@ public function testGetDeleteOldItemsCommand(): void new SnowflakeColumn( 'id', new Snowflake( - Snowflake::TYPE_INT - ) + Snowflake::TYPE_INT, + ), ), SnowflakeColumn::createGenericColumn('pk1'), SnowflakeColumn::createGenericColumn('pk2'), SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $tableSql = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($tableDefinition)); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","pk1","pk2","col1","col2") VALUES (1,1,1,\'1\',\'1\')', - $tableSql - ) + $tableSql, + ), ); $stagingTableDefinition = new SnowflakeTableDefinition( self::TEST_SCHEMA, @@ -184,43 +184,43 @@ public function testGetDeleteOldItemsCommand(): void SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stagingTableDefinition)); $stagingTableSql = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (2,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $sql = $this->getBuilder()->getDeleteOldItemsCommand( $stagingTableDefinition, $tableDefinition, - $this->getSimpleImportOptions() + $this->getSimpleImportOptions(), ); self::assertEquals( // phpcs:ignore 'DELETE FROM "import_export_test_schema"."__temp_stagingTable" "src" USING "import_export_test_schema"."import_export_test_test" AS "dest" WHERE "dest"."pk1" = COALESCE("src"."pk1", \'\') AND "dest"."pk2" = COALESCE("src"."pk2", \'\') ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - $stagingTableSql + $stagingTableSql, )); self::assertCount(1, $result); @@ -246,28 +246,28 @@ public function testGetDeleteOldItemsCommandRequireSameTables(): void new SnowflakeColumn( 'id', new Snowflake( - Snowflake::TYPE_INT - ) + Snowflake::TYPE_INT, + ), ), SnowflakeColumn::createGenericColumn('pk1'), SnowflakeColumn::createGenericColumn('pk2'), SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $tableSql = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($tableDefinition)); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","pk1","pk2","col1","col2") VALUES (1,1,1,\'1\',\'1\')', - $tableSql - ) + $tableSql, + ), ); $stagingTableDefinition = new SnowflakeTableDefinition( self::TEST_SCHEMA, @@ -279,25 +279,25 @@ public function testGetDeleteOldItemsCommandRequireSameTables(): void SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stagingTableDefinition)); $stagingTableSql = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SnowflakeQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (2,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $sql = $this->getBuilder()->getDeleteOldItemsCommand( @@ -317,13 +317,13 @@ public function testGetDeleteOldItemsCommandRequireSameTables(): void self::assertEquals( // phpcs:ignore 'DELETE FROM "import_export_test_schema"."__temp_stagingTable" "src" USING "import_export_test_schema"."import_export_test_test" AS "dest" WHERE "dest"."pk1" = "src"."pk1" AND "dest"."pk2" = "src"."pk2" ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - $stagingTableSql + $stagingTableSql, )); self::assertCount(1, $result); @@ -344,7 +344,7 @@ private function assertTableNotExists(string $schemaName, string $tableName): vo self::fail(sprintf( 'Table "%s.%s" is expected to not exist.', $schemaName, - $tableName + $tableName, )); } catch (TableNotExistsReflectionException $e) { } @@ -360,7 +360,7 @@ public function testGetDropTableIfExistsCommand(): void self::assertEquals( // phpcs:ignore 'DROP TABLE IF EXISTS "import_export_test_schema"."import_export_test_test"', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -372,7 +372,7 @@ public function testGetDropTableIfExistsCommand(): void self::assertEquals( // phpcs:ignore 'DROP TABLE IF EXISTS "import_export_test_schema"."import_export_test_test"', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -386,8 +386,7 @@ protected function createTestTable(): void CREATE TABLE $table ( id int NOT NULL ) -EOT - ); +EOT,); } public function testGetInsertAllIntoTargetTableCommand(): void @@ -405,7 +404,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // no convert values no timestamp @@ -413,15 +412,15 @@ public function testGetInsertAllIntoTargetTableCommand(): void $fakeStage, $destination, new SnowflakeImportOptions( - ignoreColumns: ['id'] + ignoreColumns: ['id'], ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import_export_test_schema"."import_export_test_test" ("col1", "col2") (SELECT COALESCE("col1", \'\') AS "col1",COALESCE("col2", \'\') AS "col2" FROM "import_export_test_schema"."__temp_stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); @@ -429,7 +428,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -468,35 +467,35 @@ public function testGetInsertAllIntoTargetTableCommandCasting(): void new SnowflakeColumn( 'VARIANT', new Snowflake( - Snowflake::TYPE_VARIANT + Snowflake::TYPE_VARIANT, ), ), new SnowflakeColumn( 'BINARY', new Snowflake( - Snowflake::TYPE_BINARY + Snowflake::TYPE_BINARY, ), ), new SnowflakeColumn( 'VARBINARY', new Snowflake( - Snowflake::TYPE_VARBINARY + Snowflake::TYPE_VARBINARY, ), ), new SnowflakeColumn( 'OBJECT', new Snowflake( - Snowflake::TYPE_OBJECT + Snowflake::TYPE_OBJECT, ), ), new SnowflakeColumn( 'ARRAY', new Snowflake( - Snowflake::TYPE_ARRAY + Snowflake::TYPE_ARRAY, ), ), ]), - ['pk1'] + ['pk1'], ); $stage = new SnowflakeTableDefinition( self::TEST_SCHEMA, @@ -510,13 +509,13 @@ public function testGetInsertAllIntoTargetTableCommandCasting(): void $this->createNullableGenericColumn('OBJECT'), $this->createNullableGenericColumn('ARRAY'), ]), - [] + [], ); $this->connection->executeStatement( - (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($destination) + (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($destination), ); $this->connection->executeStatement( - (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($stage) + (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($stage), ); $this->connection->executeQuery(sprintf( @@ -560,13 +559,13 @@ public function testGetInsertAllIntoTargetTableCommandCasting(): void nullManipulation: ImportOptions::NULL_MANIPULATION_SKIP, //<- skipp null manipulation ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import_export_test_schema"."import_export_test_test" ("pk1", "VARIANT", "BINARY", "VARBINARY", "OBJECT", "ARRAY") (SELECT "pk1",CAST("VARIANT" AS VARIANT) AS "VARIANT","BINARY","VARBINARY",CAST(TO_VARIANT("OBJECT") AS OBJECT) AS "OBJECT",CAST("ARRAY" AS ARRAY) AS "ARRAY" FROM "import_export_test_schema"."__temp_stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); @@ -574,7 +573,7 @@ public function testGetInsertAllIntoTargetTableCommandCasting(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -633,7 +632,7 @@ public function testGetInsertAllIntoTargetTableCommandSameTables(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // no convert values no timestamp @@ -651,13 +650,13 @@ public function testGetInsertAllIntoTargetTableCommandSameTables(): void 'id', ], ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import_export_test_schema"."import_export_test_test" ("col1", "col2") (SELECT "col1","col2" FROM "import_export_test_schema"."__temp_stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); @@ -665,7 +664,7 @@ public function testGetInsertAllIntoTargetTableCommandSameTables(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -694,7 +693,7 @@ public function testGetInsertAllIntoTargetTableCommandSameTables(): void protected function createTestTableWithColumns( bool $includeTimestamp = false, - bool $includePrimaryKey = false + bool $includePrimaryKey = false, ): SnowflakeTableDefinition { $columns = []; $pks = []; @@ -702,7 +701,7 @@ protected function createTestTableWithColumns( $pks[] = 'id'; $columns[] = new SnowflakeColumn( 'id', - new Snowflake(Snowflake::TYPE_INT) + new Snowflake(Snowflake::TYPE_INT), ); } else { $columns[] = $this->createNullableGenericColumn('id'); @@ -713,7 +712,7 @@ protected function createTestTableWithColumns( if ($includeTimestamp) { $columns[] = new SnowflakeColumn( '_timestamp', - new Snowflake(Snowflake::TYPE_TIMESTAMP) + new Snowflake(Snowflake::TYPE_TIMESTAMP), ); } @@ -722,10 +721,10 @@ protected function createTestTableWithColumns( self::TEST_TABLE, false, new ColumnCollection($columns), - $pks + $pks, ); $this->connection->executeStatement( - (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition) + (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition), ); return $tableDefinition; @@ -738,12 +737,12 @@ private function createNullableGenericColumn(string $columnName): SnowflakeColum [ 'length' => '4000', // should be changed to max in future 'nullable' => true, - ] + ], ); return new SnowflakeColumn( $columnName, - $definition + $definition, ); } @@ -761,7 +760,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // convert col1 to null @@ -773,19 +772,19 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import_export_test_schema"."import_export_test_test" ("col1", "col2") (SELECT IFF("col1" = \'\', NULL, "col1"),COALESCE("col2", \'\') AS "col2" FROM "import_export_test_schema"."__temp_stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); self::assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -826,7 +825,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // use timestamp @@ -843,19 +842,19 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "import_export_test_schema"."import_export_test_test" ("col1", "col2", "_timestamp") (SELECT IFF("col1" = \'\', NULL, "col1"),COALESCE("col2", \'\') AS "col2",\'2020-01-01 00:00:00\' FROM "import_export_test_schema"."__temp_stagingTable" AS "src")', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); self::assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -877,7 +876,7 @@ public function testGetTruncateTableWithDeleteCommand(): void $sql = $this->getBuilder()->getTruncateTable(self::TEST_SCHEMA, self::TEST_STAGING_TABLE); self::assertEquals( 'TRUNCATE TABLE "import_export_test_schema"."__temp_stagingTable"', - $sql + $sql, ); $this->connection->executeStatement($sql); self::assertEquals(0, $ref->getRowsCount()); @@ -897,7 +896,7 @@ public function testGetUpdateWithPkCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new SnowflakeTableDefinition( @@ -908,19 +907,19 @@ public function testGetUpdateWithPkCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'2\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -936,18 +935,18 @@ public function testGetUpdateWithPkCommand(): void $fakeStage, $fakeDestination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "import_export_test_schema"."import_export_test_test" AS "dest" SET "col1" = COALESCE("src"."col1", \'\'), "col2" = COALESCE("src"."col2", \'\') FROM "import_export_test_schema"."__temp_stagingTable" AS "src" WHERE "dest"."col1" = COALESCE("src"."col1", \'\') AND (COALESCE(TO_VARCHAR("dest"."col1"), \'\') != COALESCE("src"."col1", \'\') OR COALESCE(TO_VARCHAR("dest"."col2"), \'\') != COALESCE("src"."col2", \'\'))', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -973,7 +972,7 @@ public function testGetUpdateWithPkCommandRequireSameTables(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new SnowflakeTableDefinition( @@ -984,19 +983,19 @@ public function testGetUpdateWithPkCommandRequireSameTables(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'2\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -1020,18 +1019,18 @@ public function testGetUpdateWithPkCommandRequireSameTables(): void nullManipulation: ImportOptions::NULL_MANIPULATION_SKIP, //<- skipp null manipulation ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "import_export_test_schema"."import_export_test_test" AS "dest" SET "col1" = "src"."col1", "col2" = "src"."col2" FROM "import_export_test_schema"."__temp_stagingTable" AS "src" WHERE "dest"."col1" = "src"."col1" ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -1055,35 +1054,35 @@ public function testGetUpdateWithPkCommandCasting(): void new SnowflakeColumn( 'VARIANT', new Snowflake( - Snowflake::TYPE_VARIANT + Snowflake::TYPE_VARIANT, ), ), new SnowflakeColumn( 'BINARY', new Snowflake( - Snowflake::TYPE_BINARY + Snowflake::TYPE_BINARY, ), ), new SnowflakeColumn( 'VARBINARY', new Snowflake( - Snowflake::TYPE_VARBINARY + Snowflake::TYPE_VARBINARY, ), ), new SnowflakeColumn( 'OBJECT', new Snowflake( - Snowflake::TYPE_OBJECT + Snowflake::TYPE_OBJECT, ), ), new SnowflakeColumn( 'ARRAY', new Snowflake( - Snowflake::TYPE_ARRAY + Snowflake::TYPE_ARRAY, ), ), ]), - ['pk1'] + ['pk1'], ); $stage = new SnowflakeTableDefinition( self::TEST_SCHEMA, @@ -1097,13 +1096,13 @@ public function testGetUpdateWithPkCommandCasting(): void $this->createNullableGenericColumn('OBJECT'), $this->createNullableGenericColumn('ARRAY'), ]), - [] + [], ); $this->connection->executeStatement( - (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($destination) + (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($destination), ); $this->connection->executeStatement( - (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($stage) + (new SnowflakeTableQueryBuilder())->getCreateTableCommandFromDefinition($stage), ); $this->connection->executeQuery(sprintf( @@ -1147,18 +1146,18 @@ public function testGetUpdateWithPkCommandCasting(): void nullManipulation: ImportOptions::NULL_MANIPULATION_SKIP, //<- skipp null manipulation ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "import_export_test_schema"."import_export_test_test" AS "dest" SET "pk1" = "src"."pk1", "VARIANT" = CAST("src"."VARIANT" AS VARIANT), "BINARY" = "src"."BINARY", "VARBINARY" = "src"."VARBINARY", "OBJECT" = CAST(TO_VARIANT("src"."OBJECT") AS OBJECT), "ARRAY" = CAST("src"."ARRAY" AS ARRAY) FROM "import_export_test_schema"."__temp_stagingTable" AS "src" WHERE "dest"."pk1" = "src"."pk1" ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEquals([ @@ -1196,7 +1195,7 @@ public function testGetUpdateWithPkCommandConvertValues(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new SnowflakeTableDefinition( @@ -1207,25 +1206,25 @@ public function testGetUpdateWithPkCommandConvertValues(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2") VALUES (1,\'2\',\'\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -1248,18 +1247,18 @@ public function testGetUpdateWithPkCommandConvertValues(): void $fakeStage, $fakeDestination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "import_export_test_schema"."import_export_test_test" AS "dest" SET "col1" = IFF("src"."col1" = \'\', NULL, "src"."col1"), "col2" = COALESCE("src"."col2", \'\') FROM "import_export_test_schema"."__temp_stagingTable" AS "src" WHERE "dest"."col1" = COALESCE("src"."col1", \'\') AND (COALESCE(TO_VARCHAR("dest"."col1"), \'\') != COALESCE("src"."col1", \'\') OR COALESCE(TO_VARCHAR("dest"."col2"), \'\') != COALESCE("src"."col2", \'\'))', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -1293,7 +1292,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new SnowflakeTableDefinition( @@ -1304,27 +1303,27 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2","_timestamp") VALUES (1,\'\',\'1\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2","_timestamp") VALUES (1,\'2\',\'\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -1348,19 +1347,19 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $fakeStage, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) + $timestampSet->format(DateTimeHelper::FORMAT), ); self::assertEquals( // phpcs:ignore 'UPDATE "import_export_test_schema"."import_export_test_test" AS "dest" SET "col1" = IFF("src"."col1" = \'\', NULL, "src"."col1"), "col2" = COALESCE("src"."col2", \'\'), "_timestamp" = \'2020-01-01 01:01:01\' FROM "import_export_test_schema"."__temp_stagingTable" AS "src" WHERE "dest"."col1" = COALESCE("src"."col1", \'\') AND (COALESCE(TO_VARCHAR("dest"."col1"), \'\') != COALESCE("src"."col1", \'\') OR COALESCE(TO_VARCHAR("dest"."col2"), \'\') != COALESCE("src"."col2", \'\'))', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -1371,7 +1370,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void self::assertIsString($item['_timestamp']); self::assertSame( $timestampSet->format(DateTimeHelper::FORMAT), - (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT) + (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT), ); } } @@ -1393,7 +1392,7 @@ public function testGetUpdateWithPkCommandNullManipulationWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new SnowflakeTableDefinition( @@ -1404,20 +1403,20 @@ public function testGetUpdateWithPkCommandNullManipulationWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("id","col1","col2","_timestamp") VALUES (1,\'1\',\'1\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); self::assertEqualsCanonicalizing([ @@ -1443,19 +1442,19 @@ public function testGetUpdateWithPkCommandNullManipulationWithTimestamp(): void $fakeStage, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) + $timestampSet->format(DateTimeHelper::FORMAT), ); self::assertEquals( // phpcs:ignore 'UPDATE "import_export_test_schema"."import_export_test_test" AS "dest" SET "col1" = "src"."col1", "col2" = "src"."col2", "_timestamp" = \'2020-01-01 01:01:01\' FROM "import_export_test_schema"."__temp_stagingTable" AS "src" WHERE "dest"."col1" = "src"."col1" ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); // timestamp was updated to $timestampSet but there is same row as in stage table so no other value is updated @@ -1481,7 +1480,7 @@ private function getStagingTableDefinition(): SnowflakeTableDefinition $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/StageToFinalCastingErrorsTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/StageToFinalCastingErrorsTest.php index b5e92db24..22cc42ac2 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/StageToFinalCastingErrorsTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ToFinal/StageToFinalCastingErrorsTest.php @@ -91,13 +91,13 @@ public function testLoadTypedTableWithCastingValuesErrors( 1, SnowflakeImportOptions::SAME_TABLES_NOT_REQUIRED, SnowflakeImportOptions::NULL_MANIPULATION_SKIP, - [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME] + [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], ); $destinationRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'types' + 'types', ); /** @var SnowflakeTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -105,12 +105,12 @@ public function testLoadTypedTableWithCastingValuesErrors( $destination->getSchemaName(), [ $column->getColumnName(), - ] + ], ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->connection->executeQuery(sprintf( /** @lang Snowflake */ @@ -118,7 +118,7 @@ public function testLoadTypedTableWithCastingValuesErrors( $stagingTable->getSchemaName(), $stagingTable->getTableName(), $column->getColumnName(), - $insertData + $insertData, )); $toFinalTableImporter = new FullImporter($this->connection); @@ -127,7 +127,7 @@ public function testLoadTypedTableWithCastingValuesErrors( $stagingTable, $destination, $options, - new ImportState($stagingTable->getTableName()) + new ImportState($stagingTable->getTableName()), ); $this->fail('Import must fail'); } catch (Exception $e) { diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportFileTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportFileTest.php index 9344291cc..ab6caa4f0 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportFileTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportFileTest.php @@ -56,7 +56,7 @@ public function testImport( int $expectedNumberOfRows, int $expectedFirstLineLength, int $skippedLines = 0, - bool $markAsSkipped = false + bool $markAsSkipped = false, ): void { if ($markAsSkipped) { $this->markTestSkipped('Skipping test SourceDirectory not implemented.'); @@ -67,11 +67,11 @@ public function testImport( $ref = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - $table + $table, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SnowflakeTableQueryBuilder(); @@ -79,23 +79,23 @@ public function testImport( $qb->getCreateTempTableCommand( $stagingTable->getSchemaName(), $stagingTable->getTableName(), - $stagingTable->getColumnsDefinitions() - ) + $stagingTable->getColumnsDefinitions(), + ), ); $importer->importToStagingTable( $this->getSourceInstanceFromCsv( - ...$sourceSetting + ...$sourceSetting, ), $stagingTable, - $this->getSnowflakeImportOptions($skippedLines) + $this->getSnowflakeImportOptions($skippedLines), ); $importedData = $this->connection->fetchAllAssociative( sprintf( 'SELECT * FROM %s.%s', SnowflakeQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + SnowflakeQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), ); self::assertCount($expectedNumberOfRows, $importedData); self::assertCount($expectedFirstLineLength, $importedData[0]); @@ -156,7 +156,7 @@ public function importSettingProvider(): Generator $sourceDirClassExists = class_exists(sprintf( 'Keboola\Db\ImportExport\Storage\%s\SourceDirectory', - getenv('STORAGE_TYPE') + getenv('STORAGE_TYPE'), )); yield 'with directory' => [ 'table' => self::TABLE_ACCOUNTS_WITHOUT_TS, @@ -215,15 +215,15 @@ public function testWithNullifyValue(string $fileName): void $ref = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_NULLIFY + self::TABLE_NULLIFY, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer->importToStagingTable( $this->getSourceInstanceFromCsv( @@ -235,10 +235,10 @@ public function testWithNullifyValue(string $fileName): void 'col2', ], false, - false + false, ), $stagingTable, - $this->getSnowflakeImportOptions() + $this->getSnowflakeImportOptions(), ); self::assertSame([ @@ -249,8 +249,8 @@ public function testWithNullifyValue(string $fileName): void sprintf( 'SELECT * FROM %s.%s', SnowflakeQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - SnowflakeQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + SnowflakeQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), )); } @@ -274,15 +274,15 @@ public function testInvalidManifestImport(): void $ref = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_ACCOUNTS_WITHOUT_TS + self::TABLE_ACCOUNTS_WITHOUT_TS, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); if (getenv('STORAGE_TYPE') === StorageType::STORAGE_ABS) { @@ -298,10 +298,10 @@ public function testInvalidManifestImport(): void new CsvOptions(), self::TWITTER_COLUMNS, true, - false + false, ), $stagingTable, - $this->getSnowflakeImportOptions() + $this->getSnowflakeImportOptions(), ); } @@ -313,15 +313,15 @@ public function testCopyIntoInvalidTypes(): void $ref = new SnowflakeTableReflection( $this->connection, $this->getSourceSchemaName(), - self::TABLE_TYPES + self::TABLE_TYPES, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SnowflakeTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->expectException(LegacyImportException::class); @@ -337,10 +337,10 @@ public function testCopyIntoInvalidTypes(): void 'boolCol', ], false, - false + false, ), $stagingTable, - $this->getSnowflakeImportOptions() + $this->getSnowflakeImportOptions(), ); } } diff --git a/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportTest.php b/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportTest.php index a3abff752..6d458856e 100644 --- a/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportTest.php +++ b/packages/php-db-import-export/tests/functional/Snowflake/ToStage/StageImportTest.php @@ -35,14 +35,14 @@ public function testMoveDataFromAToB(): void $targetTableRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -51,22 +51,22 @@ public function testMoveDataFromAToB(): void $importer->importToStagingTable( $source, $targetTableRef->getTableDefinition(), - $this->getSnowflakeImportOptions() + $this->getSnowflakeImportOptions(), ); $dataSource = $this->connection->fetchAllAssociative( sprintf( 'SELECT * FROM %s.%s', SnowflakeQuote::quoteSingleIdentifier($this->getSourceSchemaName()), - SnowflakeQuote::quoteSingleIdentifier('sourceTable') - ) + SnowflakeQuote::quoteSingleIdentifier('sourceTable'), + ), ); $dataDest = $this->connection->fetchAllAssociative( sprintf( 'SELECT * FROM %s.%s', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), - SnowflakeQuote::quoteSingleIdentifier('targetTable') - ) + SnowflakeQuote::quoteSingleIdentifier('targetTable'), + ), ); self::assertSame($dataSource, $dataDest); @@ -80,14 +80,14 @@ public function testMoveDataFromAToTableWithWrongSourceStructure(): void $targetTableRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'XXXX', 'last_name'], - [] + [], ); $this->expectException(Exception::class); @@ -96,7 +96,7 @@ public function testMoveDataFromAToTableWithWrongSourceStructure(): void $importer->importToStagingTable( $source, $targetTableRef->getTableDefinition(), - $this->getSnowflakeImportOptions() + $this->getSnowflakeImportOptions(), ); } @@ -110,8 +110,8 @@ public function testMoveDataFromBetweenDifferentTables(): void 'ALTER TABLE %s.%s DROP COLUMN %s', SnowflakeQuote::quoteSingleIdentifier($this->getDestinationSchemaName()), SnowflakeQuote::quoteSingleIdentifier('targetTable'), - SnowflakeQuote::quoteSingleIdentifier('first_name') - ) + SnowflakeQuote::quoteSingleIdentifier('first_name'), + ), ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -120,14 +120,14 @@ public function testMoveDataFromBetweenDifferentTables(): void $targetTableRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->expectException(Exception::class); @@ -136,7 +136,7 @@ public function testMoveDataFromBetweenDifferentTables(): void $importer->importToStagingTable( $source, $targetTableRef->getTableDefinition(), - $this->getSnowflakeImportOptions() + $this->getSnowflakeImportOptions(), ); } @@ -151,21 +151,21 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnNameMismatch(): v "first_name" VARCHAR(100), "middle_name" VARCHAR(100), "last_name" VARCHAR(100) -);' +);', ); $importer = new ToStageImporter($this->connection); $targetTableRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -183,7 +183,7 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnNameMismatch(): v numberOfIgnoredLines: 1, requireSameTables: SnowflakeImportOptions::SAME_TABLES_REQUIRED, ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], - ) + ), ); } @@ -198,21 +198,21 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnCount(): void "first_name" VARCHAR(100), "last_name" VARCHAR(100), "middle_name" VARCHAR(100) -);' +);', ); $importer = new ToStageImporter($this->connection); $targetTableRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -233,7 +233,7 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnCount(): void numberOfIgnoredLines: 1, requireSameTables: SnowflakeImportOptions::SAME_TABLES_REQUIRED, ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], - ) + ), ); } @@ -247,21 +247,21 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnMismatch(): void "id" INTEGER, "first_name" VARCHAR(100), "last_name" VARCHAR(99) -);' +);', ); $importer = new ToStageImporter($this->connection); $targetTableRef = new SnowflakeTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getSourceSchemaName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->insertRowToTable($this->getSourceSchemaName(), 'sourceTable', 1, 'a', 'b'); @@ -269,7 +269,7 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnMismatch(): void $this->expectException(ColumnsMismatchException::class); $this->expectExceptionMessage( - 'Source destination columns mismatch. "last_name VARCHAR (100)"->"last_name VARCHAR (99)"' + 'Source destination columns mismatch. "last_name VARCHAR (100)"->"last_name VARCHAR (99)"', ); $importer->importToStagingTable( $source, @@ -281,7 +281,7 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnMismatch(): void numberOfIgnoredLines: 1, requireSameTables: SnowflakeImportOptions::SAME_TABLES_REQUIRED, ignoreColumns: [ToStageImporterInterface::TIMESTAMP_COLUMN_NAME], - ) + ), ); } } diff --git a/packages/php-db-import-export/tests/functional/Storage/ABS/BlobIteratorTest.php b/packages/php-db-import-export/tests/functional/Storage/ABS/BlobIteratorTest.php index 1cd640e0e..2b0c24e2e 100644 --- a/packages/php-db-import-export/tests/functional/Storage/ABS/BlobIteratorTest.php +++ b/packages/php-db-import-export/tests/functional/Storage/ABS/BlobIteratorTest.php @@ -25,7 +25,7 @@ public function testIterator(): void $iterator = new BlobIterator( $this->getClient(), (string) getenv('ABS_CONTAINER_NAME'), - $options + $options, ); $count = 0; @@ -48,7 +48,7 @@ public function testIteratorLimit100(): void $iterator = new BlobIterator( $this->getClient(), (string) getenv('ABS_CONTAINER_NAME'), - $options + $options, ); $count = 0; @@ -71,12 +71,12 @@ private function getClient(): BlobRestProxy Resources::SAS_TOKEN_NAME, $this->getCredentialsForAzureContainer( (string) getenv('ABS_CONTAINER_NAME'), - 'rl' - ) + 'rl', + ), ); return ClientFactory::createClientFromConnectionString( - $SASConnectionString + $SASConnectionString, ); } } diff --git a/packages/php-db-import-export/tests/functional/Storage/ABS/SourceDirectoryTest.php b/packages/php-db-import-export/tests/functional/Storage/ABS/SourceDirectoryTest.php index 77df2bfec..4af4acc11 100644 --- a/packages/php-db-import-export/tests/functional/Storage/ABS/SourceDirectoryTest.php +++ b/packages/php-db-import-export/tests/functional/Storage/ABS/SourceDirectoryTest.php @@ -19,7 +19,7 @@ public function testGetManifestEntriesFolder(): void new CsvOptions(), [], true, - true + true, ); $entries = $source->getManifestEntries(); self::assertCount(2, $entries); @@ -32,7 +32,7 @@ public function testGetManifestEntriesFolderWithTrailingSlash(): void new CsvOptions(), [], true, - true + true, ); $entries = $source->getManifestEntries(); self::assertCount(2, $entries); @@ -45,7 +45,7 @@ public function testGetLineEnding(): void new CsvOptions(), [], true, - true + true, ); self::assertEquals('lf', $source->getLineEnding()); } diff --git a/packages/php-db-import-export/tests/functional/Storage/S3/SourceDirectoryTest.php b/packages/php-db-import-export/tests/functional/Storage/S3/SourceDirectoryTest.php index da3a58252..945cfda9e 100644 --- a/packages/php-db-import-export/tests/functional/Storage/S3/SourceDirectoryTest.php +++ b/packages/php-db-import-export/tests/functional/Storage/S3/SourceDirectoryTest.php @@ -19,7 +19,7 @@ public function testGetManifestEntriesFolder(): void new CsvOptions(), [], true, - true + true, ); $entries = $source->getManifestEntries(); self::assertCount(2, $entries); @@ -32,7 +32,7 @@ public function testGetManifestEntriesFolderWithTrailingSlash(): void new CsvOptions(), [], true, - true + true, ); $entries = $source->getManifestEntries(); self::assertCount(2, $entries); diff --git a/packages/php-db-import-export/tests/functional/Synapse/ExportTest.php b/packages/php-db-import-export/tests/functional/Synapse/ExportTest.php index 78b2ff908..dfc0f6689 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/ExportTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/ExportTest.php @@ -49,7 +49,7 @@ public function testExportGzip(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Synapse\Table( $schema, - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $options = $this->getSimpleImportOptions(); @@ -64,7 +64,7 @@ public function testExportGzip(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -76,7 +76,7 @@ public function testExportGzip(): void } private function getExportOptions( - bool $isCompressed + bool $isCompressed, ): SynapseExportOptions { switch ((string) getenv('CREDENTIALS_IMPORT_TYPE')) { case SynapseImportOptions::CREDENTIALS_MANAGED_IDENTITY: @@ -88,13 +88,13 @@ private function getExportOptions( default: throw new RuntimeException(sprintf( 'Invalid CREDENTIALS_IMPORT_TYPE:"%s"', - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), )); } return new SynapseExportOptions( $isCompressed, $exportCredentialsType, - ExportOptions::MANIFEST_AUTOGENERATED + ExportOptions::MANIFEST_AUTOGENERATED, ); } @@ -102,13 +102,13 @@ private function getExportOptions( * @return SynapseImportOptions */ protected function getSimpleImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): ImportOptions { return new SynapseImportOptions( [], false, true, - $skipLines + $skipLines, ); } @@ -121,34 +121,34 @@ protected function getSimpleImportOptions( private function importTable( Storage\SourceInterface $source, Storage\DestinationInterface $destination, - ImportOptions $options + ImportOptions $options, ): void { $importer = new ToStageImporter($this->connection); $destinationRef = new SynapseTableReflection( $this->connection, $destination->getSchema(), - $destination->getTableName() + $destination->getTableName(), ); $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } @@ -160,7 +160,7 @@ public function testExportSimple(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Synapse\Table( $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $options = $this->getSimpleImportOptions(); assert($source instanceof ABS\SourceFile); @@ -174,7 +174,7 @@ public function testExportSimple(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -186,7 +186,7 @@ public function testExportSimple(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -202,7 +202,7 @@ public function testExportSimpleWithQuery(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Storage\Synapse\Table( $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $options = $this->getSimpleImportOptions(); @@ -214,7 +214,7 @@ public function testExportSimpleWithQuery(): void $query = sprintf( 'SELECT %s FROM %s', (new SqlBuilder())->getColumnsString($file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Synapse\SelectSource($query); $options = $this->getExportOptions(false); @@ -223,7 +223,7 @@ public function testExportSimpleWithQuery(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir()); @@ -235,7 +235,7 @@ public function testExportSimpleWithQuery(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); diff --git a/packages/php-db-import-export/tests/functional/Synapse/FromTableCTASAdapterSqlBuilderTest.php b/packages/php-db-import-export/tests/functional/Synapse/FromTableCTASAdapterSqlBuilderTest.php index 8cf2754c6..a446190c6 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/FromTableCTASAdapterSqlBuilderTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/FromTableCTASAdapterSqlBuilderTest.php @@ -51,7 +51,7 @@ private function getTableDefinition(string $schemaName, string $tableName, array new ColumnCollection($cols), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); } @@ -61,22 +61,22 @@ private function insertData(string $schemaName, string $tableName): void sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', $schemaName, - $tableName - ) + $tableName, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', $schemaName, - $tableName - ) + $tableName, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (2,2,\'2\',\'2\')', $schemaName, - $tableName - ) + $tableName, + ), ); } @@ -90,7 +90,7 @@ public function ctasProvider(): Generator 'expectedDestination' => $this->getTableDefinition( $this->getDestinationSchemaName(), 'dest', - $this->getDefaultColumns() + $this->getDefaultColumns(), ), 'requireSameTables' => SynapseImportOptions::SAME_TABLES_REQUIRED, // phpcs:ignore @@ -107,12 +107,12 @@ public function ctasProvider(): Generator [], new TableDistributionDefinition( TableDistributionDefinition::TABLE_DISTRIBUTION_HASH, - ['pk1'] + ['pk1'], ), new TableIndexDefinition( TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX, - ['pk1'] - ) + ['pk1'], + ), ), 'requireSameTables' => SynapseImportOptions::SAME_TABLES_REQUIRED, // phpcs:ignore @@ -124,7 +124,7 @@ public function ctasProvider(): Generator 'expectedDestination' => $this->getTableDefinition( $this->getDestinationSchemaName(), 'dest', - $this->getDefaultColumns() + $this->getDefaultColumns(), ), 'requireSameTables' => SynapseImportOptions::SAME_TABLES_NOT_REQUIRED, // phpcs:ignore @@ -132,13 +132,13 @@ public function ctasProvider(): Generator ]; $pk1 = new SynapseColumn('pk1', new Synapse( - Synapse::TYPE_BIGINT + Synapse::TYPE_BIGINT, )); $pk2 = new SynapseColumn('pk2', new Synapse( - Synapse::TYPE_NUMERIC + Synapse::TYPE_NUMERIC, )); $col1 = new SynapseColumn('col1', new Synapse( - Synapse::TYPE_VARCHAR + Synapse::TYPE_VARCHAR, )); yield 'typed no casting (typed tables with types)' => [ @@ -156,7 +156,7 @@ public function ctasProvider(): Generator $pk2, $col1, SynapseColumn::createGenericColumn('col2'), - ] + ], ), 'requireSameTables' => SynapseImportOptions::SAME_TABLES_REQUIRED, // phpcs:ignore @@ -173,7 +173,7 @@ public function ctasProvider(): Generator 'expectedDestination' => $this->getTableDefinition( $this->getDestinationSchemaName(), 'dest', - $this->getDefaultColumns() + $this->getDefaultColumns(), ), 'requireSameTables' => SynapseImportOptions::SAME_TABLES_NOT_REQUIRED, // phpcs:ignore @@ -189,11 +189,11 @@ public function testGetCTASCommandTableSource( array $sourceColumns, SynapseTableDefinition $expectedDest, bool $requireSameTables, - string $expectedSql + string $expectedSql, ): void { $source = $this->getTableDefinition($this->getSourceSchemaName(), 'source', $sourceColumns); $this->connection->executeStatement( - (new SynapseTableQueryBuilder())->getCreateTableCommandFromDefinition($source) + (new SynapseTableQueryBuilder())->getCreateTableCommandFromDefinition($source), ); $this->insertData($this->getSourceSchemaName(), 'source'); $sql = FromTableCTASAdapterSqlBuilder::getCTASCommand( @@ -201,21 +201,21 @@ public function testGetCTASCommandTableSource( new Table( $source->getSchemaName(), $source->getTableName(), - $source->getColumnsNames() + $source->getColumnsNames(), ), - $this->getImportOptions($requireSameTables) + $this->getImportOptions($requireSameTables), ); $this->assertSame($expectedSql, $sql); $this->connection->executeStatement($sql); $destRef = new SynapseTableReflection( $this->connection, $expectedDest->getSchemaName(), - $expectedDest->getTableName() + $expectedDest->getTableName(), ); $this->assertSame(3, $destRef->getRowsCount()); Assert::assertSameColumns( $destRef->getColumnsDefinitions(), - $expectedDest->getColumnsDefinitions() + $expectedDest->getColumnsDefinitions(), ); } @@ -228,7 +228,7 @@ private function getImportOptions(bool $requireSameTables): SynapseImportOptions 0, SynapseImportOptions::CREDENTIALS_SAS, SynapseImportOptions::TABLE_TYPES_PRESERVE, - $requireSameTables + $requireSameTables, ); } diff --git a/packages/php-db-import-export/tests/functional/Synapse/FullImportNoTypesTest.php b/packages/php-db-import-export/tests/functional/Synapse/FullImportNoTypesTest.php index 800fce18d..99aeda872 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/FullImportNoTypesTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/FullImportNoTypesTest.php @@ -38,7 +38,7 @@ public function fullImportData(): Generator $expectedEscaping, ] = $this->getExpectationFileData( 'escaping/standard-with-enclosures.csv', - self::EXPECTATION_FILE_DATA_KEEP_AS_IS + self::EXPECTATION_FILE_DATA_KEEP_AS_IS, ); [ @@ -46,7 +46,7 @@ public function fullImportData(): Generator $expectedAccounts, ] = $this->getExpectationFileData( 'tw_accounts.csv', - self::EXPECTATION_FILE_DATA_KEEP_AS_IS + self::EXPECTATION_FILE_DATA_KEEP_AS_IS, ); $file = new CsvFile(self::DATA_DIR . 'tw_accounts.changedColumnsOrder.csv'); @@ -57,7 +57,7 @@ public function fullImportData(): Generator $expectedLemma, ] = $this->getExpectationFileData( 'lemma.csv', - self::EXPECTATION_FILE_DATA_KEEP_AS_IS + self::EXPECTATION_FILE_DATA_KEEP_AS_IS, ); // large sliced manifest @@ -73,7 +73,7 @@ public function fullImportData(): Generator $escapingHeader, true, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSynapseImportOptions(ImportOptions::SKIP_NO_LINE), @@ -88,7 +88,7 @@ public function fullImportData(): Generator $escapingHeader, true, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSynapseImportOptions(ImportOptions::SKIP_NO_LINE), @@ -103,7 +103,7 @@ public function fullImportData(): Generator $lemmaHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_LEMMA], $this->getSynapseImportOptions(), @@ -118,7 +118,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSynapseImportOptions(), @@ -133,7 +133,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSynapseImportOptions(), @@ -149,7 +149,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSynapseImportOptions(), @@ -164,7 +164,7 @@ public function fullImportData(): Generator $accountChangedColumnsOrderHeader, false, false, - ['id'] + ['id'], ), [ $this->getDestinationSchemaName(), @@ -181,7 +181,7 @@ public function fullImportData(): Generator $accountsHeader, false, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSynapseImportOptions(), @@ -195,7 +195,7 @@ public function fullImportData(): Generator $accountsHeader, false, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSynapseImportOptions(), @@ -210,7 +210,7 @@ public function fullImportData(): Generator $accountsHeader, true, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSynapseImportOptions(ImportOptions::SKIP_NO_LINE), @@ -225,7 +225,7 @@ public function fullImportData(): Generator $accountsHeader, true, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSynapseImportOptions(ImportOptions::SKIP_NO_LINE), @@ -241,7 +241,7 @@ public function fullImportData(): Generator $accountsHeader, true, true, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSynapseImportOptions(ImportOptions::SKIP_NO_LINE), @@ -257,7 +257,7 @@ public function fullImportData(): Generator ['column', 'table'], false, false, - [] + [], ), [$this->getDestinationSchemaName(), self::TABLE_TABLE], $this->getSynapseImportOptions(), @@ -276,7 +276,7 @@ public function fullImportData(): Generator ], false, false, - [] + [], ), [ $this->getDestinationSchemaName(), @@ -297,7 +297,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [ $this->getDestinationSchemaName(), @@ -309,7 +309,7 @@ public function fullImportData(): Generator false, // don't use timestamp ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - (string) getenv('CREDENTIALS_IMPORT_TYPE') + (string) getenv('CREDENTIALS_IMPORT_TYPE'), ), $expectedEscaping, 7, @@ -320,7 +320,7 @@ public function fullImportData(): Generator new Storage\Synapse\Table($this->getSourceSchemaName(), self::TABLE_OUT_CSV_2COLS, $escapingHeader), [$this->getDestinationSchemaName(), self::TABLE_OUT_CSV_2COLS], $this->getSynapseImportOptions( - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), [['a', 'b'], ['c', 'd']], 2, @@ -335,14 +335,14 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationSchemaName(), 'types', ], $this->getSynapseImportOptions( - ImportOptions::SKIP_FIRST_LINE + ImportOptions::SKIP_FIRST_LINE, ), [['a', '10.5', '0.3', '1']], 1, @@ -362,7 +362,7 @@ public function testFullImport( SynapseImportOptions $options, array $expected, int $expectedImportedRowCount, - array $tablesToInit + array $tablesToInit, ): void { $this->initTables($tablesToInit); @@ -370,16 +370,16 @@ public function testFullImport( $destination = (new SynapseTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $toStageImporter = new ToStageImporter($this->connection); $toFinalTableImporter = new FullImporter($this->connection); @@ -387,20 +387,20 @@ public function testFullImport( $importState = $toStageImporter->importToStagingTable( $source, $stagingTable, - $options + $options, ); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $stagingTable->getSchemaName(), - $stagingTable->getTableName() - ) + $stagingTable->getTableName(), + ), ); } @@ -411,7 +411,7 @@ public function testFullImport( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Synapse/FullImportWithTypesTest.php b/packages/php-db-import-export/tests/functional/Synapse/FullImportWithTypesTest.php index 8f71a24f3..d641c7988 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/FullImportWithTypesTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/FullImportWithTypesTest.php @@ -57,7 +57,7 @@ protected function initTable(string $tableName): void PRIMARY KEY NONCLUSTERED("id") NOT ENFORCED ) WITH (DISTRIBUTION=%s)', $this->getDestinationSchemaName(), - $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution + $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution, )); break; case self::TABLE_TYPES: @@ -69,7 +69,7 @@ protected function initTable(string $tableName): void [boolCol] tinyint NOT NULL, [_timestamp] datetime2 );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->exec(sprintf( @@ -79,13 +79,13 @@ protected function initTable(string $tableName): void [floatCol] real NOT NULL, [boolCol] tinyint NOT NULL );', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->exec(sprintf( 'INSERT INTO [%s].[types] VALUES (\'a\', \'10.5\', \'1.4\', 1) ;', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); break; } @@ -101,7 +101,7 @@ public function fullImportData(): Generator $expectedAccounts, ] = $this->getExpectationFileData( 'expectation.tw_accounts-typed.csv', - self::EXPECTATION_FILE_DATA_CONVERT_NULLS + self::EXPECTATION_FILE_DATA_CONVERT_NULLS, ); $file = new CsvFile(self::DATA_DIR . 'tw_accounts.changedColumnsOrder.csv'); @@ -113,7 +113,7 @@ public function fullImportData(): Generator $accountChangedColumnsOrderHeader, false, false, - ['id'] + ['id'], ), [ $this->getDestinationSchemaName(), @@ -130,7 +130,7 @@ public function fullImportData(): Generator $accountsHeader, false, false, - ['id'] + ['id'], ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], $this->getSynapseImportOptions(), @@ -149,7 +149,7 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationSchemaName(), @@ -159,7 +159,7 @@ public function fullImportData(): Generator ImportOptions::SKIP_FIRST_LINE, SynapseImportOptions::TABLE_TYPES_CAST, SynapseImportOptions::SAME_TABLES_REQUIRED, - SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_CTAS + SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_CTAS, ), [['a', '10.5', '1.4', '1']], 1, @@ -176,7 +176,7 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationSchemaName(), @@ -186,7 +186,7 @@ public function fullImportData(): Generator ImportOptions::SKIP_FIRST_LINE, SynapseImportOptions::TABLE_TYPES_CAST, SynapseImportOptions::SAME_TABLES_REQUIRED, - SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_INSERT_INTO + SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_INSERT_INTO, ), [['a', '10.5', '1.4', '1']], 1, @@ -206,7 +206,7 @@ public function testFullImport( SynapseImportOptions $options, array $expected, int $expectedImportedRowCount, - array $tablesToInit + array $tablesToInit, ): void { $this->initTables($tablesToInit); @@ -214,16 +214,16 @@ public function testFullImport( $destination = (new SynapseTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $toStageImporter = new ToStageImporter($this->connection); $toFinalTableImporter = new FullImporter($this->connection); @@ -231,20 +231,20 @@ public function testFullImport( $importState = $toStageImporter->importToStagingTable( $source, $stagingTable, - $options + $options, ); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $stagingTable->getSchemaName(), - $stagingTable->getTableName() - ) + $stagingTable->getTableName(), + ), ); } @@ -255,7 +255,7 @@ public function testFullImport( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportNoTypesTest.php b/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportNoTypesTest.php index 9e1f5144a..987b6b941 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportNoTypesTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportNoTypesTest.php @@ -37,13 +37,13 @@ public function incrementalImportData(): Generator $expectedAccountsRows, ] = $this->getExpectationFileData( 'expectation.tw_accounts.increment.csv', - self::EXPECTATION_FILE_DATA_KEEP_AS_IS + self::EXPECTATION_FILE_DATA_KEEP_AS_IS, ); [ $multiPkColumns, ] = $this->getExpectationFileData( 'expectation.multi-pk.increment.csv', - self::EXPECTATION_FILE_DATA_KEEP_AS_IS + self::EXPECTATION_FILE_DATA_KEEP_AS_IS, ); $tests = []; @@ -53,7 +53,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getSynapseImportOptions(), $this->createABSSourceInstance( @@ -61,7 +61,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getSynapseIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'accounts-3'], @@ -75,7 +75,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), new SynapseImportOptions( [], @@ -83,14 +83,14 @@ public function incrementalImportData(): Generator false, // disable timestamp ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ), $this->createABSSourceInstance( 'tw_accounts.increment.csv', $accountColumns, false, false, - ['id'] + ['id'], ), new SynapseImportOptions( [], @@ -98,7 +98,7 @@ public function incrementalImportData(): Generator false, // disable timestamp ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_WITHOUT_TS], $expectedAccountsRows, @@ -111,7 +111,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSynapseImportOptions(), $this->createABSSourceInstance( @@ -119,7 +119,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSynapseIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'multi-pk'], @@ -146,7 +146,7 @@ public function testIncrementalImport( array $table, $expected, int $expectedImportedRowCount, - array $tablesToInit + array $tablesToInit, ): void { $this->initTables($tablesToInit); @@ -154,7 +154,7 @@ public function testIncrementalImport( $destination = (new SynapseTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $toStageImporter = new ToStageImporter($this->connection); @@ -163,59 +163,59 @@ public function testIncrementalImport( $fullLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $fullLoadSource->getColumnsNames() + $fullLoadSource->getColumnsNames(), ); $incrementalLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $incrementalSource->getColumnsNames() + $incrementalSource->getColumnsNames(), ); try { // full load $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $fullLoadSource, $fullLoadStagingTable, - $fullLoadOptions + $fullLoadOptions, ); $fullImporter->importToTable( $fullLoadStagingTable, $destination, $fullLoadOptions, - $importState + $importState, ); // incremental load $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $incrementalSource, $incrementalLoadStagingTable, - $incrementalOptions + $incrementalOptions, ); $result = $incrementalImporter->importToTable( $incrementalLoadStagingTable, $destination, $incrementalOptions, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $fullLoadStagingTable->getSchemaName(), - $fullLoadStagingTable->getTableName() - ) + $fullLoadStagingTable->getTableName(), + ), ); $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $incrementalLoadStagingTable->getSchemaName(), - $incrementalLoadStagingTable->getTableName() - ) + $incrementalLoadStagingTable->getTableName(), + ), ); } @@ -227,13 +227,13 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } else { $this->assertSynapseTableExpectedRowCount( $destination, $incrementalOptions, - $expected + $expected, ); } } diff --git a/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportWithTypesTest.php b/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportWithTypesTest.php index 820d57034..b0f1c96d3 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportWithTypesTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/IncrementalImportWithTypesTest.php @@ -46,7 +46,7 @@ protected function initTable(string $tableName): void PRIMARY KEY NONCLUSTERED("Col1") NOT ENFORCED ) WITH (DISTRIBUTION=%s)', $this->getDestinationSchemaName(), - $tableDistribution === 'HASH' ? 'HASH([Col1])' : $tableDistribution + $tableDistribution === 'HASH' ? 'HASH([Col1])' : $tableDistribution, )); break; case self::TABLE_ACCOUNTS_3: @@ -68,7 +68,7 @@ protected function initTable(string $tableName): void PRIMARY KEY NONCLUSTERED("id") NOT ENFORCED ) WITH (DISTRIBUTION=%s)', $this->getDestinationSchemaName(), - $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution + $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution, )); break; case self::TABLE_MULTI_PK: @@ -82,7 +82,7 @@ protected function initTable(string $tableName): void [_timestamp] datetime2, PRIMARY KEY NONCLUSTERED("VisitID","Value","MenuItem") NOT ENFORCED );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); break; } @@ -98,14 +98,14 @@ public function incrementalImportData(): Generator $expectedAccountsRows, ] = $this->getExpectationFileData( 'expectation.tw_accounts.increment-typed.csv', - self::EXPECTATION_FILE_DATA_CONVERT_NULLS + self::EXPECTATION_FILE_DATA_CONVERT_NULLS, ); [ $multiPkColumns, ] = $this->getExpectationFileData( 'expectation.multi-pk.increment.csv', - self::EXPECTATION_FILE_DATA_CONVERT_NULLS + self::EXPECTATION_FILE_DATA_CONVERT_NULLS, ); [ @@ -113,7 +113,7 @@ public function incrementalImportData(): Generator $expectedSimpleRows, ] = $this->getExpectationFileData( 'expectation.simple.increment.csv', - self::EXPECTATION_FILE_DATA_CONVERT_NULLS + self::EXPECTATION_FILE_DATA_CONVERT_NULLS, ); $tests = []; @@ -123,7 +123,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getSynapseImportOptions(), $this->createABSSourceInstance( @@ -131,7 +131,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getSynapseIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'accounts-3'], @@ -145,7 +145,7 @@ public function incrementalImportData(): Generator $simpleColumns, false, false, - ['Col1'] + ['Col1'], ), $this->getSynapseImportOptions(), $this->createABSSourceInstance( @@ -153,7 +153,7 @@ public function incrementalImportData(): Generator $simpleColumns, false, false, - ['Col1'] + ['Col1'], ), $this->getSynapseIncrementalImportOptions(), [$this->getDestinationSchemaName(), self::TABLE_SIMPLE], @@ -167,7 +167,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSynapseImportOptions(), $this->createABSSourceInstance( @@ -175,7 +175,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getSynapseIncrementalImportOptions(), [$this->getDestinationSchemaName(), 'multi-pk'], @@ -202,7 +202,7 @@ public function testIncrementalImport( array $table, $expected, int $expectedImportedRowCount, - array $tablesToInit + array $tablesToInit, ): void { $this->initTables($tablesToInit); @@ -210,7 +210,7 @@ public function testIncrementalImport( $destination = (new SynapseTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); $toStageImporter = new ToStageImporter($this->connection); @@ -219,59 +219,59 @@ public function testIncrementalImport( $fullLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $fullLoadSource->getColumnsNames() + $fullLoadSource->getColumnsNames(), ); $incrementalLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $incrementalSource->getColumnsNames() + $incrementalSource->getColumnsNames(), ); try { // full load $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $fullLoadSource, $fullLoadStagingTable, - $fullLoadOptions + $fullLoadOptions, ); $fullImporter->importToTable( $fullLoadStagingTable, $destination, $fullLoadOptions, - $importState + $importState, ); // incremental load $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $incrementalSource, $incrementalLoadStagingTable, - $incrementalOptions + $incrementalOptions, ); $result = $incrementalImporter->importToTable( $incrementalLoadStagingTable, $destination, $incrementalOptions, - $importState + $importState, ); } finally { $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $fullLoadStagingTable->getSchemaName(), - $fullLoadStagingTable->getTableName() - ) + $fullLoadStagingTable->getTableName(), + ), ); $this->connection->executeStatement( (new SqlBuilder())->getDropTableIfExistsCommand( $incrementalLoadStagingTable->getSchemaName(), - $incrementalLoadStagingTable->getTableName() - ) + $incrementalLoadStagingTable->getTableName(), + ), ); } @@ -283,13 +283,13 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } else { $this->assertSynapseTableExpectedRowCount( $destination, $incrementalOptions, - $expected + $expected, ); } } diff --git a/packages/php-db-import-export/tests/functional/Synapse/OtherImports/FullImportTest.php b/packages/php-db-import-export/tests/functional/Synapse/OtherImports/FullImportTest.php index d273d8f99..e6ffcf4b9 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/OtherImports/FullImportTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/OtherImports/FullImportTest.php @@ -38,14 +38,14 @@ public function testImportShouldNotFailOnColumnNameRowNumber(): void ], false, false, - [] + [], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_COLUMN_NAME_ROW_NUMBER + self::TABLE_COLUMN_NAME_ROW_NUMBER, ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition($destination, [ @@ -54,19 +54,19 @@ public function testImportShouldNotFailOnColumnNameRowNumber(): void ]); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(2, $result->getImportedRowsCount()); @@ -76,19 +76,19 @@ public function testNullifyCopy(): void { $this->connection->query(sprintf( 'CREATE TABLE [%s].[nullify] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->query(sprintf( 'CREATE TABLE [%s].[nullify_src] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'1\', \'\', NULL)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->query(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'2\', NULL, 500)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new SynapseImportOptions( @@ -97,51 +97,51 @@ public function testNullifyCopy(): void false, ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); $source = new Storage\Synapse\Table( $this->getSourceSchemaName(), 'nullify_src', ['id', 'name', 'price'], - [] + [], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); $destination = $ref->getTableDefinition(); $ref = new SynapseTableReflection( $this->connection, $this->getSourceSchemaName(), - 'nullify_src' + 'nullify_src', ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative(sprintf( 'SELECT [id], [name], [price] FROM [%s].[nullify] ORDER BY [id] ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); self::assertCount(2, $importedData); self::assertTrue($importedData[0]['name'] === null); @@ -153,7 +153,7 @@ public function testNullifyCsv(): void { $this->connection->query(sprintf( 'CREATE TABLE [%s].[nullify] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $options = new SynapseImportOptions( @@ -162,46 +162,46 @@ public function testNullifyCsv(): void false, ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); $source = $this->createABSSourceInstance( 'nullify.csv', ['id', 'name', 'price'], false, false, - [] + [], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative(sprintf( 'SELECT [id], [name], [price] FROM [%s].[nullify] ORDER BY [id] ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); self::assertCount(3, $importedData); self::assertTrue($importedData[1]['name'] === null); diff --git a/packages/php-db-import-export/tests/functional/Synapse/OtherImports/IncrementalImportTest.php b/packages/php-db-import-export/tests/functional/Synapse/OtherImports/IncrementalImportTest.php index a5080108c..5e7ac9f8a 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/OtherImports/IncrementalImportTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/OtherImports/IncrementalImportTest.php @@ -32,7 +32,7 @@ public function testIncrementalImportFromTable(): void $fetchSQL = sprintf( 'SELECT [col1], [col2] FROM [%s].[%s]', $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $source = new Storage\Synapse\SelectSource( @@ -43,35 +43,35 @@ public function testIncrementalImportFromTable(): void 'col1', 'col2', ], - [] + [], ); $options = $this->getSynapseImportOptions(); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative($fetchSQL); @@ -81,21 +81,21 @@ public function testIncrementalImportFromTable(): void (\'e\', \'f\'); ', $this->getSourceSchemaName())); $this->connection->executeStatement( - $qb->getDropTableCommand($stagingTable->getSchemaName(), $stagingTable->getTableName()) + $qb->getDropTableCommand($stagingTable->getSchemaName(), $stagingTable->getTableName()), ); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative($fetchSQL); @@ -107,23 +107,23 @@ public function testNullifyCopyIncremental(): void { $this->connection->executeQuery(sprintf( 'CREATE TABLE [%s].[nullify] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify] VALUES(\'4\', NULL, 50)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( 'CREATE TABLE [%s].[nullify_src] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'1\', \'\', NULL)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'2\', NULL, 500)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new SynapseImportOptions( @@ -132,45 +132,45 @@ public function testNullifyCopyIncremental(): void false, ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); $source = new Storage\Synapse\Table( $this->getSourceSchemaName(), 'nullify_src', ['id', 'name', 'price'], - [] + [], ); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer = new ToStageImporter($this->connection); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new IncrementalImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative(sprintf( 'SELECT [id], [name], [price] FROM [%s].[nullify] ORDER BY [id] ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->assertCount(3, $importedData); $this->assertTrue($importedData[0]['name'] === null); @@ -184,28 +184,28 @@ public function testNullifyCopyIncrementalWithPk(): void $this->connection->executeQuery(sprintf( // phpcs:ignore 'CREATE TABLE [%s].[nullify] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC, PRIMARY KEY NONCLUSTERED([id]) NOT ENFORCED)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify] VALUES(\'4\', \'3\', 2)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( // phpcs:ignore 'CREATE TABLE [%s].[nullify_src] ([id] nvarchar(4000) NOT NULL, [name] nvarchar(4000) NOT NULL, [price] nvarchar(4000) NOT NULL, PRIMARY KEY NONCLUSTERED([id]) NOT ENFORCED)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'1\', \'\', \'\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'2\', \'\', \'500\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'4\', \'\', \'\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new SynapseImportOptions( @@ -214,45 +214,45 @@ public function testNullifyCopyIncrementalWithPk(): void false, SynapseImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); $source = new Storage\Synapse\Table( $this->getSourceSchemaName(), 'nullify_src', ['id', 'name', 'price'], - ['id'] + ['id'], ); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinitionWithText( $ref->getTableDefinition(), - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer = new ToStageImporter($this->connection); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new IncrementalImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative(sprintf( 'SELECT [id], [name], [price] FROM [%s].[nullify]', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $expectedData = [ [ @@ -281,28 +281,28 @@ public function testNullifyCopyIncrementalWithPkDestinationWithNull(): void $this->connection->executeQuery(sprintf( // phpcs:ignore 'CREATE TABLE [%s].[nullify] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC, PRIMARY KEY NONCLUSTERED([id]) NOT ENFORCED)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify] VALUES(\'4\', NULL, NULL)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( // phpcs:ignore 'CREATE TABLE [%s].[nullify_src] ([id] nvarchar(4000) NOT NULL, [name] nvarchar(4000) NOT NULL, [price] nvarchar(4000) NOT NULL, PRIMARY KEY NONCLUSTERED([id]) NOT ENFORCED)', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'1\', \'\', \'\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'2\', \'\', \'500\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify_src] VALUES(\'4\', \'\', \'500\')', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $options = new SynapseImportOptions( @@ -311,45 +311,45 @@ public function testNullifyCopyIncrementalWithPkDestinationWithNull(): void false, ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); $source = new Storage\Synapse\Table( $this->getSourceSchemaName(), 'nullify_src', ['id', 'name', 'price'], - ['id'] + ['id'], ); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinitionWithText( $ref->getTableDefinition(), - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer = new ToStageImporter($this->connection); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new IncrementalImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative(sprintf( 'SELECT [id], [name], [price] FROM [%s].[nullify]', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $expectedData = [ [ @@ -377,11 +377,11 @@ public function testNullifyCsvIncremental(): void { $this->connection->executeQuery(sprintf( 'CREATE TABLE [%s].[nullify] ([id] nvarchar(4000), [name] nvarchar(4000), [price] NUMERIC)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->executeQuery(sprintf( 'INSERT INTO [%s].[nullify] VALUES(\'4\', NULL, 50)', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $options = new SynapseImportOptions( @@ -390,45 +390,45 @@ public function testNullifyCsvIncremental(): void false, ImportOptions::SKIP_FIRST_LINE, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); $source = $this->createABSSourceInstance( 'nullify.csv', ['id', 'name', 'price'], false, false, - [] + [], ); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - 'nullify' + 'nullify', ); $destination = $ref->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer = new ToStageImporter($this->connection); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new IncrementalImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); $importedData = $this->connection->fetchAllAssociative(sprintf( 'SELECT [id], [name], [price] FROM [%s].[nullify] ORDER BY [id] ASC', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->assertCount(4, $importedData); $this->assertTrue($importedData[1]['name'] === null); diff --git a/packages/php-db-import-export/tests/functional/Synapse/OtherImports/StageImportTest.php b/packages/php-db-import-export/tests/functional/Synapse/OtherImports/StageImportTest.php index e622b6426..fc195a6ea 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/OtherImports/StageImportTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/OtherImports/StageImportTest.php @@ -43,7 +43,7 @@ public function testInvalidFieldQuote(): void $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->expectException(Throwable::class); @@ -51,7 +51,7 @@ public function testInvalidFieldQuote(): void $importer->importToStagingTable( $this->createABSSourceInstanceFromCsv('raw.rs.csv', new CsvOptions("\t", '', '\\')), StageTableDefinitionFactory::createStagingTableDefinition($ref->getTableDefinition(), $escapingHeader), - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -63,13 +63,13 @@ public function testCopyInvalidSourceDataShouldThrowException(): void $this->getSourceSchemaName(), 'names', ['c1', 'c2'], - [] + [], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->expectException(Exception::class); @@ -78,9 +78,9 @@ public function testCopyInvalidSourceDataShouldThrowException(): void $source, StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ), - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -94,13 +94,13 @@ public function testInvalidManifestImport(): void $initialFile->getHeader(), true, false, - ['id'] + ['id'], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_ACCOUNTS_3 + self::TABLE_ACCOUNTS_3, ); $this->expectException(Exception::class); @@ -109,9 +109,9 @@ public function testInvalidManifestImport(): void $source, StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ), - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -127,14 +127,14 @@ public function testMoreColumnsShouldThrowException(): void ], false, false, - ['id'] + ['id'], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $this->expectException(Exception::class); $this->expectExceptionCode(Exception::COLUMNS_COUNT_NOT_MATCH); @@ -144,9 +144,9 @@ public function testMoreColumnsShouldThrowException(): void $source, StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ), - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -156,22 +156,22 @@ public function testLongColumnImport6k(): void $this->expectException(Exception::class); $this->expectExceptionMessage( - '[SQL Server]Bulk load data conversion error' + '[SQL Server]Bulk load data conversion error', ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer->importToStagingTable( $this->createABSSourceInstanceFromCsv( @@ -183,10 +183,10 @@ public function testLongColumnImport6k(): void ], false, false, - [] + [], ), $stagingTable, - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -196,21 +196,21 @@ public function testLongColumnImport10k(): void $this->expectException(Exception::class); $this->expectExceptionMessage( - '[SQL Server]Bulk load data conversion error' + '[SQL Server]Bulk load data conversion error', ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getDestinationSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importer->importToStagingTable( $this->createABSSourceInstanceFromCsv( @@ -222,10 +222,10 @@ public function testLongColumnImport10k(): void ], false, false, - [] + [], ), $stagingTable, - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -243,32 +243,32 @@ public function testCopyIntoInvalidTypes(): void ], false, false, - [] + [], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getSourceSchemaName(), - self::TABLE_TYPES + self::TABLE_TYPES, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->expectException(Exception::class); $this->expectExceptionMessage( - '[SQL Server]Bulk load data conversion error' + '[SQL Server]Bulk load data conversion error', ); $importer->importToStagingTable( $source, $stagingTable, - $this->getSynapseImportOptions() + $this->getSynapseImportOptions(), ); } @@ -284,22 +284,22 @@ public function testInsertIntoColumnsCountMismatch(): void 'col1', 'col2', 'invalidCol', - ] + ], ); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getSourceSchemaName(), - self::TABLE_OUT_CSV_2COLS + self::TABLE_OUT_CSV_2COLS, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - [...$ref->getColumnsNames(), 'invalidCol'] + [...$ref->getColumnsNames(), 'invalidCol'], ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->expectException(Exception::class); @@ -314,8 +314,8 @@ public function testInsertIntoColumnsCountMismatch(): void ImportOptions::SKIP_FIRST_LINE, null, SynapseImportOptions::SAME_TABLES_REQUIRED, - SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_CTAS - ) + SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_CTAS, + ), ); } @@ -331,33 +331,33 @@ public function testInsertIntoInvalidTypes(): void 'numCol', 'floatCol', 'boolCol', - ] + ], ); $this->connection->exec(sprintf( 'INSERT INTO [%s].[types] VALUES (\'a\', \'test\', \'test\', 1, \'\') ;', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $importer = new ToStageImporter($this->connection); $ref = new SynapseTableReflection( $this->connection, $this->getSourceSchemaName(), - self::TABLE_TYPES + self::TABLE_TYPES, ); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $ref->getTableDefinition(), - $ref->getColumnsNames() + $ref->getColumnsNames(), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $this->expectException(Exception::class); $this->expectExceptionMessage( - 'Source destination columns mismatch. "numCol NVARCHAR(4000) NOT NULL"->"numCol DECIMAL(10,1)"' + 'Source destination columns mismatch. "numCol NVARCHAR(4000) NOT NULL"->"numCol DECIMAL(10,1)"', ); $importer->importToStagingTable( $source, @@ -366,8 +366,8 @@ public function testInsertIntoInvalidTypes(): void ImportOptions::SKIP_FIRST_LINE, null, SynapseImportOptions::SAME_TABLES_REQUIRED, - SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_CTAS - ) + SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_CTAS, + ), ); } } diff --git a/packages/php-db-import-export/tests/functional/Synapse/SqlBuilderTest.php b/packages/php-db-import-export/tests/functional/Synapse/SqlBuilderTest.php index d09cc7bb3..6360efb25 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/SqlBuilderTest.php +++ b/packages/php-db-import-export/tests/functional/Synapse/SqlBuilderTest.php @@ -71,7 +71,7 @@ public function testGetDedupCommand(): void 'pk2', ], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); $qb = new SynapseTableQueryBuilder(); $this->connection->exec($qb->getCreateTableCommandFromDefinition($deduplicationDef)); @@ -79,18 +79,18 @@ public function testGetDedupCommand(): void $sql = $this->getBuilder()->getDedupCommand( $stageDef, $deduplicationDef, - $deduplicationDef->getPrimaryKeysNames() + $deduplicationDef->getPrimaryKeysNames(), ); self::assertEquals( // phpcs:ignore 'INSERT INTO [import-export-test-ng_schema].[#tempTable] ([col1], [col2]) SELECT a.[col1],a.[col2] FROM (SELECT [col1], [col2], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', - $sql + $sql, ); $this->connection->exec($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', SynapseQuote::quoteSingleIdentifier($deduplicationDef->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($deduplicationDef->getTableName()) + SynapseQuote::quoteSingleIdentifier($deduplicationDef->getTableName()), )); self::assertCount(2, $result); @@ -106,22 +106,22 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): S sprintf( 'INSERT INTO %s.%s([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE - ) + self::TEST_STAGING_TABLE, + ), ); $this->connection->exec( sprintf( 'INSERT INTO %s.%s([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE - ) + self::TEST_STAGING_TABLE, + ), ); $this->connection->exec( sprintf( 'INSERT INTO %s.%s([pk1],[pk2],[col1],[col2]) VALUES (2,2,\'2\',\'2\')', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE - ) + self::TEST_STAGING_TABLE, + ), ); if ($includeEmptyValues) { @@ -129,8 +129,8 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): S sprintf( 'INSERT INTO %s.%s([pk1],[pk2],[col1],[col2]) VALUES (2,2,\'\',NULL)', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE - ) + self::TEST_STAGING_TABLE, + ), ); } @@ -154,8 +154,8 @@ public function testGetDeleteOldItemsCommand(): void new SynapseColumn( 'id', new Synapse( - Synapse::TYPE_INT - ) + Synapse::TYPE_INT, + ), ), SynapseColumn::createGenericColumn('pk1'), SynapseColumn::createGenericColumn('pk2'), @@ -164,20 +164,20 @@ public function testGetDeleteOldItemsCommand(): void ]), ['pk1', 'pk2'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); $tableSql = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new SynapseTableQueryBuilder(); $this->connection->exec($qb->getCreateTableCommandFromDefinition($tableDefinition)); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[pk1],[pk2],[col1],[col2]) VALUES (1,1,1,\'1\',\'1\')', - $tableSql - ) + $tableSql, + ), ); $stagingTableDefinition = new SynapseTableDefinition( self::TEST_SCHEMA, @@ -191,42 +191,42 @@ public function testGetDeleteOldItemsCommand(): void ]), ['pk1', 'pk2'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); $this->connection->exec($qb->getCreateTableCommandFromDefinition($stagingTableDefinition)); $stagingTableSql = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + SynapseQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->connection->exec( sprintf( 'INSERT INTO %s([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $this->connection->exec( sprintf( 'INSERT INTO %s([pk1],[pk2],[col1],[col2]) VALUES (2,1,\'1\',\'1\')', - $stagingTableSql - ) + $stagingTableSql, + ), ); $sql = $this->getBuilder()->getDeleteOldItemsCommand( $stagingTableDefinition, - $tableDefinition + $tableDefinition, ); $this->assertEquals( // phpcs:ignore 'DELETE [import-export-test-ng_schema].[#stagingTable] WHERE EXISTS (SELECT * FROM [import-export-test-ng_schema].[import-export-test-ng_test] WHERE [import-export-test-ng_schema].[import-export-test-ng_test].[pk1] = [import-export-test-ng_schema].[#stagingTable].[pk1] AND [import-export-test-ng_schema].[import-export-test-ng_test].[pk2] = [import-export-test-ng_schema].[#stagingTable].[pk2])', - $sql + $sql, ); $this->connection->exec($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - $stagingTableSql + $stagingTableSql, )); $this->assertCount(1, $result); @@ -248,7 +248,7 @@ public function testGetDropCommand(): void $this->assertEquals( 'DROP TABLE [import-export-test-ng_schema].[import-export-test-ng_test]', - $sql + $sql, ); $this->connection->exec($sql); @@ -263,7 +263,7 @@ private function assertTableNotExists(string $schemaName, string $tableName): vo self::fail(sprintf( 'Table "%s.%s" is expected to not exist.', $schemaName, - $tableName + $tableName, )); } catch (TableNotExistsReflectionException $e) { $this->assertEquals(sprintf('Table "%s.%s" does not exist.', $schemaName, $tableName), $e->getMessage()); @@ -279,7 +279,7 @@ public function testGetDropTableIfExistsCommand(): void $this->assertEquals( // phpcs:ignore 'IF OBJECT_ID (N\'[import-export-test-ng_schema].[import-export-test-ng_test]\', N\'U\') IS NOT NULL DROP TABLE [import-export-test-ng_schema].[import-export-test-ng_test]', - $sql + $sql, ); $this->connection->exec($sql); @@ -292,7 +292,7 @@ public function testGetDropTableIfExistsCommand(): void $this->assertEquals( // phpcs:ignore 'IF OBJECT_ID (N\'[import-export-test-ng_schema].[import-export-test-ng_test]\', N\'U\') IS NOT NULL DROP TABLE [import-export-test-ng_schema].[import-export-test-ng_test]', - $sql + $sql, ); $this->connection->exec($sql); @@ -311,8 +311,7 @@ protected function createTestTable(): void PARTITION ( id RANGE LEFT FOR VALUES ( )), CLUSTERED COLUMNSTORE INDEX ) -EOT - ); +EOT,); } public function testGetInsertAllIntoTargetTableCommand(): void @@ -332,7 +331,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // no convert values no timestamp @@ -340,13 +339,13 @@ public function testGetInsertAllIntoTargetTableCommand(): void $fakeStage, $destination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'INSERT INTO [import-export-test-ng_schema].[import-export-test-ng_test] ([col1], [col2]) (SELECT CAST(COALESCE([col1], \'\') as NVARCHAR(4000)) AS [col1],CAST(COALESCE([col2], \'\') as NVARCHAR(4000)) AS [col2] FROM [import-export-test-ng_schema].[#stagingTable] AS [src])', - $sql + $sql, ); $out = $this->connection->exec($sql); @@ -354,7 +353,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -386,8 +385,8 @@ public function testGetInsertAllIntoTargetTableCommandNotString(): void $col2 = new SynapseColumn( 'col2', new Synapse( - Synapse::TYPE_NUMERIC - ) + Synapse::TYPE_NUMERIC, + ), ); $this->createTestSchema(); @@ -405,7 +404,7 @@ public function testGetInsertAllIntoTargetTableCommandNotString(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // no convert values no timestamp @@ -413,13 +412,13 @@ public function testGetInsertAllIntoTargetTableCommandNotString(): void $fakeStage, $destination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'INSERT INTO [import-export-test-ng_schema].[import-export-test-ng_test] ([col1], [col2]) (SELECT CAST(COALESCE([col1], \'\') as NVARCHAR(4000)) AS [col1],CAST([col2] as NUMERIC) AS [col2] FROM [import-export-test-ng_schema].[#stagingTable] AS [src])', - $sql + $sql, ); $out = $this->connection->exec($sql); @@ -427,7 +426,7 @@ public function testGetInsertAllIntoTargetTableCommandNotString(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -457,15 +456,15 @@ public function testGetInsertAllIntoTargetTableCommandNotString(): void protected function createTestTableWithColumns( bool $includeTimestamp = false, bool $includePrimaryKey = false, - ?SynapseColumn $overwriteColumn2 = null + ?SynapseColumn $overwriteColumn2 = null, ): SynapseTableDefinition { $tableDefinition = $this->getTestTableWithColumnsDefinition( $includeTimestamp, $includePrimaryKey, - $overwriteColumn2 + $overwriteColumn2, ); $this->connection->exec( - (new SynapseTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition) + (new SynapseTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition), ); return $tableDefinition; @@ -478,12 +477,12 @@ private function createGenericColumn(string $columnName, bool $nullable = true): [ 'length' => '4000', // should be changed to max in future 'nullable' => $nullable, - ] + ], ); return new SynapseColumn( $columnName, - $definition + $definition, ); } @@ -503,7 +502,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // convert col1 to null @@ -512,19 +511,19 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'INSERT INTO [import-export-test-ng_schema].[import-export-test-ng_test] ([col1], [col2]) (SELECT NULLIF([col1], \'\'),CAST(COALESCE([col2], \'\') as NVARCHAR(4000)) AS [col2] FROM [import-export-test-ng_schema].[#stagingTable] AS [src])', - $sql + $sql, ); $out = $this->connection->exec($sql); $this->assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -567,7 +566,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // use timestamp @@ -576,19 +575,19 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'INSERT INTO [import-export-test-ng_schema].[import-export-test-ng_test] ([col1], [col2], [_timestamp]) (SELECT NULLIF([col1], \'\'),CAST(COALESCE([col2], \'\') as NVARCHAR(4000)) AS [col2],\'2020-01-01 00:00:00\' FROM [import-export-test-ng_schema].[#stagingTable] AS [src])', - $sql + $sql, ); $out = $this->connection->exec($sql); $this->assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -608,7 +607,7 @@ public function testGetRenameTableCommand(): void $this->assertEquals( 'RENAME OBJECT [import-export-test-ng_schema].[import-export-test-ng_test] TO [newTable]', - $sql + $sql, ); $this->connection->exec($sql); @@ -630,7 +629,7 @@ public function testGetTruncateTableWithDeleteCommand(): void $sql = $this->getBuilder()->getTruncateTableWithDeleteCommand(self::TEST_SCHEMA, self::TEST_STAGING_TABLE); $this->assertEquals( 'DELETE FROM [import-export-test-ng_schema].[#stagingTable]', - $sql + $sql, ); $this->connection->exec($sql); $this->assertEquals(0, $ref->getRowsCount()); @@ -652,7 +651,7 @@ public function testGetUpdateWithPkCommand(): void ]), ['col1'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // create fake stage and say that there is less columns $fakeStage = new SynapseTableDefinition( @@ -665,19 +664,19 @@ public function testGetUpdateWithPkCommand(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[col1],[col2]) VALUES (1,\'2\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEquals([ @@ -693,18 +692,18 @@ public function testGetUpdateWithPkCommand(): void $fakeStage, $fakeDestination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'UPDATE [import-export-test-ng_schema].[import-export-test-ng_test] SET [col2] = COALESCE([src].[col2], \'\') FROM [import-export-test-ng_schema].[#stagingTable] AS [src] WHERE [import-export-test-ng_schema].[import-export-test-ng_test].[col1] = [src].[col1] AND (COALESCE(CAST([import-export-test-ng_schema].[import-export-test-ng_test].[col2] AS NVARCHAR(4000)), \'\') != COALESCE([src].[col2], \'\')) ', - $sql + $sql, ); $this->connection->exec($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEquals([ @@ -728,7 +727,7 @@ public function testGetUpdateWithPkCommandOnlyPKs(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ), new SynapseTableDefinition( self::TEST_SCHEMA, @@ -739,16 +738,16 @@ public function testGetUpdateWithPkCommandOnlyPKs(): void ]), ['id'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ), $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); // only primary keys will result to empty string as there is nothing to update $this->assertEquals( '', - $sql + $sql, ); } @@ -757,8 +756,8 @@ public function testGetUpdateWithPkCommandNotString(): void $col2 = new SynapseColumn( 'col2', new Synapse( - Synapse::TYPE_NUMERIC - ) + Synapse::TYPE_NUMERIC, + ), ); $this->createTestSchema(); @@ -775,7 +774,7 @@ public function testGetUpdateWithPkCommandNotString(): void ]), ['col1'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // create fake stage and say that there is less columns $fakeStage = new SynapseTableDefinition( @@ -788,19 +787,19 @@ public function testGetUpdateWithPkCommandNotString(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[col1],[col2]) VALUES (1,\'2\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEquals([ @@ -816,18 +815,18 @@ public function testGetUpdateWithPkCommandNotString(): void $fakeStage, $fakeDestination, $this->getDummyImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'UPDATE [import-export-test-ng_schema].[import-export-test-ng_test] SET [col2] = [src].[col2] FROM [import-export-test-ng_schema].[#stagingTable] AS [src] WHERE [import-export-test-ng_schema].[import-export-test-ng_test].[col1] = [src].[col1] AND (CAST([import-export-test-ng_schema].[import-export-test-ng_test].[col2] AS NUMERIC) != [src].[col2]) ', - $sql + $sql, ); $this->connection->exec($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEquals([ @@ -855,7 +854,7 @@ public function testGetUpdateWithPkCommandConvertValues(): void ]), ['col1'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // create fake stage and say that there is less columns $fakeStage = new SynapseTableDefinition( @@ -868,25 +867,25 @@ public function testGetUpdateWithPkCommandConvertValues(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[col1],[col2]) VALUES (1,\'\',\'1\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[col1],[col2]) VALUES (1,\'2\',\'\')', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -909,18 +908,18 @@ public function testGetUpdateWithPkCommandConvertValues(): void $fakeStage, $fakeDestination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'UPDATE [import-export-test-ng_schema].[import-export-test-ng_test] SET [col2] = COALESCE([src].[col2], \'\') FROM [import-export-test-ng_schema].[#stagingTable] AS [src] WHERE [import-export-test-ng_schema].[import-export-test-ng_test].[col1] = [src].[col1] AND (COALESCE(CAST([import-export-test-ng_schema].[import-export-test-ng_test].[col2] AS NVARCHAR(4000)), \'\') != COALESCE([src].[col2], \'\')) ', - $sql + $sql, ); $this->connection->exec($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -956,7 +955,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void ]), ['col1'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // create fake stage and say that there is less columns $fakeStage = new SynapseTableDefinition( @@ -969,27 +968,27 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[col1],[col2],[_timestamp]) VALUES (1,\'\',\'1\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $this->connection->exec( sprintf( 'INSERT INTO %s([id],[col1],[col2],[_timestamp]) VALUES (1,\'2\',\'\',\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -1013,19 +1012,19 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $fakeStage, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) . '.000' + $timestampSet->format(DateTimeHelper::FORMAT) . '.000', ); $this->assertEquals( // phpcs:ignore 'UPDATE [import-export-test-ng_schema].[import-export-test-ng_test] SET [col2] = COALESCE([src].[col2], \'\'), [_timestamp] = \'2020-01-01 01:01:01.000\' FROM [import-export-test-ng_schema].[#stagingTable] AS [src] WHERE [import-export-test-ng_schema].[import-export-test-ng_test].[col1] = [src].[col1] AND (COALESCE(CAST([import-export-test-ng_schema].[import-export-test-ng_test].[col2] AS NVARCHAR(4000)), \'\') != COALESCE([src].[col2], \'\')) ', - $sql + $sql, ); $this->connection->exec($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -1035,7 +1034,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->assertArrayHasKey('_timestamp', $item); $this->assertSame( $timestampSet->format(DateTimeHelper::FORMAT), - (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT) + (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT), ); } } @@ -1054,16 +1053,16 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void new ColumnCollection([ new SynapseColumn( 'id', - new Synapse(Synapse::TYPE_INT) + new Synapse(Synapse::TYPE_INT), ), new SynapseColumn( '_timestamp', - new Synapse(Synapse::TYPE_DATETIME) + new Synapse(Synapse::TYPE_DATETIME), ), ]), ['id'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); $qb = new SynapseTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($destDef)); @@ -1078,7 +1077,7 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stageDef)); @@ -1086,8 +1085,8 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void sprintf( 'INSERT INTO %s.%s([id]) VALUES (1)', self::TEST_SCHEMA_QUOTED, - self::TEST_STAGING_TABLE - ) + self::TEST_STAGING_TABLE, + ), ); // create fake destination definition without timestamp column @@ -1100,7 +1099,7 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void ]), ['id'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // insert values into destination @@ -1108,20 +1107,20 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void sprintf( 'INSERT INTO %s([id],[_timestamp]) VALUES (1,\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s([id],[_timestamp]) VALUES (1,\'%s\')', self::TEST_TABLE_IN_SCHEMA, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -1141,19 +1140,19 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void $stageDef, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) . '.000' + $timestampSet->format(DateTimeHelper::FORMAT) . '.000', ); $this->assertEquals( // phpcs:ignore 'UPDATE [import-export-test-ng_schema].[import-export-test-ng_test] SET [_timestamp] = \'2020-01-01 01:01:01.000\' FROM [import-export-test-ng_schema].[#stagingTable] AS [src] WHERE [import-export-test-ng_schema].[import-export-test-ng_test].[id] = [src].[id] ', - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); /** @var array{id:string,_timestamp:string} $item */ @@ -1162,7 +1161,7 @@ public function testGetUpdateWithPkCommandOnlyPksWithTimestamp(): void $this->assertArrayHasKey('_timestamp', $item); $this->assertSame( $timestampSet->format(DateTimeHelper::FORMAT), - (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT) + (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT), ); } } @@ -1179,8 +1178,8 @@ public function testTransaction(): void $this->connection->exec( sprintf( 'INSERT INTO %s([id]) VALUES (1)', - self::TEST_TABLE_IN_SCHEMA - ) + self::TEST_TABLE_IN_SCHEMA, + ), ); $sql = $this->getBuilder()->getCommitTransaction(); @@ -1216,7 +1215,7 @@ public function testCtasCommandFailOnMissingColumns(string $function): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $destination = new SynapseTableDefinition( @@ -1229,18 +1228,18 @@ public function testCtasCommandFailOnMissingColumns(string $function): void ]), ['pk1'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ); $this->expectException(Exception::class); $this->expectExceptionMessage( - 'Columns "pk2" can be imported as it was not found between columns "pk1, notExists" of destination table.' + 'Columns "pk2" can be imported as it was not found between columns "pk1, notExists" of destination table.', ); $this->getBuilder()->$function( $stage, $destination, new SynapseImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); } @@ -1252,7 +1251,7 @@ public function testGetCtasDedupCommand( SynapseTableDefinition $destination, SynapseImportOptions $options, string $expectedSql, - bool $isTimestampExpected = true + bool $isTimestampExpected = true, ): void { $this->createTestSchema(); $this->createStagingTableWithData(true); @@ -1261,18 +1260,18 @@ public function testGetCtasDedupCommand( $stage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( $expectedSql, - $sql + $sql, ); $out = $this->connection->executeStatement($sql); $this->assertEquals(2, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -1290,11 +1289,11 @@ public function testGetCtasDedupCommand( $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); /** @var SynapseColumn[] $timestampColumns */ $timestampColumns = array_filter(iterator_to_array($ref->getColumnsDefinitions()), function ( - SynapseColumn $column + SynapseColumn $column, ) { return $column->getColumnName() === '_timestamp'; }); @@ -1333,14 +1332,14 @@ public function ctasDedupProvider(): Generator new SynapseColumn( 'col1', new Synapse( - Synapse::TYPE_INT - ) + Synapse::TYPE_INT, + ), ), $this->createGenericColumn('col2'), ]), $stage->getPrimaryKeysNames(), $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseTableDefinition( $stage->getSchemaName(), @@ -1349,7 +1348,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( [], @@ -1357,7 +1356,7 @@ public function ctasDedupProvider(): Generator true, 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST + SynapseImportOptions::TABLE_TYPES_CAST, ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1],COALESCE(CAST([pk2] as NVARCHAR(4000)), \'\') AS [pk2],COALESCE(CAST([col1] as NVARCHAR(4000)), \'\') AS [col1],COALESCE(CAST([col2] as NVARCHAR(4000)), \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1374,14 +1373,14 @@ public function ctasDedupProvider(): Generator new SynapseColumn( 'col1', new Synapse( - Synapse::TYPE_INT - ) + Synapse::TYPE_INT, + ), ), $this->createGenericColumn('col2'), ]), $stage->getPrimaryKeysNames(), $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseTableDefinition( $stage->getSchemaName(), @@ -1395,7 +1394,7 @@ public function ctasDedupProvider(): Generator ]), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( [], @@ -1403,7 +1402,7 @@ public function ctasDedupProvider(): Generator true, 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST + SynapseImportOptions::TABLE_TYPES_CAST, ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1],COALESCE(CAST([pk2] as NVARCHAR(4000)), \'\') AS [pk2],COALESCE(CAST([col1] as NVARCHAR(4000)), \'\') AS [col1],ISNULL(CAST([col2] as NVARCHAR(4000)), \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1418,7 +1417,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_HASH, ['pk1']), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( ['col1'], @@ -1426,7 +1425,7 @@ public function ctasDedupProvider(): Generator true, // use timestamp 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST // cast values + SynapseImportOptions::TABLE_TYPES_CAST, // cast values ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=HASH([pk1]),HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1],COALESCE(CAST([pk2] as NVARCHAR(4000)), \'\') AS [pk2],CAST(NULLIF([col1], \'\') as NVARCHAR(4000)) AS [col1],COALESCE(CAST([col2] as NVARCHAR(4000)), \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1441,7 +1440,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_HASH, ['pk1']), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( @@ -1450,7 +1449,7 @@ public function ctasDedupProvider(): Generator true, // use timestamp 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_PRESERVE // dont cast values + SynapseImportOptions::TABLE_TYPES_PRESERVE, // dont cast values ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=HASH([pk1]),HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE([pk1], \'\') AS [pk1],COALESCE([pk2], \'\') AS [pk2],NULLIF([col1], \'\') AS [col1],COALESCE([col2], \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1465,7 +1464,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( ['col1'], @@ -1473,7 +1472,7 @@ public function ctasDedupProvider(): Generator true, // use timestamp 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST // cast values + SynapseImportOptions::TABLE_TYPES_CAST, // cast values ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1],COALESCE(CAST([pk2] as NVARCHAR(4000)), \'\') AS [pk2],CAST(NULLIF([col1], \'\') as NVARCHAR(4000)) AS [col1],COALESCE(CAST([col2] as NVARCHAR(4000)), \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1488,7 +1487,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( ['col1'], @@ -1496,7 +1495,7 @@ public function ctasDedupProvider(): Generator true, // use timestamp 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_PRESERVE // don't cast values + SynapseImportOptions::TABLE_TYPES_PRESERVE, // don't cast values ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE([pk1], \'\') AS [pk1],COALESCE([pk2], \'\') AS [pk2],NULLIF([col1], \'\') AS [col1],COALESCE([col2], \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1511,7 +1510,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( ['col1'], @@ -1519,7 +1518,7 @@ public function ctasDedupProvider(): Generator false, // don't use timestamp 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST + SynapseImportOptions::TABLE_TYPES_CAST, ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2] FROM (SELECT COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1],COALESCE(CAST([pk2] as NVARCHAR(4000)), \'\') AS [pk2],CAST(NULLIF([col1], \'\') as NVARCHAR(4000)) AS [col1],COALESCE(CAST([col2] as NVARCHAR(4000)), \'\') AS [col2], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1535,7 +1534,7 @@ public function ctasDedupProvider(): Generator $stage->getColumnsDefinitions(), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( ['col1'], @@ -1543,7 +1542,7 @@ public function ctasDedupProvider(): Generator false, // don't use timestamp 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_PRESERVE // don't cast + SynapseImportOptions::TABLE_TYPES_PRESERVE, // don't cast ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2] FROM (SELECT COALESCE([pk1], \'\') AS [pk1],COALESCE([pk2], \'\') AS [pk2],NULLIF([col1], \'\') AS [col1],COALESCE([col2], \'\') AS [col2], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1559,11 +1558,11 @@ public function ctasDedupProvider(): Generator // add _timestamp column to destination new ColumnCollection(array_merge( iterator_to_array($stage->getColumnsDefinitions()), - [SynapseColumn::createGenericColumn('_timestamp')] + [SynapseColumn::createGenericColumn('_timestamp')], )), ['pk1', 'pk2'], $stage->getTableDistribution(), - $stage->getTableIndex() + $stage->getTableIndex(), ), new SynapseImportOptions( [], @@ -1571,7 +1570,7 @@ public function ctasDedupProvider(): Generator true, 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST + SynapseImportOptions::TABLE_TYPES_CAST, ), // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,HEAP) AS SELECT a.[pk1],a.[pk2],a.[col1],a.[col2],a.[_timestamp] FROM (SELECT COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1],COALESCE(CAST([pk2] as NVARCHAR(4000)), \'\') AS [pk2],COALESCE(CAST([col1] as NVARCHAR(4000)), \'\') AS [col1],COALESCE(CAST([col2] as NVARCHAR(4000)), \'\') AS [col2],CAST(\'2020-01-01 00:00:00\' as DATETIME2) AS [_timestamp], ROW_NUMBER() OVER (PARTITION BY [pk1],[pk2] ORDER BY [pk1],[pk2]) AS "_row_number_" FROM [import-export-test-ng_schema].[#stagingTable]) AS a WHERE a."_row_number_" = 1', @@ -1592,7 +1591,7 @@ private function getStagingTableDefinition(): SynapseTableDefinition ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); } @@ -1624,7 +1623,7 @@ public function testGetCTASInsertAllIntoTargetTableCommand(string $cast, string false, false, null, - true + true, ); $this->createStagingTableWithData(true); @@ -1640,7 +1639,7 @@ public function testGetCTASInsertAllIntoTargetTableCommand(string $cast, string ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // no convert values no timestamp @@ -1650,19 +1649,19 @@ public function testGetCTASInsertAllIntoTargetTableCommand(string $cast, string false, 0, SynapseImportOptions::CREDENTIALS_SAS, - $cast + $cast, ); $sql = $this->getBuilder()->getCTASInsertAllIntoTargetTableCommand( $fakeStage, $destination, $importOptions, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore $expectedSQL, - $sql + $sql, ); $out = $this->connection->exec($sql); @@ -1670,7 +1669,7 @@ public function testGetCTASInsertAllIntoTargetTableCommand(string $cast, string $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -1699,7 +1698,7 @@ public function testGetCTASInsertAllIntoTargetTableCommand(string $cast, string $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $resultColumns = $ref->getColumnsDefinitions(); $this->assertColumnsDefinitions($resultColumns, $destination, $importOptions); @@ -1734,8 +1733,8 @@ public function testGetCTASInsertAllIntoTargetTableCommandNotString(string $cast Synapse::TYPE_NUMERIC, [ 'length' => '18,0', - ] - ) + ], + ), ); $this->createTestSchema(); @@ -1743,7 +1742,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandNotString(string $cast false, false, $col2, - true + true, ); $this->createStagingTableWithData(true); @@ -1759,7 +1758,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandNotString(string $cast ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // no convert values no timestamp @@ -1769,19 +1768,19 @@ public function testGetCTASInsertAllIntoTargetTableCommandNotString(string $cast false, 0, SynapseImportOptions::CREDENTIALS_SAS, - $cast + $cast, ); $sql = $this->getBuilder()->getCTASInsertAllIntoTargetTableCommand( $fakeStage, $destination, $importOptions, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore $expectedSQL, - $sql + $sql, ); $out = $this->connection->exec($sql); @@ -1789,7 +1788,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandNotString(string $cast $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -1818,7 +1817,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandNotString(string $cast $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $resultColumns = $ref->getColumnsDefinitions(); $this->assertColumnsDefinitions($resultColumns, $destination, $importOptions); @@ -1853,7 +1852,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNull(string $ false, false, null, - true + true, ); // create fake stage and say that there is less columns $fakeStage = new SynapseTableDefinition( @@ -1867,7 +1866,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNull(string $ ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // convert col1 to null @@ -1877,24 +1876,24 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNull(string $ false, 0, SynapseImportOptions::CREDENTIALS_SAS, - $cast + $cast, ); $sql = $this->getBuilder()->getCTASInsertAllIntoTargetTableCommand( $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( $expectedSQL, - $sql + $sql, ); $out = $this->connection->exec($sql); $this->assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -1923,7 +1922,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNull(string $ $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $resultColumns = $ref->getColumnsDefinitions(); $this->assertColumnsDefinitions($resultColumns, $destination, $options); @@ -1952,14 +1951,14 @@ public function getCTASInsertAllIntoTargetTableCommandConvertToNullWithTimestamp */ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNullWithTimestamp( string $cast, - string $expectedSQL + string $expectedSQL, ): void { $this->createTestSchema(); $destination = $this->getTestTableWithColumnsDefinition( true, false, null, - true + true, ); $this->createStagingTableWithData(true); // create fake stage and say that there is less columns @@ -1974,7 +1973,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNullWithTimes ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // use timestamp @@ -1984,24 +1983,24 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNullWithTimes true, 0, SynapseImportOptions::CREDENTIALS_SAS, - $cast + $cast, ); $sql = $this->getBuilder()->getCTASInsertAllIntoTargetTableCommand( $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( $expectedSQL, - $sql + $sql, ); $out = $this->connection->exec($sql); $this->assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); foreach ($result as $item) { @@ -2013,7 +2012,7 @@ public function testGetCTASInsertAllIntoTargetTableCommandConvertToNullWithTimes $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $resultColumns = $ref->getColumnsDefinitions(); $this->assertColumnsDefinitions($resultColumns, $destination, $options); @@ -2042,11 +2041,11 @@ public function testGetCTASInsertAllIntoTargetTableCommandSourceToDestinationNum function ($name) { return $this->createGenericColumn($name); }, - $columns + $columns, )), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stage)); $records = [ @@ -2062,8 +2061,8 @@ function ($name) { self::TEST_SCHEMA_QUOTED, self::TEST_STAGING_TABLE, implode(',', $columns), - implode(',', $record) - ) + implode(',', $record), + ), ); } @@ -2080,8 +2079,8 @@ function ($name) { [ 'nullable' => true, 'length' => '18,0', - ] - ) + ], + ), ), new SynapseColumn( 'colNumeric', @@ -2090,8 +2089,8 @@ function ($name) { [ 'nullable' => true, 'length' => '18,0', - ] - ) + ], + ), ), new SynapseColumn( 'colInteger', @@ -2099,8 +2098,8 @@ function ($name) { Synapse::TYPE_INT, [ 'nullable' => true, - ] - ) + ], + ), ), new SynapseColumn( 'colFloat', @@ -2108,8 +2107,8 @@ function ($name) { Synapse::TYPE_FLOAT, [ 'nullable' => true, - ] - ) + ], + ), ), new SynapseColumn( 'colBool', @@ -2117,8 +2116,8 @@ function ($name) { Synapse::TYPE_BIT, [ 'nullable' => true, - ] - ) + ], + ), ), new SynapseColumn( 'colDate', @@ -2126,8 +2125,8 @@ function ($name) { Synapse::TYPE_DATE, [ 'nullable' => true, - ] - ) + ], + ), ), new SynapseColumn( 'colTimestamp', @@ -2136,13 +2135,13 @@ function ($name) { [ 'nullable' => true, 'length' => '7', - ] - ) + ], + ), ), ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); // create fake stage and say that there is less columns $fakeStage = new SynapseTableDefinition( @@ -2161,7 +2160,7 @@ function ($name) { ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); // convert colNumericNull to null @@ -2171,25 +2170,25 @@ function ($name) { false, 0, SynapseImportOptions::CREDENTIALS_SAS, - SynapseImportOptions::TABLE_TYPES_CAST + SynapseImportOptions::TABLE_TYPES_CAST, ); $sql = $this->getBuilder()->getCTASInsertAllIntoTargetTableCommand( $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $this->assertEquals( // phpcs:ignore 'CREATE TABLE [import-export-test-ng_schema].[import-export-test-ng_test] WITH (DISTRIBUTION=ROUND_ROBIN,CLUSTERED COLUMNSTORE INDEX) AS SELECT CAST([colNumericNull] as NUMERIC(18,0)) AS [colNumericNull],CAST([colNumeric] as NUMERIC(18,0)) AS [colNumeric],CAST([colInteger] as INT) AS [colInteger],CAST([colFloat] as FLOAT) AS [colFloat],CAST([colBool] as BIT) AS [colBool],CAST([colDate] as DATE) AS [colDate],CAST([colTimestamp] as DATETIME2(7)) AS [colTimestamp],COALESCE(CAST([pk1] as NVARCHAR(4000)), \'\') AS [pk1] FROM [import-export-test-ng_schema].[#stagingTable]', - $sql + $sql, ); $out = $this->connection->executeStatement($sql); $this->assertEquals(4, $out); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - self::TEST_TABLE_IN_SCHEMA + self::TEST_TABLE_IN_SCHEMA, )); $this->assertEqualsCanonicalizing([ @@ -2238,7 +2237,7 @@ function ($name) { $ref = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $resultColumns = $ref->getColumnsDefinitions(); $this->assertColumnsDefinitions($resultColumns, $destination, $options); @@ -2250,12 +2249,12 @@ private function createIntColumn(string $columnName): SynapseColumn Synapse::TYPE_INT, [ 'nullable' => false, - ] + ], ); return new SynapseColumn( $columnName, - $definition + $definition, ); } @@ -2263,7 +2262,7 @@ protected function getTestTableWithColumnsDefinition( bool $includeTimestamp = false, bool $includePrimaryKey = false, ?SynapseColumn $overwriteColumn2 = null, - bool $includeNotNullableColumn = false + bool $includeNotNullableColumn = false, ): SynapseTableDefinition { $columns = []; $pks = []; @@ -2271,7 +2270,7 @@ protected function getTestTableWithColumnsDefinition( $pks[] = 'id'; $columns[] = new SynapseColumn( 'id', - new Synapse(Synapse::TYPE_INT) + new Synapse(Synapse::TYPE_INT), ); } else { $columns[] = $this->createGenericColumn('id'); @@ -2286,7 +2285,7 @@ protected function getTestTableWithColumnsDefinition( if ($includeTimestamp) { $columns[] = new SynapseColumn( '_timestamp', - new Synapse(Synapse::TYPE_DATETIME) + new Synapse(Synapse::TYPE_DATETIME), ); } @@ -2301,7 +2300,7 @@ protected function getTestTableWithColumnsDefinition( new ColumnCollection($columns), $pks, new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); return $tableDefinition; } @@ -2309,7 +2308,7 @@ protected function getTestTableWithColumnsDefinition( private function assertColumnsDefinitions( ColumnCollection $resultColumns, SynapseTableDefinition $destination, - SynapseImportOptions $options + SynapseImportOptions $options, ): void { /** @var SynapseColumn $resultCol */ foreach ($resultColumns as $resultCol) { @@ -2329,13 +2328,13 @@ private function assertColumnsDefinitions( $this->assertSame( $expectedCol->getColumnDefinition()->getSQLDefinition(), $resultCol->getColumnDefinition()->getSQLDefinition(), - sprintf('Column "%s" definition not match.', $resultCol->getColumnName()) + sprintf('Column "%s" definition not match.', $resultCol->getColumnName()), ); } else { $this->assertSame( $expectedCol->getColumnDefinition()->isNullable(), $resultCol->getColumnDefinition()->isNullable(), - sprintf('Column "%s" nullability not match.', $resultCol->getColumnName()) + sprintf('Column "%s" nullability not match.', $resultCol->getColumnName()), ); } } diff --git a/packages/php-db-import-export/tests/functional/Synapse/SynapseBaseTestCase.php b/packages/php-db-import-export/tests/functional/Synapse/SynapseBaseTestCase.php index 156d5073b..4f0f4cf0c 100644 --- a/packages/php-db-import-export/tests/functional/Synapse/SynapseBaseTestCase.php +++ b/packages/php-db-import-export/tests/functional/Synapse/SynapseBaseTestCase.php @@ -47,12 +47,12 @@ protected function dropAllWithinSchema(string $schema): void FROM sys.tables WHERE schema_name(schema_id) = '$schema' order by name; -EOT +EOT, ); foreach ($tables as $table) { $this->connection->exec( - $this->qb->getDropCommand($schema, $table['name']) + $this->qb->getDropCommand($schema, $table['name']), ); } @@ -60,16 +60,16 @@ protected function dropAllWithinSchema(string $schema): void $schemas = $this->connection->fetchAllAssociative( sprintf( 'SELECT name FROM sys.schemas WHERE name = \'%s\'', - $schema - ) + $schema, + ), ); foreach ($schemas as $item) { $this->connection->exec( sprintf( 'DROP SCHEMA %s', - SynapseQuote::quoteSingleIdentifier($item['name']) - ) + SynapseQuote::quoteSingleIdentifier($item['name']), + ), ); } } @@ -103,7 +103,7 @@ protected function initTable(string $tableName): void [lemmaIndex] nvarchar(4000) NOT NULL DEFAULT \'\', [_timestamp] datetime2 );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); break; case self::TABLE_OUT_CSV_2COLS: @@ -117,7 +117,7 @@ protected function initTable(string $tableName): void 'INSERT INTO [%s].[out.csv_2Cols] VALUES (\'x\', \'y\', \'%s\');', $this->getDestinationSchemaName(), - $now + $now, )); $this->connection->exec(sprintf('CREATE TABLE [%s].[out.csv_2Cols] ( @@ -151,7 +151,7 @@ protected function initTable(string $tableName): void PRIMARY KEY NONCLUSTERED("id") NOT ENFORCED ) WITH (DISTRIBUTION=%s)', $this->getDestinationSchemaName(), - $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution + $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution, )); break; case self::TABLE_ACCOUNTS_WITHOUT_TS: @@ -172,7 +172,7 @@ protected function initTable(string $tableName): void PRIMARY KEY NONCLUSTERED("id") NOT ENFORCED ) WITH (DISTRIBUTION=%s)', $this->getDestinationSchemaName(), - $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution + $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution, )); break; case self::TABLE_TABLE: @@ -182,7 +182,7 @@ protected function initTable(string $tableName): void [table] nvarchar(4000) NOT NULL DEFAULT \'\', [_timestamp] datetime2 );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); break; case self::TABLE_TYPES: @@ -194,7 +194,7 @@ protected function initTable(string $tableName): void [boolCol] nvarchar(4000) NOT NULL, [_timestamp] datetime2 );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); $this->connection->exec(sprintf( @@ -204,13 +204,13 @@ protected function initTable(string $tableName): void [floatCol] float NOT NULL, [boolCol] tinyint NOT NULL );', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); $this->connection->exec(sprintf( 'INSERT INTO [%s].[types] VALUES (\'a\', \'10.5\', \'0.3\', 1) ;', - $this->getSourceSchemaName() + $this->getSourceSchemaName(), )); break; case self::TABLE_OUT_NO_TIMESTAMP_TABLE: @@ -219,7 +219,7 @@ protected function initTable(string $tableName): void [col1] nvarchar(4000) NOT NULL DEFAULT \'\', [col2] nvarchar(4000) NOT NULL DEFAULT \'\' );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); break; case self::TABLE_COLUMN_NAME_ROW_NUMBER: @@ -231,7 +231,7 @@ protected function initTable(string $tableName): void PRIMARY KEY NONCLUSTERED("id") NOT ENFORCED ) WITH (DISTRIBUTION=%s)', $this->getDestinationSchemaName(), - $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution + $tableDistribution === 'HASH' ? 'HASH([id])' : $tableDistribution, )); break; case self::TABLE_MULTI_PK: @@ -245,7 +245,7 @@ protected function initTable(string $tableName): void [_timestamp] datetime2, PRIMARY KEY NONCLUSTERED("VisitID","Value","MenuItem") NOT ENFORCED );', - $this->getDestinationSchemaName() + $this->getDestinationSchemaName(), )); break; } @@ -291,12 +291,12 @@ protected function assertTableEqualsExpected( SynapseImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = (new SynapseTableReflection( $this->connection, $table->getSchema(), - $table->getTableName() + $table->getTableName(), ))->getColumnsNames(); if ($options->useTimestamp()) { @@ -318,7 +318,7 @@ protected function assertTableEqualsExpected( $sql = sprintf( 'SELECT %s FROM %s', implode(', ', $tableColumns), - $table->getQuotedTableWithScheme() + $table->getQuotedTableWithScheme(), ); $queryResult = array_map(function ($row) { @@ -331,7 +331,7 @@ protected function assertTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } @@ -344,7 +344,7 @@ protected function getSynapseImportOptions( int $skipLines = ImportOptions::SKIP_FIRST_LINE, ?string $castValueTypes = null, ?bool $requireSameTables = null, - ?string $tableToTableAdapter = null + ?string $tableToTableAdapter = null, ): SynapseImportOptions { return new SynapseImportOptions( [], @@ -355,12 +355,12 @@ protected function getSynapseImportOptions( getenv('CREDENTIALS_IMPORT_TYPE'), $castValueTypes ?? SynapseImportOptions::TABLE_TYPES_PRESERVE, $requireSameTables ?? SynapseImportOptions::SAME_TABLES_NOT_REQUIRED, - $tableToTableAdapter ?? SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_INSERT_INTO + $tableToTableAdapter ?? SynapseImportOptions::TABLE_TO_TABLE_ADAPTER_INSERT_INTO, ); } protected function getSynapseIncrementalImportOptions( - int $skipLines = ImportOptions::SKIP_FIRST_LINE + int $skipLines = ImportOptions::SKIP_FIRST_LINE, ): SynapseImportOptions { return new SynapseImportOptions( [], @@ -368,7 +368,7 @@ protected function getSynapseIncrementalImportOptions( true, $skipLines, // @phpstan-ignore-next-line - getenv('CREDENTIALS_IMPORT_TYPE') + getenv('CREDENTIALS_IMPORT_TYPE'), ); } @@ -384,12 +384,12 @@ protected function assertSynapseTableEqualsExpected( SynapseImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = (new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ))->getColumnsNames(); if ($options->useTimestamp()) { @@ -412,7 +412,7 @@ protected function assertSynapseTableEqualsExpected( 'SELECT %s FROM [%s].[%s]', implode(', ', $tableColumns), $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $queryResult = array_map(function ($row) { @@ -425,7 +425,7 @@ protected function assertSynapseTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } @@ -433,12 +433,12 @@ protected function assertSynapseTableExpectedRowCount( SynapseTableDefinition $destination, SynapseImportOptions $options, int $expectedCount, - string $message = 'Imported tables don\'t have expected number of rows' + string $message = 'Imported tables don\'t have expected number of rows', ): void { $destRef = new SynapseTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ); $tableColumns = $destRef->getColumnsNames(); diff --git a/packages/php-db-import-export/tests/functional/Teradata/ExportTest.php b/packages/php-db-import-export/tests/functional/Teradata/ExportTest.php index c2171bf3f..3061d6a53 100644 --- a/packages/php-db-import-export/tests/functional/Teradata/ExportTest.php +++ b/packages/php-db-import-export/tests/functional/Teradata/ExportTest.php @@ -55,7 +55,7 @@ public function testExportGzip(): void $source = $this->getSourceInstance('big_table.csv', $file->getHeader()); $destination = new Table( $schema, - self::BIGGER_TABLE + self::BIGGER_TABLE, ); $importOptions = $this->getSimpleImportOptions(ImportOptions::SKIP_FIRST_LINE, false); @@ -70,7 +70,7 @@ public function testExportGzip(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $exportOptions + $exportOptions, ); /** @var array $files */ @@ -107,7 +107,7 @@ public function testExportOptionsForSlicing(array $providedExportOptions, array $source = $this->getSourceInstance('big_table.csv', $file->getHeader()); $destination = new Table( $schema, - self::BIGGER_TABLE + self::BIGGER_TABLE, ); $importOptions = $this->getSimpleImportOptions(ImportOptions::SKIP_FIRST_LINE, false); @@ -121,7 +121,7 @@ public function testExportOptionsForSlicing(array $providedExportOptions, array (new Exporter($this->connection))->exportTable( $source, $destination, - $exportOptions + $exportOptions, ); /** @var array $files */ @@ -147,7 +147,7 @@ public static function assertFilesMatch(array $expectedFiles, array $files): voi if ($expectedFileSize !== 0) { self::assertTrue( ($expectedFileSize - 10000) < $fileSize && $fileSize < ($expectedFileSize + 10000), - sprintf('Actual size is %s but expected is %s', $fileSize, $expectedFileSize) + sprintf('Actual size is %s but expected is %s', $fileSize, $expectedFileSize), ); } } @@ -164,30 +164,30 @@ private function importTable( Storage\SourceInterface $source, Storage\DestinationInterface $destinationTable, ImportOptions $options, - int $repeatImport = 0 + int $repeatImport = 0, ): void { $importer = new ToStageImporter($this->connection); /** @var Table $destinationTable */ $destinationRef = new TeradataTableReflection( $this->connection, $destinationTable->getSchema(), - $destinationTable->getTableName() + $destinationTable->getTableName(), ); /** @var TeradataTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); // re-insert inserted data -> make the table BIIIG @@ -206,7 +206,7 @@ private function importTable( $stagingTable, $destination, $options, - $importState + $importState, ); } @@ -219,7 +219,7 @@ public function testExportSimple(): void $source = $this->getSourceInstance('with-ts.csv', $file->getHeader()); $destination = new Table( $this->getDestinationDbName(), - 'out_csv_2Cols' + 'out_csv_2Cols', ); $options = $this->getSimpleImportOptions(); $this->importTable($source, $destination, $options, 0); @@ -232,7 +232,7 @@ public function testExportSimple(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir() . '/ts_test'); @@ -244,7 +244,7 @@ public function testExportSimple(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -261,7 +261,7 @@ public function testExportSimpleWithQuery(): void $source = $this->getSourceInstance('tw_accounts.csv', $file->getHeader()); $destination = new Table( $this->getDestinationDbName(), - 'accounts-3' + 'accounts-3', ); $options = $this->getSimpleImportOptions(); @@ -272,7 +272,7 @@ public function testExportSimpleWithQuery(): void $query = sprintf( 'SELECT %s FROM %s', (new SqlBuilder)->getColumnsString($file->getHeader()), - $destination->getQuotedTableWithScheme() + $destination->getQuotedTableWithScheme(), ); $source = new Storage\Teradata\SelectSource($query); $options = $this->getExportOptions(); @@ -281,7 +281,7 @@ public function testExportSimpleWithQuery(): void (new Exporter($this->connection))->exportTable( $source, $destination, - $options + $options, ); $files = $this->listFiles($this->getExportDir() . '/tw_test'); @@ -293,7 +293,7 @@ public function testExportSimpleWithQuery(): void CsvOptions::DEFAULT_DELIMITER, CsvOptions::DEFAULT_ENCLOSURE, CsvOptions::DEFAULT_ESCAPED_BY, - 1 // skip header + 1, // skip header ); $this->assertCsvFilesSame($expected, $actual); @@ -416,7 +416,7 @@ public function pipelineOptions(): array public function testExportImportPipeline( bool $compressed, bool $singlePartFile, - string $exportedFilenameSuffix + string $exportedFilenameSuffix, ): void { // import $schema = $this->getDestinationDbName(); @@ -425,7 +425,7 @@ public function testExportImportPipeline( $source = $this->getSourceInstance('big_table.csv', $file->getHeader()); $destinationTable = new Table( $schema, - self::BIGGER_TABLE + self::BIGGER_TABLE, ); $importOptions = $this->getSimpleImportOptions(ImportOptions::SKIP_FIRST_LINE, false); @@ -438,7 +438,7 @@ public function testExportImportPipeline( TeradataExportOptions::DEFAULT_BUFFER_SIZE, TeradataExportOptions::DEFAULT_MAX_OBJECT_SIZE, TeradataExportOptions::DEFAULT_SPLIT_ROWS, - $singlePartFile + $singlePartFile, ); $exportedFilePath = $this->getExportDir() . '/gz_test/gzip.csv'; $destinationExport = $this->getDestinationInstance($exportedFilePath); @@ -446,7 +446,7 @@ public function testExportImportPipeline( (new Exporter($this->connection))->exportTable( $sourceTable, $destinationExport, - $exportOptions + $exportOptions, ); $reImportTableName = 'big_table_re-import'; @@ -457,13 +457,13 @@ public function testExportImportPipeline( TeradataQuote::quoteSingleIdentifier($schema), TeradataQuote::quoteSingleIdentifier($reImportTableName), TeradataQuote::quoteSingleIdentifier($schema), - TeradataQuote::quoteSingleIdentifier(self::BIGGER_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::BIGGER_TABLE), + ), ); $destinationTableReImport = new Table( $schema, - $reImportTableName + $reImportTableName, ); $awsKey = (string) getenv('AWS_S3_KEY'); @@ -476,7 +476,7 @@ public function testExportImportPipeline( $sourceReimport = $this->getSourceInstanceFromCsv( $exportedFilePath . $exportedFilenameSuffix, new CsvOptions(), - $file->getHeader() + $file->getHeader(), ); $this->importTable($sourceReimport, $destinationTableReImport, $importOptions); @@ -486,7 +486,7 @@ public function testExportImportPipeline( 'SELECT COUNT(*) AS counter FROM %s.%s', TeradataQuote::quoteSingleIdentifier($schema), TeradataQuote::quoteSingleIdentifier($reImportTableName), - ) + ), ); self::assertEquals(96271, $counter[0]['counter']); } diff --git a/packages/php-db-import-export/tests/functional/Teradata/TeradataBaseTestCase.php b/packages/php-db-import-export/tests/functional/Teradata/TeradataBaseTestCase.php index 356abe623..9cba475d9 100644 --- a/packages/php-db-import-export/tests/functional/Teradata/TeradataBaseTestCase.php +++ b/packages/php-db-import-export/tests/functional/Teradata/TeradataBaseTestCase.php @@ -104,7 +104,7 @@ private function getTeradataConnection(): Connection } $db->executeStatement(sprintf( 'SET SESSION DATABASE %s;', - TeradataQuote::quoteSingleIdentifier($dbname) + TeradataQuote::quoteSingleIdentifier($dbname), )); return $db; @@ -118,11 +118,11 @@ protected function cleanDatabase(string $dbname): void // delete all objects in the DB $this->connection->executeQuery( - sprintf('DELETE DATABASE %s ALL', TeradataQuote::quoteSingleIdentifier($dbname)) + sprintf('DELETE DATABASE %s ALL', TeradataQuote::quoteSingleIdentifier($dbname)), ); // drop the empty db $this->connection->executeQuery( - sprintf('DROP DATABASE %s', TeradataQuote::quoteSingleIdentifier($dbname)) + sprintf('DROP DATABASE %s', TeradataQuote::quoteSingleIdentifier($dbname)), ); } @@ -152,7 +152,7 @@ protected function dbExists(string $dbname): bool protected function initSingleTable( string $db = self::TERADATA_SOURCE_DATABASE_NAME, - string $table = self::TABLE_TABLE + string $table = self::TABLE_TABLE, ): void { if (!$this->dbExists($db)) { $this->createDatabase($db); @@ -165,8 +165,8 @@ protected function initSingleTable( "Other" VARCHAR(50) );', TeradataQuote::quoteSingleIdentifier($db), - TeradataQuote::quoteSingleIdentifier($table) - ) + TeradataQuote::quoteSingleIdentifier($table), + ), ); } @@ -196,8 +196,8 @@ protected function initTable(string $tableName, string $dbName = ''): void "GlobalID" VARCHAR(500) CHARACTER SET UNICODE );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) - ) + TeradataQuote::quoteSingleIdentifier($tableName), + ), ); break; @@ -214,8 +214,8 @@ protected function initTable(string $tableName, string $dbName = ''): void "_timestamp" TIMESTAMP )', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) - ) + TeradataQuote::quoteSingleIdentifier($tableName), + ), ); break; case self::TABLE_SINGLE_PK: @@ -231,8 +231,8 @@ protected function initTable(string $tableName, string $dbName = ''): void PRIMARY KEY ("VisitID") )', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) - ) + TeradataQuote::quoteSingleIdentifier($tableName), + ), ); break; case self::TABLE_MULTI_PK: @@ -248,8 +248,8 @@ protected function initTable(string $tableName, string $dbName = ''): void PRIMARY KEY ("VisitID", "Something") )', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) - ) + TeradataQuote::quoteSingleIdentifier($tableName), + ), ); break; case self::TABLE_COLUMN_NAME_ROW_NUMBER: @@ -260,7 +260,7 @@ protected function initTable(string $tableName, string $dbName = ''): void "row_number" VARCHAR(50) )', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_TRANSLATIONS: @@ -273,7 +273,7 @@ protected function initTable(string $tableName, string $dbName = ''): void "isDeleted" INT )', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_CSV_2COLS: @@ -285,14 +285,14 @@ protected function initTable(string $tableName, string $dbName = ''): void "_timestamp" TIMESTAMP );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) - ) + TeradataQuote::quoteSingleIdentifier($tableName), + ), ); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'x\', \'y\', NOW());', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( @@ -301,19 +301,19 @@ protected function initTable(string $tableName, string $dbName = ''): void "col2" VARCHAR(50) );', TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'a\', \'b\');', TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (\'c\', \'d\');', TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_LEMMA: @@ -325,7 +325,7 @@ protected function initTable(string $tableName, string $dbName = ''): void "_timestamp" TIMESTAMP );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_ACCOUNTS_3: @@ -347,7 +347,7 @@ protected function initTable(string $tableName, string $dbName = ''): void PRIMARY KEY ("id") );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_TABLE: @@ -359,7 +359,7 @@ protected function initTable(string $tableName, string $dbName = ''): void "_timestamp" TIMESTAMP );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_OUT_NO_TIMESTAMP_TABLE: @@ -369,7 +369,7 @@ protected function initTable(string $tableName, string $dbName = ''): void "col2" VARCHAR(50) );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; @@ -382,7 +382,7 @@ protected function initTable(string $tableName, string $dbName = ''): void "boolCol" VARCHAR(50) CHARACTER SET UNICODE, "_timestamp" TIMESTAMP );', - TeradataQuote::quoteSingleIdentifier($dbName) + TeradataQuote::quoteSingleIdentifier($dbName), )); $this->connection->executeQuery(sprintf( @@ -392,13 +392,13 @@ protected function initTable(string $tableName, string $dbName = ''): void "floatCol" float , "boolCol" BYTEINT );', - TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()) + TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()), )); $this->connection->executeQuery(sprintf( 'INSERT INTO %s."types" VALUES (\'a\', \'10.5\', \'0.3\', 1) ;', - TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()) + TeradataQuote::quoteSingleIdentifier($this->getSourceDbName()), )); break; case self::TABLE_ACCOUNTS_WITHOUT_TS: @@ -419,7 +419,7 @@ protected function initTable(string $tableName, string $dbName = ''): void PRIMARY KEY ("id") ) ', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; case self::TABLE_MULTI_PK_WITH_TS: @@ -434,7 +434,7 @@ protected function initTable(string $tableName, string $dbName = ''): void PRIMARY KEY ("VisitID", "Value", "MenuItem") );', TeradataQuote::quoteSingleIdentifier($dbName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); break; default: @@ -451,7 +451,7 @@ protected function getImportOptions( bool $isIncremental = false, bool $useTimestamp = false, int $numberOfIgnoredLines = 0, - string $usingTypes = ImportOptionsInterface::USING_TYPES_STRING + string $usingTypes = ImportOptionsInterface::USING_TYPES_STRING, ): TeradataImportOptions { [$host, $username, $password, $port, $dbname] = $this->getTeradataConnectionParams(); @@ -465,7 +465,7 @@ protected function getImportOptions( $isIncremental, $useTimestamp, $numberOfIgnoredLines, - $usingTypes + $usingTypes, ); } @@ -474,7 +474,7 @@ protected function getExportOptions( string $bufferSize = TeradataExportOptions::DEFAULT_BUFFER_SIZE, string $maxObjectSize = TeradataExportOptions::DEFAULT_MAX_OBJECT_SIZE, bool $dontSplitRows = TeradataExportOptions::DEFAULT_SPLIT_ROWS, - bool $singlePartFile = TeradataExportOptions::DEFAULT_SINGLE_PART_FILE + bool $singlePartFile = TeradataExportOptions::DEFAULT_SINGLE_PART_FILE, ): TeradataExportOptions { [$host, $username, $password, $port, $dbname] = $this->getTeradataConnectionParams(); @@ -489,13 +489,13 @@ protected function getExportOptions( $maxObjectSize, $dontSplitRows, $singlePartFile, - ExportOptions::MANIFEST_AUTOGENERATED + ExportOptions::MANIFEST_AUTOGENERATED, ); } protected function getSimpleImportOptions( int $skipLines = ImportOptionsInterface::SKIP_FIRST_LINE, - bool $useTimestamp = true + bool $useTimestamp = true, ): TeradataImportOptions { [$host, $username, $password, $port, $dbname] = $this->getTeradataConnectionParams(); @@ -508,7 +508,7 @@ protected function getSimpleImportOptions( [], false, $useTimestamp, - $skipLines + $skipLines, ); } @@ -523,12 +523,12 @@ protected function assertTeradataTableEqualsExpected( TeradataImportOptions $options, array $expected, $sortKey, - string $message = 'Imported tables are not the same as expected' + string $message = 'Imported tables are not the same as expected', ): void { $tableColumns = (new TeradataTableReflection( $this->connection, $destination->getSchemaName(), - $destination->getTableName() + $destination->getTableName(), ))->getColumnsNames(); if ($options->useTimestamp()) { @@ -553,7 +553,7 @@ protected function assertTeradataTableEqualsExpected( return TeradataQuote::quoteSingleIdentifier($item); }, $tableColumns)), TeradataQuote::quoteSingleIdentifier($destination->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($destination->getTableName()) + TeradataQuote::quoteSingleIdentifier($destination->getTableName()), ); $queryResult = array_map(static function ($row) { @@ -566,7 +566,7 @@ protected function assertTeradataTableEqualsExpected( $expected, $queryResult, $sortKey, - $message + $message, ); } } diff --git a/packages/php-db-import-export/tests/functional/Teradata/ToFinal/FullImportTest.php b/packages/php-db-import-export/tests/functional/Teradata/ToFinal/FullImportTest.php index f3e4c6142..8db149dd7 100644 --- a/packages/php-db-import-export/tests/functional/Teradata/ToFinal/FullImportTest.php +++ b/packages/php-db-import-export/tests/functional/Teradata/ToFinal/FullImportTest.php @@ -56,14 +56,14 @@ public function testLoadToFinalTableWithoutDedup(): void ], false, false, - [] + [], ); $importer = new ToStageImporter($this->connection); $destinationRef = new TeradataTableReflection( $this->connection, $this->getDestinationDbName(), - self::TABLE_TRANSLATIONS + self::TABLE_TRANSLATIONS, ); /** @var TeradataTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -75,19 +75,19 @@ public function testLoadToFinalTableWithoutDedup(): void ]); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(3, $destinationRef->getRowsCount()); @@ -110,14 +110,14 @@ public function testLoadToTableWithDedupWithSinglePK(): void ], false, false, - ['VisitID'] + ['VisitID'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new TeradataTableReflection( $this->connection, $this->getDestinationDbName(), - self::TABLE_SINGLE_PK + self::TABLE_SINGLE_PK, ); /** @var TeradataTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -130,19 +130,19 @@ public function testLoadToTableWithDedupWithSinglePK(): void ]); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); $toFinalTableImporter = new FullImporter($this->connection); $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(4, $destinationRef->getRowsCount()); @@ -165,14 +165,14 @@ public function testLoadToTableWithDedupWithMultiPK(): void ], false, false, - ['VisitID', 'Something'] + ['VisitID', 'Something'], ); $importer = new ToStageImporter($this->connection); $destinationRef = new TeradataTableReflection( $this->connection, $this->getDestinationDbName(), - self::TABLE_MULTI_PK + self::TABLE_MULTI_PK, ); /** @var TeradataTableDefinition $destination */ $destination = $destinationRef->getTableDefinition(); @@ -185,12 +185,12 @@ public function testLoadToTableWithDedupWithMultiPK(): void ]); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $importState = $importer->importToStagingTable( $source, $stagingTable, - $options + $options, ); // now 6 lines. Add one with same VisitId and Something as an existing line has @@ -199,15 +199,15 @@ public function testLoadToTableWithDedupWithMultiPK(): void sprintf( "INSERT INTO %s.%s VALUES ('134', 'xx', 'yy', 'abc', 'def');", TeradataQuote::quoteSingleIdentifier($stagingTable->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($stagingTable->getTableName()) - ) + TeradataQuote::quoteSingleIdentifier($stagingTable->getTableName()), + ), ); $toFinalTableImporter = new FullImporter($this->connection); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); self::assertEquals(6, $destinationRef->getRowsCount()); @@ -261,7 +261,7 @@ public function fullImportData(): Generator $escapingHeader, true, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(ImportOptionsInterface::SKIP_NO_LINE), @@ -276,7 +276,7 @@ public function fullImportData(): Generator $escapingHeader, true, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -291,7 +291,7 @@ public function fullImportData(): Generator $lemmaHeader, false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_LEMMA], $this->getSimpleImportOptions(), @@ -306,7 +306,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -321,7 +321,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -337,7 +337,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_OUT_CSV_2COLS], $this->getSimpleImportOptions(), @@ -352,7 +352,7 @@ public function fullImportData(): Generator $accountChangedColumnsOrderHeader, false, false, - ['id'] + ['id'], ), [ $this->getDestinationDbName(), @@ -370,7 +370,7 @@ public function fullImportData(): Generator $accountsHeader, false, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(), @@ -386,7 +386,7 @@ public function fullImportData(): Generator $accountsHeader, false, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(), @@ -402,7 +402,7 @@ public function fullImportData(): Generator $accountsHeader, true, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(ImportOptionsInterface::SKIP_NO_LINE), @@ -417,7 +417,7 @@ public function fullImportData(): Generator $accountsHeader, true, false, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(ImportOptionsInterface::SKIP_NO_LINE), @@ -433,7 +433,7 @@ public function fullImportData(): Generator $accountsHeader, true, true, - ['id'] + ['id'], ), [$this->getDestinationDbName(), self::TABLE_ACCOUNTS_3], $this->getSimpleImportOptions(ImportOptionsInterface::SKIP_NO_LINE), @@ -449,7 +449,7 @@ public function fullImportData(): Generator ['column', 'table'], false, false, - [] + [], ), [$this->getDestinationDbName(), self::TABLE_TABLE], $this->getSimpleImportOptions(), @@ -468,7 +468,7 @@ public function fullImportData(): Generator ], false, false, - [] + [], ), [ $this->getDestinationDbName(), @@ -489,7 +489,7 @@ public function fullImportData(): Generator $escapingHeader, false, false, - [] + [], ), [ $this->getDestinationDbName(), @@ -499,7 +499,7 @@ public function fullImportData(): Generator [], false, false, // don't use timestamp - ImportOptionsInterface::SKIP_FIRST_LINE + ImportOptionsInterface::SKIP_FIRST_LINE, ), $expectedEscaping, 7, @@ -523,7 +523,7 @@ public function fullImportData(): Generator 'numCol', 'floatCol', 'boolCol', - ] + ], ), [ $this->getDestinationDbName(), @@ -548,7 +548,7 @@ public function testFullImportWithDataSet( TeradataImportOptions $options, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { if (getenv('STORAGE_TYPE') === StorageType::STORAGE_ABS && $this->dataName() === 'large manifest') { $this->markTestIncomplete('large manifest end with timeout'); @@ -561,18 +561,18 @@ public function testFullImportWithDataSet( $destination = (new TeradataTableReflection( $this->connection, $schemaName, - $tableName + $tableName, ))->getTableDefinition(); // TPT $stagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $source->getColumnsNames() + $source->getColumnsNames(), ); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($stagingTable) + $qb->getCreateTableCommandFromDefinition($stagingTable), ); $toStageImporter = new ToStageImporter($this->connection); $toFinalTableImporter = new FullImporter($this->connection); @@ -580,13 +580,13 @@ public function testFullImportWithDataSet( $importState = $toStageImporter->importToStagingTable( $source, $stagingTable, - $options + $options, ); $result = $toFinalTableImporter->importToTable( $stagingTable, $destination, $options, - $importState + $importState, ); } finally { $this->dropTableIfExists($stagingTable->getSchemaName(), $stagingTable->getTableName()); @@ -599,7 +599,7 @@ public function testFullImportWithDataSet( $destination, $options, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Teradata/ToFinal/IncrementalImportTest.php b/packages/php-db-import-export/tests/functional/Teradata/ToFinal/IncrementalImportTest.php index 246312a6e..948392721 100644 --- a/packages/php-db-import-export/tests/functional/Teradata/ToFinal/IncrementalImportTest.php +++ b/packages/php-db-import-export/tests/functional/Teradata/ToFinal/IncrementalImportTest.php @@ -24,13 +24,13 @@ class IncrementalImportTest extends TeradataBaseTestCase use StorageTrait; protected function getTeradataIncrementalImportOptions( - int $skipLines = ImportOptionsInterface::SKIP_FIRST_LINE + int $skipLines = ImportOptionsInterface::SKIP_FIRST_LINE, ): TeradataImportOptions { return $this->getImportOptions( [], true, true, - $skipLines + $skipLines, ); } @@ -93,7 +93,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getImportOptions([], false, false, ImportOptionsInterface::SKIP_FIRST_LINE), $this->getSourceInstance( @@ -101,7 +101,7 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getTeradataIncrementalImportOptions(), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_3], @@ -115,26 +115,26 @@ public function incrementalImportData(): Generator $accountColumns, false, false, - ['id'] + ['id'], ), $this->getImportOptions( [], false, false, // disable timestamp - ImportOptionsInterface::SKIP_FIRST_LINE + ImportOptionsInterface::SKIP_FIRST_LINE, ), $this->getSourceInstance( 'tw_accounts.increment.csv', $accountColumns, false, false, - ['id'] + ['id'], ), $this->getImportOptions( [], true, false, // disable timestamp - ImportOptionsInterface::SKIP_FIRST_LINE + ImportOptionsInterface::SKIP_FIRST_LINE, ), [$this->getDestinationSchemaName(), self::TABLE_ACCOUNTS_WITHOUT_TS], $expectedAccountsRows, @@ -147,20 +147,20 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getImportOptions( [], false, true, // disable timestamp - ImportOptionsInterface::SKIP_FIRST_LINE + ImportOptionsInterface::SKIP_FIRST_LINE, ), $this->getSourceInstance( 'multi-pk_not-null.increment.csv', $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getTeradataIncrementalImportOptions(), [$this->getDestinationSchemaName(), self::TABLE_MULTI_PK_WITH_TS], @@ -174,20 +174,20 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getImportOptions( [], false, true, // disable timestamp - ImportOptionsInterface::SKIP_FIRST_LINE + ImportOptionsInterface::SKIP_FIRST_LINE, ), $this->getSourceInstance( 'multi-pk.increment.csv', $multiPkColumns, false, false, - ['VisitID', 'Value', 'MenuItem'] + ['VisitID', 'Value', 'MenuItem'], ), $this->getTeradataIncrementalImportOptions(), [$this->getDestinationSchemaName(), self::TABLE_MULTI_PK_WITH_TS], @@ -201,7 +201,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - [] + [], ), $this->getImportOptions([], false, false, 1), $this->getSourceInstance( @@ -209,7 +209,7 @@ public function incrementalImportData(): Generator $multiPkColumns, false, false, - [] + [], ), $this->getTeradataIncrementalImportOptions(), [$this->getDestinationSchemaName(), self::TABLE_NO_PK], @@ -233,7 +233,7 @@ public function testIncrementalImport( array $table, array $expected, int $expectedImportedRowCount, - string $tablesToInit + string $tablesToInit, ): void { [$dbName, $tableName] = $table; @@ -243,7 +243,7 @@ public function testIncrementalImport( $destination = (new TeradataTableReflection( $this->connection, $dbName, - $tableName + $tableName, ))->getTableDefinition(); $toStageImporter = new ToStageImporter($this->connection); @@ -252,56 +252,56 @@ public function testIncrementalImport( $fullLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $fullLoadSource->getColumnsNames() + $fullLoadSource->getColumnsNames(), ); $incrementalLoadStagingTable = StageTableDefinitionFactory::createStagingTableDefinition( $destination, - $incrementalSource->getColumnsNames() + $incrementalSource->getColumnsNames(), ); try { // full load $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($fullLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $fullLoadSource, $fullLoadStagingTable, - $fullLoadOptions + $fullLoadOptions, ); $fullImporter->importToTable( $fullLoadStagingTable, $destination, $fullLoadOptions, - $importState + $importState, ); // incremental load $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement( - $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable) + $qb->getCreateTableCommandFromDefinition($incrementalLoadStagingTable), ); $importState = $toStageImporter->importToStagingTable( $incrementalSource, $incrementalLoadStagingTable, - $incrementalOptions + $incrementalOptions, ); $result = $incrementalImporter->importToTable( $incrementalLoadStagingTable, $destination, $incrementalOptions, - $importState + $importState, ); } finally { $this->dropTableIfExists( $fullLoadStagingTable->getSchemaName(), - $fullLoadStagingTable->getTableName() + $fullLoadStagingTable->getTableName(), ); $this->dropTableIfExists( $incrementalLoadStagingTable->getSchemaName(), - $incrementalLoadStagingTable->getTableName() + $incrementalLoadStagingTable->getTableName(), ); } @@ -312,7 +312,7 @@ public function testIncrementalImport( $destination, $incrementalOptions, $expected, - 0 + 0, ); } } diff --git a/packages/php-db-import-export/tests/functional/Teradata/ToFinal/SqlBuilderTest.php b/packages/php-db-import-export/tests/functional/Teradata/ToFinal/SqlBuilderTest.php index 80f34bdf8..46844766a 100644 --- a/packages/php-db-import-export/tests/functional/Teradata/ToFinal/SqlBuilderTest.php +++ b/packages/php-db-import-export/tests/functional/Teradata/ToFinal/SqlBuilderTest.php @@ -72,22 +72,22 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): T sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (2,2,\'2\',\'2\')', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), + ), ); if ($includeEmptyValues) { @@ -95,8 +95,8 @@ private function createStagingTableWithData(bool $includeEmptyValues = false): T sprintf( 'INSERT INTO %s.%s("pk1","pk2","col1","col2") VALUES (2,2,\'\',NULL)', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), + ), ); } @@ -115,7 +115,7 @@ private function getStagingTableDefinition(): TeradataTableDefinition $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); } @@ -126,18 +126,18 @@ private function createNullableGenericColumn(string $columnName): TeradataColumn [ 'length' => '50', // should be changed to max in future 'nullable' => true, - ] + ], ); return new TeradataColumn( $columnName, - $definition + $definition, ); } protected function createTestTableWithColumns( bool $includeTimestamp = false, - bool $includePrimaryKey = false + bool $includePrimaryKey = false, ): TeradataTableDefinition { $columns = []; $pks = []; @@ -145,7 +145,7 @@ protected function createTestTableWithColumns( $pks[] = 'id'; $columns[] = new TeradataColumn( 'id', - new Teradata(Teradata::TYPE_INT) + new Teradata(Teradata::TYPE_INT), ); } else { $columns[] = $this->createNullableGenericColumn('id'); @@ -156,7 +156,7 @@ protected function createTestTableWithColumns( if ($includeTimestamp) { $columns[] = new TeradataColumn( '_timestamp', - new Teradata(Teradata::TYPE_TIMESTAMP) + new Teradata(Teradata::TYPE_TIMESTAMP), ); } @@ -165,10 +165,10 @@ protected function createTestTableWithColumns( self::TEST_TABLE, false, new ColumnCollection($columns), - $pks + $pks, ); $this->connection->executeStatement( - (new TeradataTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition) + (new TeradataTableQueryBuilder())->getCreateTableCommandFromDefinition($tableDefinition), ); return $tableDefinition; @@ -189,7 +189,7 @@ public function testGetDropTableIfExistsCommand(): void self::assertEquals( // phpcs:ignore sprintf('DROP TABLE %s."import-export-test_test"', TeradataQuote::quoteSingleIdentifier($this->getTestDBName())), - $sql + $sql, ); $this->connection->executeStatement($sql); } catch (DriverException $e) { @@ -224,9 +224,9 @@ public function testGetTruncateTableWithDeleteCommand(): void self::assertEquals( sprintf( 'DELETE %s."stagingTable" ALL', - TeradataQuote::quoteSingleIdentifier($this->getTestDBName()) + TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), ), - $sql + $sql, ); $this->connection->executeStatement($sql); self::assertEquals(0, $ref->getRowsCount()); @@ -249,7 +249,7 @@ public function testGetDedupCommand(): void [ 'pk1', 'pk2', - ] + ], ); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($deduplicationDef)); @@ -257,19 +257,19 @@ public function testGetDedupCommand(): void $sql = $this->getBuilder()->getDedupCommand( $stageDef, $deduplicationDef, - $deduplicationDef->getPrimaryKeysNames() + $deduplicationDef->getPrimaryKeysNames(), ); $testDbName = TeradataQuote::quoteSingleIdentifier($this->getTestDBName()); self::assertEquals( // phpcs:ignore sprintf('INSERT INTO %s."__temp_tempTable" ("col1", "col2") SELECT a."col1",a."col2" FROM (SELECT "col1", "col2", ROW_NUMBER() OVER (PARTITION BY "pk1","pk2" ORDER BY "pk1","pk2") AS "_row_number_" FROM %s."stagingTable") AS a WHERE a."_row_number_" = 1', $testDbName, $testDbName), - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($deduplicationDef->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($deduplicationDef->getTableName()) + TeradataQuote::quoteSingleIdentifier($deduplicationDef->getTableName()), )); self::assertCount(2, $result); @@ -291,7 +291,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // no convert values no timestamp @@ -299,7 +299,7 @@ public function testGetInsertAllIntoTargetTableCommand(): void $fakeStage, $destination, $this->getImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( @@ -307,9 +307,9 @@ public function testGetInsertAllIntoTargetTableCommand(): void // phpcs:ignore 'INSERT INTO %s."import-export-test_test" ("col1", "col2") SELECT CAST(COALESCE("col1", \'\') as VARCHAR (50)) AS "col1",CAST(COALESCE("col2", \'\') as VARCHAR (50)) AS "col2" FROM %s."stagingTable" AS "src"', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier($this->getTestDBName()) + TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), ), - $sql + $sql, ); $out = $this->connection->executeStatement($sql); @@ -360,7 +360,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // convert col1 to null @@ -369,15 +369,15 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore sprintf('INSERT INTO %s."import-export-test_test" ("col1", "col2") SELECT NULLIF("col1", \'\'),CAST(COALESCE("col2", \'\') as VARCHAR (50)) AS "col2" FROM %s."stagingTable" AS "src"', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier($this->getTestDBName()) + TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), ), - $sql + $sql, ); $out = $this->connection->executeStatement($sql); self::assertEquals(4, $out); @@ -385,7 +385,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNull(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), )); self::assertEqualsCanonicalizing([ @@ -426,7 +426,7 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); // use timestamp @@ -435,16 +435,16 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp $fakeStage, $destination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( sprintf( // phpcs:ignore 'INSERT INTO %s."import-export-test_test" ("col1", "col2", "_timestamp") SELECT NULLIF("col1", \'\'),CAST(COALESCE("col2", \'\') as VARCHAR (50)) AS "col2",\'2020-01-01 00:00:00\' FROM %s."stagingTable" AS "src"', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier($this->getTestDBName()) + TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), ), - $sql + $sql, ); $out = $this->connection->executeStatement($sql); self::assertEquals(4, $out); @@ -453,8 +453,8 @@ public function testGetInsertAllIntoTargetTableCommandConvertToNullWithTimestamp sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), + ), )); foreach ($result as $item) { @@ -480,7 +480,7 @@ public function testGetUpdateWithPkCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new TeradataTableDefinition( @@ -491,21 +491,21 @@ public function testGetUpdateWithPkCommand(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s.%s("id","col1","col2") VALUES (1,\'2\',\'1\')', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) - ) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), + ), ); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), )); self::assertEquals([ @@ -521,7 +521,7 @@ public function testGetUpdateWithPkCommand(): void $fakeStage, $fakeDestination, $this->getImportOptions(), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $dest = sprintf('"%s"."%s"', $this->getTestDBName(), self::TEST_TABLE); $expectedSql = sprintf( @@ -530,7 +530,7 @@ public function testGetUpdateWithPkCommand(): void $dest, TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), - $dest + $dest, ); self::assertEquals($expectedSql, $sql); @@ -539,7 +539,7 @@ public function testGetUpdateWithPkCommand(): void $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), )); self::assertEquals([ @@ -565,7 +565,7 @@ public function testGetUpdateWithPkCommandWhenTypedTables(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new TeradataTableDefinition( @@ -576,18 +576,18 @@ public function testGetUpdateWithPkCommandWhenTypedTables(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $dest = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("id","col1","col2") VALUES (1,\'2\',\'1\')', - $dest - ) + $dest, + ), ); $result = $this->connection->fetchAllAssociative(sprintf('SELECT * FROM %s', $dest)); @@ -609,9 +609,9 @@ public function testGetUpdateWithPkCommandWhenTypedTables(): void false, false, 0, - ImportOptionsInterface::USING_TYPES_USER + ImportOptionsInterface::USING_TYPES_USER, ), - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $expectedSql = sprintf( @@ -620,7 +620,7 @@ public function testGetUpdateWithPkCommandWhenTypedTables(): void $dest, TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), - $dest + $dest, ); self::assertEquals($expectedSql, $sql); @@ -651,7 +651,7 @@ public function testGetUpdateWithPkCommandConvertValues(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new TeradataTableDefinition( @@ -662,20 +662,20 @@ public function testGetUpdateWithPkCommandConvertValues(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $dest = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), ); $this->connection->executeStatement( - sprintf('INSERT INTO %s ("id","col1","col2") VALUES (1,\'\',\'1\')', $dest) + sprintf('INSERT INTO %s ("id","col1","col2") VALUES (1,\'\',\'1\')', $dest), ); $this->connection->executeStatement( - sprintf('INSERT INTO %s ("id","col1","col2") VALUES (1,\'2\',\'\')', $dest) + sprintf('INSERT INTO %s ("id","col1","col2") VALUES (1,\'2\',\'\')', $dest), ); $result = $this->connection->fetchAllAssociative(sprintf('SELECT * FROM %s', $dest)); @@ -700,7 +700,7 @@ public function testGetUpdateWithPkCommandConvertValues(): void $fakeStage, $fakeDestination, $options, - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); $expectedSql = sprintf( @@ -709,12 +709,12 @@ public function testGetUpdateWithPkCommandConvertValues(): void $dest, TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), - $dest + $dest, ); self::assertEquals( // phpcs:ignore $expectedSql, - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -751,7 +751,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - ['col1'] + ['col1'], ); // create fake stage and say that there is less columns $fakeStage = new TeradataTableDefinition( @@ -762,28 +762,28 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $this->createNullableGenericColumn('col1'), $this->createNullableGenericColumn('col2'), ]), - [] + [], ); $dest = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), - TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE) + TeradataQuote::quoteSingleIdentifier(self::TEST_TABLE), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("id","col1","col2","_timestamp") VALUES (1,\'\',\'1\',\'%s\')', $dest, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("id","col1","col2","_timestamp") VALUES (1,\'2\',\'\',\'%s\')', $dest, - $timestampInit->format(DateTimeHelper::FORMAT) - ) + $timestampInit->format(DateTimeHelper::FORMAT), + ), ); $result = $this->connection->fetchAllAssociative(sprintf('SELECT * FROM %s', $dest)); @@ -808,7 +808,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $fakeStage, $fakeDestination, $options, - $timestampSet->format(DateTimeHelper::FORMAT) + $timestampSet->format(DateTimeHelper::FORMAT), ); $expectedSql = sprintf( // phpcs:ignore @@ -816,7 +816,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void $dest, TeradataQuote::quoteSingleIdentifier($this->getTestDBName()), TeradataQuote::quoteSingleIdentifier(self::TEST_STAGING_TABLE), - $dest + $dest, ); self::assertEquals($expectedSql, $sql); @@ -833,7 +833,7 @@ public function testGetUpdateWithPkCommandConvertValuesWithTimestamp(): void self::assertIsString($item['_timestamp']); self::assertSame( $timestampSet->format(DateTimeHelper::FORMAT), - (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT) + (new DateTime($item['_timestamp']))->format(DateTimeHelper::FORMAT), ); } } @@ -851,28 +851,28 @@ public function testGetDeleteOldItemsCommand(): void new TeradataColumn( 'id', new Teradata( - Teradata::TYPE_INT - ) + Teradata::TYPE_INT, + ), ), TeradataColumn::createGenericColumn('pk1'), TeradataColumn::createGenericColumn('pk2'), TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $storageTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($tableDefinition)); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("id","pk1","pk2","col1","col2") VALUES (1,1,1,\'1\',\'1\')', - $storageTable - ) + $storageTable, + ), ); $stagingTableDefinition = new TeradataTableDefinition( $this->getTestDbName(), @@ -884,31 +884,31 @@ public function testGetDeleteOldItemsCommand(): void TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stagingTableDefinition)); $stagingTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', - $stagingTable - ) + $stagingTable, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("pk1","pk2","col1","col2") VALUES (2,1,\'1\',\'1\')', - $stagingTable - ) + $stagingTable, + ), ); $sql = $this->getBuilder()->getDeleteOldItemsCommand( $stagingTableDefinition, $tableDefinition, - $this->getSimpleImportOptions() + $this->getSimpleImportOptions(), ); $expectedSql = sprintf( @@ -921,13 +921,13 @@ public function testGetDeleteOldItemsCommand(): void ); self::assertEquals( $expectedSql, - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - $stagingTable + $stagingTable, )); self::assertCount(1, $result); @@ -953,28 +953,28 @@ public function testGetDeleteOldItemsCommandWhenUsingTypedTable(): void new TeradataColumn( 'id', new Teradata( - Teradata::TYPE_INT - ) + Teradata::TYPE_INT, + ), ), TeradataColumn::createGenericColumn('pk1'), TeradataColumn::createGenericColumn('pk2'), TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $storageTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($tableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($tableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($tableDefinition->getTableName()), ); $qb = new TeradataTableQueryBuilder(); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($tableDefinition)); $this->connection->executeStatement( sprintf( 'INSERT INTO %s ("id","pk1","pk2","col1","col2") VALUES (1,1,1,\'1\',\'1\')', - $storageTable - ) + $storageTable, + ), ); $stagingTableDefinition = new TeradataTableDefinition( $this->getTestDbName(), @@ -986,25 +986,25 @@ public function testGetDeleteOldItemsCommandWhenUsingTypedTable(): void TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), ]), - ['pk1', 'pk2'] + ['pk1', 'pk2'], ); $this->connection->executeStatement($qb->getCreateTableCommandFromDefinition($stagingTableDefinition)); $stagingTable = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getSchemaName()), - TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()) + TeradataQuote::quoteSingleIdentifier($stagingTableDefinition->getTableName()), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (1,1,\'1\',\'1\')', - $stagingTable - ) + $stagingTable, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO %s("pk1","pk2","col1","col2") VALUES (2,1,\'1\',\'1\')', - $stagingTable - ) + $stagingTable, + ), ); $sql = $this->getBuilder()->getDeleteOldItemsCommand( @@ -1016,7 +1016,7 @@ public function testGetDeleteOldItemsCommandWhenUsingTypedTable(): void false, 0, ImportOptionsInterface::USING_TYPES_USER, - ) + ), ); $expectedSql = sprintf( @@ -1029,14 +1029,14 @@ public function testGetDeleteOldItemsCommandWhenUsingTypedTable(): void ); self::assertEquals( $expectedSql, - $sql + $sql, ); $this->connection->executeStatement($sql); $result = $this->connection->fetchAllAssociative(sprintf( 'SELECT * FROM %s', - $stagingTable + $stagingTable, )); self::assertCount(1, $result); diff --git a/packages/php-db-import-export/tests/functional/Teradata/ToStage/StageImportTest.php b/packages/php-db-import-export/tests/functional/Teradata/ToStage/StageImportTest.php index 1a186fbab..d74c1b981 100644 --- a/packages/php-db-import-export/tests/functional/Teradata/ToStage/StageImportTest.php +++ b/packages/php-db-import-export/tests/functional/Teradata/ToStage/StageImportTest.php @@ -37,15 +37,15 @@ public function testSimpleStageImport(): void "last_name" CHAR(50) );', TeradataQuote::quoteSingleIdentifier($this->getDestinationDbName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $importer = new ToStageImporter($this->connection); $ref = new TeradataTableReflection( $this->connection, $this->getDestinationDbName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); $state = $importer->importToStagingTable( @@ -55,8 +55,8 @@ public function testSimpleStageImport(): void [], false, false, - 1 - ) + 1, + ), ); self::assertEquals(1, $state->getResult()->getImportedRowsCount()); @@ -73,15 +73,15 @@ public function testFailingImport(): void "first_name" CHAR(1) );', TeradataQuote::quoteSingleIdentifier($this->getDestinationDbName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $importer = new ToStageImporter($this->connection); $ref = new TeradataTableReflection( $this->connection, $this->getDestinationDbName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); try { @@ -92,8 +92,8 @@ public function testFailingImport(): void [], false, false, - 1 - ) + 1, + ), ); self::fail('should fail'); } catch (FailedTPTLoadException $e) { @@ -117,14 +117,14 @@ public function testItWontFitIn(): void $ref = new TeradataTableReflection( $this->connection, $dbName, - self::BIGGER_TABLE + self::BIGGER_TABLE, ); $this->expectException(NoMoreRoomInTDException::class); $importer->importToStagingTable( $this->getSourceInstanceFromCsv('big_table.csv', new CsvOptions()), $ref->getTableDefinition(), - $this->getImportOptions() + $this->getImportOptions(), ); } @@ -140,8 +140,8 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnNameMismatch(): v "last_name" VARCHAR(100) );', TeradataQuote::quoteSingleIdentifier($this->getDestinationDbName()), - TeradataQuote::quoteSingleIdentifier('sourceTable') - ) + TeradataQuote::quoteSingleIdentifier('sourceTable'), + ), ); $this->connection->executeQuery( @@ -154,22 +154,22 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnNameMismatch(): v "last_name" VARCHAR(100) );', TeradataQuote::quoteSingleIdentifier($this->getDestinationDbName()), - TeradataQuote::quoteSingleIdentifier('targetTable') - ) + TeradataQuote::quoteSingleIdentifier('targetTable'), + ), ); $importer = new ToStageImporter($this->connection); $targetTableRef = new TeradataTableReflection( $this->connection, $this->getDestinationDbName(), - 'targetTable' + 'targetTable', ); $source = new Table( $this->getDestinationDbName(), 'sourceTable', ['id', 'first_name', 'last_name'], - [] + [], ); $this->expectException(ColumnsMismatchException::class); @@ -182,8 +182,8 @@ public function testMoveDataFromAToBRequireSameTablesFailColumnNameMismatch(): v false, false, 0, - ImportOptionsInterface::USING_TYPES_USER - ) + ImportOptionsInterface::USING_TYPES_USER, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Backend/AssertTest.php b/packages/php-db-import-export/tests/unit/Backend/AssertTest.php index 430f3b586..83edb350c 100644 --- a/packages/php-db-import-export/tests/unit/Backend/AssertTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/AssertTest.php @@ -31,8 +31,8 @@ public function testAssertSameColumns(): void Snowflake::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; $destCols = [ @@ -44,14 +44,14 @@ public function testAssertSameColumns(): void Snowflake::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -71,7 +71,7 @@ public function testAssertSameColumnsIgnore(): void SnowflakeColumn::createGenericColumn('test'), SnowflakeColumn::createGenericColumn('test1'), ]), - ['test2'] + ['test2'], ); // middle @@ -85,7 +85,7 @@ public function testAssertSameColumnsIgnore(): void SnowflakeColumn::createGenericColumn('test'), SnowflakeColumn::createGenericColumn('test1'), ]), - ['test2'] + ['test2'], ); // end @@ -99,7 +99,7 @@ public function testAssertSameColumnsIgnore(): void SnowflakeColumn::createGenericColumn('test'), SnowflakeColumn::createGenericColumn('test1'), ]), - ['test2'] + ['test2'], ); } @@ -119,7 +119,7 @@ public function testAssertSameColumnsInvalidCountExtraSource(): void $this->expectExceptionMessage('Tables don\'t have same number of columns.'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -139,7 +139,7 @@ public function testAssertSameColumnsInvalidCountExtraDestination(): void $this->expectExceptionMessage('Tables don\'t have same number of columns.'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -158,7 +158,7 @@ public function testAssertSameColumnsInvalidColumnName(): void $this->expectExceptionMessage('Source destination columns name mismatch. "test1x"->"test1"'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -173,8 +173,8 @@ public function testAssertSameColumnsInvalidType(): void Snowflake::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; $destCols = [ @@ -186,18 +186,18 @@ public function testAssertSameColumnsInvalidType(): void Snowflake::TYPE_TIMESTAMP_NTZ, [ 'length' => '3', - ] - ) + ], + ), ), ]; $this->expectException(Exception::class); $this->expectExceptionMessage( - 'Source destination columns mismatch. "test2 TIME (3)"->"test2 TIMESTAMP_NTZ (3)"' + 'Source destination columns mismatch. "test2 TIME (3)"->"test2 TIMESTAMP_NTZ (3)"', ); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -212,8 +212,8 @@ public function testAssertSameColumnsInvalidLength(): void Snowflake::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; $destCols = [ @@ -225,8 +225,8 @@ public function testAssertSameColumnsInvalidLength(): void Snowflake::TYPE_TIME, [ 'length' => '4', - ] - ) + ], + ), ), ]; @@ -234,7 +234,7 @@ public function testAssertSameColumnsInvalidLength(): void $this->expectExceptionMessage('Source destination columns mismatch. "test2 TIME (3)"->"test2 TIME (4)"'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -245,7 +245,7 @@ public function testAssertSameColumnsInvalidLength2(): void SnowflakeColumn::createGenericColumn('test1'), new SnowflakeColumn( 'test2', - new Snowflake(Snowflake::TYPE_TIME) + new Snowflake(Snowflake::TYPE_TIME), ), ]; $destCols = [ @@ -257,8 +257,8 @@ public function testAssertSameColumnsInvalidLength2(): void Snowflake::TYPE_TIME, [ 'length' => '4', - ] - ) + ], + ), ), ]; @@ -266,7 +266,7 @@ public function testAssertSameColumnsInvalidLength2(): void $this->expectExceptionMessage('Source destination columns mismatch. "test2 TIME"->"test2 TIME (4)"'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -407,7 +407,7 @@ public function testAssertSameColumnsWithSpecificLengths( string $sourceLength, string $destType, string $destLength, - array|null $expectedException = null + array|null $expectedException = null, ): void { $sourceCols = [ SnowflakeColumn::createGenericColumn('test'), @@ -432,7 +432,7 @@ public function testAssertSameColumnsWithSpecificLengths( new ColumnCollection($destCols), [], ['SIMPLETYPE'], - ['COMPLEXTYPE'] + ['COMPLEXTYPE'], ); } @@ -479,7 +479,7 @@ public static function createGenericColumn(string $columnName): ColumnInterface } public static function createTimestampColumn( - string $columnName = self::TIMESTAMP_COLUMN_NAME + string $columnName = self::TIMESTAMP_COLUMN_NAME, ): ColumnInterface { throw new NativeException('Not implemented'); } diff --git a/packages/php-db-import-export/tests/unit/Backend/Bigquery/BigqueryExceptionTest.php b/packages/php-db-import-export/tests/unit/Backend/Bigquery/BigqueryExceptionTest.php index 5661bf852..924fe8764 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Bigquery/BigqueryExceptionTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Bigquery/BigqueryExceptionTest.php @@ -1,6 +1,6 @@ 'bigquery#job', 'etag' => '/ty8yus/A/JoTZZvf1qgFQ==', 'id' => 'tf2-56:US.eb64d133-213d-4e99-9cc0-4e37d0c18de9', + // phpcs:ignore Generic.Files.LineLength 'selfLink' => 'https://bigquery.googleapis.com/bigquery/v2/projects/tf2-56/jobs/eb64d133-213d-4e99-9cc0-4e37d0c18de9?location=US', 'user_email' => 'tf2-56@617348738050.iam.gserviceaccount.com', 'configuration' => [ @@ -83,16 +84,19 @@ public function provideJobAndExpectedError() 'status' => [ 'errorResult' => [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 1; errors: 1; max bad: 0; error percent: 0', ], 'errors' => [ [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 1; errors: 1; max bad: 0; error percent: 0', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], ], @@ -105,9 +109,11 @@ public function provideJobAndExpectedError() ], function (Throwable $e) { $this->assertStringStartsWith( - 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD ' - . 'HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 ' - . 'column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File:', $e->getMessage() + 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp.' + . ' Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]];' + . ' line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 ' + . 'column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File:', + $e->getMessage(), ); $this->assertCount(1, explode(PHP_EOL, $e->getMessage())); $this->assertInstanceOf(BigqueryInputDataException::class, $e); @@ -118,6 +124,7 @@ function (Throwable $e) { 'kind' => 'bigquery#job', 'etag' => '/ty8yus/A/JoTZZvf1qgFQ==', 'id' => 'tf2-56:US.eb64d133-213d-4e99-9cc0-4e37d0c18de9', + // phpcs:ignore Generic.Files.LineLength 'selfLink' => 'https://bigquery.googleapis.com/bigquery/v2/projects/tf2-56/jobs/eb64d133-213d-4e99-9cc0-4e37d0c18de9?location=US', 'user_email' => 'tf2-56@617348738050.iam.gserviceaccount.com', 'configuration' => [ @@ -171,21 +178,25 @@ function (Throwable $e) { 'status' => [ 'errorResult' => [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2; errors: 2; max bad: 0; error percent: 0', ], 'errors' => [ [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2; errors: 2; max bad: 0; error percent: 0', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], ], @@ -197,16 +208,22 @@ function (Throwable $e) { ], ], function (Throwable $e) { + // phpcs:ignore Generic.Files.LineLength $this->assertStringStartsWith( - 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD ' - . 'HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 ' - . 'column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File:', $e->getMessage() + 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp.' + . 'Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]];' + . 'line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 ' + . 'column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File:', + $e->getMessage(), ); + // phpcs:ignore Generic.Files.LineLength $this->assertStringContainsString( // different line number - 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD ' - . 'HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 ' - . 'column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File:', $e->getMessage() + 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp.' + . ' Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]];' + . ' line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 ' + . 'column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File:', + $e->getMessage(), ); $this->assertCount(2, explode(PHP_EOL, $e->getMessage())); $this->assertInstanceOf(BigqueryInputDataException::class, $e); @@ -217,6 +234,7 @@ function (Throwable $e) { 'kind' => 'bigquery#job', 'etag' => '/ty8yus/A/JoTZZvf1qgFQ==', 'id' => 'tf2-56:US.eb64d133-213d-4e99-9cc0-4e37d0c18de9', + // phpcs:ignore Generic.Files.LineLength 'selfLink' => 'https://bigquery.googleapis.com/bigquery/v2/projects/tf2-56/jobs/eb64d133-213d-4e99-9cc0-4e37d0c18de9?location=US', 'user_email' => 'tf2-56@617348738050.iam.gserviceaccount.com', 'configuration' => [ @@ -270,71 +288,85 @@ function (Throwable $e) { 'status' => [ 'errorResult' => [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], 'errors' => [ [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 2 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], @@ -348,7 +380,8 @@ function (Throwable $e) { ], function (Throwable $e) { $this->assertStringStartsWith( - 'There were too many errors during the import. For more information check job', $e->getMessage() + 'There were too many errors during the import. For more information check job', + $e->getMessage(), ); $this->assertCount(1, explode(PHP_EOL, $e->getMessage())); @@ -360,6 +393,7 @@ function (Throwable $e) { 'kind' => 'bigquery#job', 'etag' => '/ty8yus/A/JoTZZvf1qgFQ==', 'id' => 'tf2-56:US.eb64d133-213d-4e99-9cc0-4e37d0c18de9', + // phpcs:ignore Generic.Files.LineLength 'selfLink' => 'https://bigquery.googleapis.com/bigquery/v2/projects/tf2-56/jobs/eb64d133-213d-4e99-9cc0-4e37d0c18de9?location=US', 'user_email' => 'tf2-56@617348738050.iam.gserviceaccount.com', 'configuration' => [ @@ -413,11 +447,13 @@ function (Throwable $e) { 'status' => [ 'errorResult' => [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], 'errors' => [ [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], [ @@ -428,56 +464,67 @@ function (Throwable $e) { [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], @@ -500,6 +547,7 @@ function (Throwable $e) { 'kind' => 'bigquery#job', 'etag' => '/ty8yus/A/JoTZZvf1qgFQ==', 'id' => 'tf2-56:US.eb64d133-213d-4e99-9cc0-4e37d0c18de9', + // phpcs:ignore Generic.Files.LineLength 'selfLink' => 'https://bigquery.googleapis.com/bigquery/v2/projects/tf2-56/jobs/eb64d133-213d-4e99-9cc0-4e37d0c18de9?location=US', 'user_email' => 'tf2-56@617348738050.iam.gserviceaccount.com', 'configuration' => [ @@ -553,11 +601,13 @@ function (Throwable $e) { 'status' => [ 'errorResult' => [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], 'errors' => [ [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], [ @@ -568,6 +618,7 @@ function (Throwable $e) { [ 'reason' => 'invalid', 'location' => 'gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: Could not parse \'00:00:00\' as a timestamp. Required format is YYYY-MM-DD HH:MM[:SS[.SSSSSS]] or YYYY/MM/DD HH:MM[:SS[.SSSSSS]]; line_number: 3 byte_offset_to_start_of_line: 17 column_index: 1 column_name: "timestamp" column_type: TIMESTAMP value: "00:00:00" File: gs://kbc-tf2-files-storage/exp-15/56/files/2023/11/23/3121.keboola7ecguy.gz', ], @@ -582,7 +633,7 @@ function (Throwable $e) { function (Throwable $e) { $this->assertStringContainsString( 'There were additional errors during the import. For more information check job ', - $e->getMessage() + $e->getMessage(), ); $this->assertCount(2, explode(PHP_EOL, $e->getMessage())); $this->assertInstanceOf(BigqueryInputDataException::class, $e); @@ -593,6 +644,7 @@ function (Throwable $e) { 'kind' => 'bigquery#job', 'etag' => '/ty8yus/A/JoTZZvf1qgFQ==', 'id' => 'tf2-56:US.eb64d133-213d-4e99-9cc0-4e37d0c18de9', + // phpcs:ignore Generic.Files.LineLength 'selfLink' => 'https://bigquery.googleapis.com/bigquery/v2/projects/tf2-56/jobs/eb64d133-213d-4e99-9cc0-4e37d0c18de9?location=US', 'user_email' => 'tf2-56@617348738050.iam.gserviceaccount.com', 'configuration' => [ @@ -646,11 +698,13 @@ function (Throwable $e) { 'status' => [ 'errorResult' => [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], 'errors' => [ [ 'reason' => 'invalid', + // phpcs:ignore Generic.Files.LineLength 'message' => 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', ], [ @@ -678,8 +732,9 @@ function (Throwable $e) { ], function (Throwable $e) { $this->assertStringContainsString( - 'Error while reading data, error message: CSV processing encountered too many errors, giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', - $e->getMessage() + 'Error while reading data, error message: CSV processing encountered too many errors,' + . 'giving up. Rows: 2000; errors: 1500; max bad: 0; error percent: 0', + $e->getMessage(), ); $this->assertInstanceOf(BigqueryException::class, $e); }, diff --git a/packages/php-db-import-export/tests/unit/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelperTest.php b/packages/php-db-import-export/tests/unit/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelperTest.php index e7b74f0a9..b54e94ea0 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelperTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Bigquery/Helper/CopyCommandCsvOptionsHelperTest.php @@ -15,7 +15,7 @@ public function testGetCsvCopyCommandOptions(): void { $result = CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( new ImportOptions(), - new CsvOptions() + new CsvOptions(), ); self::assertSame([ @@ -31,8 +31,8 @@ public function testGetCsvCopyCommandOptionsNoEscapeNoEnclosure(): void new ImportOptions([], false, false, 1), new CsvOptions( CsvOptions::DEFAULT_DELIMITER, - '' - ) + '', + ), ); self::assertSame([ @@ -45,7 +45,7 @@ public function testGetCsvCopyCommandOptionsSkipHeader(): void { $result = CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( new ImportOptions([], false, false, 1), - new CsvOptions() + new CsvOptions(), ); self::assertSame([ @@ -63,8 +63,8 @@ public function testGetCsvCopyCommandOptionsUnenclosedField(): void new CsvOptions( CsvOptions::DEFAULT_DELIMITER, '', - '\\' - ) + '\\', + ), ); self::assertSame([ diff --git a/packages/php-db-import-export/tests/unit/Backend/Exasol/MockConnectionTrait.php b/packages/php-db-import-export/tests/unit/Backend/Exasol/MockConnectionTrait.php index 5377723b3..e6d732d19 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Exasol/MockConnectionTrait.php +++ b/packages/php-db-import-export/tests/unit/Backend/Exasol/MockConnectionTrait.php @@ -19,7 +19,7 @@ private function mockConnection() /** @var Connection|MockObject $mock */ $mock = $this->createMock(Connection::class); $mock->expects(self::any())->method('getDatabasePlatform')->willReturn( - new OraclePlatform() + new OraclePlatform(), ); $mock->expects(self::any())->method('quote')->willReturnCallback(static function ($input) { return QuoteHelper::quote($input); diff --git a/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromS3CopyIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromS3CopyIntoAdapterTest.php index 6754ae0ad..97b98d67a 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromS3CopyIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromS3CopyIntoAdapterTest.php @@ -37,7 +37,7 @@ public function testGetCopyCommands(): void COLUMN SEPARATOR=',' COLUMN DELIMITER='"' -EOT +EOT, ); $conn->expects(self::once())->method('fetchOne') @@ -49,14 +49,14 @@ public function testGetCopyCommands(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new ExasolImportOptions(); $adapter = new FromS3CopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); @@ -81,7 +81,7 @@ public function testGetCopyCommandsRowSkip(): void COLUMN SEPARATOR=',' COLUMN DELIMITER='"' -EOT +EOT, ); $conn->expects(self::once())->method('fetchOne') @@ -93,14 +93,14 @@ public function testGetCopyCommandsRowSkip(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new ExasolImportOptions([], false, false, 3); $adapter = new FromS3CopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); @@ -150,14 +150,14 @@ public function testGetCopyCommandWithMoreChunksOfFiles(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new ExasolImportOptions(); $adapter = new FromS3CopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromTableInsertIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromTableInsertIntoAdapterTest.php index 25bc0842c..22b51b7d5 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromTableInsertIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Exasol/ToStage/FromTableInsertIntoAdapterTest.php @@ -38,14 +38,14 @@ public function testGetCopyCommands(): void ExasolColumn::createGenericColumn('col1'), ExasolColumn::createGenericColumn('col2'), ]), - [] + [], ); $options = new ExasolImportOptions([]); $adapter = new FromTableInsertIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); @@ -57,7 +57,7 @@ public function testGetCopyCommandsSelectSource(): void 'SELECT * FROM "test_schema"."test_table"', ['val'], ['1'], - ['col1', 'col2'] + ['col1', 'col2'], ); $conn = $this->mockConnection(); @@ -65,7 +65,7 @@ public function testGetCopyCommandsSelectSource(): void // phpcs:ignore 'INSERT INTO "test_schema"."stagingTable" ("col1", "col2") SELECT * FROM "test_schema"."test_table"', ['val'], - [1] + [1], ); $conn->expects(self::once())->method('fetchOne') ->with('SELECT COUNT(*) AS NumberOfRows FROM "test_schema"."stagingTable"') @@ -79,14 +79,14 @@ public function testGetCopyCommandsSelectSource(): void ExasolColumn::createGenericColumn('col1'), ExasolColumn::createGenericColumn('col2'), ]), - [] + [], ); $options = new ExasolImportOptions([]); $adapter = new FromTableInsertIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/AbsExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/AbsExportAdapterTest.php index ac692f18d..a9681b256 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/AbsExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/AbsExportAdapterTest.php @@ -47,7 +47,7 @@ public function testGetCopyCommand(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -59,8 +59,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -98,7 +98,7 @@ public function testGetCopyCommandCompressed(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -110,8 +110,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -149,7 +149,7 @@ public function testGetCopyCommandQuery(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\SelectSource('SELECT * FROM "schema"."table"'); @@ -161,8 +161,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/GcsExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/GcsExportAdapterTest.php index e707ceb7d..deb7d86ac 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/GcsExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/GcsExportAdapterTest.php @@ -40,7 +40,7 @@ public function testGetCopyCommand(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn([]); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -52,8 +52,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -84,7 +84,7 @@ public function testGetCopyCommandCompressed(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn([]); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -96,8 +96,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -128,7 +128,7 @@ public function testGetCopyCommandQuery(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn([]); $source = new Storage\Snowflake\SelectSource('SELECT * FROM "schema"."tableName"'); @@ -140,8 +140,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/S3ExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/S3ExportAdapterTest.php index 0d3179947..bc9befdb3 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/S3ExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Exporter/S3ExportAdapterTest.php @@ -57,7 +57,7 @@ public function testGetCopyCommand(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -69,8 +69,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -118,7 +118,7 @@ public function testGetCopyCommandCompressed(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -130,8 +130,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -179,7 +179,7 @@ public function testGetCopyCommandQuery(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\SelectSource('SELECT * FROM "schema"."table"'); @@ -191,8 +191,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelperTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelperTest.php index d2e8a9ff2..f535f3b36 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelperTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/Helper/CopyCommandCsvOptionsHelperTest.php @@ -15,7 +15,7 @@ public function testGetCsvCopyCommandOptions(): void { $result = CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( new ImportOptions(), - new CsvOptions() + new CsvOptions(), ); self::assertSame([ @@ -31,8 +31,8 @@ public function testGetCsvCopyCommandOptionsNoEscapeNoEnclosure(): void new ImportOptions([], false, false, 1), new CsvOptions( CsvOptions::DEFAULT_DELIMITER, - '' - ) + '', + ), ); self::assertSame([ @@ -45,7 +45,7 @@ public function testGetCsvCopyCommandOptionsSkipHeader(): void { $result = CopyCommandCsvOptionsHelper::getCsvCopyCommandOptions( new ImportOptions([], false, false, 1), - new CsvOptions() + new CsvOptions(), ); self::assertSame([ @@ -63,8 +63,8 @@ public function testGetCsvCopyCommandOptionsUnenclosedField(): void new CsvOptions( CsvOptions::DEFAULT_DELIMITER, '', - '\\' - ) + '\\', + ), ); self::assertSame([ diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ImporterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ImporterTest.php index 774f17955..c208994b5 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ImporterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ImporterTest.php @@ -62,7 +62,7 @@ public function testGetAdapterInvalidAdapter(): void $importer->setAdapters([get_class(new class implements BackendImportAdapterInterface{ public static function isSupported( Storage\SourceInterface $source, - Storage\DestinationInterface $destination + Storage\DestinationInterface $destination, ): bool { return false; } @@ -71,7 +71,7 @@ public function runCopyCommand( Storage\SourceInterface $source, Storage\DestinationInterface $destination, ImportOptionsInterface $importOptions, - string $stagingTableName + string $stagingTableName, ): int { return 0; } diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/SqlCommandBuilderTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/SqlCommandBuilderTest.php index 7c8c55de8..9991ad26b 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/SqlCommandBuilderTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/SqlCommandBuilderTest.php @@ -48,12 +48,12 @@ public function testGetDedupCommand(): void 'pk2', ], 'stagingTable', - 'tempTable' + 'tempTable', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "schema"."tempTable" ("col1", "col2") SELECT a."col1",a."col2" FROM (SELECT "col1", "col2", ROW_NUMBER() OVER (PARTITION BY "pk1","pk2" ORDER BY "pk1","pk2") AS "_row_number_"FROM "schema"."stagingTable") AS a WHERE a."_row_number_" = 1', - $sql + $sql, ); } @@ -90,7 +90,7 @@ public function testGetDedupCommandNoPrimaryKeys(): void $this->getDummyTableDestination(), [], 'stagingTable', - 'tempTable' + 'tempTable', ); self::assertEquals('', $sql); } @@ -103,12 +103,12 @@ public function testGetDeleteOldItemsCommand(): void [ 'pk1', 'pk2', - ] + ], ); self::assertEquals( // phpcs:ignore 'DELETE FROM "schema"."stagingTable" "src" USING "schema"."table" AS "dest" WHERE "dest"."pk1" = COALESCE("src"."pk1", \'\') AND "dest"."pk2" = COALESCE("src"."pk2", \'\') ', - $sql + $sql, ); } @@ -125,12 +125,12 @@ public function testGetInsertAllIntoTargetTableCommand(): void $this->getDummySource(), $this->getDummyTableDestination(), $this->getDummyImportOptions(), - 'staging table' + 'staging table', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "schema"."table" ("col1", "col2") (SELECT COALESCE("col1", \'\') AS "col1", COALESCE("col2", \'\') AS "col2" FROM "schema"."staging table")', - $sql + $sql, ); // converver values @@ -139,12 +139,12 @@ public function testGetInsertAllIntoTargetTableCommand(): void $this->getDummySource(), $this->getDummyTableDestination(), $options, - 'staging table' + 'staging table', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "schema"."table" ("col1", "col2") (SELECT IFF("col1" = \'\', NULL, "col1"), COALESCE("col2", \'\') AS "col2" FROM "schema"."staging table")', - $sql + $sql, ); // use timestamp @@ -153,17 +153,17 @@ public function testGetInsertAllIntoTargetTableCommand(): void $this->getDummySource(), $this->getDummyTableDestination(), $options, - 'staging table' + 'staging table', ); self::assertStringStartsWith( // phpcs:ignore 'INSERT INTO "schema"."table" ("col1", "col2", "_timestamp") (SELECT IFF("col1" = \'\', NULL, "col1"), COALESCE("col2", \'\') AS "col2", \'', - $sql + $sql, ); // there is datetime between self::assertStringEndsWith( '\' FROM "schema"."staging table")', - $sql + $sql, ); } @@ -175,12 +175,12 @@ public function testGetInsertFromStagingToTargetTableCommand(): void $this->getDummyTableDestination(), $options, 'stagingTable', - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "schema"."table" ("col1", "col2") SELECT IFF("src"."col1" = \'\', NULL, "col1"),COALESCE("src"."col2", \'\') FROM "schema"."stagingTable" AS "src"', - $sql + $sql, ); $options = new ImportOptions(['col1'], false, true); $sql = $this->getInstance()->getInsertFromStagingToTargetTableCommand( @@ -188,12 +188,12 @@ public function testGetInsertFromStagingToTargetTableCommand(): void $this->getDummyTableDestination(), $options, 'stagingTable', - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'INSERT INTO "schema"."table" ("col1", "col2", "_timestamp") SELECT IFF("src"."col1" = \'\', NULL, "col1"),COALESCE("src"."col2", \'\'),\'2020-01-01 00:00:00\' FROM "schema"."stagingTable" AS "src"', - $sql + $sql, ); } @@ -224,12 +224,12 @@ public function testGetUpdateWithPkCommand(): void $this->getDummyImportOptions(), 'staging table', ['col1'], - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "schema"."table" AS "dest" SET "col1" = COALESCE("src"."col1", \'\'), "col2" = COALESCE("src"."col2", \'\') FROM "schema"."staging table" AS "src" WHERE "dest"."col1" = COALESCE("src"."col1", \'\') AND (COALESCE(TO_VARCHAR("dest"."col1"), \'\') != COALESCE("src"."col1", \'\') OR COALESCE(TO_VARCHAR("dest"."col2"), \'\') != COALESCE("src"."col2", \'\')) ', - $sql + $sql, ); // converver values @@ -240,12 +240,12 @@ public function testGetUpdateWithPkCommand(): void $options, 'staging table', ['col1'], - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "schema"."table" AS "dest" SET "col1" = IFF("src"."col1" = \'\', NULL, "src"."col1"), "col2" = COALESCE("src"."col2", \'\') FROM "schema"."staging table" AS "src" WHERE "dest"."col1" = COALESCE("src"."col1", \'\') AND (COALESCE(TO_VARCHAR("dest"."col1"), \'\') != COALESCE("src"."col1", \'\') OR COALESCE(TO_VARCHAR("dest"."col2"), \'\') != COALESCE("src"."col2", \'\')) ', - $sql + $sql, ); // use timestamp @@ -256,13 +256,13 @@ public function testGetUpdateWithPkCommand(): void $options, 'staging table', ['col1'], - '2020-01-01 00:00:00' + '2020-01-01 00:00:00', ); self::assertEquals( // phpcs:ignore 'UPDATE "schema"."table" AS "dest" SET "col1" = IFF("src"."col1" = \'\', NULL, "src"."col1"), "col2" = COALESCE("src"."col2", \'\'), "_timestamp" = \'2020-01-01 00:00:00\' FROM "schema"."staging table" AS "src" WHERE "dest"."col1" = COALESCE("src"."col1", \'\') AND (COALESCE(TO_VARCHAR("dest"."col1"), \'\') != COALESCE("src"."col1", \'\') OR COALESCE(TO_VARCHAR("dest"."col2"), \'\') != COALESCE("src"."col2", \'\')) ', - $sql + $sql, ); } } diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromABSCopyIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromABSCopyIntoAdapterTest.php index 7272444fc..126c71a1c 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromABSCopyIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromABSCopyIntoAdapterTest.php @@ -55,14 +55,14 @@ public function testGetCopyCommands(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions(); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); @@ -106,14 +106,14 @@ public function testGetCopyCommandsRowSkip(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions([], false, false, 3); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); @@ -168,14 +168,14 @@ public function testGetCopyCommandWithMoreChunksOfFiles(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions(); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapterTest.php index a9a108d6b..a6abdcfd1 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromGCSCopyIntoAdapterTest.php @@ -38,7 +38,7 @@ public function testGetCopyCommands(): void ESCAPE_UNENCLOSED_FIELD = NONE , NULL_IF=('')) FILES = ('https:url') -EOT +EOT, ); $conn->expects(self::once())->method('fetchAllAssociative') @@ -55,14 +55,14 @@ public function testGetCopyCommands(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions(); $adapter = new FromGCSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); @@ -88,7 +88,7 @@ public function testGetCopyCommandsRowSkip(): void ESCAPE_UNENCLOSED_FIELD = NONE , NULL_IF=('')) FILES = ('https:url') -EOT +EOT, ); $conn->expects(self::once())->method('fetchAllAssociative') @@ -105,14 +105,14 @@ public function testGetCopyCommandsRowSkip(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions([], false, false, 3); $adapter = new FromGCSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); @@ -167,14 +167,14 @@ public function testGetCopyCommandWithMoreChunksOfFiles(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions(); $adapter = new FromGCSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromS3CopyIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromS3CopyIntoAdapterTest.php index 45f559c19..ff6f86793 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromS3CopyIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromS3CopyIntoAdapterTest.php @@ -38,7 +38,7 @@ public function testGetCopyCommands(): void ESCAPE_UNENCLOSED_FIELD = NONE , NULL_IF=('')) FILES = ('https:url') -EOT +EOT, ); $conn->expects(self::once())->method('fetchAllAssociative') @@ -55,14 +55,14 @@ public function testGetCopyCommands(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions(); $adapter = new FromS3CopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); @@ -88,7 +88,7 @@ public function testGetCopyCommandsRowSkip(): void ESCAPE_UNENCLOSED_FIELD = NONE , NULL_IF=('')) FILES = ('https:url') -EOT +EOT, ); $conn->expects(self::once())->method('fetchAllAssociative') @@ -105,14 +105,14 @@ public function testGetCopyCommandsRowSkip(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions([], false, false, 3); $adapter = new FromS3CopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); @@ -167,14 +167,14 @@ public function testGetCopyCommandWithMoreChunksOfFiles(): void 'stagingTable', true, new ColumnCollection([]), - [] + [], ); $options = new SnowflakeImportOptions(); $adapter = new FromS3CopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(7, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromTableInsertIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromTableInsertIntoAdapterTest.php index 8bcab08ec..51b81523e 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromTableInsertIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/FromTableInsertIntoAdapterTest.php @@ -43,14 +43,14 @@ public function testGetCopyCommands(): void SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), ]), - [] + [], ); $options = new SnowflakeImportOptions([]); $adapter = new FromTableInsertIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); @@ -63,7 +63,7 @@ public function testGetCopyCommandsSelectSource(): void ['bind' => 'val'], ['col1', 'col2'], [], - ['1'] + ['1'], ); $conn = $this->mockConnection(); @@ -71,7 +71,7 @@ public function testGetCopyCommandsSelectSource(): void // phpcs:ignore 'INSERT INTO "test_schema"."stagingTable" ("col1", "col2") SELECT * FROM "test_schema"."test_table"', ['bind' => 'val'], - [1] + [1], ); $conn->expects(self::once())->method('fetchAllAssociative') // phpcs:ignore @@ -90,14 +90,14 @@ public function testGetCopyCommandsSelectSource(): void SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), ]), - [] + [], ); $options = new SnowflakeImportOptions([]); $adapter = new FromTableInsertIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); self::assertEquals(10, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/StageTableDefinitionFactoryTest.php b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/StageTableDefinitionFactoryTest.php index b83b638b8..8902a86ba 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/StageTableDefinitionFactoryTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Snowflake/ToStage/StageTableDefinitionFactoryTest.php @@ -24,11 +24,11 @@ public function testCreateStagingTableDefinitionWithTypes(): void new SnowflakeColumn('name', new Snowflake(Snowflake::TYPE_DATE)), SnowflakeColumn::createGenericColumn('id'), ]), - [] + [], ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinition( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -45,7 +45,7 @@ public function testCreateStagingTableDefinitionWithTypes(): void // notInDef has default NVARCHAR self::assertSame( Snowflake::TYPE_VARCHAR, - $definitions[2]->getColumnDefinition()->getType() + $definitions[2]->getColumnDefinition()->getType(), ); } @@ -54,7 +54,7 @@ public function testCreateStagingTableDefinitionWithText(): void $columns = ['id', 'name', 'number', 'notInDef']; $stageDefinition = StageTableDefinitionFactory::createVarcharStagingTableDefinition( 'schema', - $columns + $columns, ); self::assertSame('schema', $stageDefinition->getSchemaName()); diff --git a/packages/php-db-import-export/tests/unit/Backend/SourceDestinationColumnMapTest.php b/packages/php-db-import-export/tests/unit/Backend/SourceDestinationColumnMapTest.php index edb075d37..1677af0cf 100644 --- a/packages/php-db-import-export/tests/unit/Backend/SourceDestinationColumnMapTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/SourceDestinationColumnMapTest.php @@ -39,7 +39,7 @@ private function getMap(): array $map = new SourceDestinationColumnMap( $source, - $destination + $destination, ); return [$col1, $col1Dest, $map]; } @@ -111,7 +111,7 @@ public static function createGenericColumn(string $columnName): ColumnInterface } public static function createTimestampColumn( - string $columnName = self::TIMESTAMP_COLUMN_NAME + string $columnName = self::TIMESTAMP_COLUMN_NAME, ): ColumnInterface { throw new Exception('Not implemented'); } @@ -145,7 +145,7 @@ public function testCreateForTablesModeKeep(): void $source, $destination, [], - SourceDestinationColumnMap::MODE_MAP_BY_ORDER + SourceDestinationColumnMap::MODE_MAP_BY_ORDER, ); $this->assertSame($col1Dest, $map->getDestination($col1)); @@ -170,7 +170,7 @@ public function testCreateForTablesModeNameOrder(): void $source, $destination, [], - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); $this->assertSame($col1Dest, $map->getDestination($col1)); @@ -198,7 +198,7 @@ public function testColumnMismatchModeKeep(): void $this->expectException(ColumnsMismatchException::class); new SourceDestinationColumnMap( $source, - $destination + $destination, ); } @@ -219,7 +219,7 @@ public function testColumnMismatchModeNameOrder(): void $source, $destination, [], - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); } @@ -239,7 +239,7 @@ public function testIgnoreColumnModeKeep(): void new SourceDestinationColumnMap( $source, $destination, - ['col3'] + ['col3'], ); } @@ -260,7 +260,7 @@ public function testIgnoreColumnModeNameOrder(): void $source, $destination, ['col3'], - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); } @@ -282,7 +282,7 @@ public function testIgnoreColumnsMoreThanOneModeKeep(): void new SourceDestinationColumnMap( $source, $destination, - ['col3', 'col4', 'col5'] + ['col3', 'col4', 'col5'], ); } @@ -306,7 +306,7 @@ public function testIgnoreColumnsMoreThanOneModeNameOrderImplicitIgnore(): void $source, $destination, [], - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); } @@ -329,7 +329,7 @@ public function testIgnoreColumnsMoreThanOneModeNameOrderExplicitIgnoreInSource( $source, $destination, ['col3', 'col4', 'col5'], - SourceDestinationColumnMap::MODE_MAP_BY_NAME + SourceDestinationColumnMap::MODE_MAP_BY_NAME, ); } diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/AssertTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/AssertTest.php index b9fe3905b..a2e94fc45 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/AssertTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/AssertTest.php @@ -52,8 +52,8 @@ public function getPrimaryKeysNames(): ?array ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) - ) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), + ), ); } @@ -84,8 +84,8 @@ public function getPrimaryKeysNames(): ?array ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) - ) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), + ), ); } @@ -116,8 +116,8 @@ public function getPrimaryKeysNames(): ?array ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) - ) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), + ), ); } @@ -142,9 +142,9 @@ public function getPrimaryKeysNames(): ?array [], new TableDistribution( 'ROUND_ROBIN', - [] - ) - ) + [], + ), + ), ); } @@ -170,9 +170,9 @@ public function getPrimaryKeysNames(): ?array [], new TableDistribution( 'ROUND_ROBIN', - [] - ) - ) + [], + ), + ), ); } @@ -199,9 +199,9 @@ public function getPrimaryKeysNames(): ?array [], new TableDistribution( 'ROUND_ROBIN', - [] - ) - ) + [], + ), + ), ); } @@ -246,11 +246,11 @@ public function testAssertValidSourcePass(): void '', '', new CsvOptions(), - false + false, )); Assert::assertValidSource(new Table( '', - '' + '', )); } @@ -268,9 +268,9 @@ public function testAssertValidSourceFail(): void '', new CsvOptions( CsvOptions::DEFAULT_DELIMITER, - '' + '', ), - false + false, )); } @@ -278,7 +278,7 @@ public function testAssertHashDistributionFailNoHashKey(): void { $this->expectException(Throwable::class); $this->expectExceptionMessage( - 'HASH table distribution must have one distribution key specified.' + 'HASH table distribution must have one distribution key specified.', ); Assert::assertValidHashDistribution('HASH', []); } @@ -287,7 +287,7 @@ public function testAssertHashDistributionFailMoreThanOneHashKey(): void { $this->expectException(Throwable::class); $this->expectExceptionMessage( - 'HASH table distribution must have one distribution key specified.' + 'HASH table distribution must have one distribution key specified.', ); Assert::assertValidHashDistribution('HASH', ['id', 'name']); } @@ -302,7 +302,7 @@ public function testAssertTableDistributionFail(): void { $this->expectException(Throwable::class); $this->expectExceptionMessage( - 'Unknown table distribution "UNKNOWN" specified.' + 'Unknown table distribution "UNKNOWN" specified.', ); Assert::assertTableDistribution('UNKNOWN'); } @@ -319,7 +319,7 @@ public function testAssertStagingTableFail(): void { $this->expectException(Throwable::class); $this->expectExceptionMessage( - 'Staging table must start with "#" table name "normalNotTempTable" supplied.' + 'Staging table must start with "#" table name "normalNotTempTable" supplied.', ); Assert::assertStagingTable('normalNotTempTable'); } @@ -342,8 +342,8 @@ public function testAssertSameColumns(): void Synapse::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; $destCols = [ @@ -355,14 +355,14 @@ public function testAssertSameColumns(): void Synapse::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -382,7 +382,7 @@ public function testAssertSameColumnsInvalidCountExtraSource(): void $this->expectExceptionMessage('Tables don\'t have same number of columns.'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -402,7 +402,7 @@ public function testAssertSameColumnsInvalidCountExtraDestination(): void $this->expectExceptionMessage('Tables don\'t have same number of columns.'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -421,7 +421,7 @@ public function testAssertSameColumnsInvalidColumnName(): void $this->expectExceptionMessage('Source destination columns name mismatch. "test1x"->"test1"'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -436,8 +436,8 @@ public function testAssertSameColumnsInvalidType(): void Synapse::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; $destCols = [ @@ -449,8 +449,8 @@ public function testAssertSameColumnsInvalidType(): void Synapse::TYPE_DATETIME2, [ 'length' => '3', - ] - ) + ], + ), ), ]; @@ -458,7 +458,7 @@ public function testAssertSameColumnsInvalidType(): void $this->expectExceptionMessage('Source destination columns mismatch. "test2 TIME(3)"->"test2 DATETIME2(3)"'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } @@ -473,8 +473,8 @@ public function testAssertSameColumnsInvalidLength(): void Synapse::TYPE_TIME, [ 'length' => '3', - ] - ) + ], + ), ), ]; $destCols = [ @@ -486,8 +486,8 @@ public function testAssertSameColumnsInvalidLength(): void Synapse::TYPE_TIME, [ 'length' => '4', - ] - ) + ], + ), ), ]; @@ -495,7 +495,7 @@ public function testAssertSameColumnsInvalidLength(): void $this->expectExceptionMessage('Source destination columns mismatch. "test2 TIME(3)"->"test2 TIME(4)"'); Assert::assertSameColumns( new ColumnCollection($sourceCols), - new ColumnCollection($destCols) + new ColumnCollection($destCols), ); } } diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/DestinationTableOptionsTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/DestinationTableOptionsTest.php index 4d2c2daff..6dfce7e06 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/DestinationTableOptionsTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/DestinationTableOptionsTest.php @@ -15,7 +15,7 @@ public function testDefaultValues(): void $options = new DestinationTableOptions( ['pk1', 'pk1', 'col1', 'col2'], ['pk1', 'pk1'], - new TableDistribution() + new TableDistribution(), ); self::assertEquals(['pk1', 'pk1', 'col1', 'col2'], $options->getColumnNamesInOrder()); self::assertEquals(['pk1', 'pk1'], $options->getPrimaryKeys()); @@ -30,8 +30,8 @@ public function testDistributionValues(): void ['pk1', 'pk1'], new TableDistribution( TableDistribution::TABLE_DISTRIBUTION_HASH, - ['pk1'] - ) + ['pk1'], + ), ); self::assertEquals(['pk1', 'pk1', 'col1', 'col2'], $options->getColumnNamesInOrder()); self::assertEquals(['pk1', 'pk1'], $options->getPrimaryKeys()); diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseExportOptionsTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseExportOptionsTest.php index a9eb4601b..51ff5b9e4 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseExportOptionsTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseExportOptionsTest.php @@ -24,7 +24,7 @@ public function testValues(): void $options = new SynapseExportOptions( true, SynapseExportOptions::CREDENTIALS_MANAGED_IDENTITY, - ExportOptions::MANIFEST_AUTOGENERATED + ExportOptions::MANIFEST_AUTOGENERATED, ); self::assertTrue($options->isCompressed()); diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseImportOptionsTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseImportOptionsTest.php index c22eef963..6a1c64f59 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseImportOptionsTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/SynapseImportOptionsTest.php @@ -29,7 +29,7 @@ public function testValues(): void true, SynapseImportOptions::SKIP_FIRST_LINE, SynapseImportOptions::CREDENTIALS_MANAGED_IDENTITY, - SynapseImportOptions::TABLE_TYPES_CAST + SynapseImportOptions::TABLE_TYPES_CAST, ); self::assertSame(['col1'], $options->getConvertEmptyValuesToNull()); diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/TableDistributionTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/TableDistributionTest.php index a9f0a5400..63a779afd 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/TableDistributionTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/TableDistributionTest.php @@ -21,7 +21,7 @@ public function testDistributionValues(): void { $options = new TableDistribution( TableDistribution::TABLE_DISTRIBUTION_HASH, - ['pk1'] + ['pk1'], ); self::assertEquals(['pk1'], $options->getDistributionColumnsNames()); self::assertEquals('HASH', $options->getDistributionName()); diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromABSCopyIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromABSCopyIntoAdapterTest.php index 3ff471f2a..b5fc4c21f 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromABSCopyIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromABSCopyIntoAdapterTest.php @@ -44,7 +44,7 @@ public function testGetCopyCommands(): void IDENTITY_INSERT = 'OFF' ) -EOT +EOT, ); $conn->expects($this->once())->method('fetchOne') @@ -58,14 +58,14 @@ public function testGetCopyCommands(): void new ColumnCollection([]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $options = new SynapseImportOptions(); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); $this->assertEquals(10, $count); @@ -95,7 +95,7 @@ public function testGetCopyCommandsWindowsLineEnding(): void IDENTITY_INSERT = 'OFF' ) -EOT +EOT, ); $conn->expects($this->once())->method('fetchOne') @@ -109,14 +109,14 @@ public function testGetCopyCommandsWindowsLineEnding(): void new ColumnCollection([]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $options = new SynapseImportOptions(); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); $this->assertEquals(10, $count); @@ -145,7 +145,7 @@ public function testGetCopyCommandsRowSkip(): void IDENTITY_INSERT = 'OFF' ,FIRSTROW=2 ) -EOT +EOT, ); $conn->expects($this->once())->method('fetchOne') ->with('SELECT COUNT_BIG(*) AS [count] FROM [schema].[stagingTable]') @@ -158,14 +158,14 @@ public function testGetCopyCommandsRowSkip(): void new ColumnCollection([]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $options = new SynapseImportOptions([], false, false, 1); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); $this->assertEquals(10, $count); @@ -193,7 +193,7 @@ public function testGetCopyCommandsManagedIdentity(): void IDENTITY_INSERT = 'OFF' ) -EOT +EOT, ); $conn->expects($this->once())->method('fetchOne') @@ -207,20 +207,20 @@ public function testGetCopyCommandsManagedIdentity(): void new ColumnCollection([]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $options = new SynapseImportOptions( [], false, false, SynapseImportOptions::SKIP_NO_LINE, - SynapseImportOptions::CREDENTIALS_MANAGED_IDENTITY + SynapseImportOptions::CREDENTIALS_MANAGED_IDENTITY, ); $adapter = new FromABSCopyIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); $this->assertEquals(10, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromTableInsertIntoAdapterTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromTableInsertIntoAdapterTest.php index 58567a9d2..d711cd799 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromTableInsertIntoAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/FromTableInsertIntoAdapterTest.php @@ -42,14 +42,14 @@ public function testGetCopyCommands(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $options = new SynapseImportOptions([]); $adapter = new FromTableInsertIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); $this->assertEquals(10, $count); @@ -61,7 +61,7 @@ public function testGetCopyCommandsSelectSource(): void 'SELECT * FROM [test_schema].[test_table]', ['val'], [1], - ['col1','col2'] + ['col1','col2'], ); $conn = $this->mockConnection(); @@ -69,7 +69,7 @@ public function testGetCopyCommandsSelectSource(): void // phpcs:ignore 'INSERT INTO [test_schema].[stagingTable] ([col1], [col2]) SELECT * FROM [test_schema].[test_table]', ['val'], - [1] + [1], ); $conn->expects($this->once())->method('fetchOne') ->with('SELECT COUNT_BIG(*) AS [count] FROM [test_schema].[stagingTable]') @@ -85,14 +85,14 @@ public function testGetCopyCommandsSelectSource(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $options = new SynapseImportOptions([]); $adapter = new FromTableInsertIntoAdapter($conn); $count = $adapter->runCopyCommand( $source, $destination, - $options + $options, ); $this->assertEquals(10, $count); diff --git a/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/StageTableDefinitionFactoryTest.php b/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/StageTableDefinitionFactoryTest.php index de98348e8..7fab96341 100644 --- a/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/StageTableDefinitionFactoryTest.php +++ b/packages/php-db-import-export/tests/unit/Backend/Synapse/ToStage/StageTableDefinitionFactoryTest.php @@ -27,11 +27,11 @@ public function testCreateStagingTableDefinition(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinition( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -49,12 +49,12 @@ public function testCreateStagingTableDefinition(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -70,11 +70,11 @@ public function testCreateStagingTableDefinitionCaseInsensitivity(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinition( $definition, - ['iD', 'naMe', 'notInDef'] + ['iD', 'naMe', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -92,12 +92,12 @@ public function testCreateStagingTableDefinitionCaseInsensitivity(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -113,11 +113,11 @@ public function testCreateStagingTableDefinitionReplicate(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_REPLICATE), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinition( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -135,12 +135,12 @@ public function testCreateStagingTableDefinitionReplicate(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -156,12 +156,12 @@ public function testCreateStagingTableDefinitionWithClusteredColumnstore(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinition( $definition, ['id', 'name', 'notInDef'], - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -181,12 +181,12 @@ public function testCreateStagingTableDefinitionWithClusteredColumnstore(): void self::assertTrue($definitions[2]->getColumnDefinition()->isNullable()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -202,12 +202,12 @@ public function testCreateStagingTableDefinitionWithClusteredIndex(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinition( $definition, ['id', 'name', 'notInDef'], - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX, ['id']) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX, ['id']), ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -227,17 +227,17 @@ public function testCreateStagingTableDefinitionWithClusteredIndex(): void self::assertTrue($definitions[2]->getColumnDefinition()->isNullable()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is CI self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); // index is CI self::assertSame( ['id'], - $stageDefinition->getTableIndex()->getIndexedColumnsNames() + $stageDefinition->getTableIndex()->getIndexedColumnsNames(), ); } @@ -253,11 +253,11 @@ public function testCreateStagingTableDefinitionWithText(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinitionWithText( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -273,12 +273,12 @@ public function testCreateStagingTableDefinitionWithText(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -294,11 +294,11 @@ public function testCreateStagingTableDefinitionWithTextReplicate(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_REPLICATE), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinitionWithText( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -314,12 +314,12 @@ public function testCreateStagingTableDefinitionWithTextReplicate(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -335,12 +335,12 @@ public function testCreateStagingTableDefinitionWithTextWithIndex(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createStagingTableDefinitionWithText( $definition, ['id', 'name', 'notInDef'], - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -356,12 +356,12 @@ public function testCreateStagingTableDefinitionWithTextWithIndex(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -377,11 +377,11 @@ public function testCreateDedupStagingTableDefinition(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createDedupStagingTableDefinition( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -399,12 +399,12 @@ public function testCreateDedupStagingTableDefinition(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -420,11 +420,11 @@ public function testCreateDedupStagingTableDefinitionCaseInsensitivity(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createDedupStagingTableDefinition( $definition, - ['iD', 'naMe', 'notInDef'] + ['iD', 'naMe', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -442,12 +442,12 @@ public function testCreateDedupStagingTableDefinitionCaseInsensitivity(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -463,11 +463,11 @@ public function testCreateDedupStagingTableDefinitionReplicate(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_REPLICATE), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createDedupStagingTableDefinition( $definition, - ['id', 'name', 'notInDef'] + ['id', 'name', 'notInDef'], ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -485,12 +485,12 @@ public function testCreateDedupStagingTableDefinitionReplicate(): void self::assertSame(Synapse::TYPE_NVARCHAR, $definitions[2]->getColumnDefinition()->getType()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -506,12 +506,12 @@ public function testCreateDedupStagingTableDefinitionWithClusteredColumnstore(): ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createDedupStagingTableDefinition( $definition, ['id', 'name', 'notInDef'], - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -531,12 +531,12 @@ public function testCreateDedupStagingTableDefinitionWithClusteredColumnstore(): self::assertTrue($definitions[2]->getColumnDefinition()->isNullable()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is heap self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); } @@ -552,12 +552,12 @@ public function testCreateDedupStagingTableDefinitionWithClusteredIndex(): void ]), [], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_HEAP), ); $stageDefinition = StageTableDefinitionFactory::createDedupStagingTableDefinition( $definition, ['id', 'name', 'notInDef'], - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX, ['id']) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX, ['id']), ); self::assertSame('schema', $stageDefinition->getSchemaName()); @@ -577,17 +577,17 @@ public function testCreateDedupStagingTableDefinitionWithClusteredIndex(): void self::assertTrue($definitions[2]->getColumnDefinition()->isNullable()); self::assertSame( TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN, - $stageDefinition->getTableDistribution()->getDistributionName() + $stageDefinition->getTableDistribution()->getDistributionName(), ); // index is CI self::assertSame( TableIndexDefinition::TABLE_INDEX_TYPE_HEAP, - $stageDefinition->getTableIndex()->getIndexType() + $stageDefinition->getTableIndex()->getIndexType(), ); // index is CI self::assertSame( [], - $stageDefinition->getTableIndex()->getIndexedColumnsNames() + $stageDefinition->getTableIndex()->getIndexedColumnsNames(), ); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/ABS/BaseFileTest.php b/packages/php-db-import-export/tests/unit/Storage/ABS/BaseFileTest.php index 73625c838..cf8d3ef8d 100644 --- a/packages/php-db-import-export/tests/unit/Storage/ABS/BaseFileTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/ABS/BaseFileTest.php @@ -22,11 +22,11 @@ public function testDefaultValues(): void self::assertEquals('file.csv', $baseFile->getFilePath()); self::assertEquals( 'azure://absAccount.blob.core.windows.net/absContainer/', - $baseFile->getContainerUrl($baseFile::PROTOCOL_AZURE) + $baseFile->getContainerUrl($baseFile::PROTOCOL_AZURE), ); self::assertEquals( 'https://absAccount.blob.core.windows.net/absContainer/', - $baseFile->getContainerUrl($baseFile::PROTOCOL_HTTPS) + $baseFile->getContainerUrl($baseFile::PROTOCOL_HTTPS), ); self::assertEquals('azureCredentials', $baseFile->getSasToken()); } diff --git a/packages/php-db-import-export/tests/unit/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGeneratorTest.php b/packages/php-db-import-export/tests/unit/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGeneratorTest.php index 67f4da83e..2b1c1f737 100644 --- a/packages/php-db-import-export/tests/unit/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGeneratorTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/ABS/ManifestGenerator/AbsSlicedManifestFromFolderGeneratorTest.php @@ -44,7 +44,7 @@ public function testGenerateAndSaveManifest(): void ->with( 'container', 'prefix/xxxmanifest', - '{"entries":[{"url":"azure:\/\/1","mandatory":true},{"url":"azure:\/\/2","mandatory":true}]}' + '{"entries":[{"url":"azure:\/\/1","mandatory":true},{"url":"azure:\/\/2","mandatory":true}]}', ); $path = RelativePath::createFromRootAndPath(new AbsProvider(), 'container', 'prefix/xxx'); diff --git a/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeExportAdapterTest.php index bec6ccdc6..3abc4a4d1 100644 --- a/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeExportAdapterTest.php @@ -45,7 +45,7 @@ public function testGetCopyCommand(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -57,8 +57,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -95,7 +95,7 @@ public function testGetCopyCommandCompressed(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -107,8 +107,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -145,7 +145,7 @@ public function testGetCopyCommandQuery(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\SelectSource('SELECT * FROM "schema"."table"'); @@ -157,8 +157,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeImportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeImportAdapterTest.php index 8f4b4a95a..5c1c22c02 100644 --- a/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeImportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/ABS/SnowflakeImportAdapterTest.php @@ -28,22 +28,22 @@ public function testIsSupported(): void $this->assertTrue( SnowflakeImportAdapter::isSupported( $absSource, - $snowflakeTable - ) + $snowflakeTable, + ), ); $this->assertFalse( SnowflakeImportAdapter::isSupported( $snowflakeSelectSource, - $snowflakeTable - ) + $snowflakeTable, + ), ); $this->assertFalse( SnowflakeImportAdapter::isSupported( $absSource, - $synapseTable - ) + $synapseTable, + ), ); } @@ -64,7 +64,7 @@ public function testGetCopyCommands(): void CREDENTIALS=(AZURE_SAS_TOKEN='sasToken') FILE_FORMAT = (TYPE=CSV FIELD_DELIMITER = ',' FIELD_OPTIONALLY_ENCLOSED_BY = '\"' ESCAPE_UNENCLOSED_FIELD = NONE) FILES = ('azure://url') -EOT +EOT, ); $conn->expects($this->once())->method('fetchAll') ->with('SELECT COUNT(*) AS "count" FROM "schema"."stagingTable"') @@ -73,7 +73,7 @@ public function testGetCopyCommands(): void [ 'count' => 10, ], - ] + ], ); $destination = new Storage\Snowflake\Table('schema', 'table'); @@ -83,7 +83,7 @@ public function testGetCopyCommands(): void $source, $destination, $options, - 'stagingTable' + 'stagingTable', ); $this->assertEquals(10, $count); } @@ -133,7 +133,7 @@ public function testGetCopyCommandsChunk(): void FILES = ($cmd2Files) EOT , - ] + ], ); $conn->expects($this->once())->method('fetchAll') ->with('SELECT COUNT(*) AS "count" FROM "schema"."stagingTable"') @@ -142,7 +142,7 @@ public function testGetCopyCommandsChunk(): void [ 'count' => 10, ], - ] + ], ); $destination = new Storage\Snowflake\Table('schema', 'table'); @@ -152,7 +152,7 @@ public function testGetCopyCommandsChunk(): void $source, $destination, $options, - 'stagingTable' + 'stagingTable', ); $this->assertEquals(10, $count); } diff --git a/packages/php-db-import-export/tests/unit/Storage/ABS/SynapseExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/ABS/SynapseExportAdapterTest.php index cb24a8f0f..392034d4b 100644 --- a/packages/php-db-import-export/tests/unit/Storage/ABS/SynapseExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/ABS/SynapseExportAdapterTest.php @@ -37,7 +37,7 @@ public function testGetCopyCommandQuery(): void ) AS SELECT * FROM "schema"."table" WHERE id = ? -EOT +EOT, ); $conn->expects($this->exactly(7))->method('exec')->withConsecutive( @@ -104,7 +104,7 @@ public function testGetCopyCommandQuery(): void DROP DATABASE SCOPED CREDENTIAL [random_export_id_StorageCredential] EOT , - ] + ], ); $source = new Storage\Synapse\SelectSource('SELECT * FROM "schema"."table" WHERE id = ?', [1]); @@ -113,7 +113,7 @@ public function testGetCopyCommandQuery(): void $this->assertIsArray($adapter->runCopyCommand( $source, $destination, - $options + $options, )); } @@ -153,7 +153,7 @@ public function testRunCopyCommand(): void ) AS SELECT * FROM [schema].[table] -EOT +EOT, ); $conn->expects($this->exactly(7))->method('exec')->withConsecutive( @@ -220,7 +220,7 @@ public function testRunCopyCommand(): void DROP DATABASE SCOPED CREDENTIAL [random_export_id_StorageCredential] EOT , - ] + ], ); $source = new Storage\Synapse\Table('schema', 'table'); @@ -229,7 +229,7 @@ public function testRunCopyCommand(): void $this->assertIsArray($adapter->runCopyCommand( $source, $destination, - $options + $options, )); } @@ -250,7 +250,7 @@ public function testRunCopyCommandCompressed(): void ) AS SELECT * FROM [schema].[table] -EOT +EOT, ); $conn->expects($this->exactly(7))->method('exec')->withConsecutive( @@ -317,7 +317,7 @@ public function testRunCopyCommandCompressed(): void DROP DATABASE SCOPED CREDENTIAL [random_export_id_StorageCredential] EOT , - ] + ], ); $source = new Storage\Synapse\Table('schema', 'table'); @@ -326,7 +326,7 @@ public function testRunCopyCommandCompressed(): void $this->assertIsArray($adapter->runCopyCommand( $source, $destination, - $options + $options, )); } @@ -347,7 +347,7 @@ public function testRunCopyCommandManagedIdentity(): void ) AS SELECT * FROM [schema].[table] -EOT +EOT, ); $conn->expects($this->exactly(7))->method('exec')->withConsecutive( @@ -413,7 +413,7 @@ public function testRunCopyCommandManagedIdentity(): void DROP DATABASE SCOPED CREDENTIAL [random_export_id_StorageCredential] EOT , - ] + ], ); $source = new Storage\Synapse\Table('schema', 'table'); @@ -422,7 +422,7 @@ public function testRunCopyCommandManagedIdentity(): void $this->assertIsArray($adapter->runCopyCommand( $source, $destination, - $options + $options, )); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/Bigquery/TableTest.php b/packages/php-db-import-export/tests/unit/Storage/Bigquery/TableTest.php index 9931c9a6a..407c3a9cd 100644 --- a/packages/php-db-import-export/tests/unit/Storage/Bigquery/TableTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/Bigquery/TableTest.php @@ -29,7 +29,7 @@ public function testColumns(): void self::assertEquals('SELECT `col1`, `col2` FROM `schema`.`table`', $source->getFromStatement()); self::assertEquals( 'SELECT CAST(`col1` AS STRING), CAST(`col2` AS STRING) FROM `schema`.`table`', - $source->getFromStatementWithStringCasting() + $source->getFromStatementWithStringCasting(), ); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/GCS/DestinationFileTest.php b/packages/php-db-import-export/tests/unit/Storage/GCS/DestinationFileTest.php index 94920c1f5..a82c12d84 100644 --- a/packages/php-db-import-export/tests/unit/Storage/GCS/DestinationFileTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/GCS/DestinationFileTest.php @@ -29,7 +29,7 @@ public function testDefaultValues(): void 'token_uri' => '', 'auth_provider_x509_cert_url' => '', 'client_x509_cert_url' => '', - ] + ], ); self::assertInstanceOf(Storage\GCS\BaseFile::class, $source); self::assertInstanceOf(Storage\DestinationInterface::class, $source); diff --git a/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GCSSlicedManifestFromFolderGeneratorTest.php b/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GCSSlicedManifestFromFolderGeneratorTest.php index 3438ef915..d26d8deb1 100644 --- a/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GCSSlicedManifestFromFolderGeneratorTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GCSSlicedManifestFromFolderGeneratorTest.php @@ -49,13 +49,13 @@ public function testGenerateAndSaveManifest(): void $this->assertSame( //phpcs:ignore '{"entries":[{"url":"gs:\\/\\/bucket1\\/prefix\\/xxx\\/obj1_000000.csv","mandatory":true},{"url":"gs:\\/\\/bucket1\\/prefix\\/xxx\\/obj2_000000.csv","mandatory":true}]}', - $content + $content, ); return true; }), [ 'name' => 'prefix/xxxmanifest', - ] + ], ); $clientMock = $this->createMock(StorageClient::class); $clientMock diff --git a/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGeneratorTest.php b/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGeneratorTest.php index 7cf2b886b..bee271f01 100644 --- a/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGeneratorTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/GCS/ManifestGenerator/GcsSlicedManifestFromUnloadQueryResultGeneratorTest.php @@ -39,7 +39,7 @@ public function testGenerateAndSaveManifest(): void $path = RelativePath::createFromRootAndPath( new GcsProvider(), 'tomasfejfar-kbc-services-filestorag-s3filesbucket-ggrrgg35547q', - 'permanent/256/snapshots/in/c-API-tests-e46793dac57ccf8cefb82ae9b8c05844cfabf985/languages/17982.csv.gz' + 'permanent/256/snapshots/in/c-API-tests-e46793dac57ccf8cefb82ae9b8c05844cfabf985/languages/17982.csv.gz', ); $generator = new GcsSlicedManifestFromUnloadQueryResultGenerator($gcsClientMock); diff --git a/packages/php-db-import-export/tests/unit/Storage/GCS/SnowflakeExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/GCS/SnowflakeExportAdapterTest.php index 22ec07368..8f2730777 100644 --- a/packages/php-db-import-export/tests/unit/Storage/GCS/SnowflakeExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/GCS/SnowflakeExportAdapterTest.php @@ -38,7 +38,7 @@ public function testGetCopyCommand(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn([]); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -50,8 +50,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -81,7 +81,7 @@ public function testGetCopyCommandCompressed(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn([]); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -93,8 +93,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -124,7 +124,7 @@ public function testGetCopyCommandQuery(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn([]); $source = new Storage\Snowflake\SelectSource('SELECT * FROM "schema"."tableName"'); @@ -136,8 +136,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/S3/DestinationFileTest.php b/packages/php-db-import-export/tests/unit/Storage/S3/DestinationFileTest.php index 6e88ad73d..dc00c8161 100644 --- a/packages/php-db-import-export/tests/unit/Storage/S3/DestinationFileTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/S3/DestinationFileTest.php @@ -16,7 +16,7 @@ public function testDefaultValues(): void 's3Secret', 'eu-central-1', 'myBucket', - 'file.csv' + 'file.csv', ); self::assertInstanceOf(Storage\S3\DestinationFile::class, $destination); self::assertInstanceOf(Storage\DestinationInterface::class, $destination); diff --git a/packages/php-db-import-export/tests/unit/Storage/S3/ExasolExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/S3/ExasolExportAdapterTest.php index 2f58ac730..6738c18e0 100644 --- a/packages/php-db-import-export/tests/unit/Storage/S3/ExasolExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/S3/ExasolExportAdapterTest.php @@ -19,7 +19,7 @@ public function testGetCopyCommand(): void 's3Secret', 'eu-central-1', 'myBucket', - 'file.csv' + 'file.csv', ); /** @var Connection|MockObject $conn */ @@ -64,7 +64,7 @@ public function testGetCopyCommand(): void REPLACE EOT , - [] + [], )->willReturn([]); $source = new Storage\Exasol\Table('schema', 'table'); @@ -76,8 +76,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -88,7 +88,7 @@ public function testGetCopyCommandCompressed(): void 's3Secret', 'eu-central-1', 'myBucket', - 'file.csv' + 'file.csv', ); /** @var Connection|MockObject $conn */ @@ -111,7 +111,7 @@ public function testGetCopyCommandCompressed(): void REPLACE EOT , - [] + [], )->willReturn([]); $source = new Storage\Exasol\Table('schema', 'table'); @@ -123,8 +123,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -135,7 +135,7 @@ public function testGetCopyCommandQuery(): void 's3Secret', 'eu-central-1', 'myBucket', - 'file.csv' + 'file.csv', ); /** @var Connection|MockObject $conn */ @@ -180,7 +180,7 @@ public function testGetCopyCommandQuery(): void REPLACE EOT , - [] + [], )->willReturn([]); $source = new Storage\Exasol\SelectSource('SELECT * FROM "schema"."table"'); @@ -192,8 +192,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/S3/ManifestGenerator/S3SlicedManifestFromUnloadQueryResultGeneratorTest.php b/packages/php-db-import-export/tests/unit/Storage/S3/ManifestGenerator/S3SlicedManifestFromUnloadQueryResultGeneratorTest.php index bb103522d..0ee785334 100644 --- a/packages/php-db-import-export/tests/unit/Storage/S3/ManifestGenerator/S3SlicedManifestFromUnloadQueryResultGeneratorTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/S3/ManifestGenerator/S3SlicedManifestFromUnloadQueryResultGeneratorTest.php @@ -34,7 +34,7 @@ public function testGenerateAndSaveManifest(): void $path = RelativePath::createFromRootAndPath( new S3Provider(), 'tomasfejfar-kbc-services-filestorag-s3filesbucket-ggrrgg35547q', - 'permanent/256/snapshots/in/c-API-tests-e46793dac57ccf8cefb82ae9b8c05844cfabf985/languages/17982.csv.gz' + 'permanent/256/snapshots/in/c-API-tests-e46793dac57ccf8cefb82ae9b8c05844cfabf985/languages/17982.csv.gz', ); $generator = new S3SlicedManifestFromUnloadQueryResultGenerator($s3ClientMock); diff --git a/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeExportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeExportAdapterTest.php index 9a4ede86e..ccdc67a8a 100644 --- a/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeExportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeExportAdapterTest.php @@ -55,7 +55,7 @@ public function testGetCopyCommand(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -67,8 +67,8 @@ public function testGetCopyCommand(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -115,7 +115,7 @@ public function testGetCopyCommandCompressed(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\Table('schema', 'table'); @@ -127,8 +127,8 @@ public function testGetCopyCommandCompressed(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } @@ -175,7 +175,7 @@ public function testGetCopyCommandQuery(): void DETAILED_OUTPUT = TRUE EOT , - [] + [], )->willReturn($expectedCopyResult); $source = new Storage\Snowflake\SelectSource('SELECT * FROM "schema"."table"'); @@ -187,8 +187,8 @@ public function testGetCopyCommandQuery(): void $adapter->runCopyCommand( $source, $destination, - $options - ) + $options, + ), ); } } diff --git a/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeImportAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeImportAdapterTest.php index a13d03096..6a86618d2 100644 --- a/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeImportAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/S3/SnowflakeImportAdapterTest.php @@ -28,22 +28,22 @@ public function testIsSupported(): void $this->assertTrue( SnowflakeImportAdapter::isSupported( $s3Source, - $snowflakeTable - ) + $snowflakeTable, + ), ); $this->assertFalse( SnowflakeImportAdapter::isSupported( $snowflakeSelectSource, - $snowflakeTable - ) + $snowflakeTable, + ), ); $this->assertFalse( SnowflakeImportAdapter::isSupported( $s3Source, - $synapseTable - ) + $synapseTable, + ), ); } @@ -66,7 +66,7 @@ public function testGetCopyCommands(): void REGION = 's3Region' FILE_FORMAT = (TYPE=CSV FIELD_DELIMITER = ',' FIELD_OPTIONALLY_ENCLOSED_BY = '\"' ESCAPE_UNENCLOSED_FIELD = NONE) FILES = ('s3://url') -EOT +EOT, ); $conn->expects(self::once())->method('fetchAll') ->with('SELECT COUNT(*) AS "count" FROM "schema"."stagingTable"') @@ -75,7 +75,7 @@ public function testGetCopyCommands(): void [ 'count' => 10, ], - ] + ], ); $destination = new Storage\Snowflake\Table('schema', 'table'); @@ -85,7 +85,7 @@ public function testGetCopyCommands(): void $source, $destination, $options, - 'stagingTable' + 'stagingTable', ); self::assertEquals(10, $count); } @@ -138,7 +138,7 @@ public function testGetCopyCommandsChunk(): void FILES = ($cmd2Files) EOT , - ] + ], ); $conn->expects(self::once())->method('fetchAll') ->with('SELECT COUNT(*) AS "count" FROM "schema"."stagingTable"') @@ -147,7 +147,7 @@ public function testGetCopyCommandsChunk(): void [ 'count' => 10, ], - ] + ], ); $destination = new Storage\Snowflake\Table('schema', 'table'); @@ -157,7 +157,7 @@ public function testGetCopyCommandsChunk(): void $source, $destination, $options, - 'stagingTable' + 'stagingTable', ); self::assertEquals(10, $count); } diff --git a/packages/php-db-import-export/tests/unit/Storage/Snowflake/SnowflakeAdapterTest.php b/packages/php-db-import-export/tests/unit/Storage/Snowflake/SnowflakeAdapterTest.php index 913b59e69..d295a65eb 100644 --- a/packages/php-db-import-export/tests/unit/Storage/Snowflake/SnowflakeAdapterTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/Snowflake/SnowflakeAdapterTest.php @@ -26,22 +26,22 @@ public function testIsSupported(): void $this->assertTrue( SnowflakeImportAdapter::isSupported( $snowflakeTable, - $snowflakeTable - ) + $snowflakeTable, + ), ); $this->assertFalse( SnowflakeImportAdapter::isSupported( $snowflakeSelectSource, - $synapseTable - ) + $synapseTable, + ), ); $this->assertFalse( SnowflakeImportAdapter::isSupported( $absSource, - $synapseTable - ) + $synapseTable, + ), ); } @@ -51,7 +51,7 @@ public function testGetCopyCommands(): void $conn = $this->mockConnection(); $conn->expects($this->once())->method('query')->with( - 'INSERT INTO "schema"."stagingTable" ("col1", "col2") SELECT "col1", "col2" FROM "schema"."table"' + 'INSERT INTO "schema"."stagingTable" ("col1", "col2") SELECT "col1", "col2" FROM "schema"."table"', ); $conn->expects($this->once())->method('fetchAll') ->with('SELECT COUNT(*) AS "count" FROM "schema"."stagingTable"') @@ -60,7 +60,7 @@ public function testGetCopyCommands(): void [ 'count' => 10, ], - ] + ], ); $destination = new Storage\Snowflake\Table('schema', 'table', ['col1', 'col2']); @@ -70,7 +70,7 @@ public function testGetCopyCommands(): void $source, $destination, $options, - 'stagingTable' + 'stagingTable', ); $this->assertEquals(10, $count); diff --git a/packages/php-db-import-export/tests/unit/Storage/Synapse/TableTest.php b/packages/php-db-import-export/tests/unit/Storage/Synapse/TableTest.php index 75381a590..2d38f1296 100644 --- a/packages/php-db-import-export/tests/unit/Storage/Synapse/TableTest.php +++ b/packages/php-db-import-export/tests/unit/Storage/Synapse/TableTest.php @@ -34,7 +34,7 @@ public function testColumns(): void self::assertEquals( // phpcs:ignore 'SELECT a.[col1], a.[col2] FROM (SELECT CAST([col1] as NVARCHAR(4000)) AS [col1], CAST([col2] as NVARCHAR(4000)) AS [col2] FROM [schema].[table]) AS a', - $source->getFromStatementForStaging(true) + $source->getFromStatementForStaging(true), ); } } diff --git a/packages/php-storage-driver-common/Shared/Driver/Exception/Command/ObjectNotFoundException.php b/packages/php-storage-driver-common/Shared/Driver/Exception/Command/ObjectNotFoundException.php index e76df2992..844550bbc 100644 --- a/packages/php-storage-driver-common/Shared/Driver/Exception/Command/ObjectNotFoundException.php +++ b/packages/php-storage-driver-common/Shared/Driver/Exception/Command/ObjectNotFoundException.php @@ -18,7 +18,7 @@ public function __construct(string $objectName, int $code = self::ERR_NOT_FOUND, $this->objectName = $objectName; parent::__construct(sprintf( 'Object "%s" not found.', - $objectName + $objectName, ), $code, $previous); } diff --git a/packages/php-storage-driver-common/Shared/Driver/Exception/Command/TooManyRequestsException.php b/packages/php-storage-driver-common/Shared/Driver/Exception/Command/TooManyRequestsException.php index 828b962cc..f9849e9fd 100644 --- a/packages/php-storage-driver-common/Shared/Driver/Exception/Command/TooManyRequestsException.php +++ b/packages/php-storage-driver-common/Shared/Driver/Exception/Command/TooManyRequestsException.php @@ -14,12 +14,12 @@ final class TooManyRequestsException extends Exception public function __construct( string $message = self::TOO_MANY_REQUESTS, int $code = self::ERR_RESOURCE_FULL, - ?Throwable $previous = null + ?Throwable $previous = null, ) { parent::__construct( $message, $code, - $previous + $previous, ); } } diff --git a/packages/php-storage-driver-common/Shared/Driver/Exception/Command/UnknownObjectException.php b/packages/php-storage-driver-common/Shared/Driver/Exception/Command/UnknownObjectException.php index 677a2413f..bd44f6fda 100644 --- a/packages/php-storage-driver-common/Shared/Driver/Exception/Command/UnknownObjectException.php +++ b/packages/php-storage-driver-common/Shared/Driver/Exception/Command/UnknownObjectException.php @@ -16,10 +16,10 @@ public function __construct(string $objectName, int $code = self::ERR_UNKNOWN_OB parent::__construct( sprintf( 'Unknown object "%s".', - $objectName + $objectName, ), $code, - $previous + $previous, ); } } diff --git a/packages/php-storage-driver-common/Shared/Driver/Exception/CommandNotSupportedException.php b/packages/php-storage-driver-common/Shared/Driver/Exception/CommandNotSupportedException.php index 27023ef29..7add4a7b6 100644 --- a/packages/php-storage-driver-common/Shared/Driver/Exception/CommandNotSupportedException.php +++ b/packages/php-storage-driver-common/Shared/Driver/Exception/CommandNotSupportedException.php @@ -13,7 +13,7 @@ public function __construct(string $command) { parent::__construct(sprintf( 'Command "%s" not supported.', - $command + $command, )); } } diff --git a/packages/php-storage-driver-common/Shared/Driver/MetaHelper.php b/packages/php-storage-driver-common/Shared/Driver/MetaHelper.php index 25d7898e5..e09af0572 100644 --- a/packages/php-storage-driver-common/Shared/Driver/MetaHelper.php +++ b/packages/php-storage-driver-common/Shared/Driver/MetaHelper.php @@ -25,7 +25,7 @@ public static function getMetaRestricted(Message $command, string $expectedMetaI throw new Exception(sprintf( 'Unexpected meta instance "%s" expected "%s"', get_class($meta), - $expectedMetaInstance + $expectedMetaInstance, )); } diff --git a/packages/php-storage-driver-common/Shared/NameGenerator/GenericNameGenerator.php b/packages/php-storage-driver-common/Shared/NameGenerator/GenericNameGenerator.php index 1fbcc7b7c..a82f3136f 100644 --- a/packages/php-storage-driver-common/Shared/NameGenerator/GenericNameGenerator.php +++ b/packages/php-storage-driver-common/Shared/NameGenerator/GenericNameGenerator.php @@ -17,7 +17,7 @@ class GenericNameGenerator implements BackendNameGeneratorInterface, BackendSupp protected string $stackPrefix; public function __construct( - string $clientDbPrefix + string $clientDbPrefix, ) { if ($clientDbPrefix === '') { throw new LogicException('Client db prefix must be set'); @@ -48,8 +48,8 @@ public function createObjectNameForBucketInProject(string $bucketId, string $pro sprintf( '%s-%s', $this->createObjectNameForProject($projectId), - $bucketId - ) + $bucketId, + ), ); } @@ -85,14 +85,14 @@ public function supportsBackend(string $backendName): bool public function createShareRoleNameForBucket( string $projectId, - string $bucketId + string $bucketId, ): string { return strtoupper(sprintf( '%s_%s_%s%s', rtrim($this->stackPrefix, '_'), $projectId, $bucketId, - self::SHARE_ROLE_SUFFIX + self::SHARE_ROLE_SUFFIX, )); } } diff --git a/packages/php-storage-driver-common/Shared/NameGenerator/NameGeneratorFactory.php b/packages/php-storage-driver-common/Shared/NameGenerator/NameGeneratorFactory.php index a56fdadd4..81578d19e 100644 --- a/packages/php-storage-driver-common/Shared/NameGenerator/NameGeneratorFactory.php +++ b/packages/php-storage-driver-common/Shared/NameGenerator/NameGeneratorFactory.php @@ -10,7 +10,7 @@ final class NameGeneratorFactory { public static function getGeneratorForBackendAndPrefix( string $backend, - string $stackPrefix + string $stackPrefix, ): BackendNameGeneratorInterface { switch ($backend) { case BackendSupportsInterface::BACKEND_SYNAPSE: diff --git a/packages/php-storage-driver-common/Shared/NameGenerator/SynapseNameGenerator.php b/packages/php-storage-driver-common/Shared/NameGenerator/SynapseNameGenerator.php index 266f40cec..c21e31596 100644 --- a/packages/php-storage-driver-common/Shared/NameGenerator/SynapseNameGenerator.php +++ b/packages/php-storage-driver-common/Shared/NameGenerator/SynapseNameGenerator.php @@ -11,7 +11,7 @@ public function createGlobalSchemaOwner(): string return strtoupper( $this->stackPrefix . 'GLOBAL_SCHEMA_OWNER' - . self::ROLE_SUFFIX + . self::ROLE_SUFFIX, ); } } diff --git a/packages/php-storage-driver-common/Shared/Utils/MetaHelper.php b/packages/php-storage-driver-common/Shared/Utils/MetaHelper.php index 894697796..5e494a809 100644 --- a/packages/php-storage-driver-common/Shared/Utils/MetaHelper.php +++ b/packages/php-storage-driver-common/Shared/Utils/MetaHelper.php @@ -30,7 +30,7 @@ public static function getMetaFromCommand(Message $command, string $expectedMeta throw new Exception(sprintf( 'Unexpected meta instance "%s" expected "%s"', get_class($meta), - $expectedMetaInstance + $expectedMetaInstance, )); } diff --git a/packages/php-storage-driver-common/Shared/Utils/Password.php b/packages/php-storage-driver-common/Shared/Utils/Password.php index 12e4dac6d..7b7ddcfa5 100644 --- a/packages/php-storage-driver-common/Shared/Utils/Password.php +++ b/packages/php-storage-driver-common/Shared/Utils/Password.php @@ -22,7 +22,7 @@ final class Password public static function generate( int $length = self::DEFAULT_PASSWORD_LENGTH, int $usedSets = self::DEFAULT_SETS, - string $excludeChars = self::DEFAULT_EXCLUDED_CHARACTERS + string $excludeChars = self::DEFAULT_EXCLUDED_CHARACTERS, ): string { $sets = []; diff --git a/packages/php-storage-driver-common/composer.json b/packages/php-storage-driver-common/composer.json index 7c0430a56..c64389cdd 100644 --- a/packages/php-storage-driver-common/composer.json +++ b/packages/php-storage-driver-common/composer.json @@ -22,7 +22,7 @@ "phpstan/phpstan": "^1.4", "phpstan/phpstan-phpunit": "^1", "phpstan/phpstan-symfony": "^1.1", - "keboola/coding-standard": "^14", + "keboola/coding-standard": "^15", "php-parallel-lint/php-parallel-lint": "^1.3", "symfony/finder": "^5.4", "keboola/phpunit-retry-annotations": "^0.3.0" diff --git a/packages/php-storage-driver-common/contract/Driver/ClientInterface.php b/packages/php-storage-driver-common/contract/Driver/ClientInterface.php index 140b611d7..7a2640832 100644 --- a/packages/php-storage-driver-common/contract/Driver/ClientInterface.php +++ b/packages/php-storage-driver-common/contract/Driver/ClientInterface.php @@ -17,6 +17,6 @@ public function runCommand( Message $credentials, Message $command, array $features, - Message $runtimeOptions + Message $runtimeOptions, ): ?Message; } diff --git a/packages/php-storage-driver-common/tests/StubLoader/S3Loader.php b/packages/php-storage-driver-common/tests/StubLoader/S3Loader.php index 89fc2abfa..0130d8321 100644 --- a/packages/php-storage-driver-common/tests/StubLoader/S3Loader.php +++ b/packages/php-storage-driver-common/tests/StubLoader/S3Loader.php @@ -19,7 +19,7 @@ class S3Loader extends BaseStubLoader public function __construct( string $region, - string $bucket + string $bucket, ) { $this->client = new S3Client([ 'region' => $region, @@ -63,7 +63,7 @@ public function load(): void 's3://' . $this->bucket, [ 'debug' => true, - ] + ], ); // Perform the transfer synchronously. @@ -91,7 +91,7 @@ private function generateManifests(): void 's3://%s/sliced/%s/%s', $this->bucket, $directory->getBasename(), - $file->getFilename() + $file->getFilename(), ), 'mandatory' => true, ]; @@ -101,7 +101,7 @@ private function generateManifests(): void '%s/%s.%s.csvmanifest', $directory->getPathname(), self::MANIFEST_SUFFIX, - $directory->getBasename() + $directory->getBasename(), ); file_put_contents($manifestFilePath, json_encode($manifest, JSON_THROW_ON_ERROR)); } diff --git a/packages/php-storage-driver-common/tests/StubLoader/loader.php b/packages/php-storage-driver-common/tests/StubLoader/loader.php index e7ca7b0c0..bf16827f9 100644 --- a/packages/php-storage-driver-common/tests/StubLoader/loader.php +++ b/packages/php-storage-driver-common/tests/StubLoader/loader.php @@ -18,7 +18,7 @@ $loader = new S3Loader( (string) getenv('AWS_REGION'), - (string) getenv('AWS_S3_BUCKET') + (string) getenv('AWS_S3_BUCKET'), ); $loader->clearBucket(); $loader->load(); diff --git a/packages/php-storage-driver-common/tests/unit/Shared/Driver/MetaHelperTest.php b/packages/php-storage-driver-common/tests/unit/Shared/Driver/MetaHelperTest.php index 973536d8f..1df149d0d 100644 --- a/packages/php-storage-driver-common/tests/unit/Shared/Driver/MetaHelperTest.php +++ b/packages/php-storage-driver-common/tests/unit/Shared/Driver/MetaHelperTest.php @@ -17,7 +17,7 @@ class MetaHelperTest extends TestCase public function testGetMetaNotContainMeta(): void { $result = MetaHelper::getMeta( - $this->createMock(Message::class) + $this->createMock(Message::class), ); $this->assertNull($result); } @@ -25,7 +25,7 @@ public function testGetMetaNotContainMeta(): void public function testGetMetaNoMetaSet(): void { $result = MetaHelper::getMeta( - new InitBackendResponse() + new InitBackendResponse(), ); $this->assertNull($result); } @@ -35,11 +35,11 @@ public function testGetMetaCorrectMetaInstance(): void $meta = new Any(); $meta->pack( (new InitBackendResponse\InitBackendSynapseMeta()) - ->setGlobalRoleName('test') + ->setGlobalRoleName('test'), ); $result = MetaHelper::getMeta( - (new InitBackendResponse())->setMeta($meta) + (new InitBackendResponse())->setMeta($meta), ); $this->assertInstanceOf(InitBackendResponse\InitBackendSynapseMeta::class, $result); $this->assertSame('test', $result->getGlobalRoleName()); @@ -49,7 +49,7 @@ public function testGetMetaRestrictedNotContainMeta(): void { $result = MetaHelper::getMetaRestricted( $this->createMock(Message::class), - InitBackendResponse\InitBackendSynapseMeta::class + InitBackendResponse\InitBackendSynapseMeta::class, ); $this->assertNull($result); } @@ -58,7 +58,7 @@ public function testGetMetaRestrictedNoMetaSet(): void { $result = MetaHelper::getMetaRestricted( new InitBackendResponse(), - InitBackendResponse\InitBackendSynapseMeta::class + InitBackendResponse\InitBackendSynapseMeta::class, ); $this->assertNull($result); } @@ -67,13 +67,13 @@ public function testGetMetaRestrictedInvalidMetaInstance(): void { $meta = new Any(); $meta->pack( - new InitBackendResponse\InitBackendSynapseMeta() + new InitBackendResponse\InitBackendSynapseMeta(), ); $this->expectException(Throwable::class); MetaHelper::getMetaRestricted( (new InitBackendResponse())->setMeta($meta), - CreateBucketTeradataMeta::class + CreateBucketTeradataMeta::class, ); } @@ -82,12 +82,12 @@ public function testGetMetaRestrictedCorrectMetaInstance(): void $meta = new Any(); $meta->pack( (new InitBackendResponse\InitBackendSynapseMeta()) - ->setGlobalRoleName('test') + ->setGlobalRoleName('test'), ); $result = MetaHelper::getMetaRestricted( (new InitBackendResponse())->setMeta($meta), - InitBackendResponse\InitBackendSynapseMeta::class + InitBackendResponse\InitBackendSynapseMeta::class, ); $this->assertInstanceOf(InitBackendResponse\InitBackendSynapseMeta::class, $result); $this->assertSame('test', $result->getGlobalRoleName()); diff --git a/packages/php-storage-driver-common/tests/unit/Shared/Utils/CharsetTest.php b/packages/php-storage-driver-common/tests/unit/Shared/Utils/CharsetTest.php index 4a55657c4..ecf1ad82b 100644 --- a/packages/php-storage-driver-common/tests/unit/Shared/Utils/CharsetTest.php +++ b/packages/php-storage-driver-common/tests/unit/Shared/Utils/CharsetTest.php @@ -13,11 +13,11 @@ public function testGetCharlistFromRange(): void { $this->assertEquals( '0123456789', - Charset::getCharlistFromRange('0-9') + Charset::getCharlistFromRange('0-9'), ); $this->assertEquals( 'abcdefghijklmnopqrstuvwxyzABCDEF', - Charset::getCharlistFromRange('a-zA-F') + Charset::getCharlistFromRange('a-zA-F'), ); } } diff --git a/packages/php-storage-driver-common/tests/unit/Shared/Utils/PasswordTest.php b/packages/php-storage-driver-common/tests/unit/Shared/Utils/PasswordTest.php index 3146eafe9..4bda399dd 100644 --- a/packages/php-storage-driver-common/tests/unit/Shared/Utils/PasswordTest.php +++ b/packages/php-storage-driver-common/tests/unit/Shared/Utils/PasswordTest.php @@ -21,7 +21,7 @@ public function testGenerateDefaultPassword(): void $this->assertMatchesRegularExpression( '~^[^0O1Il]+$~', $password, - 'Characters "0O1Il" are not excluded from password.' + 'Characters "0O1Il" are not excluded from password.', ); } } @@ -31,7 +31,7 @@ private function assertPasswordHasNumber(string $password): void $this->assertMatchesRegularExpression( '/[0-9]+/', $password, - sprintf('Password "%s" missing numeric characters.', $password) + sprintf('Password "%s" missing numeric characters.', $password), ); } @@ -40,7 +40,7 @@ private function assertPasswordHasUppercase(string $password): void $this->assertMatchesRegularExpression( '/[A-Z]+/', $password, - sprintf('Password "%s" missing uppercase characters.', $password) + sprintf('Password "%s" missing uppercase characters.', $password), ); } @@ -49,7 +49,7 @@ private function assertPasswordHasLowercase(string $password): void $this->assertMatchesRegularExpression( '/[a-z]+/', $password, - sprintf('Password "%s" missing lowercase characters.', $password) + sprintf('Password "%s" missing lowercase characters.', $password), ); } @@ -62,7 +62,7 @@ public function testGeneratePasswordWithSpecialCharacters(): void Password::SET_LOWERCASE | Password::SET_UPPERCASE | Password::SET_NUMBER | - Password::SET_SPECIAL_CHARACTERS + Password::SET_SPECIAL_CHARACTERS, ); $this->assertPasswordHasNumber($password); $this->assertPasswordHasUppercase($password); @@ -72,7 +72,7 @@ public function testGeneratePasswordWithSpecialCharacters(): void $this->assertMatchesRegularExpression( '~^[^0O1Il]+$~', $password, - 'Characters "0O1Il" are not excluded from password.' + 'Characters "0O1Il" are not excluded from password.', ); } } @@ -82,7 +82,7 @@ private function assertPasswordHasSpecialCharacter(string $password): void $this->assertMatchesRegularExpression( '/[_\-\!\$\.\+\/\@\#\%\&\*\?]+/', $password, - sprintf('Password "%s" missing special characters.', $password) + sprintf('Password "%s" missing special characters.', $password), ); } @@ -96,7 +96,7 @@ public function testGeneratePasswordExcludeCharacters(): void Password::SET_UPPERCASE | Password::SET_NUMBER | Password::SET_SPECIAL_CHARACTERS, - 'abc' + 'abc', ); $this->assertPasswordHasNumber($password); $this->assertPasswordHasUppercase($password); @@ -106,7 +106,7 @@ public function testGeneratePasswordExcludeCharacters(): void $this->assertMatchesRegularExpression( '~^[^abc]+$~', $password, - 'Characters "abc" are not excluded from password.' + 'Characters "abc" are not excluded from password.', ); } } diff --git a/packages/php-storage-driver-common/tests/unit/Shared/Utils/StringUtilsTest.php b/packages/php-storage-driver-common/tests/unit/Shared/Utils/StringUtilsTest.php index 508151202..54486c281 100644 --- a/packages/php-storage-driver-common/tests/unit/Shared/Utils/StringUtilsTest.php +++ b/packages/php-storage-driver-common/tests/unit/Shared/Utils/StringUtilsTest.php @@ -21,7 +21,7 @@ public function testRandomizeString(): void $this->assertEquals( $randomString1, - $randomString2 + $randomString2, ); } } diff --git a/packages/php-table-backend-utils/composer.json b/packages/php-table-backend-utils/composer.json index 5e9950487..15b45e170 100644 --- a/packages/php-table-backend-utils/composer.json +++ b/packages/php-table-backend-utils/composer.json @@ -21,7 +21,7 @@ "keboola/retry": "^0.5.0" }, "require-dev": { - "keboola/coding-standard": "^14", + "keboola/coding-standard": "^15", "php-parallel-lint/php-parallel-lint": "^1.3", "phpstan/phpstan": "^1.4", "phpstan/phpstan-phpunit": "^1", diff --git a/packages/php-table-backend-utils/src/Auth/SynapseGrantQueryBuilder.php b/packages/php-table-backend-utils/src/Auth/SynapseGrantQueryBuilder.php index 122f93de2..ba3b1cbf6 100644 --- a/packages/php-table-backend-utils/src/Auth/SynapseGrantQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Auth/SynapseGrantQueryBuilder.php @@ -31,7 +31,7 @@ public function getGrantSql(GrantOptionsInterface $options): string implode(', ', $options->getPermissions()), $on, SynapseQuote::quoteSingleIdentifier($options->getGrantTo()), - $with + $with, ); } @@ -58,7 +58,7 @@ public function getRevokeSql(RevokeOptionsInterface $options): string $permissions, $on, SynapseQuote::quoteSingleIdentifier($options->getRevokeFrom()), - $with + $with, ); } @@ -87,7 +87,7 @@ private function getOnStatement(?string $grantSubject, array $grantOnTargetPath) $on = sprintf( ' ON %s%s', $grantSubject, - $path + $path, ); } return $on; diff --git a/packages/php-table-backend-utils/src/Auth/SynapseUserReflection.php b/packages/php-table-backend-utils/src/Auth/SynapseUserReflection.php index 72a6b9d7d..20e089f3a 100644 --- a/packages/php-table-backend-utils/src/Auth/SynapseUserReflection.php +++ b/packages/php-table-backend-utils/src/Auth/SynapseUserReflection.php @@ -26,7 +26,7 @@ public function endAllSessions(): void foreach ($ids as $id) { $this->connection->executeStatement(sprintf( 'KILL %s;', - SynapseQuote::quote($id) + SynapseQuote::quote($id), )); } } @@ -45,7 +45,7 @@ public function getAllSessionIds(): array EOD; /** @var string[]|false $sessions */ $sessions = $this->connection->fetchNumeric( - sprintf($sql, SynapseQuote::quote($this->userName)) + sprintf($sql, SynapseQuote::quote($this->userName)), ); if ($sessions === false) { diff --git a/packages/php-table-backend-utils/src/Column/Bigquery/BigqueryColumn.php b/packages/php-table-backend-utils/src/Column/Bigquery/BigqueryColumn.php index 791820de5..369178caa 100644 --- a/packages/php-table-backend-utils/src/Column/Bigquery/BigqueryColumn.php +++ b/packages/php-table-backend-utils/src/Column/Bigquery/BigqueryColumn.php @@ -42,12 +42,12 @@ public static function createGenericColumn(string $columnName): BigqueryColumn [ 'nullable' => false, 'default' => '\'\'', - ] + ], ); return new self( $columnName, - $definition + $definition, ); } @@ -57,7 +57,7 @@ public static function createTimestampColumn(string $columnName = self::TIMESTAM $columnName, new Bigquery( Bigquery::TYPE_TIMESTAMP, - ) + ), ); } @@ -68,7 +68,7 @@ public static function createFromDB(array $dbResponse): BigqueryColumn { return new self( $dbResponse['name'], - RESTtoSQLDatatypeConverter::convertColumnToSQLFormat($dbResponse) + RESTtoSQLDatatypeConverter::convertColumnToSQLFormat($dbResponse), ); } } diff --git a/packages/php-table-backend-utils/src/Column/Bigquery/Parser/ComplexTypeTokenizer.php b/packages/php-table-backend-utils/src/Column/Bigquery/Parser/ComplexTypeTokenizer.php index 00e52cef5..a53f5af7e 100644 --- a/packages/php-table-backend-utils/src/Column/Bigquery/Parser/ComplexTypeTokenizer.php +++ b/packages/php-table-backend-utils/src/Column/Bigquery/Parser/ComplexTypeTokenizer.php @@ -117,7 +117,7 @@ public function tokenize(string $input): ArrayIterator throw new ParsingComplexTypeLengthException(sprintf( 'Unexpected token on position "%d" in "%s". Type of field expected.', $index, - substr($input, $index) + substr($input, $index), )); } $expectTypeNext = true; @@ -134,7 +134,7 @@ public function tokenize(string $input): ArrayIterator // phpcs:ignore 'Unexpected token on position "%d" in "%s". Expected "," followed by next field or end of ARRAY|STRUCT.', $index, - substr($input, $index) + substr($input, $index), )); } $expectTypeNext = false; @@ -151,7 +151,7 @@ public function tokenize(string $input): ArrayIterator throw new ParsingComplexTypeLengthException(sprintf( 'Unexpected token on position "%d" in "%s". Closing parenthesis not found.', $index, - substr($input, $index) + substr($input, $index), )); } } @@ -162,7 +162,7 @@ public function tokenize(string $input): ArrayIterator 'Unexpected token "%s" on position "%d" in "%s"', $input[$index], $index, - substr($input, $index) + substr($input, $index), )); } diff --git a/packages/php-table-backend-utils/src/Column/Bigquery/Parser/RESTtoSQLDatatypeConverter.php b/packages/php-table-backend-utils/src/Column/Bigquery/Parser/RESTtoSQLDatatypeConverter.php index 0ec044b20..73fc1290e 100644 --- a/packages/php-table-backend-utils/src/Column/Bigquery/Parser/RESTtoSQLDatatypeConverter.php +++ b/packages/php-table-backend-utils/src/Column/Bigquery/Parser/RESTtoSQLDatatypeConverter.php @@ -33,7 +33,7 @@ public static function convertColumnToSQLFormat(array $dbResponse): Bigquery ]; return new Bigquery( $type, - $options + $options, ); } diff --git a/packages/php-table-backend-utils/src/Column/Bigquery/Parser/SQLtoRestDatatypeConverter.php b/packages/php-table-backend-utils/src/Column/Bigquery/Parser/SQLtoRestDatatypeConverter.php index 33de942a3..4e65d1139 100644 --- a/packages/php-table-backend-utils/src/Column/Bigquery/Parser/SQLtoRestDatatypeConverter.php +++ b/packages/php-table-backend-utils/src/Column/Bigquery/Parser/SQLtoRestDatatypeConverter.php @@ -62,7 +62,7 @@ private static function updateSchemaLength(?string $length, array $schema): arra private static function convertTokenToSchema( TokenizerNestedToken|TokenizerToken $token, array $schema, - ArrayIterator $tokens + ArrayIterator $tokens, ): array { if ($token->type === ComplexTypeTokenizer::T_NAME) { // handle T_NAME name of column @@ -95,7 +95,7 @@ private static function convertTokenToSchema( $arrayTokenNested = $tokens->current(); assert( $arrayTokenNested instanceof TokenizerNestedToken, - sprintf('Expected class "%s" got "%s"', TokenizerNestedToken::class, $arrayTokenNested::class) + sprintf('Expected class "%s" got "%s"', TokenizerNestedToken::class, $arrayTokenNested::class), ); $nestedTokens = $arrayTokenNested->nested; $firstNestedToken = $nestedTokens->current(); @@ -110,7 +110,7 @@ private static function convertTokenToSchema( $structNested = $tokens->current(); assert( $structNested instanceof TokenizerNestedToken, - sprintf('Expected class "%s" got "%s"', TokenizerNestedToken::class, $structNested::class) + sprintf('Expected class "%s" got "%s"', TokenizerNestedToken::class, $structNested::class), ); foreach ($structNested->nested as $nestedToken) { if ($nestedToken->type !== ComplexTypeTokenizer::T_NAME) { @@ -174,7 +174,7 @@ public static function convertColumnToRestFormat(BigqueryColumn $column): array // complex types try { $tokens = (new ComplexTypeTokenizer())->tokenize( - $column->getColumnName() . ' ' . $definition->getSQLDefinition() + $column->getColumnName() . ' ' . $definition->getSQLDefinition(), ); $schema = self::convertTokenToSchema($tokens->current(), [], $tokens); } catch (ParsingComplexTypeLengthException $e) { diff --git a/packages/php-table-backend-utils/src/Column/ColumnCollection.php b/packages/php-table-backend-utils/src/Column/ColumnCollection.php index a777c913e..ead9a1df3 100644 --- a/packages/php-table-backend-utils/src/Column/ColumnCollection.php +++ b/packages/php-table-backend-utils/src/Column/ColumnCollection.php @@ -54,7 +54,7 @@ private function assertTableColumnsCount(array $columns): void throw new ColumnException( // we have to force user to create MAX-1 columns, becase we need 1 for timestamp sprintf('Too many columns. Maximum is %s columns.', $limit - 1), - ColumnException::STRING_CODE_TO_MANY_COLUMNS + ColumnException::STRING_CODE_TO_MANY_COLUMNS, ); } } diff --git a/packages/php-table-backend-utils/src/Column/Exasol/ExasolColumn.php b/packages/php-table-backend-utils/src/Column/Exasol/ExasolColumn.php index 57e7373ee..0a76bb8c5 100644 --- a/packages/php-table-backend-utils/src/Column/Exasol/ExasolColumn.php +++ b/packages/php-table-backend-utils/src/Column/Exasol/ExasolColumn.php @@ -28,12 +28,12 @@ public static function createGenericColumn(string $columnName): ExasolColumn 'length' => '2000000', 'nullable' => false, 'default' => '\'\'', - ] + ], ); return new self( $columnName, - $definition + $definition, ); } @@ -75,8 +75,8 @@ public static function createFromDB(array $dbResponse): ExasolColumn 'length' => self::extractColumnLength($dbResponse), 'nullable' => $dbResponse['COLUMN_IS_NULLABLE'] === '1', 'default' => $defaultValue === '' ? null : $defaultValue, - ] - ) + ], + ), ); } @@ -116,8 +116,8 @@ public static function createTimestampColumn(string $columnName = self::TIMESTAM return new ExasolColumn( $columnName, new Exasol( - Exasol::TYPE_TIMESTAMP - ) + Exasol::TYPE_TIMESTAMP, + ), ); } } diff --git a/packages/php-table-backend-utils/src/Column/Snowflake/SnowflakeColumn.php b/packages/php-table-backend-utils/src/Column/Snowflake/SnowflakeColumn.php index 7ba7915d0..e74a79793 100644 --- a/packages/php-table-backend-utils/src/Column/Snowflake/SnowflakeColumn.php +++ b/packages/php-table-backend-utils/src/Column/Snowflake/SnowflakeColumn.php @@ -27,12 +27,12 @@ public static function createGenericColumn(string $columnName): SnowflakeColumn [ 'nullable' => false, 'default' => '\'\'', - ] + ], ); return new self( $columnName, - $definition + $definition, ); } @@ -75,7 +75,7 @@ public static function createFromDB(array $dbResponse): SnowflakeColumn 'nullable' => $dbResponse['null?'] === 'Y', 'length' => $length, 'default' => $default, - ] + ], )); } @@ -84,8 +84,8 @@ public static function createTimestampColumn(string $columnName = self::TIMESTAM return new self( $columnName, new Snowflake( - Snowflake::TYPE_TIMESTAMP_NTZ - ) + Snowflake::TYPE_TIMESTAMP_NTZ, + ), ); } } diff --git a/packages/php-table-backend-utils/src/Column/SynapseColumn.php b/packages/php-table-backend-utils/src/Column/SynapseColumn.php index 78e6099ab..ed0ef1c9d 100644 --- a/packages/php-table-backend-utils/src/Column/SynapseColumn.php +++ b/packages/php-table-backend-utils/src/Column/SynapseColumn.php @@ -79,8 +79,8 @@ public static function createFromDB(array $dbResponse): SynapseColumn (string) preg_replace( '/^\(\((.+)\)\)$/', '\\1', - $default - ) + $default, + ), ); } @@ -90,7 +90,7 @@ public static function createFromDB(array $dbResponse): SynapseColumn 'nullable' => strtolower($dbResponse['column_is_nullable']) === '1', 'length' => $length, 'default' => $default, - ] + ], ); return new self($dbResponse['column_name'], $definition); @@ -104,12 +104,12 @@ public static function createGenericColumn(string $columnName): SynapseColumn 'length' => '4000', // should be changed to max in future 'nullable' => false, 'default' => '\'\'', - ] + ], ); return new self( $columnName, - $definition + $definition, ); } @@ -131,8 +131,8 @@ public static function createTimestampColumn(string $columnName = self::TIMESTAM return new self( $columnName, new Synapse( - Synapse::TYPE_DATETIME2 - ) + Synapse::TYPE_DATETIME2, + ), ); } } diff --git a/packages/php-table-backend-utils/src/Column/Teradata/TeradataColumn.php b/packages/php-table-backend-utils/src/Column/Teradata/TeradataColumn.php index 35b6663d4..4882db609 100644 --- a/packages/php-table-backend-utils/src/Column/Teradata/TeradataColumn.php +++ b/packages/php-table-backend-utils/src/Column/Teradata/TeradataColumn.php @@ -28,12 +28,12 @@ public static function createGenericColumn(string $columnName): TeradataColumn 'length' => '32000', // max value is 32k for UNICODE,GRAPHIC,KANJISJIS, 64k for LATIN 'nullable' => false, 'default' => '\'\'', - ] + ], ); return new self( $columnName, - $definition + $definition, ); } @@ -65,7 +65,7 @@ public static function createTimestampColumn(string $columnName = self::TIMESTAM $columnName, new Teradata( Teradata::TYPE_TIMESTAMP, - ) + ), ); } } diff --git a/packages/php-table-backend-utils/src/ColumnException.php b/packages/php-table-backend-utils/src/ColumnException.php index a99014e7c..220ed8f48 100644 --- a/packages/php-table-backend-utils/src/ColumnException.php +++ b/packages/php-table-backend-utils/src/ColumnException.php @@ -17,7 +17,7 @@ class ColumnException extends RuntimeException implements ApplicationExceptionIn public function __construct( string $message, string $stringCode, - ?Throwable $previous = null + ?Throwable $previous = null, ) { parent::__construct($message, 0, $previous); $this->stringCode = $stringCode; diff --git a/packages/php-table-backend-utils/src/Connection/Bigquery/SessionFactory.php b/packages/php-table-backend-utils/src/Connection/Bigquery/SessionFactory.php index e85e3881c..3ff8c7740 100644 --- a/packages/php-table-backend-utils/src/Connection/Bigquery/SessionFactory.php +++ b/packages/php-table-backend-utils/src/Connection/Bigquery/SessionFactory.php @@ -26,8 +26,8 @@ public function createSession(): Session 'createSession' => true, ], ], - ] - ) + ], + ), )); } } diff --git a/packages/php-table-backend-utils/src/Connection/ConnectionRetryWrapper.php b/packages/php-table-backend-utils/src/Connection/ConnectionRetryWrapper.php index 94a0654e6..cd2d270a0 100644 --- a/packages/php-table-backend-utils/src/Connection/ConnectionRetryWrapper.php +++ b/packages/php-table-backend-utils/src/Connection/ConnectionRetryWrapper.php @@ -18,7 +18,7 @@ final class ConnectionRetryWrapper implements Connection public function __construct( Connection $connection, - RetryProxyInterface $retryProxy + RetryProxyInterface $retryProxy, ) { $this->connection = $connection; $this->retryProxy = $retryProxy; diff --git a/packages/php-table-backend-utils/src/Connection/Exasol/ExasolConnectionFactory.php b/packages/php-table-backend-utils/src/Connection/Exasol/ExasolConnectionFactory.php index 6eb4ba27e..a503b0a9d 100644 --- a/packages/php-table-backend-utils/src/Connection/Exasol/ExasolConnectionFactory.php +++ b/packages/php-table-backend-utils/src/Connection/Exasol/ExasolConnectionFactory.php @@ -15,7 +15,7 @@ public static function getConnection( string $user, string $password, ?Configuration $config = null, - bool $skipCertCheck = false + bool $skipCertCheck = false, ): Connection { return DriverManager::getConnection( [ @@ -25,7 +25,7 @@ public static function getConnection( 'password' => $password, 'skipCertCheck' => $skipCertCheck, ], - $config + $config, ); } } diff --git a/packages/php-table-backend-utils/src/Connection/Exasol/ExasolDriver.php b/packages/php-table-backend-utils/src/Connection/Exasol/ExasolDriver.php index 974faabfc..236e601c4 100644 --- a/packages/php-table-backend-utils/src/Connection/Exasol/ExasolDriver.php +++ b/packages/php-table-backend-utils/src/Connection/Exasol/ExasolDriver.php @@ -21,7 +21,7 @@ class ExasolDriver implements Driver * } $params */ public function connect( - array $params + array $params, ): ExasolConnection { assert(array_key_exists('host', $params)); assert(array_key_exists('user', $params)); diff --git a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnection.php b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnection.php index 146f1c11b..edb9de21c 100644 --- a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnection.php +++ b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnection.php @@ -24,7 +24,7 @@ public function __construct( string $dsn, string $user, string $password, - ?array $options + ?array $options, ) { try { $handle = odbc_connect($dsn, $user, $password); diff --git a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnectionFactory.php b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnectionFactory.php index 86fb8aca1..26a03d82c 100644 --- a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnectionFactory.php +++ b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeConnectionFactory.php @@ -29,7 +29,7 @@ public static function getConnection( string $user, string $password, array $params, - ?Configuration $config = null + ?Configuration $config = null, ): Connection { /** @var array{ * 'port'?:string, @@ -54,11 +54,11 @@ public static function getConnection( 'host' => $host, 'user' => $user, 'password' => $password, - ] + ], ); return DriverManager::getConnection( $params, - $config + $config, ); } } diff --git a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeDriver.php b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeDriver.php index 90c5ea402..8f69a6c4d 100644 --- a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeDriver.php +++ b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeDriver.php @@ -28,7 +28,7 @@ class SnowflakeDriver implements Driver * } $params */ public function connect( - array $params + array $params, ): SnowflakeConnection { $dsn = SnowflakeDSNGenerator::generateDSN($params); diff --git a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeExceptionConverter.php b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeExceptionConverter.php index 298c6f430..b9f024642 100644 --- a/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeExceptionConverter.php +++ b/packages/php-table-backend-utils/src/Connection/Snowflake/SnowflakeExceptionConverter.php @@ -29,9 +29,9 @@ public function convert(Exception $exception, ?Query $query): DriverException 'Incorrect username or password was specified.', null, $exception->getCode(), - $exception + $exception, ), - $query + $query, ); } @@ -45,13 +45,13 @@ public function convert(Exception $exception, ?Query $query): DriverException new SnowflakeDriverException( vsprintf( "String '%s' cannot be inserted because it's bigger than column size", - $matches + $matches, ), null, $exception->getCode(), - $exception + $exception, ), - $query + $query, ); } @@ -63,13 +63,13 @@ public function convert(Exception $exception, ?Query $query): DriverException new SnowflakeDriverException( vsprintf( 'Query reached its timeout %d second(s)', - $matches + $matches, ), null, $exception->getCode(), - $exception + $exception, ), - $query + $query, ); } @@ -79,9 +79,9 @@ public function convert(Exception $exception, ?Query $query): DriverException sprintf('Cannot access object or it does not exist. Executing query "%s"', $query->getSQL()), null, $exception->getCode(), - $exception + $exception, ), - $query + $query, ); } diff --git a/packages/php-table-backend-utils/src/Connection/Synapse/SynapseDriver.php b/packages/php-table-backend-utils/src/Connection/Synapse/SynapseDriver.php index 96b7eca3e..a154e93d5 100644 --- a/packages/php-table-backend-utils/src/Connection/Synapse/SynapseDriver.php +++ b/packages/php-table-backend-utils/src/Connection/Synapse/SynapseDriver.php @@ -59,7 +59,7 @@ public function connect(array $params) $this->constructDsn($params, $dsnOptions), $params['user'] ?? '', $params['password'] ?? '', - $driverOptions + $driverOptions, ); } catch (NativePdoException $exception) { throw PDOException::new($exception); @@ -71,8 +71,8 @@ public function connect(array $params) $conn->exec( sprintf( 'EXEC sys.sp_set_session_context @key = \'wlm_context\', @value = %s', - SynapseQuote::quote($wlmContext) - ) + SynapseQuote::quote($wlmContext), + ), ); } return $conn; diff --git a/packages/php-table-backend-utils/src/Connection/Teradata/TeradataConnectionWrapper.php b/packages/php-table-backend-utils/src/Connection/Teradata/TeradataConnectionWrapper.php index 382559cc5..61b8cb037 100644 --- a/packages/php-table-backend-utils/src/Connection/Teradata/TeradataConnectionWrapper.php +++ b/packages/php-table-backend-utils/src/Connection/Teradata/TeradataConnectionWrapper.php @@ -20,7 +20,7 @@ class TeradataConnectionWrapper implements Connection public function __construct( string $dsn, string $user, - string $password + string $password, ) { try { $handle = odbc_connect($dsn, $user, $password); diff --git a/packages/php-table-backend-utils/src/Connection/Teradata/TeradataDriver.php b/packages/php-table-backend-utils/src/Connection/Teradata/TeradataDriver.php index dcd83dc6e..bcd6e8c8c 100644 --- a/packages/php-table-backend-utils/src/Connection/Teradata/TeradataDriver.php +++ b/packages/php-table-backend-utils/src/Connection/Teradata/TeradataDriver.php @@ -31,19 +31,19 @@ public function connect( array $params, ?string $username = null, ?string $password = null, - array $driverOptions = [] + array $driverOptions = [], ): Connection { $dsn = sprintf( 'DRIVER={Teradata};DBCName=%s;TDMSTPortNumber=%s;Charset=UTF8', $params['host'], - $params['port'] + $params['port'], ); return new ConnectionRetryWrapper( new TeradataConnectionWrapper($dsn, $params['user'] ?? '', $params['password'] ?? ''), new RetryProxy( - new TeradataRetryPolicy() - ) + new TeradataRetryPolicy(), + ), ); } diff --git a/packages/php-table-backend-utils/src/Connection/Teradata/TeradataPlatform.php b/packages/php-table-backend-utils/src/Connection/Teradata/TeradataPlatform.php index 78a5ae617..a00cf31c9 100644 --- a/packages/php-table-backend-utils/src/Connection/Teradata/TeradataPlatform.php +++ b/packages/php-table-backend-utils/src/Connection/Teradata/TeradataPlatform.php @@ -132,7 +132,7 @@ protected function doModifyLimitQuery($query, $limit, $offset): string $query = preg_replace( '/^(\s*SELECT\b)/im', sprintf('$1 TOP %s', $limit), - $query + $query, ); if ($query === null) { throw new RuntimeException('Adding LIMIT to SQL retunrs error.'); diff --git a/packages/php-table-backend-utils/src/Database/Exasol/ExasolDatabaseReflection.php b/packages/php-table-backend-utils/src/Database/Exasol/ExasolDatabaseReflection.php index af3d3ba01..49bd5d774 100644 --- a/packages/php-table-backend-utils/src/Database/Exasol/ExasolDatabaseReflection.php +++ b/packages/php-table-backend-utils/src/Database/Exasol/ExasolDatabaseReflection.php @@ -31,14 +31,14 @@ public function getUsersNames(?string $like = null): array // build escaped list of system users $where = sprintf( '"U"."USER_NAME" NOT IN (%s)', - implode(', ', array_map(static fn($item) => ExasolQuote::quote($item), self::$excludedUsers)) + implode(', ', array_map(static fn($item) => ExasolQuote::quote($item), self::$excludedUsers)), ); // add LIKE if ($like !== null) { $where .= sprintf( ' AND "U"."USER_NAME" LIKE %s', - ExasolQuote::quote("%$like%") + ExasolQuote::quote("%$like%"), ); } @@ -46,7 +46,7 @@ public function getUsersNames(?string $like = null): array /** @var array $users */ $users = $this->connection->fetchAllAssociative(sprintf( 'SELECT "U"."USER_NAME" FROM "SYS"."EXA_ALL_USERS" "U" WHERE %s', - $where + $where, )); // extract data to primitive array @@ -63,7 +63,7 @@ public function getRolesNames(?string $like = null): array if ($like !== null) { $where = sprintf( ' WHERE "ROLE_NAME" LIKE %s', - ExasolQuote::quote("%$like%") + ExasolQuote::quote("%$like%"), ); } @@ -71,7 +71,7 @@ public function getRolesNames(?string $like = null): array /** @var array $roles */ $roles = $this->connection->fetchAllAssociative(sprintf( 'SELECT "ROLE_NAME" FROM "SYS"."EXA_ALL_ROLES" %s', - $where + $where, )); return array_map(static fn($record) => $record['ROLE_NAME'], $roles); diff --git a/packages/php-table-backend-utils/src/Database/Snowflake/SnowflakeDatabaseReflection.php b/packages/php-table-backend-utils/src/Database/Snowflake/SnowflakeDatabaseReflection.php index 8cce096cd..3e051fe58 100644 --- a/packages/php-table-backend-utils/src/Database/Snowflake/SnowflakeDatabaseReflection.php +++ b/packages/php-table-backend-utils/src/Database/Snowflake/SnowflakeDatabaseReflection.php @@ -27,7 +27,7 @@ public function getUsersNames(?string $like = null): array if ($like !== null) { $likeSql .= sprintf( ' LIKE %s', - SnowflakeQuote::quote('%' . $like . '%') + SnowflakeQuote::quote('%' . $like . '%'), ); } @@ -35,7 +35,7 @@ public function getUsersNames(?string $like = null): array /** @var array $users */ $users = $this->connection->fetchAllAssociative(sprintf( 'SHOW USERS%s', - $likeSql + $likeSql, )); // extract data to primitive array @@ -51,7 +51,7 @@ public function getRolesNames(?string $like = null): array if ($like !== null) { $likeSql .= sprintf( ' LIKE %s', - SnowflakeQuote::quote('%' . $like . '%') + SnowflakeQuote::quote('%' . $like . '%'), ); } @@ -59,7 +59,7 @@ public function getRolesNames(?string $like = null): array /** @var array $roles */ $roles = $this->connection->fetchAllAssociative(sprintf( 'SHOW ROLES%s', - $likeSql + $likeSql, )); // extract data to primitive array diff --git a/packages/php-table-backend-utils/src/Database/SynapseDatabaseReflection.php b/packages/php-table-backend-utils/src/Database/SynapseDatabaseReflection.php index d1d02e676..9fee90732 100644 --- a/packages/php-table-backend-utils/src/Database/SynapseDatabaseReflection.php +++ b/packages/php-table-backend-utils/src/Database/SynapseDatabaseReflection.php @@ -25,13 +25,13 @@ public function getUsersNames(?string $like = null): array if ($like !== null) { $where = sprintf( ' WHERE [name] LIKE N%s AND [issqluser] = 1', - SynapseQuote::quote($like) + SynapseQuote::quote($like), ); } /** @var array $users */ $users = $this->connection->fetchAllAssociative(sprintf( 'SELECT [name] FROM [sys].[sysusers]%s', - $where + $where, )); return array_map(static fn($record) => $record['name'], $users); @@ -46,14 +46,14 @@ public function getRolesNames(?string $like = null): array if ($like !== null) { $where = sprintf( ' WHERE [name] LIKE N%s AND [issqlrole] = 1', - SynapseQuote::quote($like) + SynapseQuote::quote($like), ); } /** @var array $roles */ $roles = $this->connection->fetchAllAssociative(sprintf( 'SELECT [name] FROM [sys].[sysusers]%s', - $where + $where, )); return array_map(static fn($record) => $record['name'], $roles); diff --git a/packages/php-table-backend-utils/src/Database/Teradata/TeradataDatabaseReflection.php b/packages/php-table-backend-utils/src/Database/Teradata/TeradataDatabaseReflection.php index 4cd942ed9..bb0311159 100644 --- a/packages/php-table-backend-utils/src/Database/Teradata/TeradataDatabaseReflection.php +++ b/packages/php-table-backend-utils/src/Database/Teradata/TeradataDatabaseReflection.php @@ -41,14 +41,14 @@ public function getUsersNames(?string $like = null): array // build escaped list of system users $where = sprintf( 'U.UserName NOT IN (%s)', - implode(', ', array_map(static fn($item) => TeradataQuote::quote($item), self::$excludedUsers)) + implode(', ', array_map(static fn($item) => TeradataQuote::quote($item), self::$excludedUsers)), ); // add LIKE if ($like !== null) { $where .= sprintf( ' AND U.UserName LIKE %s', - TeradataQuote::quote("%$like%") + TeradataQuote::quote("%$like%"), ); } @@ -56,7 +56,7 @@ public function getUsersNames(?string $like = null): array /** @var array $users */ $users = $this->connection->fetchAllAssociative(sprintf( 'SELECT U.UserName FROM DBC.UsersV U WHERE %s', - $where + $where, )); // extract data to primitive array @@ -73,7 +73,7 @@ public function getRolesNames(?string $like = null): array if ($like !== null) { $where = sprintf( ' WHERE RoleName LIKE %s', - TeradataQuote::quote("%$like%") + TeradataQuote::quote("%$like%"), ); } @@ -81,7 +81,7 @@ public function getRolesNames(?string $like = null): array /** @var array $roles */ $roles = $this->connection->fetchAllAssociative(sprintf( 'SELECT RoleName FROM DBC.RoleInfoVX %s', - $where + $where, )); // extract data to primitive array. Has to be trimmed because it comes with some extra spaces diff --git a/packages/php-table-backend-utils/src/Escaping/Snowflake/SnowflakeQuote.php b/packages/php-table-backend-utils/src/Escaping/Snowflake/SnowflakeQuote.php index eff310b0f..71e562360 100644 --- a/packages/php-table-backend-utils/src/Escaping/Snowflake/SnowflakeQuote.php +++ b/packages/php-table-backend-utils/src/Escaping/Snowflake/SnowflakeQuote.php @@ -30,7 +30,7 @@ public static function createQuotedIdentifierFromParts(array $parts): string { return implode('.', array_map( fn(string $part) => self::quoteSingleIdentifier($part), - $parts + $parts, )); } } diff --git a/packages/php-table-backend-utils/src/QueryBuilderException.php b/packages/php-table-backend-utils/src/QueryBuilderException.php index cf45184f9..52c8caca1 100644 --- a/packages/php-table-backend-utils/src/QueryBuilderException.php +++ b/packages/php-table-backend-utils/src/QueryBuilderException.php @@ -17,7 +17,7 @@ class QueryBuilderException extends RuntimeException implements ApplicationExcep public function __construct( string $message, string $stringCode, - ?Throwable $previous = null + ?Throwable $previous = null, ) { parent::__construct($message, 0, $previous); $this->stringCode = $stringCode; diff --git a/packages/php-table-backend-utils/src/Schema/Bigquery/BigquerySchemaReflection.php b/packages/php-table-backend-utils/src/Schema/Bigquery/BigquerySchemaReflection.php index 707e188db..d59fbd2eb 100644 --- a/packages/php-table-backend-utils/src/Schema/Bigquery/BigquerySchemaReflection.php +++ b/packages/php-table-backend-utils/src/Schema/Bigquery/BigquerySchemaReflection.php @@ -36,7 +36,7 @@ public function getTablesNames(): array sprintf( 'SELECT * FROM %s.INFORMATION_SCHEMA.TABLES WHERE `table_type` != \'VIEW\';', BigqueryQuote::quoteSingleIdentifier($this->datasetName), - ) + ), ); $queryResults = $this->bqClient->runQuery($query); @@ -79,7 +79,7 @@ public function getViewsNames(): array sprintf( 'SELECT * FROM %s.INFORMATION_SCHEMA.VIEWS;', BigqueryQuote::quoteSingleIdentifier($this->datasetName), - ) + ), ); $queryResults = $this->bqClient->runQuery($query); diff --git a/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaQueryBuilder.php b/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaQueryBuilder.php index 624192f82..546980a3e 100644 --- a/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaQueryBuilder.php @@ -18,7 +18,7 @@ public function getDropSchemaCommand(string $schemaName, bool $cascade = true): return sprintf( 'DROP SCHEMA %s %s', ExasolQuote::quoteSingleIdentifier($schemaName), - $cascade ? 'CASCADE' : 'RESTRICT' + $cascade ? 'CASCADE' : 'RESTRICT', ); } } diff --git a/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaReflection.php b/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaReflection.php index aff994c08..367ef7338 100644 --- a/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaReflection.php +++ b/packages/php-table-backend-utils/src/Schema/Exasol/ExasolSchemaReflection.php @@ -30,8 +30,8 @@ public function getTablesNames(): array $tables = $this->connection->fetchAllAssociative( sprintf( 'SELECT "TABLE_NAME" FROM "SYS"."EXA_ALL_TABLES" WHERE "TABLE_SCHEMA" = %s', - ExasolQuote::quote($this->schemaName) - ) + ExasolQuote::quote($this->schemaName), + ), ); return array_map(static fn($table) => $table['TABLE_NAME'], $tables); @@ -46,8 +46,8 @@ public function getViewsNames(): array $tables = $this->connection->fetchAllAssociative( sprintf( 'SELECT "VIEW_NAME" FROM "SYS"."EXA_ALL_VIEWS" WHERE "VIEW_SCHEMA" = %s', - ExasolQuote::quote($this->schemaName) - ) + ExasolQuote::quote($this->schemaName), + ), ); return array_map(static fn($table) => $table['VIEW_NAME'], $tables); diff --git a/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaQueryBuilder.php b/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaQueryBuilder.php index fa16044b9..a96984e10 100644 --- a/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaQueryBuilder.php @@ -22,7 +22,7 @@ public function getDropSchemaCommand(string $schemaName, bool $cascade = true): return sprintf( 'DROP SCHEMA %s %s', SnowflakeQuote::quoteSingleIdentifier($schemaName), - $cascade ? 'CASCADE' : 'RESTRICT' + $cascade ? 'CASCADE' : 'RESTRICT', ); } } diff --git a/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaReflection.php b/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaReflection.php index 2d8a530db..8b89cacbb 100644 --- a/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaReflection.php +++ b/packages/php-table-backend-utils/src/Schema/Snowflake/SnowflakeSchemaReflection.php @@ -30,8 +30,8 @@ public function getTablesNames(): array $tables = $this->connection->fetchAllAssociative( sprintf( 'SHOW TABLES IN SCHEMA %s', - SnowflakeQuote::quoteSingleIdentifier($this->schemaName) - ) + SnowflakeQuote::quoteSingleIdentifier($this->schemaName), + ), ); return array_map(static fn($table) => $table['name'], $tables); @@ -46,8 +46,8 @@ public function getViewsNames(): array $tables = $this->connection->fetchAllAssociative( sprintf( 'SHOW VIEWS IN SCHEMA %s', - SnowflakeQuote::quoteSingleIdentifier($this->schemaName) - ) + SnowflakeQuote::quoteSingleIdentifier($this->schemaName), + ), ); return array_map(static fn($table) => $table['name'], $tables); diff --git a/packages/php-table-backend-utils/src/Schema/SynapseSchemaReflection.php b/packages/php-table-backend-utils/src/Schema/SynapseSchemaReflection.php index 59710ee55..0739f4d30 100644 --- a/packages/php-table-backend-utils/src/Schema/SynapseSchemaReflection.php +++ b/packages/php-table-backend-utils/src/Schema/SynapseSchemaReflection.php @@ -32,7 +32,7 @@ public function getTablesNames(): array FROM sys.tables WHERE schema_name(schema_id) = $schema order by name; -EOT +EOT, ); return array_map(static fn($table) => $table['name'], $tables); @@ -51,7 +51,7 @@ public function getViewsNames(): array FROM sys.views WHERE schema_name(schema_id) = $schema order by name; -EOT +EOT, ); return array_map(static fn($table) => $table['name'], $tables); diff --git a/packages/php-table-backend-utils/src/Schema/Teradata/TeradataSchemaReflection.php b/packages/php-table-backend-utils/src/Schema/Teradata/TeradataSchemaReflection.php index 0e441f99f..ef9f9f776 100644 --- a/packages/php-table-backend-utils/src/Schema/Teradata/TeradataSchemaReflection.php +++ b/packages/php-table-backend-utils/src/Schema/Teradata/TeradataSchemaReflection.php @@ -32,7 +32,7 @@ public function getTablesNames(): array SELECT "TableName" FROM "DBC"."TablesVX" WHERE ("TableKind" = 'T' OR "TableKind" = 'O') AND "DataBaseName"=$database -EOT +EOT, ); return array_map(static fn($table) => trim($table['TableName']), $tables); @@ -50,7 +50,7 @@ public function getViewsNames(): array SELECT "TableName" FROM "DBC"."TablesVX" WHERE "TableKind" = 'V' AND "DataBaseName"=$database -EOT +EOT, ); return array_map(static fn(array $table) => trim($table['TableName']), $tables); diff --git a/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableDefinition.php b/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableDefinition.php index 154ba9a3a..1ad1b2118 100644 --- a/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableDefinition.php +++ b/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableDefinition.php @@ -30,7 +30,7 @@ public function __construct( string $tableName, bool $isTemporary, ColumnCollection $columns, - array $primaryKeysNames + array $primaryKeysNames, ) { $this->schemaName = $schemaName; $this->tableName = $tableName; diff --git a/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableQueryBuilder.php b/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableQueryBuilder.php index d6adca570..f80e93d82 100644 --- a/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableQueryBuilder.php @@ -23,7 +23,7 @@ public function getDropTableCommand(string $schemaName, string $tableName): stri return sprintf( 'DROP TABLE %s.%s', BigqueryQuote::quoteSingleIdentifier($schemaName), - BigqueryQuote::quoteSingleIdentifier($tableName) + BigqueryQuote::quoteSingleIdentifier($tableName), ); } @@ -42,7 +42,7 @@ public function getCreateTableCommand( string $schemaName, string $tableName, ColumnCollection $columns, - array $primaryKeys = [] + array $primaryKeys = [], ): string { assert(count($primaryKeys) === 0, 'primary keys aren\'t supported in BQ'); $columnsSqlDefinitions = []; @@ -54,7 +54,7 @@ public function getCreateTableCommand( $columnsSqlDefinitions[] = sprintf( '%s %s', BigqueryQuote::quoteSingleIdentifier($columnName), - $columnDefinition->getSQLDefinition() + $columnDefinition->getSQLDefinition(), ); } $columnsSql = implode(",\n", $columnsSqlDefinitions); @@ -65,13 +65,13 @@ public function getCreateTableCommand( );', BigqueryQuote::quoteSingleIdentifier($schemaName), BigqueryQuote::quoteSingleIdentifier($tableName), - $columnsSql + $columnsSql, ); } public function getCreateTableCommandFromDefinition( TableDefinitionInterface $definition, - bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS + bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS, ): string { assert($definition instanceof BigqueryTableDefinition); return $this->getCreateTableCommand( @@ -80,7 +80,7 @@ public function getCreateTableCommandFromDefinition( $definition->getColumnsDefinitions(), $definePrimaryKeys === self::CREATE_TABLE_WITH_PRIMARY_KEYS ? $definition->getPrimaryKeysNames() - : [] + : [], ); } @@ -88,18 +88,18 @@ public function getAddColumnCommand(string $schemaName, string $tableName, Bigqu { assert( $columnDefinition->getColumnDefinition()->getDefault() === null, - 'You cannot add a REQUIRED column to an existing table schema.' + 'You cannot add a REQUIRED column to an existing table schema.', ); assert( $columnDefinition->getColumnDefinition()->isNullable() === true, - 'You cannot add a REQUIRED column to an existing table schema.' + 'You cannot add a REQUIRED column to an existing table schema.', ); return sprintf( 'ALTER TABLE %s.%s ADD COLUMN %s %s', BigqueryQuote::quoteSingleIdentifier($schemaName), BigqueryQuote::quoteSingleIdentifier($tableName), BigqueryQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - $columnDefinition->getColumnDefinition()->getSQLDefinition() + $columnDefinition->getColumnDefinition()->getSQLDefinition(), ); } @@ -109,7 +109,7 @@ public function getDropColumnCommand(string $schemaName, string $tableName, stri 'ALTER TABLE %s.%s DROP COLUMN %s', BigqueryQuote::quoteSingleIdentifier($schemaName), BigqueryQuote::quoteSingleIdentifier($tableName), - BigqueryQuote::quoteSingleIdentifier($columnName) + BigqueryQuote::quoteSingleIdentifier($columnName), ); } } diff --git a/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableReflection.php b/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableReflection.php index 47c2fed54..91be01a79 100644 --- a/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableReflection.php +++ b/packages/php-table-backend-utils/src/Table/Bigquery/BigqueryTableReflection.php @@ -30,7 +30,7 @@ class BigqueryTableReflection implements TableReflectionInterface public function __construct( private readonly BigQueryClient $bqClient, private readonly string $datasetName, - private readonly string $tableName + private readonly string $tableName, ) { $this->table = $bqClient->dataset($this->datasetName)->table($this->tableName); } @@ -113,7 +113,7 @@ public function getTableDefinition(): TableDefinitionInterface $this->tableName, $this->isTemporary(), $this->getColumnsDefinitions(), - $this->getPrimaryKeysNames() + $this->getPrimaryKeysNames(), ); } @@ -137,7 +137,7 @@ public function getPartitioningConfiguration(): PartitioningConfig|null $timePartitioning = new TimePartitioningConfig( $data['type'], $data['expirationMs'] ?? null, - $data['field'] ?? null + $data['field'] ?? null, ); } $rangePartitioning = null; @@ -147,7 +147,7 @@ public function getPartitioningConfiguration(): PartitioningConfig|null $data['field'], $data['range']['start'], $data['range']['end'], - $data['range']['interval'] + $data['range']['interval'], ); } @@ -159,7 +159,7 @@ public function getPartitioningConfiguration(): PartitioningConfig|null return new PartitioningConfig( $timePartitioning, $rangePartitioning, - $requirePartitionFilter + $requirePartitionFilter, ); } @@ -182,7 +182,7 @@ public function getPartitionsList(): array $query = $this->bqClient->query(sprintf( 'SELECT * FROM %s.INFORMATION_SCHEMA.PARTITIONS WHERE table_name = %s', BigqueryQuote::quoteSingleIdentifier($this->datasetName), - BigqueryQuote::quote($this->tableName) + BigqueryQuote::quote($this->tableName), )); $result = $this->bqClient->runQuery($query); diff --git a/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableDefinition.php b/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableDefinition.php index 211316f24..ddac6f80a 100644 --- a/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableDefinition.php +++ b/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableDefinition.php @@ -30,7 +30,7 @@ public function __construct( string $tableName, bool $isTemporary, ColumnCollection $columns, - array $primaryKeysNames + array $primaryKeysNames, ) { $this->schemaName = $schemaName; $this->tableName = $tableName; diff --git a/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableQueryBuilder.php b/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableQueryBuilder.php index 4fe1510ba..4f410b674 100644 --- a/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableQueryBuilder.php @@ -29,7 +29,7 @@ public function getDropTableCommand(string $schemaName, string $tableName): stri return sprintf( 'DROP TABLE %s.%s', ExasolQuote::quoteSingleIdentifier($schemaName), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), ); } @@ -39,9 +39,9 @@ public function getRenameTableCommand(string $schemaName, string $sourceTableNam throw new QueryBuilderException( sprintf( 'Invalid table name %s: Only alphanumeric characters dash and underscores are allowed.', - $newTableName + $newTableName, ), - self::INVALID_TABLE_NAME + self::INVALID_TABLE_NAME, ); } @@ -51,7 +51,7 @@ public function getRenameTableCommand(string $schemaName, string $sourceTableNam $quotedDbName, ExasolQuote::quoteSingleIdentifier($sourceTableName), $quotedDbName, - ExasolQuote::quoteSingleIdentifier($newTableName) + ExasolQuote::quoteSingleIdentifier($newTableName), ); } @@ -60,7 +60,7 @@ public function getTruncateTableCommand(string $schemaName, string $tableName): return sprintf( 'TRUNCATE TABLE %s.%s', ExasolQuote::quoteSingleIdentifier($schemaName), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), ); } @@ -71,15 +71,15 @@ public function getCreateTableCommand( string $schemaName, string $tableName, ColumnCollection $columns, - array $primaryKeys = [] + array $primaryKeys = [], ): string { if (!$this->validateTableName($tableName)) { throw new QueryBuilderException( sprintf( 'Invalid table name %s: Only alphanumeric characters dash and underscores are allowed.', - $tableName + $tableName, ), - self::INVALID_TABLE_NAME + self::INVALID_TABLE_NAME, ); } @@ -97,14 +97,14 @@ public function getCreateTableCommand( && $columnDefinition->isNullable()) { throw new QueryBuilderException( sprintf('Trying to set PK on column %s but this column is nullable', $columnName), - self::INVALID_PKS_FOR_TABLE + self::INVALID_PKS_FOR_TABLE, ); } $columnsSqlDefinitions[] = sprintf( '%s %s', ExasolQuote::quoteSingleIdentifier($columnName), - $columnDefinition->getSQLDefinition() + $columnDefinition->getSQLDefinition(), ); } @@ -114,9 +114,9 @@ public function getCreateTableCommand( throw new QueryBuilderException( sprintf( 'Trying to set %s as PKs but not present in columns', - implode(',', $pksNotPresentInColumns) + implode(',', $pksNotPresentInColumns), ), - self::INVALID_PKS_FOR_TABLE + self::INVALID_PKS_FOR_TABLE, ); } @@ -124,7 +124,10 @@ public function getCreateTableCommand( $columnsSqlDefinitions[] = sprintf( 'CONSTRAINT PRIMARY KEY (%s)', - implode(',', array_map(static fn($item) => ExasolQuote::quoteSingleIdentifier($item), $primaryKeys)) + implode( + ',', + array_map(static fn($item) => ExasolQuote::quoteSingleIdentifier($item), $primaryKeys), + ), ); } @@ -138,7 +141,7 @@ public function getCreateTableCommand( );', ExasolQuote::quoteSingleIdentifier($schemaName), ExasolQuote::quoteSingleIdentifier($tableName), - $columnsSql + $columnsSql, ); } @@ -147,7 +150,7 @@ public function getCreateTableCommand( */ public function getCreateTableCommandFromDefinition( TableDefinitionInterface $definition, - bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS + bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS, ): string { assert($definition instanceof ExasolTableDefinition); return $this->getCreateTableCommand( @@ -156,7 +159,7 @@ public function getCreateTableCommandFromDefinition( $definition->getColumnsDefinitions(), $definePrimaryKeys === self::CREATE_TABLE_WITH_PRIMARY_KEYS ? $definition->getPrimaryKeysNames() - : [] + : [], ); } diff --git a/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableReflection.php b/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableReflection.php index 052d0939d..8c947140e 100644 --- a/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableReflection.php +++ b/packages/php-table-backend-utils/src/Table/Exasol/ExasolTableReflection.php @@ -42,8 +42,8 @@ public function getColumnsNames(): array sprintf( 'DESCRIBE %s.%s', ExasolQuote::quoteSingleIdentifier($this->schemaName), - ExasolQuote::quoteSingleIdentifier($this->tableName) - ) + ExasolQuote::quoteSingleIdentifier($this->tableName), + ), ); return array_map(static fn($column) => $column['COLUMN_NAME'], $columns); @@ -81,8 +81,8 @@ public function getColumnsDefinitions(): ColumnCollection ORDER BY "COLUMN_ORDINAL_POSITION" ', ExasolQuote::quote($this->schemaName), - ExasolQuote::quote($this->tableName) - ) + ExasolQuote::quote($this->tableName), + ), ); $columns = array_map(static fn($col) => ExasolColumn::createFromDB($col), $columns); @@ -96,7 +96,7 @@ public function getRowsCount(): int $result = $this->connection->fetchOne(sprintf( 'SELECT COUNT(*) AS NumberOfRows FROM %s.%s', ExasolQuote::quoteSingleIdentifier($this->schemaName), - ExasolQuote::quoteSingleIdentifier($this->tableName) + ExasolQuote::quoteSingleIdentifier($this->tableName), )); return (int) $result; } @@ -119,7 +119,7 @@ public function getPrimaryKeysNames(): array ', ExasolQuote::quote($this->schemaName), ExasolQuote::quote($this->tableName), - ExasolQuote::quote('PRIMARY KEY') + ExasolQuote::quote('PRIMARY KEY'), ); /** @var array $data */ $data = $this->connection->fetchAllAssociative($sql); @@ -137,7 +137,7 @@ public function getTableStats(): TableStatsInterface ', ExasolQuote::quote($this->tableName), ExasolQuote::quote($this->schemaName), - ExasolQuote::quote('SCHEMA') + ExasolQuote::quote('SCHEMA'), ); /** @var int|string $result */ $result = $this->connection->fetchOne($sql); @@ -167,7 +167,7 @@ public function getDependentViews(): array FROM "SYS"."EXA_ALL_DEPENDENCIES" WHERE "REFERENCED_OBJECT_SCHEMA" = %s AND "REFERENCED_OBJECT_NAME" = %s', ExasolQuote::quote($this->schemaName), - ExasolQuote::quote($this->tableName) + ExasolQuote::quote($this->tableName), ); return $this->connection->fetchAllAssociative($sql); @@ -181,7 +181,7 @@ public function getTableDefinition(): TableDefinitionInterface $this->tableName, $this->isTemporary(), $this->getColumnsDefinitions(), - $this->getPrimaryKeysNames() + $this->getPrimaryKeysNames(), ); } @@ -193,7 +193,7 @@ public function exists(): bool FROM "SYS"."EXA_ALL_TABLES" WHERE "TABLE_SCHEMA" = %s AND "TABLE_NAME" = %s', ExasolQuote::quote($this->schemaName), - ExasolQuote::quote($this->tableName) + ExasolQuote::quote($this->tableName), ); return count($this->connection->fetchAllAssociative($sql)) === 1; diff --git a/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableQueryBuilder.php b/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableQueryBuilder.php index 4485f0811..81ab42cbf 100644 --- a/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableQueryBuilder.php @@ -30,7 +30,7 @@ public function getCreateTempTableCommand(string $schemaName, string $tableName, $columnsSqlDefinitions[] = sprintf( '%s %s', SnowflakeQuote::quoteSingleIdentifier($column->getColumnName()), - $columnDefinition->getSQLDefinition() + $columnDefinition->getSQLDefinition(), ); } @@ -43,7 +43,7 @@ public function getCreateTempTableCommand(string $schemaName, string $tableName, );', SnowflakeQuote::quoteSingleIdentifier($schemaName), SnowflakeQuote::quoteSingleIdentifier($tableName), - $columnsSql + $columnsSql, ); } @@ -52,7 +52,7 @@ public function getDropTableCommand(string $schemaName, string $tableName): stri return sprintf( 'DROP TABLE %s.%s', SnowflakeQuote::quoteSingleIdentifier($schemaName), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), ); } @@ -66,7 +66,7 @@ public function getRenameTableCommand(string $schemaName, string $sourceTableNam $quotedDbName, SnowflakeQuote::quoteSingleIdentifier($sourceTableName), $quotedDbName, - SnowflakeQuote::quoteSingleIdentifier($newTableName) + SnowflakeQuote::quoteSingleIdentifier($newTableName), ); } @@ -75,7 +75,7 @@ public function getTruncateTableCommand(string $schemaName, string $tableName): return sprintf( 'TRUNCATE TABLE %s.%s', SnowflakeQuote::quoteSingleIdentifier($schemaName), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), ); } @@ -86,7 +86,7 @@ public function getCreateTableCommand( string $schemaName, string $tableName, ColumnCollection $columns, - array $primaryKeys = [] + array $primaryKeys = [], ): string { $this->assertTableName($tableName); @@ -102,7 +102,7 @@ public function getCreateTableCommand( $columnsSqlDefinitions[] = sprintf( '%s %s', SnowflakeQuote::quoteSingleIdentifier($columnName), - $columnDefinition->getSQLDefinition() + $columnDefinition->getSQLDefinition(), ); } @@ -112,9 +112,9 @@ public function getCreateTableCommand( throw new QueryBuilderException( sprintf( 'Trying to set %s as PKs but not present in columns', - implode(',', $pksNotPresentInColumns) + implode(',', $pksNotPresentInColumns), ), - self::INVALID_PKS_FOR_TABLE + self::INVALID_PKS_FOR_TABLE, ); } @@ -124,8 +124,8 @@ public function getCreateTableCommand( 'PRIMARY KEY (%s)', implode(',', array_map( static fn($item) => SnowflakeQuote::quoteSingleIdentifier($item), - $primaryKeys - )) + $primaryKeys, + )), ); } @@ -139,7 +139,7 @@ public function getCreateTableCommand( );', SnowflakeQuote::quoteSingleIdentifier($schemaName), SnowflakeQuote::quoteSingleIdentifier($tableName), - $columnsSql + $columnsSql, ); } @@ -148,14 +148,14 @@ public function getCreateTableCommand( */ public function getCreateTableCommandFromDefinition( TableDefinitionInterface $definition, - bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS + bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS, ): string { assert($definition instanceof SnowflakeTableDefinition); if ($definition->isTemporary()) { return $this->getCreateTempTableCommand( $definition->getSchemaName(), $definition->getTableName(), - $definition->getColumnsDefinitions() + $definition->getColumnsDefinitions(), ); } @@ -165,7 +165,7 @@ public function getCreateTableCommandFromDefinition( $definition->getColumnsDefinitions(), $definePrimaryKeys === self::CREATE_TABLE_WITH_PRIMARY_KEYS ? $definition->getPrimaryKeysNames() - : [] + : [], ); } @@ -179,9 +179,9 @@ private function assertStagingTableName(string $tableName): void throw new QueryBuilderException( sprintf( 'Invalid table name %s: Table must start with __temp_ prefix', - $tableName + $tableName, ), - self::INVALID_TABLE_NAME + self::INVALID_TABLE_NAME, ); } } @@ -193,9 +193,9 @@ private function assertTableName(string $tableName): void sprintf( // phpcs:ignore 'Invalid table name %s: Only alphanumeric characters, dash, underscores and dollar signs are allowed.', - $tableName + $tableName, ), - self::INVALID_TABLE_NAME + self::INVALID_TABLE_NAME, ); } @@ -203,9 +203,9 @@ private function assertTableName(string $tableName): void throw new QueryBuilderException( sprintf( 'Invalid table name %s: Name can contain only printable characters.', - $tableName + $tableName, ), - self::INVALID_TABLE_NAME + self::INVALID_TABLE_NAME, ); } } diff --git a/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableReflection.php b/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableReflection.php index cd12c73b7..53787f957 100644 --- a/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableReflection.php +++ b/packages/php-table-backend-utils/src/Table/Snowflake/SnowflakeTableReflection.php @@ -63,8 +63,8 @@ private function cacheTableProps(bool $force = false): void //phpcs:ignore 'SELECT TABLE_TYPE,BYTES,ROW_COUNT FROM information_schema.tables WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s;', SnowflakeQuote::quote($this->schemaName), - SnowflakeQuote::quote($this->tableName) - ) + SnowflakeQuote::quote($this->tableName), + ), ); if (count($row) === 0) { throw TableNotExistsReflectionException::createForTable([$this->schemaName, $this->tableName]); @@ -91,7 +91,7 @@ private function cacheTableProps(bool $force = false): void default: throw new RuntimeException(sprintf( 'Table type "%s" is not known.', - $row[0]['TABLE_TYPE'] + $row[0]['TABLE_TYPE'], )); } } @@ -128,8 +128,8 @@ public function getColumnsDefinitions(): ColumnCollection $columnsMeta = $this->connection->fetchAllAssociative( sprintf( 'DESC TABLE %s', - SnowflakeQuote::createQuotedIdentifierFromParts([$this->schemaName, $this->tableName,]) - ) + SnowflakeQuote::createQuotedIdentifierFromParts([$this->schemaName, $this->tableName,]), + ), ); $columns = []; @@ -166,8 +166,8 @@ public function getPrimaryKeysNames(): array $columnsMeta = $this->connection->fetchAllAssociative( sprintf( 'SHOW PRIMARY KEYS IN TABLE %s', - SnowflakeQuote::createQuotedIdentifierFromParts([$this->schemaName, $this->tableName,]) - ) + SnowflakeQuote::createQuotedIdentifierFromParts([$this->schemaName, $this->tableName,]), + ), ); return array_map(fn($pkRow) => $pkRow['column_name'], $columnsMeta); @@ -205,7 +205,7 @@ public static function getDependentViewsForObject( Connection $connection, string $objectName, string $schemaName, - string $objectType = self::DEPENDENT_OBJECT_TABLE + string $objectType = self::DEPENDENT_OBJECT_TABLE, ): array { /** @var string $databaseName */ $databaseName = $connection->fetchOne('SELECT CURRENT_DATABASE()'); @@ -213,8 +213,8 @@ public static function getDependentViewsForObject( $views = $connection->fetchAllAssociative( sprintf( 'SHOW VIEWS IN DATABASE %s', - SnowflakeQuote::quoteSingleIdentifier($databaseName) - ) + SnowflakeQuote::quoteSingleIdentifier($databaseName), + ), ); $dependentViews = []; @@ -237,8 +237,8 @@ public static function getDependentViewsForObject( SnowflakeQuote::quote($objectType), SnowflakeQuote::quote($objectName), SnowflakeQuote::quote($schemaName), - SnowflakeQuote::quote($databaseName) - ) + SnowflakeQuote::quote($databaseName), + ), ); if ($dependentObjects !== []) { @@ -281,7 +281,7 @@ public function getTableDefinition(): TableDefinitionInterface $this->isTemporary(), $this->getColumnsDefinitions(), $this->getPrimaryKeysNames(), - $this->tableType + $this->tableType, ); } diff --git a/packages/php-table-backend-utils/src/Table/Synapse/Assert.php b/packages/php-table-backend-utils/src/Table/Synapse/Assert.php index 4687f23b1..66e6fed3b 100644 --- a/packages/php-table-backend-utils/src/Table/Synapse/Assert.php +++ b/packages/php-table-backend-utils/src/Table/Synapse/Assert.php @@ -14,7 +14,7 @@ public static function assertTableIndex(string $indexName): void throw new LogicException(sprintf( 'Unknown table index type: "%s" specified. Available types are %s.', $indexName, - implode('|', TableIndexDefinition::AVAILABLE_TABLE_INDEXES) + implode('|', TableIndexDefinition::AVAILABLE_TABLE_INDEXES), )); } } @@ -36,7 +36,7 @@ public static function assertValidClusteredIndex(string $indexName, array $index */ public static function assertValidHashDistribution( string $tableDistributionName, - array $hashDistributionColumnsNames + array $hashDistributionColumnsNames, ): void { if ($tableDistributionName === TableDistributionDefinition::TABLE_DISTRIBUTION_HASH && count($hashDistributionColumnsNames) !== 1 @@ -51,7 +51,7 @@ public static function assertTableDistribution(string $tableDistributionName): v throw new LogicException(sprintf( 'Unknown table distribution: "%s" specified. Available distributions are %s.', $tableDistributionName, - implode('|', TableDistributionDefinition::AVAILABLE_TABLE_DISTRIBUTIONS) + implode('|', TableDistributionDefinition::AVAILABLE_TABLE_DISTRIBUTIONS), )); } } diff --git a/packages/php-table-backend-utils/src/Table/Synapse/TableDistributionDefinition.php b/packages/php-table-backend-utils/src/Table/Synapse/TableDistributionDefinition.php index 357667245..e1cd03995 100644 --- a/packages/php-table-backend-utils/src/Table/Synapse/TableDistributionDefinition.php +++ b/packages/php-table-backend-utils/src/Table/Synapse/TableDistributionDefinition.php @@ -27,7 +27,7 @@ final class TableDistributionDefinition */ public function __construct( string $distributionName, - array $distributionColumnsNames = [] + array $distributionColumnsNames = [], ) { Assert::assertTableDistribution($distributionName); Assert::assertValidHashDistribution($distributionName, $distributionColumnsNames); diff --git a/packages/php-table-backend-utils/src/Table/Synapse/TableIndexDefinition.php b/packages/php-table-backend-utils/src/Table/Synapse/TableIndexDefinition.php index 1a06ccb64..368a68a5d 100644 --- a/packages/php-table-backend-utils/src/Table/Synapse/TableIndexDefinition.php +++ b/packages/php-table-backend-utils/src/Table/Synapse/TableIndexDefinition.php @@ -28,7 +28,7 @@ final class TableIndexDefinition */ public function __construct( string $indexType, - array $indexedColumnsNames = [] + array $indexedColumnsNames = [], ) { Assert::assertTableIndex($indexType); Assert::assertValidClusteredIndex($indexType, $indexedColumnsNames); diff --git a/packages/php-table-backend-utils/src/Table/SynapseTableDefinition.php b/packages/php-table-backend-utils/src/Table/SynapseTableDefinition.php index 8651d6654..dc5af847d 100644 --- a/packages/php-table-backend-utils/src/Table/SynapseTableDefinition.php +++ b/packages/php-table-backend-utils/src/Table/SynapseTableDefinition.php @@ -36,7 +36,7 @@ public function __construct( ColumnCollection $columns, array $primaryKeysNames, TableDistributionDefinition $tableDistribution, - TableIndexDefinition $tableIndex + TableIndexDefinition $tableIndex, ) { $this->schemaName = $schemaName; $this->tableName = $tableName; diff --git a/packages/php-table-backend-utils/src/Table/SynapseTableQueryBuilder.php b/packages/php-table-backend-utils/src/Table/SynapseTableQueryBuilder.php index f2cd2f263..616e11335 100644 --- a/packages/php-table-backend-utils/src/Table/SynapseTableQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Table/SynapseTableQueryBuilder.php @@ -19,7 +19,7 @@ class SynapseTableQueryBuilder implements TableQueryBuilderInterface public function getCreateTempTableCommand( string $schemaName, string $tableName, - ColumnCollection $columns + ColumnCollection $columns, ): string { $this->assertTemporaryTable($tableName); @@ -28,7 +28,7 @@ public function getCreateTempTableCommand( $columnsSql[] = sprintf( '%s %s', SynapseQuote::quoteSingleIdentifier($column->getColumnName()), - $column->getColumnDefinition()->getSQLDefinition() + $column->getColumnDefinition()->getSQLDefinition(), ); } @@ -36,7 +36,7 @@ public function getCreateTempTableCommand( 'CREATE TABLE %s.%s (%s) WITH (HEAP, LOCATION = USER_DB)', SynapseQuote::quoteSingleIdentifier($schemaName), SynapseQuote::quoteSingleIdentifier($tableName), - implode(', ', $columnsSql) + implode(', ', $columnsSql), ); } @@ -47,9 +47,9 @@ private function assertTemporaryTable(string $tableName): void sprintf( // phpcs:ignore 'Temporary table name invalid, temporary table name must start with "#" a not be empty "%s" supplied.', - $tableName + $tableName, ), - QueryBuilderException::STRING_CODE_INVALID_TEMP_TABLE + QueryBuilderException::STRING_CODE_INVALID_TEMP_TABLE, ); } } @@ -61,7 +61,7 @@ public function getCreateTableCommand( string $schemaName, string $tableName, ColumnCollection $columns, - array $primaryKeys = [] + array $primaryKeys = [], ): string { $columnsSql = []; foreach ($columns as $column) { @@ -72,7 +72,7 @@ public function getCreateTableCommand( $columnsSql[] = sprintf( '%s %s', SynapseQuote::quoteSingleIdentifier($column->getColumnName()), - $column->getColumnDefinition()->getSQLDefinition() + $column->getColumnDefinition()->getSQLDefinition(), ); } @@ -80,11 +80,11 @@ public function getCreateTableCommand( if (!empty($primaryKeys)) { $quotedPrimaryKeys = array_map( static fn($columnName) => SynapseQuote::quoteSingleIdentifier($columnName), - $primaryKeys + $primaryKeys, ); $primaryKeySql = sprintf( ', PRIMARY KEY NONCLUSTERED(%s) NOT ENFORCED', - implode(',', $quotedPrimaryKeys) + implode(',', $quotedPrimaryKeys), ); } @@ -93,7 +93,7 @@ public function getCreateTableCommand( SynapseQuote::quoteSingleIdentifier($schemaName), SynapseQuote::quoteSingleIdentifier($tableName), implode(', ', $columnsSql), - $primaryKeySql + $primaryKeySql, ); } @@ -102,7 +102,7 @@ public function getCreateTableCommand( */ public function getCreateTableCommandFromDefinition( TableDefinitionInterface $definition, - bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS + bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS, ): string { assert($definition instanceof SynapseTableDefinition); $columnsSql = []; @@ -110,7 +110,7 @@ public function getCreateTableCommandFromDefinition( $columnsSql[] = sprintf( '%s %s', SynapseQuote::quoteSingleIdentifier($column->getColumnName()), - $column->getColumnDefinition()->getSQLDefinition() + $column->getColumnDefinition()->getSQLDefinition(), ); } @@ -120,38 +120,38 @@ public function getCreateTableCommandFromDefinition( ) { $quotedPrimaryKeys = array_map( static fn($columnName) => SynapseQuote::quoteSingleIdentifier($columnName), - $definition->getPrimaryKeysNames() + $definition->getPrimaryKeysNames(), ); $primaryKeySql = sprintf( ', PRIMARY KEY NONCLUSTERED(%s) NOT ENFORCED', - implode(',', $quotedPrimaryKeys) + implode(',', $quotedPrimaryKeys), ); } if ($definition->getTableDistribution()->isHashDistribution()) { $quotedColumns = array_map( static fn($columnName) => SynapseQuote::quoteSingleIdentifier($columnName), - $definition->getTableDistribution()->getDistributionColumnsNames() + $definition->getTableDistribution()->getDistributionColumnsNames(), ); $distributionSql = sprintf( 'DISTRIBUTION = %s(%s)', $definition->getTableDistribution()->getDistributionName(), - implode(',', $quotedColumns) + implode(',', $quotedColumns), ); } else { $distributionSql = sprintf( 'DISTRIBUTION = %s', - $definition->getTableDistribution()->getDistributionName() + $definition->getTableDistribution()->getDistributionName(), ); } if ($definition->getTableIndex()->getIndexType() === TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_INDEX) { $quotedColumns = array_map( static fn($columnName) => SynapseQuote::quoteSingleIdentifier($columnName), - $definition->getTableIndex()->getIndexedColumnsNames() + $definition->getTableIndex()->getIndexedColumnsNames(), ); $indexSql = sprintf( '%s(%s)', $definition->getTableIndex()->getIndexType(), - implode(',', $quotedColumns) + implode(',', $quotedColumns), ); } else { $indexSql = $definition->getTableIndex()->getIndexType(); @@ -164,42 +164,42 @@ public function getCreateTableCommandFromDefinition( implode(', ', $columnsSql), $primaryKeySql, $distributionSql, - $indexSql + $indexSql, ); } public function getDropTableCommand( string $schemaName, - string $tableName + string $tableName, ): string { return sprintf( 'DROP TABLE %s.%s', SynapseQuote::quoteSingleIdentifier($schemaName), - SynapseQuote::quoteSingleIdentifier($tableName) + SynapseQuote::quoteSingleIdentifier($tableName), ); } public function getRenameTableCommand( string $schemaName, string $sourceTableName, - string $newTableName + string $newTableName, ): string { return sprintf( 'RENAME OBJECT %s.%s TO %s', SynapseQuote::quoteSingleIdentifier($schemaName), SynapseQuote::quoteSingleIdentifier($sourceTableName), - SynapseQuote::quoteSingleIdentifier($newTableName) + SynapseQuote::quoteSingleIdentifier($newTableName), ); } public function getTruncateTableCommand( string $schemaName, - string $tableName + string $tableName, ): string { return sprintf( 'TRUNCATE TABLE %s.%s', SynapseQuote::quoteSingleIdentifier($schemaName), - SynapseQuote::quoteSingleIdentifier($tableName) + SynapseQuote::quoteSingleIdentifier($tableName), ); } } diff --git a/packages/php-table-backend-utils/src/Table/SynapseTableReflection.php b/packages/php-table-backend-utils/src/Table/SynapseTableReflection.php index f351fb65b..890b00f5a 100644 --- a/packages/php-table-backend-utils/src/Table/SynapseTableReflection.php +++ b/packages/php-table-backend-utils/src/Table/SynapseTableReflection.php @@ -49,7 +49,7 @@ public function getColumnsNames(): array /** @var array $columns */ $columns = $this->connection->fetchAllAssociative(sprintf( 'SELECT [name] FROM [sys].[columns] WHERE [object_id] = %s ORDER BY [column_id]', - SynapseQuote::quote($tableId) + SynapseQuote::quote($tableId), )); return array_map(static fn($column) => $column['name'], $columns); @@ -72,27 +72,27 @@ public function getObjectId(): string if ($this->isTemporary) { $object = SynapseQuote::quote( 'tempdb..' - . SynapseQuote::quoteSingleIdentifier($this->tableName) + . SynapseQuote::quoteSingleIdentifier($this->tableName), ); } else { $object = SynapseQuote::quote( SynapseQuote::quoteSingleIdentifier($this->schemaName) . '.' . - SynapseQuote::quoteSingleIdentifier($this->tableName) + SynapseQuote::quoteSingleIdentifier($this->tableName), ); } /** @var string|null $objectId */ $objectId = $this->connection->fetchOne(sprintf( 'SELECT OBJECT_ID(N%s)', - $object + $object, )); if ($objectId === null) { throw new TableNotExistsReflectionException(sprintf( 'Table "%s.%s" does not exist.', $this->schemaName, - $this->tableName + $this->tableName, )); } @@ -147,7 +147,7 @@ public function getRowsCount(): int $count = $this->connection->fetchOne(sprintf( 'SELECT COUNT_BIG(*) AS [count] FROM %s.%s', SynapseQuote::quoteSingleIdentifier($this->schemaName), - SynapseQuote::quoteSingleIdentifier($this->tableName) + SynapseQuote::quoteSingleIdentifier($this->tableName), )); return (int) $count; @@ -172,7 +172,7 @@ public function getPrimaryKeysNames(): array sys.index_columns AS ic ON i.OBJECT_ID = ic.OBJECT_ID AND i.index_id = ic.index_id WHERE i.is_primary_key = 1 AND i.OBJECT_ID = '$tableId' ORDER BY ic.index_column_id -EOT +EOT, ); return array_map(static fn($item) => $item['column_name'], $result); @@ -197,15 +197,15 @@ public function getTableStats(): TableStatsInterface $info = $this->connection->fetchAssociative(sprintf( 'EXEC sp_spaceused \'%s.%s\'', SynapseQuote::quoteSingleIdentifier($this->schemaName), - SynapseQuote::quoteSingleIdentifier($this->tableName) + SynapseQuote::quoteSingleIdentifier($this->tableName), )); return new TableStats( (int) returnBytes( // removes all whitespaces and unit(bytes) - preg_replace('/[B\s]+/ui', '', $info['data']) + preg_replace('/[B\s]+/ui', '', $info['data']), ), - (int) $info['rows'] + (int) $info['rows'], ); } @@ -229,7 +229,7 @@ public function getDependentViews(): array $objectNameWithSchema = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($this->schemaName), - SynapseQuote::quoteSingleIdentifier($this->tableName) + SynapseQuote::quoteSingleIdentifier($this->tableName), ); /** @@ -268,7 +268,7 @@ public function getTableDistribution(): string SELECT distribution_policy_desc FROM sys.pdw_table_distribution_properties AS dp WHERE dp.OBJECT_ID = '$tableId' -EOT +EOT, ); return $distribution; } @@ -287,7 +287,7 @@ public function getTableDistributionColumnsNames(): array FROM sys.pdw_column_distribution_properties AS dp INNER JOIN sys.columns AS c ON dp.column_id = c.column_id WHERE dp.distribution_ordinal = 1 AND dp.OBJECT_ID = '$tableId' AND c.object_id = '$tableId' -EOT +EOT, ); return array_map(static fn($item) => $item['name'], $result); @@ -306,12 +306,12 @@ public function getTableDefinition(): TableDefinitionInterface $this->getPrimaryKeysNames(), new TableDistributionDefinition( $this->getTableDistribution(), - $this->getTableDistributionColumnsNames() + $this->getTableDistributionColumnsNames(), ), new TableIndexDefinition( $this->getTableIndex(), - $this->getTableIndexColumnsNames() - ) + $this->getTableIndexColumnsNames(), + ), ); } @@ -332,7 +332,7 @@ public function getTableIndex(): string FULL OUTER JOIN sys.pdw_table_distribution_properties dp ON t.object_id = dp.object_id WHERE t.object_id = '$tableId' -EOT +EOT, ); $indexType = $result[0]; @@ -349,7 +349,7 @@ public function getTableIndex(): string throw new LogicException(sprintf( 'Unknown index type for Synapse "%s"', - $indexType + $indexType, )); } @@ -382,7 +382,7 @@ public function getTableIndexColumnsNames(): array AND EXISTS (SELECT * FROM sys.columns c2 WHERE ic.object_id = c2.object_id ) -EOT +EOT, ); if ($result === []) { @@ -397,12 +397,12 @@ public function exists(): bool $object = SynapseQuote::quote( SynapseQuote::quoteSingleIdentifier($this->schemaName) . '.' . - SynapseQuote::quoteSingleIdentifier($this->tableName) + SynapseQuote::quoteSingleIdentifier($this->tableName), ); $objectId = $this->connection->fetchOne(sprintf( 'SELECT OBJECT_ID(N%s)', - $object + $object, )); return $objectId !== null; diff --git a/packages/php-table-backend-utils/src/Table/TableQueryBuilderInterface.php b/packages/php-table-backend-utils/src/Table/TableQueryBuilderInterface.php index 0988d9ab6..d802028c6 100644 --- a/packages/php-table-backend-utils/src/Table/TableQueryBuilderInterface.php +++ b/packages/php-table-backend-utils/src/Table/TableQueryBuilderInterface.php @@ -14,7 +14,7 @@ interface TableQueryBuilderInterface public function getCreateTempTableCommand( string $schemaName, string $tableName, - ColumnCollection $columns + ColumnCollection $columns, ): string; public function getDropTableCommand(string $schemaName, string $tableName): string; @@ -30,11 +30,11 @@ public function getCreateTableCommand( string $schemaName, string $tableName, ColumnCollection $columns, - array $primaryKeys = [] + array $primaryKeys = [], ): string; public function getCreateTableCommandFromDefinition( TableDefinitionInterface $definition, - bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS + bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS, ): string; } diff --git a/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableDefinition.php b/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableDefinition.php index 6a0ad99d8..a5d5390a6 100644 --- a/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableDefinition.php +++ b/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableDefinition.php @@ -30,7 +30,7 @@ public function __construct( string $tableName, bool $isTemporary, ColumnCollection $columns, - array $primaryKeysNames + array $primaryKeysNames, ) { $this->schemaName = $schemaName; $this->tableName = $tableName; diff --git a/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableQueryBuilder.php b/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableQueryBuilder.php index 08283c286..431144f69 100644 --- a/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableQueryBuilder.php +++ b/packages/php-table-backend-utils/src/Table/Teradata/TeradataTableQueryBuilder.php @@ -36,7 +36,7 @@ public function getDropTableCommand(string $schemaName, string $tableName): stri return sprintf( 'DROP TABLE %s.%s', TeradataQuote::quoteSingleIdentifier($schemaName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), ); } @@ -48,7 +48,7 @@ public function getRenameTableCommand(string $dbName, string $sourceTableName, s $quotedDbName, TeradataQuote::quoteSingleIdentifier($sourceTableName), $quotedDbName, - TeradataQuote::quoteSingleIdentifier($newTableName) + TeradataQuote::quoteSingleIdentifier($newTableName), ); } @@ -57,7 +57,7 @@ public function getTruncateTableCommand(string $schemaName, string $tableName): return sprintf( 'DELETE %s.%s ALL', TeradataQuote::quoteSingleIdentifier($schemaName), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), ); } @@ -68,7 +68,7 @@ public function getAddColumnCommand(string $schemaName, string $tableName, Terad TeradataQuote::quoteSingleIdentifier($schemaName), TeradataQuote::quoteSingleIdentifier($tableName), TeradataQuote::quoteSingleIdentifier($columnDefinition->getColumnName()), - $columnDefinition->getColumnDefinition()->getSQLDefinition() + $columnDefinition->getColumnDefinition()->getSQLDefinition(), ); } @@ -78,7 +78,7 @@ public function getDropColumnCommand(string $schemaName, string $tableName, stri 'ALTER TABLE %s.%s DROP %s', TeradataQuote::quoteSingleIdentifier($schemaName), TeradataQuote::quoteSingleIdentifier($tableName), - TeradataQuote::quoteSingleIdentifier($columnName) + TeradataQuote::quoteSingleIdentifier($columnName), ); } @@ -89,7 +89,7 @@ public function getCreateTableCommand( string $schemaName, string $tableName, ColumnCollection $columns, - array $primaryKeys = [] + array $primaryKeys = [], ): string { $columnNames = []; $columnsSqlDefinitions = []; @@ -102,7 +102,7 @@ public function getCreateTableCommand( $columnsSqlDefinitions[] = sprintf( '%s %s', TeradataQuote::quoteSingleIdentifier($columnName), - $columnDefinition->getSQLDefinition() + $columnDefinition->getSQLDefinition(), ); // check if PK can be defined on selected columns @@ -114,16 +114,16 @@ public function getCreateTableCommand( sprintf( 'Trying to set PK on column %s but type %s is not supported for PK', $columnName, - $columnType + $columnType, ), - self::INVALID_PKS_FOR_TABLE + self::INVALID_PKS_FOR_TABLE, ); } if ($columnDefinition->isNullable()) { throw new QueryBuilderException( sprintf('Trying to set PK on column %s but this column is nullable', $columnName), - self::INVALID_PKS_FOR_TABLE + self::INVALID_PKS_FOR_TABLE, ); } } @@ -135,9 +135,9 @@ public function getCreateTableCommand( throw new QueryBuilderException( sprintf( 'Trying to set %s as PKs but not present in columns', - implode(',', $pksNotPresentInColumns) + implode(',', $pksNotPresentInColumns), ), - self::INVALID_PKS_FOR_TABLE + self::INVALID_PKS_FOR_TABLE, ); } @@ -149,8 +149,8 @@ public function getCreateTableCommand( self::PK_CONSTRAINT_NAME, implode( ', ', - array_map(static fn($item) => TeradataQuote::quoteSingleIdentifier($item), $primaryKeys) - ) + array_map(static fn($item) => TeradataQuote::quoteSingleIdentifier($item), $primaryKeys), + ), ); } @@ -162,13 +162,13 @@ public function getCreateTableCommand( TeradataQuote::quoteSingleIdentifier($tableName), $columnsSql, // NoPI table support duplications in table - $primaryKeys !== [] ? '' : ' NO PRIMARY INDEX' + $primaryKeys !== [] ? '' : ' NO PRIMARY INDEX', ); } public function getCreateTableCommandFromDefinition( TableDefinitionInterface $definition, - bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS + bool $definePrimaryKeys = self::CREATE_TABLE_WITHOUT_PRIMARY_KEYS, ): string { assert($definition instanceof TeradataTableDefinition); return $this->getCreateTableCommand( @@ -177,7 +177,7 @@ public function getCreateTableCommandFromDefinition( $definition->getColumnsDefinitions(), $definePrimaryKeys === self::CREATE_TABLE_WITH_PRIMARY_KEYS ? $definition->getPrimaryKeysNames() - : [] + : [], ); } @@ -191,7 +191,7 @@ public function getAddPrimaryKeyCommand(string $schemaName, string $tableName, a TeradataQuote::quoteSingleIdentifier($schemaName), TeradataQuote::quoteSingleIdentifier($tableName), self::PK_CONSTRAINT_NAME, - implode(',', array_map(fn($item) => TeradataQuote::quoteSingleIdentifier($item), $columns)) + implode(',', array_map(fn($item) => TeradataQuote::quoteSingleIdentifier($item), $columns)), ); } @@ -201,7 +201,7 @@ public function getDropPrimaryKeyCommand(string $schemaName, string $tableName): 'ALTER TABLE %s.%s DROP CONSTRAINT %s;', TeradataQuote::quoteSingleIdentifier($schemaName), TeradataQuote::quoteSingleIdentifier($tableName), - self::PK_CONSTRAINT_NAME + self::PK_CONSTRAINT_NAME, ); } @@ -212,7 +212,7 @@ public function getCommandForDuplicates(string $schemaName, string $tableName, a { $formattedColumns = implode( ',', - array_map(fn($item) => TeradataQuote::quoteSingleIdentifier($item), $columns) + array_map(fn($item) => TeradataQuote::quoteSingleIdentifier($item), $columns), ); return sprintf( <<dbName), - TeradataQuote::quoteSingleIdentifier($this->tableName) - ) + TeradataQuote::quoteSingleIdentifier($this->tableName), + ), ); return array_map(static fn($table) => trim($table['Column Name']), $columns); @@ -67,8 +67,8 @@ public function getColumnsDefinitions(): ColumnCollection sprintf( 'HELP TABLE %s.%s', TeradataQuote::quoteSingleIdentifier($this->dbName), - TeradataQuote::quoteSingleIdentifier($this->tableName) - ) + TeradataQuote::quoteSingleIdentifier($this->tableName), + ), ); // types with structure of length , hidden in extra columns in table description @@ -109,7 +109,7 @@ public function getColumnsDefinitions(): ColumnCollection $fractionalTypes, $timeTypes, $charTypes, - $totalTypes + $totalTypes, ): TeradataColumn { $colName = trim($col['Column Name']); $colType = trim($col['Type']); @@ -140,8 +140,8 @@ public function getColumnsDefinitions(): ColumnCollection 'nullable' => $col['Nullable'] === 'Y', 'isLatin' => $isLatin, 'default' => is_string($defaultvalue) ? trim($defaultvalue) : $defaultvalue, - ] - ) + ], + ), ); }, $columns); @@ -154,7 +154,7 @@ public function getRowsCount(): int $result = $this->connection->fetchOne(sprintf( 'SELECT COUNT(*) AS NumberOfRows FROM %s.%s', TeradataQuote::quoteSingleIdentifier($this->dbName), - TeradataQuote::quoteSingleIdentifier($this->tableName) + TeradataQuote::quoteSingleIdentifier($this->tableName), )); return (int) $result; } @@ -173,7 +173,7 @@ public function getPrimaryKeysNames(): array AND DatabaseName = %s AND TableName = %s ORDER BY ColumnName;", TeradataQuote::quote($this->dbName), - TeradataQuote::quote($this->tableName) + TeradataQuote::quote($this->tableName), ); /** @var array $data */ @@ -190,7 +190,7 @@ public function getTableStats(): TableStatsInterface WHERE DATABASENAME = %s AND TABLENAME = %s ', TeradataQuote::quote($this->dbName), - TeradataQuote::quote($this->tableName) + TeradataQuote::quote($this->tableName), ); /** @var string|int $result */ $result = $this->connection->fetchOne($sql); @@ -222,7 +222,7 @@ public function getTableDefinition(): TableDefinitionInterface $this->tableName, $this->isTemporary(), $this->getColumnsDefinitions(), - $this->getPrimaryKeysNames() + $this->getPrimaryKeysNames(), ); } @@ -231,7 +231,7 @@ public function exists(): bool $sql = sprintf( 'SELECT * FROM DBC.TablesVX WHERE DataBaseName=%s AND TableName=%s;', TeradataQuote::quote($this->dbName), - TeradataQuote::quote($this->tableName) + TeradataQuote::quote($this->tableName), ); $data = $this->connection->fetchAllAssociative($sql); diff --git a/packages/php-table-backend-utils/src/TableNotExistsReflectionException.php b/packages/php-table-backend-utils/src/TableNotExistsReflectionException.php index f1ab33ba0..91b46b267 100644 --- a/packages/php-table-backend-utils/src/TableNotExistsReflectionException.php +++ b/packages/php-table-backend-utils/src/TableNotExistsReflectionException.php @@ -17,9 +17,9 @@ public static function createForTable(array $path): self ',', array_map( fn(string $item) => sprintf('"%s"', $item), - $path - ) - ) + $path, + ), + ), )); } } diff --git a/packages/php-table-backend-utils/src/View/Exasol/ExasolViewReflection.php b/packages/php-table-backend-utils/src/View/Exasol/ExasolViewReflection.php index 3038022ef..ecd79b763 100644 --- a/packages/php-table-backend-utils/src/View/Exasol/ExasolViewReflection.php +++ b/packages/php-table-backend-utils/src/View/Exasol/ExasolViewReflection.php @@ -42,7 +42,7 @@ public function getDependentViews(): array FROM "SYS"."EXA_ALL_DEPENDENCIES" WHERE "REFERENCED_OBJECT_SCHEMA" = %s AND "REFERENCED_OBJECT_NAME" = %s', ExasolQuote::quote($this->schemaName), - ExasolQuote::quote($this->viewName) + ExasolQuote::quote($this->viewName), ); return $this->connection->fetchAllAssociative($sql); @@ -53,7 +53,7 @@ public function getViewDefinition(): string $sql = sprintf( 'SELECT "VIEW_TEXT" FROM "SYS"."EXA_ALL_VIEWS" WHERE "VIEW_SCHEMA" = %s AND "VIEW_NAME" = %s', ExasolQuote::quote($this->schemaName), - ExasolQuote::quote($this->viewName) + ExasolQuote::quote($this->viewName), ); /** @var false|string $definition */ @@ -61,7 +61,7 @@ public function getViewDefinition(): string if ($definition === false) { throw InvalidViewDefinitionException::createForNotExistingView( $this->schemaName, - $this->viewName + $this->viewName, ); } return $definition; @@ -74,7 +74,7 @@ public function refreshView(): void $objectNameWithSchema = sprintf( '%s.%s', ExasolQuote::quoteSingleIdentifier($this->schemaName), - ExasolQuote::quoteSingleIdentifier($this->viewName) + ExasolQuote::quoteSingleIdentifier($this->viewName), ); $this->connection->executeQuery(sprintf('DROP VIEW %s', $objectNameWithSchema)); diff --git a/packages/php-table-backend-utils/src/View/InvalidViewDefinitionException.php b/packages/php-table-backend-utils/src/View/InvalidViewDefinitionException.php index 3ea967e71..ab7f63950 100644 --- a/packages/php-table-backend-utils/src/View/InvalidViewDefinitionException.php +++ b/packages/php-table-backend-utils/src/View/InvalidViewDefinitionException.php @@ -17,42 +17,42 @@ public function __construct(string $message, ?Throwable $previous = null) public static function createForNotExistingView( string $schemaName, - string $viewName + string $viewName, ): InvalidViewDefinitionException { return new self( sprintf( 'View "%s" in schema "%s" does not exists.', $viewName, - $schemaName - ) + $schemaName, + ), ); } public static function createForMissingDefinition( string $schemaName, - string $viewName + string $viewName, ): InvalidViewDefinitionException { return new self( sprintf( 'Definition of view "%s" in schema "%s"cannot be obtained from Synapse or it\'s invalid.', $viewName, - $schemaName - ) + $schemaName, + ), ); } public static function createViewRefreshError( string $schemaName, string $viewName, - Throwable $previous + Throwable $previous, ): InvalidViewDefinitionException { return new self( sprintf( 'View "%s" in schema "%s" has to be refreshed manually, since it\'s definition cannot be refreshed.', $viewName, - $schemaName + $schemaName, ), - $previous + $previous, ); } } diff --git a/packages/php-table-backend-utils/src/View/Snowflake/SnowflakeViewReflection.php b/packages/php-table-backend-utils/src/View/Snowflake/SnowflakeViewReflection.php index 5f1f0289d..e33b677b3 100644 --- a/packages/php-table-backend-utils/src/View/Snowflake/SnowflakeViewReflection.php +++ b/packages/php-table-backend-utils/src/View/Snowflake/SnowflakeViewReflection.php @@ -39,7 +39,7 @@ public function getDependentViews(): array $this->connection, $this->viewName, $this->schemaName, - SnowflakeTableReflection::DEPENDENT_OBJECT_VIEW + SnowflakeTableReflection::DEPENDENT_OBJECT_VIEW, ); } @@ -49,7 +49,7 @@ public function getViewDefinition(): string $result = $this->connection->fetchAssociative(sprintf( 'SHOW VIEWS LIKE %s IN %s', SnowflakeQuote::quote($this->viewName), - SnowflakeQuote::quoteSingleIdentifier($this->schemaName) + SnowflakeQuote::quoteSingleIdentifier($this->schemaName), )); return $result ? $result['text'] : ''; @@ -62,7 +62,7 @@ public function refreshView(): void $objectNameWithSchema = sprintf( '%s.%s', SnowflakeQuote::quoteSingleIdentifier($this->schemaName), - SnowflakeQuote::quoteSingleIdentifier($this->viewName) + SnowflakeQuote::quoteSingleIdentifier($this->viewName), ); $this->connection->executeQuery(sprintf('DROP VIEW %s', $objectNameWithSchema)); diff --git a/packages/php-table-backend-utils/src/View/SynapseViewReflection.php b/packages/php-table-backend-utils/src/View/SynapseViewReflection.php index ad5d7f711..c5f54e13a 100644 --- a/packages/php-table-backend-utils/src/View/SynapseViewReflection.php +++ b/packages/php-table-backend-utils/src/View/SynapseViewReflection.php @@ -35,7 +35,7 @@ public function getDependentViews(): array $objectNameWithSchema = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($this->schemaName), - SynapseQuote::quoteSingleIdentifier($this->viewName) + SynapseQuote::quoteSingleIdentifier($this->viewName), ); /** @@ -69,7 +69,7 @@ public function getViewDefinition(): string $sql = sprintf( 'SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s', SynapseQuote::quote($this->schemaName), - SynapseQuote::quote($this->viewName) + SynapseQuote::quote($this->viewName), ); /** @var string $definition */ @@ -94,7 +94,7 @@ public function refreshView(): void $objectNameWithSchema = sprintf( '%s.%s', SynapseQuote::quoteSingleIdentifier($this->schemaName), - SynapseQuote::quoteSingleIdentifier($this->viewName) + SynapseQuote::quoteSingleIdentifier($this->viewName), ); $this->connection->executeStatement(sprintf('DROP VIEW %s', $objectNameWithSchema)); diff --git a/packages/php-table-backend-utils/src/View/Teradata/TeradataViewReflection.php b/packages/php-table-backend-utils/src/View/Teradata/TeradataViewReflection.php index f403b05ef..050ea03b9 100644 --- a/packages/php-table-backend-utils/src/View/Teradata/TeradataViewReflection.php +++ b/packages/php-table-backend-utils/src/View/Teradata/TeradataViewReflection.php @@ -33,8 +33,8 @@ public function getDependentViews(): array sprintf( 'SELECT * FROM dbc.tables WHERE tablekind=%s AND databasename=%s', TeradataQuote::quote('V'), - TeradataQuote::quote($this->databaseName) - ) + TeradataQuote::quote($this->databaseName), + ), ); /** @@ -51,28 +51,28 @@ public function getDependentViews(): array sprintf( 'SHOW VIEW %s.%s', TeradataQuote::quoteSingleIdentifier($this->databaseName), - TeradataQuote::quoteSingleIdentifier(trim($view['TableName'])) - ) + TeradataQuote::quoteSingleIdentifier(trim($view['TableName'])), + ), ); // trim table name from teradata, returned with whitespaces $viewNameWithDatabase = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($this->databaseName), - TeradataQuote::quoteSingleIdentifier(trim($view['TableName'])) + TeradataQuote::quoteSingleIdentifier(trim($view['TableName'])), ); // remove create view statement $text = str_replace( 'CREATE VIEW ' . $viewNameWithDatabase . ' AS SELECT * FROM', '', - $viewDefinition[0]['Request Text'] + $viewDefinition[0]['Request Text'], ); $sourceNameWithDatabase = sprintf( '%s.%s', TeradataQuote::quoteSingleIdentifier($this->databaseName), - TeradataQuote::quoteSingleIdentifier($this->viewName) + TeradataQuote::quoteSingleIdentifier($this->viewName), ); if (strpos($text, $sourceNameWithDatabase) === false) { diff --git a/packages/php-table-backend-utils/tests/Functional/Bigquery/BigqueryBaseCase.php b/packages/php-table-backend-utils/tests/Functional/Bigquery/BigqueryBaseCase.php index 2b2d6fae6..a762de1a2 100644 --- a/packages/php-table-backend-utils/tests/Functional/Bigquery/BigqueryBaseCase.php +++ b/packages/php-table-backend-utils/tests/Functional/Bigquery/BigqueryBaseCase.php @@ -65,7 +65,7 @@ protected function getCredentials(): array protected function initTable( string $schema = self::TEST_SCHEMA, string $table = self::TABLE_GENERIC, - bool $createNewSchema = true + bool $createNewSchema = true, ): void { if ($createNewSchema) { $this->createDataset($schema); @@ -80,8 +80,8 @@ protected function initTable( `last_name` STRING(100) );', BigqueryQuote::quoteSingleIdentifier($schema), - BigqueryQuote::quoteSingleIdentifier($table) - ) + BigqueryQuote::quoteSingleIdentifier($table), + ), ); $this->bqClient->runQuery($query); @@ -105,7 +105,7 @@ protected function insertRowToTable( string $tableName, int $id, string $firstName, - string $lastName + string $lastName, ): void { $this->bqClient->runQuery($this->bqClient->query(sprintf( 'INSERT INTO %s.%s VALUES (%d, %s, %s)', @@ -113,7 +113,7 @@ protected function insertRowToTable( BigqueryQuote::quoteSingleIdentifier($tableName), $id, BigqueryQuote::quote($firstName), - BigqueryQuote::quote($lastName) + BigqueryQuote::quote($lastName), ))); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Bigquery/Schema/BigquerySchemaReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Bigquery/Schema/BigquerySchemaReflectionTest.php index edf2670aa..29fc6386e 100644 --- a/packages/php-table-backend-utils/tests/Functional/Bigquery/Schema/BigquerySchemaReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Bigquery/Schema/BigquerySchemaReflectionTest.php @@ -83,7 +83,7 @@ public function testListTablesOnNonExistingDatasetThrowException(): void public function testGetCreateTableCommandFromDefinition( BigqueryTableDefinition $definition, string $expectedSql, - bool $createPrimaryKeys + bool $createPrimaryKeys, ): void { $this->cleanDataset($this->getDatasetName()); $this->createDataset($this->getDatasetName()); @@ -95,7 +95,7 @@ public function testGetCreateTableCommandFromDefinition( $tableReflection = new BigqueryTableReflection( $this->bqClient, $this->getDatasetName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame($definition->getColumnsNames(), $tableReflection->getColumnsNames()); if ($createPrimaryKeys) { @@ -126,9 +126,9 @@ public function createTableTestFromDefinitionSqlProvider(): Generator [ BigqueryColumn::createGenericColumn('col1'), BigqueryColumn::createGenericColumn('col2'), - ] + ], ), - [] + [], ), 'query' => <<cleanDataset(self::TEST_SCHEMA); $this->createDataset(self::TEST_SCHEMA); @@ -48,7 +48,7 @@ public function testGetCreateCommand( self::TEST_SCHEMA, self::TABLE_GENERIC, new ColumnCollection($columns), - [] // primary keys aren't supported in BQ + [], // primary keys aren't supported in BQ ); self::assertSame($expectedSql, $sql); @@ -120,7 +120,7 @@ public function testAddAndDropColumn(): void self::TEST_SCHEMA, self::TABLE_GENERIC, new ColumnCollection($columns), - [] // primary keys aren't supported in BQ + [], // primary keys aren't supported in BQ ); $this->bqClient->runQuery($this->bqClient->query($sql)); @@ -130,23 +130,23 @@ public function testAddAndDropColumn(): void self::TEST_SCHEMA, self::TABLE_GENERIC, new BigqueryColumn('col3', new Bigquery( - Bigquery::TYPE_STRING - )) + Bigquery::TYPE_STRING, + )), ); $this->assertEquals( sprintf( 'ALTER TABLE `%s`.`%s` ADD COLUMN `col3` STRING', self::TEST_SCHEMA, - self::TABLE_GENERIC + self::TABLE_GENERIC, ), - $sql + $sql, ); $this->bqClient->runQuery($this->bqClient->query($sql)); $tableReflection = new BigqueryTableReflection( $this->bqClient, self::TEST_SCHEMA, - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame(['col1', 'col2', 'col3'], $tableReflection->getColumnsNames()); @@ -155,14 +155,14 @@ public function testAddAndDropColumn(): void $this->assertEquals(sprintf( 'ALTER TABLE `%s`.`%s` DROP COLUMN `col2`', self::TEST_SCHEMA, - self::TABLE_GENERIC + self::TABLE_GENERIC, ), $sql); $this->bqClient->runQuery($this->bqClient->query($sql)); $tableReflection = new BigqueryTableReflection( $this->bqClient, self::TEST_SCHEMA, - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame(['col1', 'col3'], $tableReflection->getColumnsNames()); } diff --git a/packages/php-table-backend-utils/tests/Functional/Bigquery/Table/BigqueryTableReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Bigquery/Table/BigqueryTableReflectionTest.php index 5e73f127a..890493f72 100644 --- a/packages/php-table-backend-utils/tests/Functional/Bigquery/Table/BigqueryTableReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Bigquery/Table/BigqueryTableReflectionTest.php @@ -48,7 +48,7 @@ public function testColumnDefinition( string $expectedType, ?string $expectedDefault, ?string $expectedLength, - bool $expectedNullable + bool $expectedNullable, ): void { $this->cleanDataset(self::TEST_SCHEMA); $this->createDataset(self::TEST_SCHEMA); @@ -60,7 +60,7 @@ public function testColumnDefinition( );', BigqueryQuote::quoteSingleIdentifier(self::TEST_SCHEMA), BigqueryQuote::quoteSingleIdentifier(self::TABLE_GENERIC), - $sqlDef + $sqlDef, ); $query = $this->bqClient->query($sql); @@ -84,11 +84,11 @@ public function testColumnDefinition( $this->bqClient ->dataset(self::TEST_SCHEMA) ->table(self::TABLE_GENERIC) - ->info()['schema']['fields'][1] + ->info()['schema']['fields'][1], ), RESTtoSQLDatatypeConverter::convertColumnToSQLFormat( - SQLtoRestDatatypeConverter::convertColumnToRestFormat($column) - ) + SQLtoRestDatatypeConverter::convertColumnToRestFormat($column), + ), ); } @@ -437,7 +437,7 @@ public function testTableWithPartitioning(): void ], ], 'requirePartitionFilter' => false, - ] + ], ); $rows = []; @@ -451,7 +451,7 @@ public function testTableWithPartitioning(): void SQL, BigqueryQuote::quoteSingleIdentifier(self::TEST_SCHEMA), BigqueryQuote::quoteSingleIdentifier('test-partitions'), - implode(',', $rows) + implode(',', $rows), ))); $ref = new BigqueryTableReflection($this->bqClient, self::TEST_SCHEMA, 'test-partitions'); $this->assertCount(1, $ref->getPartitionsList()); @@ -478,7 +478,7 @@ public function testTableWithoutPartitioning(): void ], ], ], - ] + ], ); $this->bqClient->runQuery($this->bqClient->query(sprintf( @@ -486,7 +486,7 @@ public function testTableWithoutPartitioning(): void INSERT %s.%s (`id`,`test`) VALUES (1,'test'); SQL, BigqueryQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - BigqueryQuote::quoteSingleIdentifier('test-partitions') + BigqueryQuote::quoteSingleIdentifier('test-partitions'), ))); $ref = new BigqueryTableReflection($this->bqClient, self::TEST_SCHEMA, 'test-partitions'); // expect none partition returned by reflection class @@ -506,10 +506,10 @@ public function partitioningProvider(): Generator new TimePartitioningConfig( 'DAY', null, - null + null, ), null, - false + false, ), 'expectedClustering' => null, ]; @@ -527,10 +527,10 @@ public function partitioningProvider(): Generator new TimePartitioningConfig( 'DAY', '100000', - 'timestamp' + 'timestamp', ), null, - true + true, ), 'expectedClustering' => null, ]; @@ -553,9 +553,9 @@ public function partitioningProvider(): Generator 'id', '1', '100', - '10' + '10', ), - true + true, ), 'expectedClustering' => null, ]; @@ -586,9 +586,9 @@ public function partitioningProvider(): Generator 'id', '1', '100', - '10' + '10', ), - true + true, ), 'expectedClustering' => new ClusteringConfig(['id', 'timestamp']), ]; @@ -601,7 +601,7 @@ public function partitioningProvider(): Generator public function testTableWithPartitioningConfig( array $config, ?PartitioningConfig $expectedPartitioning, - ?ClusteringConfig $expectedClustering + ?ClusteringConfig $expectedClustering, ): void { $dataset = $this->bqClient->createDataset(self::TEST_SCHEMA); $options = [ @@ -628,7 +628,7 @@ public function testTableWithPartitioningConfig( ]; $dataset->createTable( 'test-partitions', - array_merge($options, $config) + array_merge($options, $config), ); $ref = new BigqueryTableReflection($this->bqClient, self::TEST_SCHEMA, 'test-partitions'); diff --git a/packages/php-table-backend-utils/tests/Functional/Exasol/ExasolBaseCase.php b/packages/php-table-backend-utils/tests/Functional/Exasol/ExasolBaseCase.php index 0691d97f0..8ffeb01eb 100644 --- a/packages/php-table-backend-utils/tests/Functional/Exasol/ExasolBaseCase.php +++ b/packages/php-table-backend-utils/tests/Functional/Exasol/ExasolBaseCase.php @@ -31,13 +31,13 @@ private function getExasolConnection(): Connection (string) getenv('EXASOL_USERNAME'), (string) getenv('EXASOL_PASSWORD'), null, - true + true, ); } protected function initTable( string $database = self::TEST_SCHEMA, - string $table = self::TABLE_GENERIC + string $table = self::TABLE_GENERIC, ): void { $this->createSchema($database); $this->connection->executeQuery( @@ -48,8 +48,8 @@ protected function initTable( "last_name" VARCHAR(100) );', ExasolQuote::quoteSingleIdentifier($database), - ExasolQuote::quoteSingleIdentifier($table) - ) + ExasolQuote::quoteSingleIdentifier($table), + ), ); } @@ -62,8 +62,8 @@ protected function cleanSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'DROP SCHEMA %s CASCADE', - ExasolQuote::quoteSingleIdentifier($schemaName) - ) + ExasolQuote::quoteSingleIdentifier($schemaName), + ), ); } @@ -72,8 +72,8 @@ protected function schemaExists(string $schemaName): bool return (bool) $this->connection->fetchOne( sprintf( 'SELECT "SCHEMA_NAME" FROM "SYS"."EXA_ALL_SCHEMAS" WHERE "SCHEMA_NAME" = %s', - ExasolQuote::quote($schemaName) - ) + ExasolQuote::quote($schemaName), + ), ); } @@ -83,8 +83,8 @@ public function createSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'CREATE SCHEMA %s;', - ExasolQuote::quoteSingleIdentifier($schemaName) - ) + ExasolQuote::quoteSingleIdentifier($schemaName), + ), ); } @@ -92,7 +92,7 @@ public function testConnection(): void { self::assertEquals( 1, - $this->connection->fetchOne('SELECT 1') + $this->connection->fetchOne('SELECT 1'), ); } @@ -107,14 +107,14 @@ protected function setUpUser(string $userName): void // delete existing users $this->connection->executeQuery(sprintf( 'DROP USER IF EXISTS %s CASCADE', - ExasolQuote::quoteSingleIdentifier($userName) + ExasolQuote::quoteSingleIdentifier($userName), )); // create user $this->connection->executeQuery(sprintf( 'CREATE USER %s IDENTIFIED BY "%s";', ExasolQuote::quoteSingleIdentifier($userName), - bin2hex(random_bytes(8)) + bin2hex(random_bytes(8)), )); } @@ -123,13 +123,13 @@ protected function setUpRole(string $roleName): void // delete existing role $this->connection->executeQuery(sprintf( 'DROP ROLE IF EXISTS %s CASCADE', - ExasolQuote::quoteSingleIdentifier($roleName) + ExasolQuote::quoteSingleIdentifier($roleName), )); // create role $this->connection->executeQuery(sprintf( 'CREATE ROLE %s;', - ExasolQuote::quoteSingleIdentifier($roleName) + ExasolQuote::quoteSingleIdentifier($roleName), )); } @@ -138,7 +138,7 @@ protected function insertRowToTable( string $tableName, int $id, string $firstName, - string $lastName + string $lastName, ): void { $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (%d, %s, %s)', @@ -146,7 +146,7 @@ protected function insertRowToTable( ExasolQuote::quoteSingleIdentifier($tableName), $id, ExasolQuote::quote($firstName), - ExasolQuote::quote($lastName) + ExasolQuote::quote($lastName), )); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaQueryBuilderTest.php index ccc559038..4b445b607 100644 --- a/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaQueryBuilderTest.php @@ -48,8 +48,8 @@ private function getSchemaFromDatabase(): array $schemas = $this->connection->fetchAllAssociative( sprintf( 'SELECT "SCHEMA_NAME" FROM "SYS"."EXA_ALL_SCHEMAS" WHERE "SCHEMA_NAME" = %s', - ExasolQuote::quote(self::TEST_SCHEMA) - ) + ExasolQuote::quote(self::TEST_SCHEMA), + ), ); return array_map(static fn(array $schema) => trim($schema['SCHEMA_NAME']), $schemas); diff --git a/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaReflectionTest.php index 17cee2036..282e27422 100644 --- a/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Exasol/Schema/ExasolSchemaReflectionTest.php @@ -43,7 +43,7 @@ public function testListViews(): void ExasolQuote::quoteSingleIdentifier($schemaName), ExasolQuote::quoteSingleIdentifier($viewName), ExasolQuote::quoteSingleIdentifier($schemaName), - ExasolQuote::quoteSingleIdentifier($tableName) + ExasolQuote::quoteSingleIdentifier($tableName), ); $this->connection->executeQuery($sql); self::assertSame([$viewName], $this->schemaRef->getViewsNames()); diff --git a/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableQueryBuilderTest.php index 72459a0d4..e4599dddd 100644 --- a/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableQueryBuilderTest.php @@ -110,7 +110,7 @@ public function testGetCreateCommand( array $primaryKeys, array $expectedColumnNames, array $expectedPKs, - string $expectedSql + string $expectedSql, ): void { $this->cleanSchema(self::TEST_SCHEMA); $this->createSchema(self::TEST_SCHEMA); @@ -118,7 +118,7 @@ public function testGetCreateCommand( self::TEST_SCHEMA, self::TABLE_GENERIC, new ColumnCollection($columns), - $primaryKeys + $primaryKeys, ); self::assertSame($expectedSql, $sql); $this->connection->executeQuery($sql); @@ -213,9 +213,9 @@ public function createTableTestFromDefinitionSqlProvider(): Generator [ ExasolColumn::createGenericColumn('col1'), ExasolColumn::createGenericColumn('col2'), - ] + ], ), - [] + [], ), 'query' => << << << <<cleanSchema(self::TEST_SCHEMA); $this->createSchema(self::TEST_SCHEMA); diff --git a/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableReflectionTest.php index 3056dce2b..1086d067a 100644 --- a/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Exasol/Table/ExasolTableReflectionTest.php @@ -44,8 +44,8 @@ public function testGetPrimaryKeysNames(): void sprintf( 'ALTER TABLE %s.%s ADD CONSTRAINT PRIMARY KEY ("id")', ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $ref = new ExasolTableReflection($this->connection, self::TEST_SCHEMA, self::TABLE_GENERIC); self::assertEquals(['id'], $ref->getPrimaryKeysNames()); @@ -75,7 +75,7 @@ public function testColumnDefinition( string $expectedType, ?string $expectedDefault, ?string $expectedLength, - bool $expectedNullable + bool $expectedNullable, ): void { $this->cleanSchema(self::TEST_SCHEMA); $this->createSchema(self::TEST_SCHEMA); @@ -87,7 +87,7 @@ public function testColumnDefinition( );', ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC), - $sqlDef + $sqlDef, ); $this->connection->executeQuery($sql); @@ -588,8 +588,8 @@ private function initView(): void ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), ExasolQuote::quoteSingleIdentifier(self::VIEW_GENERIC), ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); } diff --git a/packages/php-table-backend-utils/tests/Functional/Exasol/View/ExasolViewReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Exasol/View/ExasolViewReflectionTest.php index 768387f56..eb0ed106c 100644 --- a/packages/php-table-backend-utils/tests/Functional/Exasol/View/ExasolViewReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Exasol/View/ExasolViewReflectionTest.php @@ -52,8 +52,8 @@ private function initView(string $viewName, string $parentName): void ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), ExasolQuote::quoteSingleIdentifier($viewName), ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - ExasolQuote::quoteSingleIdentifier($parentName) - ) + ExasolQuote::quoteSingleIdentifier($parentName), + ), ); } @@ -69,7 +69,7 @@ public function testGetViewDefinition(): void EOT // phpcs:enable , - $viewRef->getViewDefinition() + $viewRef->getViewDefinition(), ); } @@ -89,7 +89,7 @@ public function testRefreshView(): void $this->connection->executeQuery(sprintf( 'ALTER TABLE %s.%s ADD "xxx" VARCHAR(300) NULL;', ExasolQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + ExasolQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); $tableRef = new ExasolTableReflection($this->connection, self::TEST_SCHEMA, self::VIEW_GENERIC); // the view is updated as soon as it gets compiled again diff --git a/packages/php-table-backend-utils/tests/Functional/Snowflake/ConnectionTest.php b/packages/php-table-backend-utils/tests/Functional/Snowflake/ConnectionTest.php index 676e2e709..efe9d9c61 100644 --- a/packages/php-table-backend-utils/tests/Functional/Snowflake/ConnectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Snowflake/ConnectionTest.php @@ -39,27 +39,27 @@ public function testSnowflakeFetchAll(): void $sqlSelect = sprintf( 'SELECT * FROM %s.%s', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = :first_name', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindMultipleNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = :first_name AND "last_name" = :last_name ', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindNotNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = ?', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindMultipleNotNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = ? AND "last_name" = ?', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $result = $this->connection->fetchAllAssociative($sqlSelect); @@ -205,14 +205,14 @@ public function testStringToLong(): void $this->expectExceptionMessage(sprintf( // phpcs:ignore 'An exception occurred while executing a query: String \'%s\' cannot be inserted because it\'s bigger than column size', - $longString + $longString, )); $this->insertRowToTable( self::TEST_SCHEMA, self::TABLE_GENERIC, 1, 'franta', - $longString + $longString, ); } @@ -225,7 +225,7 @@ public function testInvalidCredentials(): void [ 'port' => (string) getenv('SNOWFLAKE_PORT'), 'warehouse' => (string) getenv('SNOWFLAKE_WAREHOUSE'), - ] + ], ); $this->expectException(DriverException::class); @@ -245,7 +245,7 @@ public function testInvalidAccessToDatabase(): void 'port' => (string) getenv('SNOWFLAKE_PORT'), 'warehouse' => (string) getenv('SNOWFLAKE_WAREHOUSE'), 'database' => 'invalidDatabase', - ] + ], ); $this->assertConnectionIsWorking($connection); @@ -254,7 +254,7 @@ public function testInvalidAccessToDatabase(): void $this->assertConnectionIsWorking($this->connection); $this->assertSame( (string) getenv('SNOWFLAKE_DATABASE'), - $this->connection->fetchOne('SELECT CURRENT_DATABASE()') + $this->connection->fetchOne('SELECT CURRENT_DATABASE()'), ); } @@ -301,7 +301,7 @@ public function testQueryTagging(): void 'port' => (string) getenv('SNOWFLAKE_PORT'), 'warehouse' => (string) getenv('SNOWFLAKE_WAREHOUSE'), 'database' => (string) getenv('SNOWFLAKE_DATABASE'), - ] + ], ); $connection->executeQuery('SELECT current_date;'); @@ -313,8 +313,7 @@ public function testQueryTagging(): void WHERE QUERY_TEXT = 'SELECT current_date;' ORDER BY START_TIME DESC LIMIT 1 -SQL - ); +SQL,); $this->assertEquals('{"runId":"runIdValue"}', $queries[0]['QUERY_TAG']); } @@ -329,7 +328,7 @@ public function testQueryTimeoutLimit(): void $this->assertSame(WarehouseTimeoutReached::class, get_class($e)); $this->assertSame( 'An exception occurred while executing a query: Query reached its timeout 3 second(s)', - $e->getMessage() + $e->getMessage(), ); } finally { $connection->executeStatement('ALTER SESSION UNSET STATEMENT_TIMEOUT_IN_SECONDS'); @@ -364,27 +363,27 @@ public function testSchema(): void 'warehouse' => (string) getenv('SNOWFLAKE_WAREHOUSE'), 'database' => (string) getenv('SNOWFLAKE_DATABASE'), 'schema' => 'tableUtils-testSchema', - ] + ], ); //tests if you set schema in constructor it really set in connection $this->assertSame( 'tableUtils-testSchema', - $connection->fetchOne('SELECT CURRENT_SCHEMA()') + $connection->fetchOne('SELECT CURRENT_SCHEMA()'), ); $this->connection->close(); $connection->close(); //main connection has still no schema $this->assertNull( - $this->connection->fetchOne('SELECT CURRENT_SCHEMA()') + $this->connection->fetchOne('SELECT CURRENT_SCHEMA()'), ); $this->expectException(Exception::class); $this->expectExceptionMessage( sprintf( 'Cannot access object or it does not exist. Executing query "USE SCHEMA %s"', - SnowflakeQuote::quoteSingleIdentifier('Other schema') - ) + SnowflakeQuote::quoteSingleIdentifier('Other schema'), + ), ); $connection->executeQuery(sprintf('USE SCHEMA %s', SnowflakeQuote::quoteSingleIdentifier('Other schema'))); } diff --git a/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaQueryBuilderTest.php index b69dc7a44..ce3ae1f90 100644 --- a/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaQueryBuilderTest.php @@ -44,7 +44,7 @@ private function getSchemaFromDatabase(): array { /** @var array $schemas */ $schemas = $this->connection->fetchAllAssociative( - 'SHOW SCHEMAS' + 'SHOW SCHEMAS', ); return array_map(static fn(array $schema) => trim($schema['name']), $schemas); @@ -96,8 +96,8 @@ public function testGetDropSchemaCommandWithRestrictWithFK(): void ' ALTER TABLE %s.%s ADD PRIMARY KEY ("id");', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier('users') - ) + SnowflakeQuote::quoteSingleIdentifier('users'), + ), ); $this->connection->executeQuery( sprintf( @@ -109,8 +109,8 @@ public function testGetDropSchemaCommandWithRestrictWithFK(): void CONSTRAINT "fkey_1" FOREIGN KEY ("id_user") REFERENCES "users" ("id") );', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier('roles') - ) + SnowflakeQuote::quoteSingleIdentifier('roles'), + ), ); try { @@ -127,8 +127,8 @@ public function testGetDropSchemaCommandWithRestrictWithFK(): void ' ALTER TABLE %s.%s DROP FOREIGN KEY ("id_user");', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier('roles') - ) + SnowflakeQuote::quoteSingleIdentifier('roles'), + ), ); $this->connection->executeQuery($qb->getDropSchemaCommand(self::TEST_SCHEMA, false)); diff --git a/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaReflectionTest.php index e1bba9cff..4ffbedd25 100644 --- a/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Snowflake/Schema/SnowflakeSchemaReflectionTest.php @@ -33,8 +33,8 @@ public function testListTables(): void "last_name" VARCHAR(100) );', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier('transient_table') - ) + SnowflakeQuote::quoteSingleIdentifier('transient_table'), + ), ); // create temporary table @@ -46,8 +46,8 @@ public function testListTables(): void "last_name" VARCHAR(100) );', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier('temporary_table') - ) + SnowflakeQuote::quoteSingleIdentifier('temporary_table'), + ), ); $tables = $this->schemaRef->getTablesNames(); @@ -73,7 +73,7 @@ public function testListViews(): void SnowflakeQuote::quoteSingleIdentifier($schemaName), SnowflakeQuote::quoteSingleIdentifier($viewName), SnowflakeQuote::quoteSingleIdentifier($schemaName), - SnowflakeQuote::quoteSingleIdentifier($tableName) + SnowflakeQuote::quoteSingleIdentifier($tableName), ); $this->connection->executeQuery($sql); self::assertSame([$viewName], $this->schemaRef->getViewsNames()); diff --git a/packages/php-table-backend-utils/tests/Functional/Snowflake/SnowflakeBaseCase.php b/packages/php-table-backend-utils/tests/Functional/Snowflake/SnowflakeBaseCase.php index 7779d376c..171e60219 100644 --- a/packages/php-table-backend-utils/tests/Functional/Snowflake/SnowflakeBaseCase.php +++ b/packages/php-table-backend-utils/tests/Functional/Snowflake/SnowflakeBaseCase.php @@ -41,7 +41,7 @@ private function getConnection(): Connection protected function initTable( string $schema = self::TEST_SCHEMA, string $table = self::TABLE_GENERIC, - bool $createNewSchema = true + bool $createNewSchema = true, ): void { if ($createNewSchema) { $this->createSchema($schema); @@ -56,8 +56,8 @@ protected function initTable( "last_name" VARCHAR(100) );', SnowflakeQuote::quoteSingleIdentifier($schema), - SnowflakeQuote::quoteSingleIdentifier($table) - ) + SnowflakeQuote::quoteSingleIdentifier($table), + ), ); } @@ -66,8 +66,8 @@ public function createSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'CREATE SCHEMA %s;', - SnowflakeQuote::quoteSingleIdentifier($schemaName) - ) + SnowflakeQuote::quoteSingleIdentifier($schemaName), + ), ); } @@ -80,8 +80,8 @@ protected function cleanSchema(string $schemaName): void $this->connection->executeQuery( sprintf( 'DROP SCHEMA %s CASCADE', - SnowflakeQuote::quoteSingleIdentifier($schemaName) - ) + SnowflakeQuote::quoteSingleIdentifier($schemaName), + ), ); } @@ -90,8 +90,8 @@ protected function schemaExists(string $schemaName): bool return (bool) $this->connection->fetchOne( sprintf( 'SHOW SCHEMAS LIKE %s', - SnowflakeQuote::quote($schemaName) - ) + SnowflakeQuote::quote($schemaName), + ), ); } @@ -104,7 +104,7 @@ public function assertConnectionIsWorking(Connection $connection): void { self::assertEquals( 1, - $connection->fetchOne('SELECT 1') + $connection->fetchOne('SELECT 1'), ); } @@ -119,14 +119,14 @@ protected function setUpUser(string $userName): void // delete existing user $this->connection->executeQuery(sprintf( 'DROP USER IF EXISTS %s', - SnowflakeQuote::quoteSingleIdentifier($userName) + SnowflakeQuote::quoteSingleIdentifier($userName), )); // create user $this->connection->executeQuery(sprintf( 'CREATE USER %s PASSWORD = %s', SnowflakeQuote::quoteSingleIdentifier($userName), - SnowflakeQuote::quote(bin2hex(random_bytes(8))) + SnowflakeQuote::quote(bin2hex(random_bytes(8))), )); } @@ -135,13 +135,13 @@ protected function setUpRole(string $roleName): void // delete existing role $this->connection->executeQuery(sprintf( 'DROP ROLE IF EXISTS %s', - SnowflakeQuote::quoteSingleIdentifier($roleName) + SnowflakeQuote::quoteSingleIdentifier($roleName), )); // create role $this->connection->executeQuery(sprintf( 'CREATE ROLE %s;', - SnowflakeQuote::quoteSingleIdentifier($roleName) + SnowflakeQuote::quoteSingleIdentifier($roleName), )); } @@ -150,7 +150,7 @@ protected function insertRowToTable( string $tableName, int $id, string $firstName, - string $lastName + string $lastName, ): void { $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (%d, %s, %s)', @@ -158,7 +158,7 @@ protected function insertRowToTable( SnowflakeQuote::quoteSingleIdentifier($tableName), $id, SnowflakeQuote::quote($firstName), - SnowflakeQuote::quote($lastName) + SnowflakeQuote::quote($lastName), )); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableQueryBuilderTest.php index a0496a4e7..4cf80df13 100644 --- a/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableQueryBuilderTest.php @@ -46,7 +46,7 @@ public function testGetRenameTableCommand(): void $sql = $this->qb->getRenameTableCommand(self::TEST_SCHEMA, self::TABLE_GENERIC, $testTableNew); self::assertEquals( "ALTER TABLE \"{$testDb}\".\"{$testTable}\" RENAME TO \"{$testDb}\".\"{$testTableNew}\"", - $sql + $sql, ); $this->connection->executeQuery($sql); @@ -116,7 +116,7 @@ public function testGetCreateCommand( array $primaryKeys, array $expectedColumnNames, array $expectedPKs, - string $expectedSql + string $expectedSql, ): void { $this->cleanSchema(self::TEST_SCHEMA); $this->createSchema(self::TEST_SCHEMA); @@ -124,7 +124,7 @@ public function testGetCreateCommand( self::TEST_SCHEMA, self::TABLE_GENERIC, new ColumnCollection($columns), - $primaryKeys + $primaryKeys, ); self::assertSame($expectedSql, $sql); $this->connection->executeQuery($sql); @@ -147,7 +147,7 @@ public function testCreateTempTable(): void new ColumnCollection([ SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), - ]) + ]), ); self::assertSame( 'CREATE TEMPORARY TABLE "' . self::TEST_SCHEMA . '"."' . $tableName . '" @@ -155,7 +155,7 @@ public function testCreateTempTable(): void "col1" VARCHAR NOT NULL DEFAULT \'\', "col2" VARCHAR NOT NULL DEFAULT \'\' );', - $sql + $sql, ); $this->connection->executeQuery($sql); @@ -234,7 +234,7 @@ public function createTableTestSqlProvider(): Generator [ 'nullable' => true, 'default' => '\'\'', - ] + ], )), SnowflakeColumn::createGenericColumn('col2'), ], @@ -274,9 +274,9 @@ public function createTableTestFromDefinitionSqlProvider(): Generator [ SnowflakeColumn::createGenericColumn('col1'), SnowflakeColumn::createGenericColumn('col2'), - ] + ], ), - [] + [], ), 'query' => << << << << << <<cleanSchema(self::TEST_SCHEMA); $this->createSchema(self::TEST_SCHEMA); @@ -426,7 +426,7 @@ public function testGetCreateTableCommandFromDefinition( $tableReflection = new SnowflakeTableReflection( $this->connection, self::TEST_SCHEMA, - $definition->getTableName() + $definition->getTableName(), ); self::assertSame($definition->getColumnsNames(), $tableReflection->getColumnsNames()); diff --git a/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableReflectionTest.php index e502623e0..89b347103 100644 --- a/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Snowflake/Table/SnowflakeTableReflectionTest.php @@ -77,8 +77,8 @@ public function testGetPrimaryKeysNames(): void sprintf( 'ALTER TABLE %s.%s ADD PRIMARY KEY ("id")', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) - ) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), + ), ); $ref = new SnowflakeTableReflection($this->connection, self::TEST_SCHEMA, self::TABLE_GENERIC); self::assertEquals(['id'], $ref->getPrimaryKeysNames()); @@ -155,7 +155,7 @@ public function testColumnDefinition( string $expectedType, ?string $expectedDefault, ?string $expectedLength, - bool $expectedNullable + bool $expectedNullable, ): void { $this->cleanSchema(self::TEST_SCHEMA); $this->createSchema(self::TEST_SCHEMA); @@ -167,7 +167,7 @@ public function testColumnDefinition( );', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), - $sqlDef + $sqlDef, ); $this->connection->executeQuery($sql); @@ -451,16 +451,16 @@ public function testDependenciesWithCaseSensitivity(): void self::assertCount(0, $refB->getDependentViews()); $this->connection->executeQuery( - 'CREATE VIEW TEST_UTIL_SCHEMA.A_ESCAPED AS SELECT * FROM TEST_UTIL_SCHEMA."case_sensitive";' + 'CREATE VIEW TEST_UTIL_SCHEMA.A_ESCAPED AS SELECT * FROM TEST_UTIL_SCHEMA."case_sensitive";', ); $this->connection->executeQuery( - 'CREATE VIEW TEST_UTIL_SCHEMA.B_UPPER AS SELECT * FROM TEST_UTIL_SCHEMA.CASE_SENSITIVE;' + 'CREATE VIEW TEST_UTIL_SCHEMA.B_UPPER AS SELECT * FROM TEST_UTIL_SCHEMA.CASE_SENSITIVE;', ); $this->connection->executeQuery( - 'CREATE VIEW TEST_UTIL_SCHEMA.B_UPPER_ESCAPED AS SELECT * FROM TEST_UTIL_SCHEMA."CASE_SENSITIVE";' + 'CREATE VIEW TEST_UTIL_SCHEMA.B_UPPER_ESCAPED AS SELECT * FROM TEST_UTIL_SCHEMA."CASE_SENSITIVE";', ); $this->connection->executeQuery( - 'CREATE VIEW TEST_UTIL_SCHEMA.B_UPPER_AUTO AS SELECT * FROM TEST_UTIL_SCHEMA.case_sensitive;' + 'CREATE VIEW TEST_UTIL_SCHEMA.B_UPPER_AUTO AS SELECT * FROM TEST_UTIL_SCHEMA.case_sensitive;', ); $dependentViewsA = $refA->getDependentViews(); @@ -476,7 +476,7 @@ public function testDependenciesWithCaseSensitivity(): void 'name' => 'A_ESCAPED', ], ], - $dependentViewsA + $dependentViewsA, ); self::assertSame( @@ -494,7 +494,7 @@ public function testDependenciesWithCaseSensitivity(): void 'name' => 'B_UPPER_ESCAPED', ], ], - $dependentViewsB + $dependentViewsB, ); } @@ -536,8 +536,8 @@ public function testDetectTempTable(): void sprintf( 'CREATE TEMPORARY TABLE %s.%s (id INT)', SnowflakeQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SnowflakeQuote::quoteSingleIdentifier($tableName) - ) + SnowflakeQuote::quoteSingleIdentifier($tableName), + ), ); $refTemp = new SnowflakeTableReflection($this->connection, self::TEST_SCHEMA, $tableName); self::assertTrue($refTemp->isTemporary()); @@ -563,7 +563,7 @@ private function initView( string $viewName = self::VIEW_GENERIC, string $tableName = self::TABLE_GENERIC, string $viewSchema = self::TEST_SCHEMA, - string $tableSchema = self::TEST_SCHEMA + string $tableSchema = self::TEST_SCHEMA, ): void { $this->connection->executeQuery( sprintf( @@ -571,8 +571,8 @@ private function initView( SnowflakeQuote::quoteSingleIdentifier($viewSchema), SnowflakeQuote::quoteSingleIdentifier($viewName), SnowflakeQuote::quoteSingleIdentifier($tableSchema), - SnowflakeQuote::quoteSingleIdentifier($tableName) - ) + SnowflakeQuote::quoteSingleIdentifier($tableName), + ), ); } @@ -620,7 +620,7 @@ public function testDetectVirtualColumn(): void FROM VALUES ('{"date":"2017-04-28","dealership":"Valley View Auto Sales"}'), ('{"date":"2017-04-28","dealership":"Tindel Toyota"}') v; -SQL +SQL, ); $ref = new SnowflakeTableReflection($this->connection, self::TEST_SCHEMA, 'CAR_SALES'); @@ -642,7 +642,7 @@ public function testDetectVirtualColumn(): void foreach ($columns as $column) { $this->assertSame( $expectedDefinitions[$column->getColumnName()], - $column->getColumnDefinition()->toArray() + $column->getColumnDefinition()->toArray(), ); } @@ -675,7 +675,7 @@ public function testDetectExternalTable(): void <<connection->executeQuery( <<connection, self::TEST_SCHEMA, self::VIEW_GENERIC); self::assertEquals( 'CREATE VIEW "utilsTest_refView" AS SELECT * FROM "utilsTest_refTableSchema"."utilsTest_refTab";', - $viewRef->getViewDefinition() + $viewRef->getViewDefinition(), ); } @@ -76,7 +76,7 @@ public function testRefreshView(): void // add new column to table A $this->connection->executeQuery(sprintf( 'ALTER TABLE %s ADD COLUMN "xxx" VARCHAR(300) NULL;', - SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SnowflakeQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); // check that table A has new column (3->4) $tableRef = new SnowflakeTableReflection($this->connection, self::TEST_SCHEMA, self::TABLE_GENERIC); diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/BaseAuthTestCase.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/BaseAuthTestCase.php index ab19fce2d..4ac6b09b1 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/BaseAuthTestCase.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/BaseAuthTestCase.php @@ -52,12 +52,12 @@ protected function dropRoles(string $prefix): void /** @var array $roles */ $roles = $this->connection->fetchAllAssociative(sprintf( 'SELECT [name] FROM [sys].[sysusers] WHERE [name] LIKE N%s AND [issqlrole] = 1', - SynapseQuote::quote($prefix . '%') + SynapseQuote::quote($prefix . '%'), )); foreach ($roles as $role) { $this->connection->executeStatement(sprintf( 'DROP ROLE %s', - SynapseQuote::quoteSingleIdentifier($role['name']) + SynapseQuote::quoteSingleIdentifier($role['name']), )); } } @@ -70,12 +70,12 @@ protected function setUpUser(string $loginPrefix): void /** @var array $users */ $users = $this->connection->fetchAllAssociative(sprintf( 'SELECT [name] FROM [sys].[sysusers] WHERE [name] LIKE N%s AND [issqluser] = 1', - SynapseQuote::quote($loginPrefix . '%') + SynapseQuote::quote($loginPrefix . '%'), )); foreach ($users as $user) { $this->connection->executeStatement(sprintf( 'DROP USER %s', - SynapseQuote::quoteSingleIdentifier($user['name']) + SynapseQuote::quoteSingleIdentifier($user['name']), )); } @@ -83,12 +83,12 @@ protected function setUpUser(string $loginPrefix): void /** @var array $logins */ $logins = $masterDb->fetchAllAssociative(sprintf( 'SELECT [name] FROM [sys].[sql_logins] WHERE [name] LIKE N%s', - SynapseQuote::quote($loginPrefix . '%') + SynapseQuote::quote($loginPrefix . '%'), )); foreach ($logins as $login) { $masterDb->executeStatement(sprintf( 'DROP LOGIN %s', - SynapseQuote::quoteSingleIdentifier($login['name']) + SynapseQuote::quoteSingleIdentifier($login['name']), )); } @@ -100,7 +100,7 @@ protected function setUpUser(string $loginPrefix): void $masterDb->executeStatement(sprintf( 'CREATE LOGIN %s WITH PASSWORD = %s', $loginQuoted, - SynapseQuote::quote(self::LOGIN_PASSWORD) + SynapseQuote::quote(self::LOGIN_PASSWORD), )); $masterDb->close(); @@ -108,7 +108,7 @@ protected function setUpUser(string $loginPrefix): void $this->connection->executeStatement(sprintf( 'CREATE USER %s FOR LOGIN %s', $loginQuoted, - $loginQuoted + $loginQuoted, )); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/SynapseGrantQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/SynapseGrantQueryBuilderTest.php index f6e0f1b42..3d452124e 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/SynapseGrantQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Auth/SynapseGrantQueryBuilderTest.php @@ -81,20 +81,20 @@ protected function setUp(): void $this->connection->executeStatement(sprintf( 'CREATE ROLE %s', - SynapseQuote::quoteSingleIdentifier($this->currentLogin . '_ROLE') + SynapseQuote::quoteSingleIdentifier($this->currentLogin . '_ROLE'), )); assert($this->currentLogin !== null); $this->connection->executeStatement(sprintf( 'CREATE SCHEMA %s AUTHORIZATION %s', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier($this->currentLogin) + SynapseQuote::quoteSingleIdentifier($this->currentLogin), )); $this->connection->executeStatement(sprintf( 'CREATE TABLE %s.%s ([col1] nvarchar(4000) NOT NULL DEFAULT \'\')', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier(self::TEST_TABLE) + SynapseQuote::quoteSingleIdentifier(self::TEST_TABLE), )); } @@ -344,7 +344,7 @@ public function testGrant( bool $allowGrantOption, bool $grantToRole, string $expectedGrant, - string $expectedRevoke + string $expectedRevoke, ): void { assert($this->currentLogin !== null); if ($useCurrentLoginOnEndPath) { @@ -354,7 +354,7 @@ public function testGrant( $options = (new GrantOptions( $permissions, - $grantTo + $grantTo, )) ->setOnTargetPath($grantOnTargetPath) ->grantOnSubject($grantSubject) @@ -371,7 +371,7 @@ public function testGrant( $options = (new RevokeOptions( $permissions, - $grantTo + $grantTo, )) ->setOnTargetPath($grantOnTargetPath) ->revokeOnSubject($grantSubject) diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Connection/WlmContextTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Connection/WlmContextTest.php index 09d4ed5fa..c34938a8f 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Connection/WlmContextTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Connection/WlmContextTest.php @@ -39,7 +39,7 @@ public function testSynapseWlmContext(): void $sessionSetQuery = $conn->fetchOne(sprintf($fetchSessionSetSql, $sessionId1)); $this->assertSame( 'EXEC sys.sp_set_session_context @key = \'wlm_context\', @value = \'test\'', - $sessionSetQuery + $sessionSetQuery, ); // reconnect and check if wlm_context is set on next session @@ -52,7 +52,7 @@ public function testSynapseWlmContext(): void $sessionSetQuery = $conn->fetchOne(sprintf($fetchSessionSetSql, $sessionId2)); $this->assertSame( 'EXEC sys.sp_set_session_context @key = \'wlm_context\', @value = \'test\'', - $sessionSetQuery + $sessionSetQuery, ); } @@ -65,7 +65,7 @@ public function testSynapseWlmContextNotSet(): void $sessionSetQuery = $this->connection->fetchOne(sprintf($fetchSessionSetSql, $sessionId1)); $this->assertNotSame( 'EXEC sys.sp_set_session_context @key = \'wlm_context\', @value = \'test\'', - $sessionSetQuery + $sessionSetQuery, ); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Database/SynapseDatabaseReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Database/SynapseDatabaseReflectionTest.php index d8a6c4b10..be5a07c15 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Database/SynapseDatabaseReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Database/SynapseDatabaseReflectionTest.php @@ -25,7 +25,7 @@ public function testGetRolesNames(): void $this->connection->executeStatement(sprintf( 'CREATE ROLE %s', - SynapseQuote::quoteSingleIdentifier($this->currentLogin . '_ROLE') + SynapseQuote::quoteSingleIdentifier($this->currentLogin . '_ROLE'), )); $ref = new SynapseDatabaseReflection($this->connection); $names = $ref->getRolesNames(self::LOGIN_PREFIX . '%'); diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaQueryBuilderTest.php index dec359dfe..a8a2775d0 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaQueryBuilderTest.php @@ -45,8 +45,8 @@ private function getSchemaFromDatabase(): array $schemas = $this->connection->fetchAllAssociative( sprintf( 'SELECT name FROM sys.schemas WHERE name = \'%s\'', - self::TEST_SCHEMA - ) + self::TEST_SCHEMA, + ), ); return array_map(static fn(array $schema) => $schema['name'], $schemas); diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaReflectionTest.php index 1bd995932..f2a9e3c6d 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Schema/SynapseSchemaReflectionTest.php @@ -43,23 +43,23 @@ public function testGetTablesNames(): void $this->connection->executeStatement($qb->getCreateTableCommand( self::TEST_SCHEMA, 'table1', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); $this->connection->executeStatement($qb->getCreateTableCommand( self::TEST_SCHEMA, 'table2', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); // init tables in testing schema 2 $this->connection->executeStatement($qb->getCreateTableCommand( self::TEST_SCHEMA_2, 'table1', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); $this->connection->executeStatement($qb->getCreateTableCommand( self::TEST_SCHEMA_2, 'table2', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); $tables = $ref->getTablesNames(); @@ -80,31 +80,31 @@ public function testGetViewsNames(): void $this->connection->executeStatement($qb->getCreateTableCommand( self::TEST_SCHEMA, 'table1', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); // init view in testing schema $this->connection->executeStatement(sprintf( 'CREATE VIEW [%s].[view1] AS SELECT [col1] FROM [%s].[table1]', self::TEST_SCHEMA, - self::TEST_SCHEMA + self::TEST_SCHEMA, )); $this->connection->executeStatement(sprintf( 'CREATE VIEW [%s].[view2] AS SELECT [col1] FROM [%s].[table1]', self::TEST_SCHEMA, - self::TEST_SCHEMA + self::TEST_SCHEMA, )); // init view in testing schema 2 $this->connection->executeStatement(sprintf( 'CREATE VIEW [%s].[view1] AS SELECT [col1] FROM [%s].[table1]', self::TEST_SCHEMA_2, - self::TEST_SCHEMA + self::TEST_SCHEMA, )); $this->connection->executeStatement(sprintf( 'CREATE VIEW [%s].[view2] AS SELECT [col1] FROM [%s].[table1]', self::TEST_SCHEMA_2, - self::TEST_SCHEMA + self::TEST_SCHEMA, )); $tables = $ref->getViewsNames(); diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/SynapseBaseCase.php b/packages/php-table-backend-utils/tests/Functional/Synapse/SynapseBaseCase.php index 9332f8154..7dfe9c0f6 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/SynapseBaseCase.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/SynapseBaseCase.php @@ -29,7 +29,7 @@ protected function dropAllWithinSchema(string $schema): void foreach ($tables as $table) { $this->connection->executeStatement( - $this->tableQb->getDropTableCommand($schema, $table) + $this->tableQb->getDropTableCommand($schema, $table), ); } @@ -44,13 +44,13 @@ protected function dropAllWithinSchema(string $schema): void $schemas = $this->connection->fetchAllAssociative( sprintf( 'SELECT name FROM sys.schemas WHERE name = \'%s\'', - $schema - ) + $schema, + ), ); foreach ($schemas as $item) { $this->connection->executeStatement( - $this->schemaQb->getDropSchemaCommand($item['name']) + $this->schemaQb->getDropSchemaCommand($item['name']), ); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableQueryBuilderTest.php index 24e108f1f..6c97e385f 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableQueryBuilderTest.php @@ -44,13 +44,13 @@ public function testGetCreateTempTableCommand(): void new ColumnCollection([ SynapseColumn::createGenericColumn('col1'), SynapseColumn::createGenericColumn('col2'), - ]) + ]), ); $this->assertEquals( // phpcs:ignore 'CREATE TABLE [utils-test_qb-schema].[#utils-test_test] ([col1] NVARCHAR(4000) NOT NULL DEFAULT \'\', [col2] NVARCHAR(4000) NOT NULL DEFAULT \'\') WITH (HEAP, LOCATION = USER_DB)', - $sql + $sql, ); $this->connection->executeStatement($sql); // try to create same table @@ -76,7 +76,7 @@ public function testGetCreateTableCommand(): void $this->assertEquals( // phpcs:ignore 'CREATE TABLE [utils-test_qb-schema].[utils-test_test] ([col1] NVARCHAR(4000) NOT NULL DEFAULT \'\', [col2] NVARCHAR(4000) NOT NULL DEFAULT \'\')', - $sql + $sql, ); $this->connection->executeStatement($sql); $ref = $this->getSynapseTableReflection(); @@ -89,7 +89,7 @@ public function testGetCreateTableCommand(): void private function getSynapseTableReflection( string $schema = self::TEST_SCHEMA, - string $table = self::TEST_TABLE + string $table = self::TEST_TABLE, ): SynapseTableReflection { return new SynapseTableReflection($this->connection, $schema, $table); } @@ -107,7 +107,7 @@ public function testGetCreateTableCommandWithTimestamp(): void $this->assertEquals( // phpcs:ignore 'CREATE TABLE [utils-test_qb-schema].[utils-test_test] ([col1] NVARCHAR(4000) NOT NULL DEFAULT \'\', [col2] NVARCHAR(4000) NOT NULL DEFAULT \'\', [_timestamp] DATETIME2)', - $sql + $sql, ); $this->connection->executeStatement($sql); $ref = $this->getSynapseTableReflection(); @@ -129,12 +129,12 @@ public function testGetCreateTableCommandWithTimestampAndPrimaryKeys(): void self::TEST_SCHEMA, self::TEST_TABLE, new ColumnCollection($cols), - ['pk1', 'col1'] + ['pk1', 'col1'], ); $this->assertEquals( // phpcs:ignore 'CREATE TABLE [utils-test_qb-schema].[utils-test_test] ([pk1] INT, [col1] NVARCHAR(4000) NOT NULL DEFAULT \'\', [col2] NVARCHAR(4000) NOT NULL DEFAULT \'\', [_timestamp] DATETIME2, PRIMARY KEY NONCLUSTERED([pk1],[col1]) NOT ENFORCED)', - $sql + $sql, ); $this->connection->executeStatement($sql); $ref = $this->getSynapseTableReflection(); @@ -250,7 +250,7 @@ public function testGetCreateTableCommandFromDefinition(string $sql, bool $defin // create table from definition $sql = $qb->getCreateTableCommandFromDefinition( $definitionSource, - $definePrimaryKeys + $definePrimaryKeys, ); $this->connection->executeStatement($sql); @@ -260,52 +260,52 @@ public function testGetCreateTableCommandFromDefinition(string $sql, bool $defin $this->assertDefinitionsSame( $definitionSource, $definitionCreated, - $definePrimaryKeys + $definePrimaryKeys, ); } private function assertDefinitionsSame( SynapseTableDefinition $expectedDefinition, SynapseTableDefinition $actualDefinition, - bool $expectPrimaryKeys = true + bool $expectPrimaryKeys = true, ): void { if ($expectPrimaryKeys) { self::assertCount( count($expectedDefinition->getPrimaryKeysNames()), - $actualDefinition->getPrimaryKeysNames() + $actualDefinition->getPrimaryKeysNames(), ); self::assertSame( $expectedDefinition->getPrimaryKeysNames(), - $actualDefinition->getPrimaryKeysNames() + $actualDefinition->getPrimaryKeysNames(), ); } else { self::assertCount(0, $actualDefinition->getPrimaryKeysNames()); } self::assertCount( count($expectedDefinition->getColumnsNames()), - $actualDefinition->getColumnsNames() + $actualDefinition->getColumnsNames(), ); self::assertSame($expectedDefinition->getColumnsNames(), $actualDefinition->getColumnsNames()); self::assertSame($expectedDefinition->isTemporary(), $actualDefinition->isTemporary()); self::assertSame( $expectedDefinition->getTableDistribution()->getDistributionColumnsNames(), - $actualDefinition->getTableDistribution()->getDistributionColumnsNames() + $actualDefinition->getTableDistribution()->getDistributionColumnsNames(), ); self::assertSame( $expectedDefinition->getTableDistribution()->getDistributionName(), - $actualDefinition->getTableDistribution()->getDistributionName() + $actualDefinition->getTableDistribution()->getDistributionName(), ); self::assertSame( $expectedDefinition->getTableIndex()->getIndexType(), - $actualDefinition->getTableIndex()->getIndexType() + $actualDefinition->getTableIndex()->getIndexType(), ); self::assertSame( $expectedDefinition->getTableIndex()->getIndexedColumnsNames(), - $actualDefinition->getTableIndex()->getIndexedColumnsNames() + $actualDefinition->getTableIndex()->getIndexedColumnsNames(), ); self::assertCount( count($expectedDefinition->getColumnsDefinitions()), - $actualDefinition->getColumnsDefinitions() + $actualDefinition->getColumnsDefinitions(), ); /** @var SynapseColumn[] $actualColumns */ $actualColumns = iterator_to_array($actualDefinition->getColumnsDefinitions()); @@ -317,7 +317,7 @@ private function assertDefinitionsSame( self::assertSame($expectedColumn->getColumnName(), $actualColumns[$key]->getColumnName()); self::assertSame( $expectedColumn->getColumnDefinition()->getSQLDefinition(), - $actualColumns[$key]->getColumnDefinition()->getSQLDefinition() + $actualColumns[$key]->getColumnDefinition()->getSQLDefinition(), ); } } @@ -331,7 +331,7 @@ public function testGetDropCommand(): void $this->assertEquals( 'DROP TABLE [utils-test_qb-schema].[utils-test_test]', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -358,8 +358,7 @@ private function createTestTable(): void PARTITION ( id RANGE LEFT FOR VALUES ( )), CLUSTERED COLUMNSTORE INDEX ) -EOT - ); +EOT,); } } @@ -373,7 +372,7 @@ public function testGetRenameTableCommand(): void $this->assertEquals( 'RENAME OBJECT [utils-test_qb-schema].[utils-test_test] TO [newTable]', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -411,8 +410,7 @@ private function createTestTableWithColumns(bool $includeTimestamp = false, bool PARTITION ( id RANGE LEFT FOR VALUES ( )), CLUSTERED COLUMNSTORE INDEX ) -EOT - ); +EOT,); } public function testGetTruncateTableCommandTempTable(): void @@ -429,7 +427,7 @@ public function testGetTruncateTableCommandTempTable(): void $sql = $qb->getTruncateTableCommand(self::TEST_SCHEMA, self::TEST_STAGING_TABLE); $this->assertEquals( 'TRUNCATE TABLE [utils-test_qb-schema].[#stagingTable]', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -447,17 +445,17 @@ public function testGetTruncateTableCommand(): void $this->connection->executeStatement(sprintf( 'INSERT INTO [%s].[%s]([id]) VALUES (1)', self::TEST_SCHEMA, - $t + $t, )); $this->connection->executeStatement(sprintf( 'INSERT INTO [%s].[%s]([id]) VALUES (2)', self::TEST_SCHEMA, - $t + $t, )); $this->connection->executeStatement(sprintf( 'INSERT INTO [%s].[%s]([id]) VALUES (3)', self::TEST_SCHEMA, - $t + $t, )); } @@ -470,7 +468,7 @@ public function testGetTruncateTableCommand(): void $sql = $qb->getTruncateTableCommand(self::TEST_SCHEMA, self::TEST_TABLE); $this->assertEquals( 'TRUNCATE TABLE [utils-test_qb-schema].[utils-test_test]', - $sql + $sql, ); $this->connection->executeStatement($sql); @@ -489,28 +487,28 @@ private function createCreateTempTableCommandWithData(bool $includeEmptyValues = SynapseColumn::createGenericColumn('pk2'), SynapseColumn::createGenericColumn('col1'), SynapseColumn::createGenericColumn('col2'), - ]) + ]), )); $this->connection->executeStatement( sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA, - $t - ) + $t, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (1,1,\'1\',\'1\')', self::TEST_SCHEMA, - $t - ) + $t, + ), ); $this->connection->executeStatement( sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (2,2,\'2\',\'2\')', self::TEST_SCHEMA, - $t - ) + $t, + ), ); if ($includeEmptyValues) { @@ -518,8 +516,8 @@ private function createCreateTempTableCommandWithData(bool $includeEmptyValues = sprintf( 'INSERT INTO [%s].[%s]([pk1],[pk2],[col1],[col2]) VALUES (2,2,\'\',NULL)', self::TEST_SCHEMA, - $t - ) + $t, + ), ); } } diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableReflectionTest.php index b7f1e4704..f6faed213 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/Table/SynapseTableReflectionTest.php @@ -51,7 +51,7 @@ public function testGetTableColumnsNames(): void protected function initTable( string $schema = self::TEST_SCHEMA, - string $table = self::TABLE_GENERIC + string $table = self::TABLE_GENERIC, ): void { $this->connection->executeStatement( sprintf( @@ -62,8 +62,8 @@ protected function initTable( [_time] datetime2 NOT NULL DEFAULT \'2020-02-01 00:00:00\' );', SynapseQuote::quoteSingleIdentifier($schema), - SynapseQuote::quoteSingleIdentifier($table) - ) + SynapseQuote::quoteSingleIdentifier($table), + ), ); } @@ -106,7 +106,7 @@ public function testGetPrimaryKeysNames(): void $this->connection->executeStatement(sprintf( 'ALTER TABLE %s.%s ADD CONSTRAINT [PK_1] PRIMARY KEY NONCLUSTERED ([_time], [int_def]) NOT ENFORCED', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); $this->assertSame(['_time', 'int_def'], $ref->getPrimaryKeysNames()); } @@ -119,12 +119,12 @@ public function testGetRowsCount(): void $this->connection->executeStatement(sprintf( 'INSERT INTO %s.%s VALUES (10, \'xxx\', 10,\'2020-02-01 00:00:00\')', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); $this->connection->executeStatement(sprintf( 'INSERT INTO %s.%s VALUES (10, \'xxx\', 10,\'2020-02-01 00:00:00\')', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); $this->assertEquals(2, $ref->getRowsCount()); } @@ -452,7 +452,7 @@ public function testGetTableColumnsDefinitionsOrder(): void $sql = sprintf( 'CREATE TABLE [%s].[%s] ([col] VARCHAR(50) NOT NULL, [_time] DATE DEFAULT NULL)', self::TEST_SCHEMA, - 'table_defs' + 'table_defs', ); $this->connection->executeStatement($sql); @@ -478,13 +478,13 @@ public function testGetTableColumnsDefinitions( string $expectedType, ?string $expectedDefault, ?string $expectedLength, - bool $useHeapTable = false + bool $useHeapTable = false, ): void { $sql = sprintf( 'CREATE TABLE [%s].[%s] ([col] %s)', self::TEST_SCHEMA, 'table_defs', - $sqlDef + $sqlDef, ); if ($useHeapTable) { @@ -502,22 +502,22 @@ public function testGetTableColumnsDefinitions( $this->assertEquals( $expectedDefinition, $definition->getColumnDefinition()->getSQLDefinition(), - sprintf('SQL definitions don\'t match real definition was "%s".', $sqlDef) + sprintf('SQL definitions don\'t match real definition was "%s".', $sqlDef), ); $this->assertEquals( $expectedType, $definition->getColumnDefinition()->getType(), - 'Types don\'t match.' + 'Types don\'t match.', ); $this->assertEquals( $expectedDefault, $definition->getColumnDefinition()->getDefault(), - 'Defaults don\'t match.' + 'Defaults don\'t match.', ); $this->assertEquals( $expectedLength, $definition->getColumnDefinition()->getLength(), - 'Length don\'t match.' + 'Length don\'t match.', ); } @@ -534,7 +534,7 @@ public function testTemporaryTableGetObjectId(): void $this->connection->executeStatement($this->tableQb->getCreateTempTableCommand( self::TEST_SCHEMA, '#table_defs', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); $ref = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, '#table_defs'); $objectId = $ref->getObjectId(); @@ -546,7 +546,7 @@ public function testTemporaryTableGetRowsCount(): void $this->connection->executeStatement($this->tableQb->getCreateTempTableCommand( self::TEST_SCHEMA, '#table_defs', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); $ref = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, '#table_defs'); $count = $ref->getRowsCount(); @@ -554,7 +554,7 @@ public function testTemporaryTableGetRowsCount(): void $this->connection->executeStatement(sprintf( 'INSERT INTO [%s].[%s] VALUES (\'xxx\')', self::TEST_SCHEMA, - '#table_defs' + '#table_defs', )); $count = $ref->getRowsCount(); $this->assertEquals(1, $count); @@ -579,7 +579,7 @@ public function testTemporaryTableGetColumnsNames(string $operation): void $this->connection->executeStatement($this->tableQb->getCreateTempTableCommand( self::TEST_SCHEMA, '#table_defs', - new ColumnCollection([SynapseColumn::createGenericColumn('col1')]) + new ColumnCollection([SynapseColumn::createGenericColumn('col1')]), )); $ref = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, '#table_defs'); $this->expectException(ReflectionException::class); @@ -617,12 +617,12 @@ public function testGetTableStats(): void $this->connection->executeStatement(sprintf( 'INSERT INTO %s.%s VALUES (10, \'xxx\', 10,\'2020-02-01 00:00:00\')', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); $this->connection->executeStatement(sprintf( 'INSERT INTO %s.%s VALUES (10, \'xxx\', 10,\'2020-02-01 00:00:00\')', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), )); $stats2 = $ref->getTableStats(); @@ -666,8 +666,8 @@ public function testGetTableDistribution(string $with, string $expectedDistribut ;', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), - $with - ) + $with, + ), ); $ref = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, self::TABLE_GENERIC); self::assertEquals($expectedDistribution, $ref->getTableDistribution()); @@ -712,8 +712,8 @@ public function testGetTableDistributionColumnsNames(string $with, array $expect ;', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), - $with - ) + $with, + ), ); $ref = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, self::TABLE_GENERIC); self::assertEquals($expectedDistributionKeys, $ref->getTableDistributionColumnsNames()); @@ -771,8 +771,8 @@ public function testGetTableIndexName(?string $with, string $expectedIndexType, ;', SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), SynapseQuote::quoteSingleIdentifier(self::TABLE_GENERIC), - $with === null ? '': 'WITH('.$with.')' - ) + $with === null ? '': 'WITH('.$with.')', + ), ); $ref = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, self::TABLE_GENERIC); self::assertEquals($expectedIndexType, $ref->getTableIndex()); @@ -787,8 +787,8 @@ private function initView(string $viewName, string $parentName): void SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), SynapseQuote::quoteSingleIdentifier($viewName), SynapseQuote::quoteSingleIdentifier(self::TEST_SCHEMA), - SynapseQuote::quoteSingleIdentifier($parentName) - ) + SynapseQuote::quoteSingleIdentifier($parentName), + ), ); } diff --git a/packages/php-table-backend-utils/tests/Functional/Synapse/View/SynapseViewReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Synapse/View/SynapseViewReflectionTest.php index 22838453a..a09e630c2 100644 --- a/packages/php-table-backend-utils/tests/Functional/Synapse/View/SynapseViewReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Synapse/View/SynapseViewReflectionTest.php @@ -64,8 +64,8 @@ private function initTable(): void [_time] datetime2 NOT NULL DEFAULT \'2020-02-01 00:00:00\' );', self::TEST_SCHEMA, - self::TABLE_GENERIC - ) + self::TABLE_GENERIC, + ), ); } @@ -77,8 +77,8 @@ private function initView(string $viewName, string $parentName): void self::TEST_SCHEMA, $viewName, self::TEST_SCHEMA, - $parentName - ) + $parentName, + ), ); } @@ -94,7 +94,7 @@ public function testGetViewDefinition(): void EOT // phpcs:enable , - $viewRef->getViewDefinition() + $viewRef->getViewDefinition(), ); // try same with lowe case @@ -104,8 +104,8 @@ public function testGetViewDefinition(): void self::TEST_SCHEMA, '[utils-test_ref-view2', self::TEST_SCHEMA, - self::TABLE_GENERIC - ) + self::TABLE_GENERIC, + ), ); $viewRef = new SynapseViewReflection($this->connection, self::TEST_SCHEMA, '[utils-test_ref-view2'); @@ -116,7 +116,7 @@ public function testGetViewDefinition(): void EOT // phpcs:enable , - $viewRef->getViewDefinition() + $viewRef->getViewDefinition(), ); } @@ -139,7 +139,7 @@ private function initHugeView(): void $colsNames[] = $colsName; $cols[] = sprintf( '[%s] INT NOT NULL DEFAULT 0', - $colsName + $colsName, ); } @@ -147,7 +147,7 @@ private function initHugeView(): void 'CREATE TABLE [%s].[%s] (%s);', self::TEST_SCHEMA, self::TABLE_GENERIC, - implode(',', $cols) + implode(',', $cols), )); $this->connection->executeStatement(sprintf( 'CREATE VIEW [%s].[%s] AS SELECT %s FROM [%s].[%s];', @@ -155,7 +155,7 @@ private function initHugeView(): void self::VIEW_GENERIC, implode(',', $colsNames), self::TEST_SCHEMA, - self::TABLE_GENERIC + self::TABLE_GENERIC, )); } @@ -167,7 +167,7 @@ public function testRefreshView(): void $this->connection->executeStatement(sprintf( 'ALTER TABLE [%s].[%s] ADD [xxx] varchar NULL;', self::TEST_SCHEMA, - self::TABLE_GENERIC + self::TABLE_GENERIC, )); $tableRef = new SynapseTableReflection($this->connection, self::TEST_SCHEMA, self::VIEW_GENERIC); self::assertCount(4, $tableRef->getColumnsNames()); diff --git a/packages/php-table-backend-utils/tests/Functional/Teradata/ConnectionTest.php b/packages/php-table-backend-utils/tests/Functional/Teradata/ConnectionTest.php index b0ae4ed05..26aa75353 100644 --- a/packages/php-table-backend-utils/tests/Functional/Teradata/ConnectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Teradata/ConnectionTest.php @@ -49,27 +49,27 @@ public function testTeradataFetchAll(): void $sqlSelect = sprintf( 'SELECT * FROM %s.%s', TeradataQuote::quoteSingleIdentifier($this->getDatabaseName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = :first_name', TeradataQuote::quoteSingleIdentifier($this->getDatabaseName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindMultipleNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = :first_name AND "last_name" = :last_name ', TeradataQuote::quoteSingleIdentifier($this->getDatabaseName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindNotNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = ?', TeradataQuote::quoteSingleIdentifier($this->getDatabaseName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $sqlSelectBindMultipleNotNamed = sprintf( 'SELECT * FROM %s.%s WHERE "first_name" = ? AND "last_name" = ?', TeradataQuote::quoteSingleIdentifier($this->getDatabaseName()), - TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC) + TeradataQuote::quoteSingleIdentifier(self::TABLE_GENERIC), ); $result = $this->connection->fetchAllAssociative($sqlSelect); @@ -87,7 +87,7 @@ public function testTeradataFetchAll(): void ], ], $result, - 'id' + 'id', ); $result = $this->connection->fetchAllAssociative($sqlSelectBindNamed, ['first_name' => 'franta']); diff --git a/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableQueryBuilderTest.php index 8ad12c12b..3294daf10 100644 --- a/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableQueryBuilderTest.php @@ -112,13 +112,13 @@ public function testGetCreateCommand( array $primaryKeys, array $expectedColumnNames, array $expectedPKs, - string $expectedSql + string $expectedSql, ): void { $sql = $this->qb->getCreateTableCommand( $this->getDatabaseName(), self::TABLE_GENERIC, new ColumnCollection($columns), - $primaryKeys + $primaryKeys, ); self::assertSame($expectedSql, $sql); $this->connection->executeQuery($sql); @@ -127,7 +127,7 @@ public function testGetCreateCommand( $tableReflection = new TeradataTableReflection( $this->connection, $this->getDatabaseName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame($expectedColumnNames, $tableReflection->getColumnsNames()); self::assertSame($expectedPKs, $tableReflection->getPrimaryKeysNames()); @@ -149,22 +149,22 @@ public function testAddAndDropColumn(): void $sql = $this->qb->getAddColumnCommand( $dbName, self::TABLE_GENERIC, - TeradataColumn::createGenericColumn('col3') + TeradataColumn::createGenericColumn('col3'), ); $this->assertEquals( sprintf( 'ALTER TABLE "%s"."%s" ADD "col3" VARCHAR (32000) NOT NULL DEFAULT \'\' CHARACTER SET UNICODE', $dbName, - self::TABLE_GENERIC + self::TABLE_GENERIC, ), - $sql + $sql, ); $this->connection->executeQuery($sql); $tableReflection = new TeradataTableReflection( $this->connection, $this->getDatabaseName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame(['col1', 'col2', 'col3'], $tableReflection->getColumnsNames()); @@ -176,7 +176,7 @@ public function testAddAndDropColumn(): void $tableReflection = new TeradataTableReflection( $this->connection, $this->getDatabaseName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame(['col1', 'col3'], $tableReflection->getColumnsNames()); } @@ -260,9 +260,9 @@ public function createTableTestFromDefinitionSqlProvider(): Generator [ TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), - ] + ], ), - [] + [], ), 'query' => << << << <<cleanDatabase($this->getDatabaseName()); $this->createDatabase($this->getDatabaseName()); @@ -358,7 +358,7 @@ public function testGetCreateTableCommandFromDefinition( $tableReflection = new TeradataTableReflection( $this->connection, $this->getDatabaseName(), - self::TABLE_GENERIC + self::TABLE_GENERIC, ); self::assertSame($definition->getColumnsNames(), $tableReflection->getColumnsNames()); if ($createPrimaryKeys) { @@ -382,9 +382,9 @@ public function testAddAndDropPK(): void [ TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), - ] + ], ), - ['col1'] + ['col1'], ); // create table @@ -426,9 +426,9 @@ public function testDeduplication(): void TeradataColumn::createGenericColumn('col1'), TeradataColumn::createGenericColumn('col2'), TeradataColumn::createGenericColumn('col3'), - ] + ], ), - [] + [], ); $sql = $this->qb->getCreateTableCommandFromDefinition($definition, true); @@ -439,7 +439,7 @@ public function testDeduplication(): void 'INSERT INTO %s.%s VALUES (%s)', TeradataQuote::quoteSingleIdentifier($testDb), TeradataQuote::quoteSingleIdentifier($tableName), - implode(',', $i) + implode(',', $i), )); } $duplicatedSql = $this->qb->getCommandForDuplicates($testDb, $tableName, ['col2', 'col3']); @@ -449,7 +449,7 @@ public function testDeduplication(): void $this->connection->executeStatement(sprintf( 'INSERT INTO %s.%s VALUES (5,3,3)', TeradataQuote::quoteSingleIdentifier($testDb), - TeradataQuote::quoteSingleIdentifier($tableName) + TeradataQuote::quoteSingleIdentifier($tableName), )); $duplicatedSql = $this->qb->getCommandForDuplicates($testDb, $tableName, ['col2', 'col3']); diff --git a/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableReflectionTest.php index 323fc961e..f1e693341 100644 --- a/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Teradata/Table/TeradataTableReflectionTest.php @@ -43,8 +43,8 @@ public function testGetPrimaryKeysNames(): void sprintf( 'ALTER TABLE %s.%s ADD PRIMARY KEY (id)', $this->getDatabaseName(), - self::TABLE_GENERIC - ) + self::TABLE_GENERIC, + ), ); $ref = new TeradataTableReflection($this->connection, $this->getDatabaseName(), self::TABLE_GENERIC); self::assertEquals(['id'], $ref->getPrimaryKeysNames()); @@ -76,7 +76,7 @@ public function testColumnDefinition( string $expectedType, $expectedDefault, $expectedLength, - bool $expectedNullable + bool $expectedNullable, ): void { $sql = sprintf( 'CREATE MULTISET TABLE %s.%s , @@ -90,7 +90,7 @@ public function testColumnDefinition( );', $this->getDatabaseName(), self::TABLE_GENERIC, - $sqlDef + $sqlDef, ); $this->connection->executeQuery($sql); diff --git a/packages/php-table-backend-utils/tests/Functional/Teradata/TeradataBaseCase.php b/packages/php-table-backend-utils/tests/Functional/Teradata/TeradataBaseCase.php index 9a681d435..37b456f29 100644 --- a/packages/php-table-backend-utils/tests/Functional/Teradata/TeradataBaseCase.php +++ b/packages/php-table-backend-utils/tests/Functional/Teradata/TeradataBaseCase.php @@ -30,7 +30,7 @@ protected function setUp(): void } protected function initTable( - string $table = self::TABLE_GENERIC + string $table = self::TABLE_GENERIC, ): void { $database = $this->getDatabaseName(); @@ -44,8 +44,8 @@ protected function initTable( "last_name" VARCHAR(10000) );', TeradataQuote::quoteSingleIdentifier($database), - TeradataQuote::quoteSingleIdentifier($table) - ) + TeradataQuote::quoteSingleIdentifier($table), + ), ); } @@ -99,7 +99,7 @@ private function getTeradataConnection(): Connection } $db->executeStatement(sprintf( 'SET SESSION DATABASE %s;', - TeradataQuote::quoteSingleIdentifier((string) getenv('TERADATA_DATABASE')) + TeradataQuote::quoteSingleIdentifier((string) getenv('TERADATA_DATABASE')), )); return $db; @@ -109,7 +109,7 @@ public function assertConnectionIsWorking(Connection $connection): void { self::assertEquals( 1, - $connection->fetchOne('SELECT 1') + $connection->fetchOne('SELECT 1'), ); } @@ -125,14 +125,14 @@ protected function setUpUser(string $userName): void /** @var array{array{RoleName: string, UserName: string}} $existingUsers */ $existingUsers = $this->connection->fetchAllAssociative(sprintf( 'SELECT UserName FROM DBC.UsersV U WHERE "U"."Username" = %s', - TeradataQuote::quote($userName) + TeradataQuote::quote($userName), )); // delete existing users foreach ($existingUsers as $existingUser) { $this->connection->executeQuery(sprintf( 'DROP USER %s', - TeradataQuote::quoteSingleIdentifier($existingUser['UserName']) + TeradataQuote::quoteSingleIdentifier($existingUser['UserName']), )); } @@ -141,7 +141,7 @@ protected function setUpUser(string $userName): void 'CREATE USER %s AS PERM = 0 PASSWORD=%s DEFAULT DATABASE = %s;', TeradataQuote::quoteSingleIdentifier($userName), TeradataQuote::quoteSingleIdentifier($this->generateRandomPassword()), - TeradataQuote::quoteSingleIdentifier($userName . 'DB') + TeradataQuote::quoteSingleIdentifier($userName . 'DB'), )); } @@ -151,21 +151,21 @@ protected function setUpRole(string $roleName): void /** @var array{array{RoleName: string}} $existingUsers */ $existingUsers = $this->connection->fetchAllAssociative(sprintf( 'SELECT RoleName FROM DBC.RoleInfoVX WHERE RoleName = %s', - TeradataQuote::quote($roleName) + TeradataQuote::quote($roleName), )); // delete existing roles foreach ($existingUsers as $existingUser) { $this->connection->executeQuery(sprintf( 'DROP ROLE %s', - TeradataQuote::quoteSingleIdentifier($existingUser['RoleName']) + TeradataQuote::quoteSingleIdentifier($existingUser['RoleName']), )); } // create role $this->connection->executeQuery(sprintf( 'CREATE ROLE %s;', - TeradataQuote::quoteSingleIdentifier($roleName) + TeradataQuote::quoteSingleIdentifier($roleName), )); } @@ -174,7 +174,7 @@ protected function insertRowToTable( string $tableName, int $id, string $firstName, - string $lastName + string $lastName, ): void { $this->connection->executeQuery(sprintf( 'INSERT INTO %s.%s VALUES (%d, %s, %s)', @@ -182,7 +182,7 @@ protected function insertRowToTable( TeradataQuote::quoteSingleIdentifier($tableName), $id, TeradataQuote::quote($firstName), - TeradataQuote::quote($lastName) + TeradataQuote::quote($lastName), )); } @@ -230,7 +230,7 @@ protected function assertArrayEqualsSorted( array $expected, array $actual, $sortKey, - string $message = '' + string $message = '', ): void { $comparison = fn($attrLeft, $attrRight) => $attrLeft[$sortKey] <=> $attrRight[$sortKey]; usort($expected, $comparison); diff --git a/packages/php-table-backend-utils/tests/Functional/Teradata/View/TeradataViewReflectionTest.php b/packages/php-table-backend-utils/tests/Functional/Teradata/View/TeradataViewReflectionTest.php index 44a754aa6..593651444 100644 --- a/packages/php-table-backend-utils/tests/Functional/Teradata/View/TeradataViewReflectionTest.php +++ b/packages/php-table-backend-utils/tests/Functional/Teradata/View/TeradataViewReflectionTest.php @@ -44,7 +44,7 @@ public function testGetDependentViews(): void private function initView( string $viewName = self::VIEW_GENERIC, - string $parentName = self::TABLE_GENERIC + string $parentName = self::TABLE_GENERIC, ): void { $this->connection->executeQuery( sprintf( @@ -53,7 +53,7 @@ private function initView( TeradataQuote::quoteSingleIdentifier($viewName), TeradataQuote::quoteSingleIdentifier($this->getDatabaseName()), TeradataQuote::quoteSingleIdentifier($parentName), - ) + ), ); } } diff --git a/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/GrantOptionsTest.php b/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/GrantOptionsTest.php index 9424f6da5..feef98e47 100644 --- a/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/GrantOptionsTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/GrantOptionsTest.php @@ -16,7 +16,7 @@ public function testOptionsDefault(): void $options = new GrantOptions([Permission::GRANT_VIEW_DEFINITION], 'ToMyUser'); $this->assertSame( [Permission::GRANT_VIEW_DEFINITION], - $options->getPermissions() + $options->getPermissions(), ); $this->assertFalse($options->isAllowGrantOption()); $this->assertSame([], $options->getOnTargetPath()); @@ -32,7 +32,7 @@ public function testOptionsFluentInterface(): void ->setAllowGrantOption(GrantOptions::OPTION_ALLOW_GRANT_OPTION); $this->assertSame( [Permission::GRANT_VIEW_DEFINITION], - $options->getPermissions() + $options->getPermissions(), ); $this->assertTrue($options->isAllowGrantOption()); $this->assertSame(['path'], $options->getOnTargetPath()); diff --git a/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/RevokeOptionsTest.php b/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/RevokeOptionsTest.php index d3b75b9d2..152240a7e 100644 --- a/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/RevokeOptionsTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Auth/Grant/Synapse/RevokeOptionsTest.php @@ -17,7 +17,7 @@ public function testOptionsDefault(): void $options = new RevokeOptions([Permission::GRANT_VIEW_DEFINITION], 'ToMyUser'); $this->assertSame( [Permission::GRANT_VIEW_DEFINITION], - $options->getPermissions() + $options->getPermissions(), ); $this->assertFalse($options->isGrantOptionRevoked()); $this->assertFalse($options->isRevokedInCascade()); @@ -35,7 +35,7 @@ public function testOptionsFluentInterface(): void ->revokeGrantOption(RevokeOptions::OPTION_DONT_REVOKE_GRANT_OPTION); $this->assertSame( [Permission::GRANT_VIEW_DEFINITION], - $options->getPermissions() + $options->getPermissions(), ); $this->assertTrue($options->isRevokedInCascade()); $this->assertFalse($options->isGrantOptionRevoked()); diff --git a/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/BigqueryColumnTest.php b/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/BigqueryColumnTest.php index 4cc388137..4f41a87ab 100644 --- a/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/BigqueryColumnTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/BigqueryColumnTest.php @@ -247,7 +247,7 @@ public function testCreateArrayColumn( array $dataToExtend, string $expectedSqlDefinition, string $expectedType, - string $expectedLength + string $expectedLength, ): void { $data = [ 'name' => 'age', diff --git a/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/Parser/SQLtoRestDatatypeConverterTest.php b/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/Parser/SQLtoRestDatatypeConverterTest.php index 2c2c6f5f0..4aaf32132 100644 --- a/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/Parser/SQLtoRestDatatypeConverterTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Column/Bigquery/Parser/SQLtoRestDatatypeConverterTest.php @@ -399,7 +399,7 @@ public function test( ?string $length, ?string $default, bool $nullable, - array $expected + array $expected, ): void { $options = [ 'nullable' => $nullable, @@ -412,7 +412,7 @@ public function test( } $col = new BigqueryColumn('myCol', new Bigquery( $type, - $options + $options, )); $rest = SQLtoRestDatatypeConverter::convertColumnToRestFormat($col); self::assertSame($expected, $rest); @@ -468,14 +468,14 @@ public function definitionsErrors(): Generator public function testErrors( string $type, ?string $length, - string $expectedError + string $expectedError, ): void { $options = [ 'length' => $length, ]; $col = new BigqueryColumn('myCol', new Bigquery( $type, - $options + $options, )); try { SQLtoRestDatatypeConverter::convertColumnToRestFormat($col); @@ -493,7 +493,7 @@ public function testLongName(): void ]; $col = new BigqueryColumn('array_struct_array-int_array-string', new Bigquery( Bigquery::TYPE_ARRAY, - $options + $options, )); $rest = SQLtoRestDatatypeConverter::convertColumnToRestFormat($col); self::assertSame([ diff --git a/packages/php-table-backend-utils/tests/Unit/Column/Teradata/TeradataColumnTest.php b/packages/php-table-backend-utils/tests/Unit/Column/Teradata/TeradataColumnTest.php index 0e0d0a38b..410e29196 100644 --- a/packages/php-table-backend-utils/tests/Unit/Column/Teradata/TeradataColumnTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Column/Teradata/TeradataColumnTest.php @@ -18,7 +18,7 @@ public function testCreateGenericColumn(): void self::assertEquals('myCol', $col->getColumnName()); self::assertEquals( 'VARCHAR (32000) NOT NULL DEFAULT \'\' CHARACTER SET UNICODE', - $col->getColumnDefinition()->getSQLDefinition() + $col->getColumnDefinition()->getSQLDefinition(), ); self::assertEquals('VARCHAR', $col->getColumnDefinition()->getType()); self::assertEquals('\'\'', $col->getColumnDefinition()->getDefault()); @@ -32,7 +32,7 @@ public function testCreateFromDB(): void self::assertEquals('tmp', $column->getColumnName()); self::assertEquals( 'VARCHAR (32000) NOT NULL DEFAULT \'\' CHARACTER SET UNICODE', - $column->getColumnDefinition()->getSQLDefinition() + $column->getColumnDefinition()->getSQLDefinition(), ); self::assertEquals('VARCHAR', $column->getColumnDefinition()->getType()); self::assertEquals('\'\'', $column->getColumnDefinition()->getDefault()); @@ -47,7 +47,7 @@ public function testCreateFromDBNotNullInt(): void self::assertEquals('tmp', $column->getColumnName()); self::assertEquals( 'VARCHAR (32000) NOT NULL DEFAULT \'\' CHARACTER SET UNICODE', - $column->getColumnDefinition()->getSQLDefinition() + $column->getColumnDefinition()->getSQLDefinition(), ); self::assertEquals('VARCHAR', $column->getColumnDefinition()->getType()); self::assertEquals('\'\'', $column->getColumnDefinition()->getDefault()); diff --git a/packages/php-table-backend-utils/tests/Unit/Connection/Snowflake/SnowflakeExceptionConverterTest.php b/packages/php-table-backend-utils/tests/Unit/Connection/Snowflake/SnowflakeExceptionConverterTest.php index d96b2de5c..f88031b80 100644 --- a/packages/php-table-backend-utils/tests/Unit/Connection/Snowflake/SnowflakeExceptionConverterTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Connection/Snowflake/SnowflakeExceptionConverterTest.php @@ -67,7 +67,7 @@ public function testConvert( string $expectedExceptionMessage, string $inputExceptionMessage, int $inputExceptionCode = 0, - ?string $inputSQL = null + ?string $inputSQL = null, ): void { $exceptionThrown = new DriverException( $inputExceptionMessage, diff --git a/packages/php-table-backend-utils/tests/Unit/Table/Exasol/ExasolTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Unit/Table/Exasol/ExasolTableQueryBuilderTest.php index 9d7054ca4..26b5bab03 100644 --- a/packages/php-table-backend-utils/tests/Unit/Table/Exasol/ExasolTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Table/Exasol/ExasolTableQueryBuilderTest.php @@ -65,7 +65,7 @@ public function testCreateTableWithInvalidTableName(): void { $this->expectException(QueryBuilderException::class); $this->expectExceptionMessage( - 'Invalid table name testTable.: Only alphanumeric characters dash and underscores are allowed.' + 'Invalid table name testTable.: Only alphanumeric characters dash and underscores are allowed.', ); $this->qb->getCreateTableCommand('testDb', 'testTable.', new ColumnCollection([])); self::fail('Should fail because of invalid table name'); @@ -75,7 +75,7 @@ public function testRenameTableWithInvalidTableName(): void { $this->expectException(QueryBuilderException::class); $this->expectExceptionMessage( - 'Invalid table name testTable.: Only alphanumeric characters dash and underscores are allowed.' + 'Invalid table name testTable.: Only alphanumeric characters dash and underscores are allowed.', ); $this->qb->getRenameTableCommand('testDb', 'testTable', 'testTable.'); self::fail('Should fail because of invalid table name'); diff --git a/packages/php-table-backend-utils/tests/Unit/Table/Snowflake/SnowflakeTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Unit/Table/Snowflake/SnowflakeTableQueryBuilderTest.php index 367e410c1..8f3e6c41e 100644 --- a/packages/php-table-backend-utils/tests/Unit/Table/Snowflake/SnowflakeTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Table/Snowflake/SnowflakeTableQueryBuilderTest.php @@ -58,7 +58,8 @@ public function testCreateTableWithInvalidTableName(): void { $this->expectException(QueryBuilderException::class); $this->expectExceptionMessage( - 'Invalid table name testTab.: Only alphanumeric characters, dash, underscores and dollar signs are allowed.' + 'Invalid table name testTab.: Only alphanumeric characters, dash,' + . ' underscores and dollar signs are allowed.', ); $this->qb->getCreateTableCommand('testDb', 'testTab.', new ColumnCollection([])); self::fail('Should fail because of invalid table name'); @@ -68,7 +69,8 @@ public function testRenameTableWithInvalidTableName(): void { $this->expectException(QueryBuilderException::class); $this->expectExceptionMessage( - 'Invalid table name testTab.: Only alphanumeric characters, dash, underscores and dollar signs are allowed.' + 'Invalid table name testTab.: Only alphanumeric characters, dash,' + . ' underscores and dollar signs are allowed.', ); $this->qb->getRenameTableCommand('testDb', 'testTab', 'testTab.'); self::fail('Should fail because of invalid table name'); diff --git a/packages/php-table-backend-utils/tests/Unit/Table/SynapseTableDefinitionTest.php b/packages/php-table-backend-utils/tests/Unit/Table/SynapseTableDefinitionTest.php index c2d863418..d5d7dcf03 100644 --- a/packages/php-table-backend-utils/tests/Unit/Table/SynapseTableDefinitionTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Table/SynapseTableDefinitionTest.php @@ -19,7 +19,7 @@ public function test(): void $columns = new ColumnCollection([ new SynapseColumn( 'col1', - new Synapse('NVARCHAR') + new Synapse('NVARCHAR'), ), ]); $definition = new SynapseTableDefinition( @@ -29,7 +29,7 @@ public function test(): void $columns, ['pk1'], new TableDistributionDefinition(TableDistributionDefinition::TABLE_DISTRIBUTION_ROUND_ROBIN), - new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX) + new TableIndexDefinition(TableIndexDefinition::TABLE_INDEX_TYPE_CLUSTERED_COLUMNSTORE_INDEX), ); self::assertSame('schema', $definition->getSchemaName()); self::assertSame('tableName', $definition->getTableName()); diff --git a/packages/php-table-backend-utils/tests/Unit/Table/Teradata/TeradataTableQueryBuilderTest.php b/packages/php-table-backend-utils/tests/Unit/Table/Teradata/TeradataTableQueryBuilderTest.php index 6a867b157..f3ae60b66 100644 --- a/packages/php-table-backend-utils/tests/Unit/Table/Teradata/TeradataTableQueryBuilderTest.php +++ b/packages/php-table-backend-utils/tests/Unit/Table/Teradata/TeradataTableQueryBuilderTest.php @@ -73,7 +73,7 @@ public function testGetPKCommand(): void { $this->assertEquals( 'ALTER TABLE "myDB"."myTable" ADD CONSTRAINT kbc_pk PRIMARY KEY ("my","rules");', - $this->qb->getAddPrimaryKeyCommand('myDB', 'myTable', ['my', 'rules']) + $this->qb->getAddPrimaryKeyCommand('myDB', 'myTable', ['my', 'rules']), ); } @@ -81,7 +81,7 @@ public function testGetDropPKCommand(): void { $this->assertEquals( 'ALTER TABLE "myDB"."myTable" DROP CONSTRAINT kbc_pk;', - $this->qb->getDropPrimaryKeyCommand('myDB', 'myTable') + $this->qb->getDropPrimaryKeyCommand('myDB', 'myTable'), ); } @@ -92,7 +92,7 @@ public function testGetDuplicationCommand(): void ( SELECT ROW_NUMBER() OVER (PARTITION BY "my","rules" ORDER BY "my","rules") AS "_row_number_" FROM "myDB"."myTable" ) "data"', - $this->qb->getCommandForDuplicates('myDB', 'myTable', ['my', 'rules']) + $this->qb->getCommandForDuplicates('myDB', 'myTable', ['my', 'rules']), ); } }