public function getTable($writerId, $id)
 {
     $outTable = $this->storageApi->getTable($id);
     $sysBucketId = $this->getSysBucketId($writerId);
     $tableName = $this->getWriterTableName($id);
     $bucketConfig = $this->readBucketConfig($sysBucketId);
     $sysTable = null;
     if (isset($bucketConfig['items']) && isset($bucketConfig['items'][$tableName])) {
         $sysTable = $bucketConfig['items'][$tableName];
     }
     //@todo: check systable attributs
     $columns = [];
     foreach ($outTable['columns'] as $col) {
         if (isset($sysTable['items']) && !empty($sysTable['items']) && ($configColumn = $this->getColumnFromConfig($sysTable['items'], $col)) != null) {
             $columns[] = $configColumn;
         } else {
             $columns[] = ['name' => $col, 'dbName' => $col, 'type' => 'IGNORE', 'size' => '', 'null' => 0, 'default' => ''];
         }
     }
     return ['id' => $id, 'bucket' => $outTable['bucket']['id'], 'name' => is_null($sysTable) ? $id : $sysTable['dbName'], 'export' => !is_null($sysTable) && $sysTable['export'], 'lastChange' => is_null($sysTable) ? 'N/A' : $sysTable['lastChange'], 'columns' => $columns];
 }
 /**
  *
  * Upload CSV file to storage API
  *
  * @param $queryNumber
  * @param $table
  * @return bool
  * @throws \Exception
  * @throws \Keboola\StorageApi\ClientException
  */
 private function _uploadCsvFile($queryNumber, $table)
 {
     if (!isset($this->_csvFiles[$queryNumber])) {
         return false;
     }
     $csvHandle = $this->_csvFiles[$queryNumber]["handle"];
     $tableId = $this->storageApiBucket . '.' . $table;
     if (!isset($this->_sapiTableCache[$tableId]) && $this->storageApi->tableExists($tableId)) {
         $this->_sapiTableCache[$tableId] = $this->storageApi->getTable($tableId);
     }
     try {
         if (isset($this->_sapiTableCache[$tableId])) {
             $this->storageApi->writeTableAsync($tableId, $csvHandle, array("incremental" => true));
         } else {
             $this->storageApi->createTableAsync($this->storageApiBucket, $table, $csvHandle, array("primaryKey" => "ex__primary"));
             $this->_sapiTableCache[$tableId] = $this->storageApi->getTable($tableId);
         }
     } catch (Exception $e) {
         throw new UserException($e->getMessage(), $e);
     }
     return true;
 }