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; }
private StorageDto toStorageDto(@Nullable final StorageDescriptor sd, final String owner) { final StorageDto result = new StorageDto(); if (sd != null) { result.setOwner(owner); result.setUri(sd.getLocation()); result.setInputFormat(sd.getInputFormat()); result.setOutputFormat(sd.getOutputFormat()); result.setParameters(sd.getParameters()); final SerDeInfo serde = sd.getSerdeInfo(); if (serde != null) { result.setSerializationLib(serde.getSerializationLib()); result.setSerdeInfoParameters(serde.getParameters()); } } return result; }
private PartitionDto mergePartition(final PartitionDto partitionDto, @Nullable final PartitionDto existingPartition) { if (existingPartition != null) { final StorageDto existingSerde = existingPartition.getSerde(); if (existingSerde != null) { StorageDto serde = partitionDto.getSerde(); if (serde == null) { serde = new StorageDto(); partitionDto.setSerde(serde); } if (serde.getUri() == null || serde.getUri().equals(existingSerde.getUri())) { serde.setUri(existingSerde.getUri()); if (serde.getInputFormat() == null) { serde.setInputFormat(existingSerde.getInputFormat()); } if (serde.getOutputFormat() == null) { serde.setOutputFormat(existingSerde.getOutputFormat()); } if (serde.getSerializationLib() == null) { serde.setSerializationLib(existingSerde.getSerializationLib()); } } } } return partitionDto; }
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); } } }
/** * {@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; }
if (sd.getSerdeInfo() != null && tableDto.getSerde() != null && Strings.isNullOrEmpty( sd.getSerdeInfo().getSerializationLib())) { sd.getSerdeInfo().setSerializationLib(tableDto.getSerde().getSerializationLib());
private void appendPartitionsCore(final String dbName, final String tblName, final String partName) throws TException { final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto(); final PartitionDto partitionDto = new PartitionDto(); partitionDto.setName(QualifiedName.ofPartition(catalogName, dbName, tblName, partName)); partitionDto.setSerde(new StorageDto()); partitionsSaveRequestDto.setPartitions(Lists.newArrayList(partitionDto)); partV1.savePartitions(catalogName, dbName, tblName, partitionsSaveRequestDto); }
table.setOwner(storageDto.getOwner());
if (sd.getSerdeInfo() != null && tableDto.getSerde() != null && Strings.isNullOrEmpty( sd.getSerdeInfo().getSerializationLib())) { sd.getSerdeInfo().setSerializationLib(tableDto.getSerde().getSerializationLib());
private void appendPartitionsCore(final String dbName, final String tblName, final String partName) throws TException { final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto(); final PartitionDto partitionDto = new PartitionDto(); partitionDto.setName(QualifiedName.ofPartition(catalogName, dbName, tblName, partName)); partitionDto.setSerde(new StorageDto()); partitionsSaveRequestDto.setPartitions(Lists.newArrayList(partitionDto)); partV1.savePartitions(catalogName, dbName, tblName, partitionsSaveRequestDto); }
@Override protected StorageInfo fromStorageDto(StorageDto serde) { if ( serde == null ) { return null; } StorageInfo storageInfo = new StorageInfo(); storageInfo.setSerializationLib( serde.getSerializationLib() ); if ( serde.getSerdeInfoParameters() != null ) { storageInfo.setSerdeInfoParameters( new HashMap<String, String>( serde.getSerdeInfoParameters() ) ); } storageInfo.setInputFormat( serde.getInputFormat() ); if ( serde.getParameters() != null ) { storageInfo.setParameters( new HashMap<String, String>( serde.getParameters() ) ); } storageInfo.setOutputFormat( serde.getOutputFormat() ); storageInfo.setUri( serde.getUri() ); return storageInfo; }
private StorageDto toStorageDto(final StorageDescriptor sd, final String owner) { final StorageDto result = new StorageDto(); if (sd != null) { result.setOwner(owner); result.setUri(sd.getLocation()); result.setInputFormat(sd.getInputFormat()); result.setOutputFormat(sd.getOutputFormat()); result.setParameters(sd.getParameters()); final SerDeInfo serde = sd.getSerdeInfo(); if (serde != null) { result.setSerializationLib(serde.getSerializationLib()); result.setSerdeInfoParameters(serde.getParameters()); } } return result; }
table.setOwner(storageDto.getOwner());
if (sd.getSerdeInfo() != null && tableDto.getSerde() != null && Strings.isNullOrEmpty( sd.getSerdeInfo().getSerializationLib())) { sd.getSerdeInfo().setSerializationLib(tableDto.getSerde().getSerializationLib());
if (storageDto.getInputFormat() != null) { inputFormat = storageDto.getInputFormat(); if (storageDto.getUri() != null) { location = storageDto.getUri(); if (storageDto.getOutputFormat() != null) { outputFormat = storageDto.getOutputFormat(); if (storageDto.getSerializationLib() != null) { serializationLib = storageDto.getSerializationLib(); if (storageDto.getParameters() != null) { sdParams = storageDto.getParameters(); if (storageDto.getSerdeInfoParameters() != null) { serdeParams = storageDto.getSerdeInfoParameters();
private StorageDto toStorageDto(@Nullable final StorageDescriptor sd, final String owner) { final StorageDto result = new StorageDto(); if (sd != null) { result.setOwner(owner); result.setUri(sd.getLocation()); result.setInputFormat(sd.getInputFormat()); result.setOutputFormat(sd.getOutputFormat()); result.setParameters(sd.getParameters()); final SerDeInfo serde = sd.getSerdeInfo(); if (serde != null) { result.setSerializationLib(serde.getSerializationLib()); result.setSerdeInfoParameters(serde.getParameters()); } } return result; }