Search in sources :

Example 1 with AzureStorageTableService

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);
    }
}
Also used : AzureStorageTableService(org.talend.components.azurestorage.table.AzureStorageTableService) DynamicTableEntity(com.microsoft.azure.storage.table.DynamicTableEntity) ComponentException(org.talend.components.api.exception.ComponentException) URISyntaxException(java.net.URISyntaxException) InvalidKeyException(java.security.InvalidKeyException) StorageException(com.microsoft.azure.storage.StorageException)

Aggregations

StorageException (com.microsoft.azure.storage.StorageException)1 DynamicTableEntity (com.microsoft.azure.storage.table.DynamicTableEntity)1 URISyntaxException (java.net.URISyntaxException)1 InvalidKeyException (java.security.InvalidKeyException)1 ComponentException (org.talend.components.api.exception.ComponentException)1 AzureStorageTableService (org.talend.components.azurestorage.table.AzureStorageTableService)1