use of org.talend.components.azurestorage.table.AzureStorageTableService in project components by Talend.
the class AzureStorageTableSourceOrSink method getEndpointSchema.
@Override
public Schema getEndpointSchema(RuntimeContainer container, String schemaName) throws IOException {
try {
AzureStorageTableService tableService = new AzureStorageTableService(getAzureConnection(container));
TableQuery<DynamicTableEntity> partitionQuery;
partitionQuery = TableQuery.from(DynamicTableEntity.class).take(1);
Iterable<DynamicTableEntity> entities = tableService.executeQuery(schemaName, partitionQuery);
if (entities.iterator().hasNext()) {
DynamicTableEntity result = entities.iterator().next();
return AzureStorageAvroRegistry.get().inferSchema(result);
} else {
return null;
}
} catch (InvalidKeyException | URISyntaxException | StorageException e) {
LOGGER.error(e.getLocalizedMessage());
throw new ComponentException(e);
}
}
Aggregations