public static Optional<DwrfTableEncryptionProperties> fromHiveTableProperties(Map<String, String> properties)
    {
        String encryptTable = properties.get(ENCRYPT_TABLE_KEY);
        String encryptColumns = properties.get(ENCRYPT_COLUMNS_KEY);

        if (encryptTable != null || encryptColumns != null) {
            if (!properties.containsKey(DWRF_ENCRYPTION_ALGORITHM_KEY) || !properties.containsKey(DWRF_ENCRYPTION_PROVIDER_KEY)) {
                throw new PrestoException(HIVE_INVALID_ENCRYPTION_METADATA, format("Both %s and %s need to be set for DWRF encryption", DWRF_ENCRYPTION_ALGORITHM_KEY, DWRF_ENCRYPTION_PROVIDER_KEY));
            }

            if (encryptTable != null) {
                return Optional.of(forTable(encryptTable, properties.get(DWRF_ENCRYPTION_ALGORITHM_KEY), properties.get(DWRF_ENCRYPTION_PROVIDER_KEY)));
            }

            return Optional.of(forPerColumn(
                    fromHiveProperty(encryptColumns),
                    properties.get(DWRF_ENCRYPTION_ALGORITHM_KEY),
                    properties.get(DWRF_ENCRYPTION_PROVIDER_KEY)));
        }

        return Optional.empty();
    }
@Test
    public void testFromHiveTablePropertiesTablePresent()
    {
        Map<String, String> hiveProperties = ImmutableMap.of(
                ENCRYPT_TABLE_KEY, "abcd",
                DWRF_ENCRYPTION_ALGORITHM_KEY, "test_algo",
                DWRF_ENCRYPTION_PROVIDER_KEY, "test_prov");
        Optional<DwrfTableEncryptionProperties> encryptionProperties = fromHiveTableProperties(hiveProperties);
        assertTrue(encryptionProperties.isPresent());
        assertEquals(encryptionProperties.get().toHiveProperties(), hiveProperties);
    }