Skip to content

Commit

Permalink
apacheGH-41947: [Java] Support catalog in JDBC driver with session op…
Browse files Browse the repository at this point in the history
…tions

PR comments
  • Loading branch information
stevelorddremio committed Jun 13, 2024
1 parent 8c30b1a commit 9a43834
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
7 changes: 7 additions & 0 deletions java/flight/flight-sql-jdbc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ under the License.
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.78.1</version>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
import org.apache.arrow.driver.jdbc.client.utils.ClientAuthenticationUtils;
import org.apache.arrow.flight.CallOption;
import org.apache.arrow.flight.CallStatus;
Expand Down Expand Up @@ -814,13 +815,13 @@ public Builder withCallOptions(final Collection<CallOption> options) {
}

/**
* Sets the catalog for this handler if it is not empty or contains only spaces.
* Sets the catalog for this handler if it is not null.
*
* @param catalog the catalog
* @return this instance.
*/
public Builder withCatalog(final String catalog) {
this.catalog = Optional.ofNullable(catalog).map(String::trim).filter(str -> !str.isEmpty());
public Builder withCatalog(@Nullable final String catalog) {
this.catalog = Optional.ofNullable(catalog);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,19 @@ public void testCatalog() {
assertFalse(rootBuilder.catalog.isPresent());

rootBuilder.withCatalog("");
assertFalse(rootBuilder.catalog.isPresent());
assertTrue(rootBuilder.catalog.isPresent());

rootBuilder.withCatalog(" ");
assertFalse(rootBuilder.catalog.isPresent());
assertTrue(rootBuilder.catalog.isPresent());

rootBuilder.withCatalog("noSpaces");
final String noSpaces = "noSpaces";
rootBuilder.withCatalog(noSpaces);
assertTrue(rootBuilder.catalog.isPresent());
assertEquals("noSpaces", rootBuilder.catalog.get());
assertEquals(noSpaces, rootBuilder.catalog.get());

rootBuilder.withCatalog(" spaces ");
final String nameWithSpaces = " spaces ";
rootBuilder.withCatalog(nameWithSpaces);
assertTrue(rootBuilder.catalog.isPresent());
assertEquals("spaces", rootBuilder.catalog.get());
assertEquals(nameWithSpaces, rootBuilder.catalog.get());
}
}

0 comments on commit 9a43834

Please sign in to comment.