-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
KBC-2394 full load
- Loading branch information
Showing
32 changed files
with
2,911 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ODBC] | ||
InstallDir=/opt/teradata/client/ODBC_64 | ||
Trace=0 | ||
TraceDll=/opt/teradata/client/ODBC_64/lib/odbctrac.so | ||
TraceFile=/usr/odbcusr/trace.log | ||
TraceAutoStop=0 | ||
|
||
[Teradata] | ||
Driver = /opt/teradata/client/ODBC_64/lib/tdataodbc_sb64.so | ||
UsageCount = 2 | ||
APILevel = CORE | ||
ConnectFunctions = YYY | ||
DriverODBCVer = 3.51 | ||
SQLLevel = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ODBC DRIVERS] | ||
Teradata=Installed | ||
|
||
[Teradata] | ||
Driver=/opt/teradata/client/ODBC_64/lib/tdataodbc_sb64.so | ||
APILevel=CORE | ||
ConnectFunctions=YYY | ||
DriverODBCVer=3.51 | ||
SQLLevel=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\Db\ImportExport\Backend\Teradata\Helper; | ||
|
||
use Keboola\Db\ImportExport\Storage\S3\SourceFile; | ||
|
||
final class BackendHelper | ||
{ | ||
public static function generateTempTableName(): string | ||
{ | ||
return '__temp_' . str_replace('.', '_', uniqid('csvimport', true)); | ||
} | ||
|
||
public static function generateTempDedupTableName(): string | ||
{ | ||
return '__temp_DEDUP_' . str_replace('.', '_', uniqid('csvimport', true)); | ||
} | ||
|
||
/** | ||
* creates a wildcard string which should match all files in manifest | ||
* [file01.csv, file01.csv] => file0* | ||
* TODO | ||
* - has to fix edgecases a) [1_file.csv, 2_file.csv] b) not all the files matched in WC have to be on s3 | ||
* @param SourceFile $source | ||
* @return string | ||
* @throws \Keboola\Db\Import\Exception | ||
*/ | ||
public static function getMask(SourceFile $source): string | ||
{ | ||
$entries = $source->getManifestEntries(); | ||
if (count($entries) === 0) { | ||
// no entries -> no data to load | ||
return ''; | ||
} | ||
// SourceDirectory returns fileName as directory/file.csv but SourceFile returns s3://bucket/directory/file.csv | ||
$toRemove = $source->getS3Prefix() . '/'; | ||
$entriesAsArrays = []; | ||
$min = 99999; | ||
$minIndex = 0; | ||
foreach ($entries as $i => $entry) { | ||
$entry = str_replace($toRemove, '', $entry); | ||
$asArray = str_split($entry); | ||
$entriesAsArrays[] = $asArray; | ||
$thisSize = count($asArray); | ||
if ($thisSize < $min) { | ||
$min = $thisSize; | ||
$minIndex = $i; | ||
} | ||
} | ||
$out = []; | ||
|
||
foreach ($entriesAsArrays[$minIndex] as $index => $letter) { | ||
$match = true; | ||
|
||
foreach ($entriesAsArrays as $fileName) { | ||
if ($fileName[$index] !== $letter) { | ||
$match = false; | ||
break; | ||
} | ||
} | ||
$out[$index] = $match ? $letter : '*'; | ||
} | ||
return implode('', $out); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\Db\ImportExport\Backend\Teradata; | ||
|
||
use Keboola\Db\Import\Exception; | ||
|
||
class TeradataException extends Exception | ||
{ | ||
|
||
public static function covertException(\Doctrine\DBAL\Exception $e): \Throwable | ||
{ | ||
// TODO | ||
return $e; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\Db\ImportExport\Backend\Teradata; | ||
|
||
use Keboola\Db\ImportExport\ImportOptions; | ||
|
||
class TeradataImportOptions extends ImportOptions | ||
{ | ||
private string $teradataHost; | ||
|
||
private string $teradataUser; | ||
|
||
private string $teradataPassword; | ||
|
||
private int $teradataPort; | ||
|
||
/** | ||
* @param string[] $convertEmptyValuesToNull | ||
*/ | ||
public function __construct( | ||
string $teradataHost, | ||
string $teradataUser, | ||
string $teradataPassword, | ||
int $teradataPort, | ||
array $convertEmptyValuesToNull = [], | ||
bool $isIncremental = false, | ||
bool $useTimestamp = false, | ||
int $numberOfIgnoredLines = 0 | ||
) { | ||
parent::__construct( | ||
$convertEmptyValuesToNull, | ||
$isIncremental, | ||
$useTimestamp, | ||
$numberOfIgnoredLines | ||
); | ||
$this->teradataHost = $teradataHost; | ||
$this->teradataUser = $teradataUser; | ||
$this->teradataPassword = $teradataPassword; | ||
$this->teradataPort = $teradataPort; | ||
} | ||
|
||
public function getTeradataHost(): string | ||
{ | ||
return $this->teradataHost; | ||
} | ||
|
||
public function getTeradataUser(): string | ||
{ | ||
return $this->teradataUser; | ||
} | ||
|
||
public function getTeradataPassword(): string | ||
{ | ||
return $this->teradataPassword; | ||
} | ||
|
||
public function getTeradataPort(): int | ||
{ | ||
return $this->teradataPort; | ||
} | ||
} |
Oops, something went wrong.