private void setOwnerIfNull(final TableDto tableDto, final String user) { if (!Strings.isNullOrEmpty(user)) { StorageDto serde = tableDto.getSerde(); if (serde == null) { serde = new StorageDto(); tableDto.setSerde(serde); } if (Strings.isNullOrEmpty(serde.getOwner())) { serde.setOwner(user); } } }
protected ConnectorTableMetadata fromTableDto(final TableDto table, final TypeManager typeManager) { return new ConnectorTableDetailMetadata( toSchemaTableName(table.getName()), columnsFromTable(table, typeManager), table.getSerde() == null ? null : table.getSerde().getOwner(), fromStorageDto(table.getSerde()), table.getMetadata(), fromAuditDto(table.getAudit()) ); }
private boolean isSerdeInfoProvided(final TableDto tableDto, final TableDto oldTableDto) { boolean result = false; final StorageDto serde = tableDto.getSerde(); if (serde == null) { result = false; } else { final StorageDto oldSerde = oldTableDto.getSerde(); final String oldUri = oldSerde != null ? oldSerde.getUri() : null; if (serde.getInputFormat() != null || serde.getOutputFormat() != null || serde.getOwner() != null || serde.getParameters() != null || serde.getSerdeInfoParameters() != null || serde.getSerializationLib() != null || (serde.getUri() != null && !Objects.equals(serde.getUri(), oldUri))) { result = true; } } return result; }
/** * {@inheritDoc} */ @Override public List<PartitionSpec> get_part_specs_by_filter(final String dbName, final String tblName, final String filter, final int maxParts) throws TException { //TODO: Handle the use case of grouping return requestWrapper("get_partitions_pspec", new Object[]{dbName, tblName, filter, maxParts}, () -> { final String databaseName = normalizeIdentifier(dbName); final String tableName = normalizeIdentifier(tblName); final TableDto tableDto = v1.getTable(catalogName, databaseName, tableName, true, false, false); final GetPartitionsRequestDto dto = new GetPartitionsRequestDto(filter, null, true, false); final List<PartitionDto> metacatPartitions = partV1.getPartitionsForRequest(catalogName, dbName, tblName, null, null, null, maxParts, false, dto); final List<Partition> partitions = Lists.newArrayListWithCapacity(metacatPartitions.size()); for (PartitionDto partition : metacatPartitions) { partitions.add(hiveConverters.metacatToHivePartition(partition, tableDto)); } final PartitionSpec pSpec = new PartitionSpec(); pSpec.setPartitionList(new PartitionListComposingSpec(partitions)); pSpec.setDbName(dbName); pSpec.setTableName(tblName); if (tableDto != null && tableDto.getSerde() != null) { pSpec.setRootPath(tableDto.getSerde().getUri()); } return Arrays.asList(pSpec); }); }
/** * {@inheritDoc} */ @Override public List<PartitionSpec> get_part_specs_by_filter(final String dbName, final String tblName, final String filter, final int maxParts) throws TException { //TODO: Handle the use case of grouping return requestWrapper("get_partitions_pspec", new Object[]{dbName, tblName, filter, maxParts}, () -> { final String databaseName = normalizeIdentifier(dbName); final String tableName = normalizeIdentifier(tblName); final TableDto tableDto = v1.getTable(catalogName, databaseName, tableName, true, false, false); final GetPartitionsRequestDto dto = new GetPartitionsRequestDto(filter, null, true, false); final List<PartitionDto> metacatPartitions = partV1.getPartitionsForRequest(catalogName, dbName, tblName, null, null, null, maxParts, false, dto); final List<Partition> partitions = Lists.newArrayListWithCapacity(metacatPartitions.size()); for (PartitionDto partition : metacatPartitions) { partitions.add(hiveConverters.metacatToHivePartition(partition, tableDto)); } final PartitionSpec pSpec = new PartitionSpec(); pSpec.setPartitionList(new PartitionListComposingSpec(partitions)); pSpec.setDbName(dbName); pSpec.setTableName(tblName); if (tableDto != null && tableDto.getSerde() != null) { pSpec.setRootPath(tableDto.getSerde().getUri()); } return Arrays.asList(pSpec); }); }
table.setDbName(databaseName); final StorageDto storageDto = dto.getSerde(); String owner = ""; if (storageDto != null && storageDto.getOwner() != null) {
final StorageDto storageDto = dto.getSerde(); if (storageDto != null) { table.setOwner(storageDto.getOwner());
final StorageDto storageDto = dto.getSerde(); if (storageDto != null) { table.setOwner(storageDto.getOwner());
/** * {@inheritDoc} */ @Override public PartitionDto hiveToMetacatPartition(final TableDto tableDto, final Partition partition) { final QualifiedName tableName = tableDto.getName(); final QualifiedName partitionName = QualifiedName.ofPartition(tableName.getCatalogName(), tableName.getDatabaseName(), tableName.getTableName(), getNameFromPartVals(tableDto, partition.getValues())); final PartitionDto result = new PartitionDto(); String owner = ""; if (tableDto.getSerde() != null) { owner = tableDto.getSerde().getOwner(); } //not setting Serde to view if (null == tableDto.getView() || Strings.isNullOrEmpty(tableDto.getView().getViewOriginalText())) { result.setSerde(toStorageDto(partition.getSd(), owner)); } result.setMetadata(partition.getParameters()); final AuditDto auditDto = new AuditDto(); auditDto.setCreatedDate(epochSecondsToDate(partition.getCreateTime())); auditDto.setLastModifiedDate(epochSecondsToDate(partition.getLastAccessTime())); result.setAudit(auditDto); result.setName(partitionName); return result; }
/** * {@inheritDoc} */ @Override public PartitionDto hiveToMetacatPartition(final TableDto tableDto, final Partition partition) { final QualifiedName tableName = tableDto.getName(); final QualifiedName partitionName = QualifiedName.ofPartition(tableName.getCatalogName(), tableName.getDatabaseName(), tableName.getTableName(), getNameFromPartVals(tableDto, partition.getValues())); final PartitionDto result = new PartitionDto(); String owner = ""; if (tableDto.getSerde() != null) { owner = tableDto.getSerde().getOwner(); } //not setting Serde to view if (null == tableDto.getView() || Strings.isNullOrEmpty(tableDto.getView().getViewOriginalText())) { result.setSerde(toStorageDto(partition.getSd(), owner)); } result.setMetadata(partition.getParameters()); final AuditDto auditDto = new AuditDto(); auditDto.setCreatedDate(epochSecondsToDate(partition.getCreateTime())); auditDto.setLastModifiedDate(epochSecondsToDate(partition.getLastAccessTime())); result.setAudit(auditDto); result.setName(partitionName); return result; }
@Override public PartitionDto hiveToMetacatPartition(final TableDto tableDto, final Partition partition) { final QualifiedName tableName = tableDto.getName(); final QualifiedName partitionName = QualifiedName.ofPartition(tableName.getCatalogName(), tableName.getDatabaseName(), tableName.getTableName(), getNameFromPartVals(tableDto, partition.getValues())); final PartitionDto result = new PartitionDto(); String owner = ""; if (tableDto.getSerde() != null) { owner = tableDto.getSerde().getOwner(); } result.setSerde(toStorageDto(partition.getSd(), owner)); result.setMetadata(partition.getParameters()); final AuditDto auditDto = new AuditDto(); auditDto.setCreatedDate(epochSecondsToDate(partition.getCreateTime())); auditDto.setLastModifiedDate(epochSecondsToDate(partition.getLastAccessTime())); result.setAudit(auditDto); result.setName(partitionName); return result; }
/** * {@inheritDoc} */ @Override public TableDto copy(final TableDto tableDto, final QualifiedName targetName) { final QualifiedName databaseName = QualifiedName.ofDatabase(targetName.getCatalogName(), targetName.getDatabaseName()); if (!databaseService.exists(databaseName)) { final DatabaseDto databaseDto = new DatabaseDto(); databaseDto.setName(databaseName); databaseService.create(databaseName, databaseDto); } final TableDto targetTableDto = new TableDto(); targetTableDto.setName(targetName); targetTableDto.setFields(tableDto.getFields()); targetTableDto.setPartition_keys(tableDto.getPartition_keys()); final StorageDto storageDto = tableDto.getSerde(); if (storageDto != null) { final StorageDto targetStorageDto = new StorageDto(); targetStorageDto.setInputFormat(storageDto.getInputFormat()); targetStorageDto.setOwner(storageDto.getOwner()); targetStorageDto.setOutputFormat(storageDto.getOutputFormat()); targetStorageDto.setParameters(storageDto.getParameters()); targetStorageDto.setUri(storageDto.getUri()); targetStorageDto.setSerializationLib(storageDto.getSerializationLib()); targetTableDto.setSerde(targetStorageDto); } create(targetName, targetTableDto); return targetTableDto; }