use of io.trino.sql.tree.PathSpecification in project trino by trinodb.
the class TestSetPathTask method testSetPathInvalidCatalog.
@Test
public void testSetPathInvalidCatalog() {
PathSpecification invalidPathSpecification = new PathSpecification(Optional.empty(), ImmutableList.of(new PathElement(Optional.of(new Identifier("invalidCatalog")), new Identifier("thisDoesNotMatter"))));
QueryStateMachine stateMachine = createQueryStateMachine("SET PATH invalidCatalog.thisDoesNotMatter");
assertThatThrownBy(() -> executeSetPathTask(invalidPathSpecification, stateMachine)).isInstanceOf(TrinoException.class).hasMessageMatching("Catalog '.*' does not exist");
}
use of io.trino.sql.tree.PathSpecification in project trino by trinodb.
the class TestSetPathTask method testSetPath.
@Test
public void testSetPath() {
PathSpecification pathSpecification = new PathSpecification(Optional.empty(), ImmutableList.of(new PathElement(Optional.empty(), new Identifier("foo"))));
QueryStateMachine stateMachine = createQueryStateMachine("SET PATH foo");
executeSetPathTask(pathSpecification, stateMachine);
assertEquals(stateMachine.getSetPath(), "foo");
}
use of io.trino.sql.tree.PathSpecification in project trino by trinodb.
the class TestSqlParser method testSetPath.
@Test
public void testSetPath() {
assertStatement("SET PATH iLikeToEat.apples, andBananas", new SetPath(new PathSpecification(Optional.empty(), ImmutableList.of(new PathElement(Optional.of(new Identifier("iLikeToEat")), new Identifier("apples")), new PathElement(Optional.empty(), new Identifier("andBananas"))))));
assertStatement("SET PATH \"schemas,with\".\"grammar.in\", \"their!names\"", new SetPath(new PathSpecification(Optional.empty(), ImmutableList.of(new PathElement(Optional.of(new Identifier("schemas,with")), new Identifier("grammar.in")), new PathElement(Optional.empty(), new Identifier("their!names"))))));
assertThatThrownBy(() -> assertStatement("SET PATH one.too.many, qualifiers", new SetPath(new PathSpecification(Optional.empty(), ImmutableList.of(new PathElement(Optional.empty(), new Identifier("dummyValue"))))))).isInstanceOf(ParsingException.class).hasMessage("line 1:17: mismatched input '.'. Expecting: ',', <EOF>");
assertThatThrownBy(() -> SQL_PARSER.createStatement("SET PATH ", new ParsingOptions())).isInstanceOf(ParsingException.class).hasMessage("line 1:10: mismatched input '<EOF>'. Expecting: <identifier>");
}
Aggregations