public static Map<String, String> buildDirectoryContextProperties(ConnectorSession session)
    {
        ImmutableMap.Builder<String, String> directoryContextProperties = ImmutableMap.builder();
        directoryContextProperties.put(PRESTO_QUERY_ID, session.getQueryId());
        session.getSource().ifPresent(source -> directoryContextProperties.put(PRESTO_QUERY_SOURCE, source));
        session.getClientInfo().ifPresent(clientInfo -> directoryContextProperties.put(PRESTO_CLIENT_INFO, clientInfo));
        getMetastoreHeaders(session).ifPresent(metastoreHeaders -> directoryContextProperties.put(PRESTO_METASTORE_HEADER, metastoreHeaders));
        directoryContextProperties.put(PRESTO_USER_NAME, session.getUser());
        if (!session.getClientTags().isEmpty()) {
            directoryContextProperties.put(PRESTO_CLIENT_TAGS, join(CLIENT_TAGS_DELIMITER, session.getClientTags()));
        }
        return directoryContextProperties.build();
    }
@Test
    public void testBuildDirectoryContextProperties()
    {
        Map<String, String> additionalProperties = buildDirectoryContextProperties(SESSION);
        assertEquals(additionalProperties.get(PRESTO_QUERY_ID), SESSION.getQueryId());
        assertEquals(Optional.ofNullable(additionalProperties.get(PRESTO_QUERY_SOURCE)), SESSION.getSource());
        assertEquals(Optional.ofNullable(additionalProperties.get(PRESTO_CLIENT_INFO)), SESSION.getClientInfo());
        assertEquals(additionalProperties.get(PRESTO_USER_NAME), SESSION.getUser());
        assertEquals(Optional.ofNullable(additionalProperties.get(PRESTO_METASTORE_HEADER)), getMetastoreHeaders(SESSION));
        assertEquals(Arrays.stream(additionalProperties.get(PRESTO_CLIENT_TAGS).split(CLIENT_TAGS_DELIMITER)).collect(toImmutableSet()), SESSION.getClientTags());
    }