lidavidm commented on code in PR #607:
URL: https://github.com/apache/arrow-adbc/pull/607#discussion_r1177435657
##########
java/driver/jdbc/src/main/java/org/apache/arrow/adbc/driver/jdbc/JdbcDriver.java:
##########
@@ -47,20 +50,64 @@ public JdbcDriver(BufferAllocator allocator) {
@Override
public AdbcDatabase open(Map<String, Object> parameters) throws
AdbcException {
- Object target = parameters.get(PARAM_URL);
- if (!(target instanceof String)) {
- throw AdbcException.invalidArgument("[JDBC] Must provide String " +
PARAM_URL + " parameter");
+ DataSource dataSource = getParam(DataSource.class, parameters,
PARAM_DATASOURCE);
+ // XXX(apache/arrow-adbc#316): allow "url" to align with C/Go
+ String target = getParam(String.class, parameters, "url", PARAM_URL);
+ if (dataSource != null && target != null) {
+ throw AdbcException.invalidArgument(
+ "[JDBC] Can only provide one of " + PARAM_URL + " and " +
PARAM_DATASOURCE);
}
- Object quirks = parameters.get(PARAM_SQL_QUIRKS);
- if (quirks != null) {
- Preconditions.checkArgument(
- quirks instanceof SqlQuirks,
- String.format(
- "[JDBC] %s must be a SqlQuirks instance, not %s",
- PARAM_SQL_QUIRKS, quirks.getClass().getName()));
- } else {
+
+ SqlQuirks quirks = getParam(SqlQuirks.class, parameters, PARAM_SQL_QUIRKS);
+ if (quirks == null) {
quirks = new SqlQuirks();
}
- return new JdbcDatabase(allocator, (String) target, (SqlQuirks) quirks);
+
+ String username = getParam(String.class, parameters, "username");
+ String password = getParam(String.class, parameters, "password");
+ if ((username != null && password == null) || (username == null &&
password != null)) {
+ throw AdbcException.invalidArgument(
+ "[JDBC] Must provide both or neither of username and password");
+ }
+
+ if (target != null) {
+ dataSource = new UrlDataSource(target);
+ }
Review Comment:
This is handled above but I added a test
##########
java/driver/jdbc-validation-derby/src/test/java/org/apache/arrow/adbc/driver/jdbc/derby/DerbyConnectionTest.java:
##########
@@ -28,4 +39,31 @@ public class DerbyConnectionTest extends
AbstractConnectionTest {
static void beforeAll() {
quirks = new DerbyQuirks(tempDir);
}
+
+ @Test
+ void newUrlOption() throws Exception {
+ try (final BufferAllocator allocator = new RootAllocator()) {
+ AdbcDriver driver = new JdbcDriver(allocator);
+ Map<String, Object> parameters = new HashMap<>();
+ parameters.put("url", "jdbc:derby:memory:newUrlOption;create=true");
Review Comment:
Fixed - now uses uri
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]