.setCatalog(catalog.orElse(null)) .setSchema(schema.orElse(null)) .setPath(session.getPath()) .setTimeZoneKey(session.getTimeZoneKey()) .setLocale(session.getLocale())
.setQueryId(queryId) .setIdentity(sessionContext.getIdentity()) .setPath(new SqlPath(Optional.empty())) .build();
@Test public void testCurrentPath() { Session session = testSessionBuilder() .setPath(new SqlPath(Optional.of("testPath"))) .build(); try (QueryAssertions queryAssertions = new QueryAssertions(session)) { queryAssertions.assertQuery("SELECT CURRENT_PATH", "SELECT CAST('" + session.getPath().toString() + "' AS VARCHAR)"); } Session emptyPathSession = testSessionBuilder() .setPath(new SqlPath(Optional.of("\"\""))) .build(); try (QueryAssertions queryAssertions = new QueryAssertions(emptyPathSession)) { queryAssertions.assertQuery("SELECT CURRENT_PATH", "SELECT CAST('" + emptyPathSession.getPath().toString() + "' AS VARCHAR)"); } } }
public static Session toSession(ConnectorTransactionHandle transactionHandle, ConnectorSession session) { TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId(); return Session.builder(new SessionPropertyManager(SYSTEM_SESSION_PROPERTIES)) .setQueryId(new QueryId(session.getQueryId())) .setTransactionId(transactionId) .setCatalog("catalog") .setSchema("schema") .setPath(new SqlPath(Optional.of("path"))) .setIdentity(session.getIdentity()) .setTimeZoneKey(session.getTimeZoneKey()) .setLocale(session.getLocale()) .setStartTime(session.getStartTime()) .build(); } }
public static SessionBuilder testSessionBuilder(SessionPropertyManager sessionPropertyManager) { return Session.builder(sessionPropertyManager) .setQueryId(queryIdGenerator.createNextQueryId()) .setIdentity(new Identity("user", Optional.empty())) .setSource("test") .setCatalog("catalog") .setSchema("schema") .setPath(new SqlPath(Optional.of("path"))) .setTimeZoneKey(DEFAULT_TIME_ZONE_KEY) .setLocale(ENGLISH) .setRemoteUserAddress("address") .setUserAgent("agent"); }