@Override public Void visitResetSession(ResetSession node, Integer context) { builder.append("RESET SESSION ") .append(node.getName()); return null; }
@Override public CompletableFuture<?> execute(ResetSession statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine) { if (statement.getName().getParts().size() > 2) { throw new SemanticException(INVALID_SESSION_PROPERTY, statement, "Invalid session property '%s'", statement.getName()); } // validate the property name metadata.getSessionPropertyManager().getSessionPropertyMetadata(statement.getName().toString()); stateMachine.addResetSessionProperties(statement.getName().toString()); return completedFuture(null); }
@Test public void test() throws Exception { Session session = TEST_SESSION.withSystemProperty("foo", "bar").withCatalogProperty("catalog", "baz", "blah"); TransactionManager transactionManager = createTestTransactionManager(); QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), "reset foo", session, URI.create("fake://uri"), false, transactionManager, executor); new ResetSessionTask().execute(new ResetSession(QualifiedName.of("catalog", "baz")), transactionManager, metadata, new AllowAllAccessControl(), stateMachine).join(); Set<String> sessionProperties = stateMachine.getResetSessionProperties(); assertEquals(sessionProperties, ImmutableSet.of("catalog.baz")); }
@Test public void testResetSession() throws Exception { assertStatement("RESET SESSION foo.bar", new ResetSession(QualifiedName.of("foo", "bar"))); assertStatement("RESET SESSION foo", new ResetSession(QualifiedName.of("foo"))); }
@Override public Node visitResetSession(SqlBaseParser.ResetSessionContext context) { return new ResetSession(getLocation(context), getQualifiedName(context.qualifiedName())); }