@Override public String toString() { if (rawPath.isPresent()) { return Joiner.on(", ").join(getParsedPath()); } //empty string is only used for an uninitialized path, as an empty path would be \"\" return ""; } }
@Override public String toString() { if (rawPath.isPresent()) { return Joiner.on(", ").join(getParsedPath()); } //empty string is only used for an uninitialized path, as an empty path would be \"\" return ""; } }
for (SqlPathElement element : sqlPath.getParsedPath()) { if (!element.getCatalog().isPresent() && !session.getCatalog().isPresent()) { throw new SemanticException(CATALOG_NOT_SPECIFIED, statement, "Catalog must be specified for each path element when session catalog is not set");
for (SqlPathElement element : sqlPath.getParsedPath()) { if (!element.getCatalog().isPresent() && !session.getCatalog().isPresent()) { throw new SemanticException(CATALOG_NOT_SPECIFIED, statement, "Catalog must be specified for each path element when session catalog is not set");
@Test(expectedExceptions = ParsingException.class, expectedExceptionsMessageRegExp = "\\Qline 1:9: mismatched input '.'. Expecting: ',', <EOF>\\E") public void testInvalidPath() { SqlEnvironmentConfig config = new SqlEnvironmentConfig().setPath("too.many.qualifiers"); new SqlPath(config.getPath()).getParsedPath(); } }
@Test(expectedExceptions = ParsingException.class, expectedExceptionsMessageRegExp = "\\Qline 1:9: mismatched input '.'. Expecting: ',', <EOF>\\E") public void testInvalidPath() { SqlEnvironmentConfig config = new SqlEnvironmentConfig().setPath("too.many.qualifiers"); new SqlPath(config.getPath()).getParsedPath(); } }
@Test public void testSqlPathCreation() { ImmutableList.Builder<SqlPathElement> correctValues = ImmutableList.builder(); correctValues.add(new SqlPathElement( Optional.of(new Identifier("normal")), new Identifier("schema"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("who.uses.periods")), new Identifier("in.schema.names"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("same,deal")), new Identifier("with,commas"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("aterrible")), new Identifier("thing!@#$%^&*()"))); List<SqlPathElement> expected = correctValues.build(); SqlPath path = new SqlPath(Optional.of("normal.schema," + "\"who.uses.periods\".\"in.schema.names\"," + "\"same,deal\".\"with,commas\"," + "aterrible.\"thing!@#$%^&*()\"")); assertEquals(path.getParsedPath(), expected); assertEquals(path.toString(), Joiner.on(", ").join(expected)); } }
@Test public void testSqlPathCreation() { ImmutableList.Builder<SqlPathElement> correctValues = ImmutableList.builder(); correctValues.add(new SqlPathElement( Optional.of(new Identifier("normal")), new Identifier("schema"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("who.uses.periods")), new Identifier("in.schema.names"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("same,deal")), new Identifier("with,commas"))); correctValues.add(new SqlPathElement( Optional.of(new Identifier("aterrible")), new Identifier("thing!@#$%^&*()"))); List<SqlPathElement> expected = correctValues.build(); SqlPath path = new SqlPath(Optional.of("normal.schema," + "\"who.uses.periods\".\"in.schema.names\"," + "\"same,deal\".\"with,commas\"," + "aterrible.\"thing!@#$%^&*()\"")); assertEquals(path.getParsedPath(), expected); assertEquals(path.toString(), Joiner.on(", ").join(expected)); } }