public function testReadTablesS3Redshift() { // Create bucket if (!$this->client->bucketExists("in.c-docker-test-redshift")) { $this->client->createBucket("docker-test-redshift", Client::STAGE_IN, "Docker Testsuite", "redshift"); } // Create table if (!$this->client->tableExists("in.c-docker-test-redshift.test")) { $csv = new CsvFile($this->tmpDir . "/upload.csv"); $csv->writeRow(["Id", "Name"]); $csv->writeRow(["test", "test"]); $this->client->createTableAsync("in.c-docker-test-redshift", "test", $csv); $this->client->setTableAttribute("in.c-docker-test-redshift.test", "attr1", "val2"); } $root = $this->tmpDir; $reader = new Reader($this->client); $configuration = [["source" => "in.c-docker-test-redshift.test", "destination" => "test-redshift.csv"]]; $reader->downloadTables($configuration, $root . "/download", "s3"); $adapter = new TableManifestAdapter(); $manifest = $adapter->readFromFile($root . "/download/test-redshift.csv.manifest"); $this->assertEquals("in.c-docker-test-redshift.test", $manifest["id"]); $this->assertEquals("val2", $manifest["attributes"][0]["value"]); $this->assertS3info($manifest); }
/** * @param $tableInfo * @param $destination * @throws \Exception */ protected function writeTableManifest($tableInfo, $destination) { $manifest = array("id" => $tableInfo["id"], "uri" => $tableInfo["uri"], "name" => $tableInfo["name"], "primary_key" => $tableInfo["primaryKey"], "indexed_columns" => $tableInfo["indexedColumns"], "created" => $tableInfo["created"], "last_change_date" => $tableInfo["lastChangeDate"], "last_import_date" => $tableInfo["lastImportDate"], "rows_count" => $tableInfo["rowsCount"], "data_size_bytes" => $tableInfo["dataSizeBytes"], "is_alias" => $tableInfo["isAlias"], "columns" => $tableInfo["columns"], "attributes" => array()); foreach ($tableInfo["attributes"] as $attribute) { $manifest["attributes"][] = array("name" => $attribute["name"], "value" => $attribute["value"], "protected" => $attribute["protected"]); } if (isset($tableInfo["s3"])) { $manifest["s3"] = $tableInfo["s3"]; } $adapter = new TableAdapter($this->getFormat()); try { $adapter->setConfig($manifest); $adapter->writeToFile($destination); } catch (InvalidInputException $e) { throw new InputOperationException("Failed to write manifest for table {$tableInfo['id']} - {$tableInfo['name']}.", $e); } }