Skip to content

Commit 7b38cf4

Browse files
authored
feat(java/driver/jni): metadata methods, validation suite (#3972)
- adds bindings for: GetObjects, GetInfo, GetTableSchema, GetTableTypes - adds jni-validation-sqlite suite, most of the stuff in there is still disabled because of sqlite issues. I'll try later to add some of those to quirks and make it work. - fixes deferred bind bug that came up in validation suite. c driver expects user to rebind if data changes, while java seems to allow a caller to alter VectorSchemaRoot after it has been bound. Added `exportBind` method in JniStatement that exports bound data to c before each execution rather than during bind call.
1 parent 7b2ae4f commit 7b38cf4

15 files changed

Lines changed: 649 additions & 28 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.arrow.adbc</groupId>
24+
<artifactId>arrow-adbc-java-root</artifactId>
25+
<version>0.23.0-SNAPSHOT</version>
26+
<relativePath>../../pom.xml</relativePath>
27+
</parent>
28+
29+
<artifactId>adbc-driver-jni-validation-sqlite</artifactId>
30+
<packaging>jar</packaging>
31+
<name>Arrow ADBC Driver JNI Validation with SQLite</name>
32+
<description>Tests validating the JNI driver against SQLite.</description>
33+
34+
<properties>
35+
<maven.deploy.skip>true</maven.deploy.skip>
36+
</properties>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>org.apache.arrow.adbc</groupId>
41+
<artifactId>adbc-core</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.apache.arrow.adbc</groupId>
46+
<artifactId>adbc-driver-jni</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
50+
<!-- Testing -->
51+
<dependency>
52+
<groupId>org.apache.arrow</groupId>
53+
<artifactId>arrow-memory-netty</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.assertj</groupId>
58+
<artifactId>assertj-core</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.apache.arrow.adbc</groupId>
68+
<artifactId>adbc-driver-validation</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
</dependencies>
72+
</project>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.arrow.adbc.driver.jni;
19+
20+
import org.apache.arrow.adbc.driver.testsuite.AbstractConnectionMetadataTest;
21+
import org.junit.jupiter.api.BeforeAll;
22+
import org.junit.jupiter.api.Disabled;
23+
24+
public class JniSqliteConnectionMetadataTest extends AbstractConnectionMetadataTest {
25+
@BeforeAll
26+
static void beforeAll() {
27+
quirks = new JniSqliteQuirks();
28+
}
29+
30+
@Override
31+
@Disabled("SQLite getInfo schema differs: map value type is List<Int32> instead of Int32")
32+
public void getInfo() {}
33+
34+
@Override
35+
@Disabled("SQLite getInfo schema differs: map value type is List<Int32> instead of Int32")
36+
public void getInfoByCode() {}
37+
38+
@Override
39+
@Disabled("SQLite does not support ALTER TABLE ... ALTER COLUMN ... SET NOT NULL")
40+
public void getObjectsConstraints() {}
41+
42+
@Override
43+
@Disabled(
44+
"SQLite getObjects schema has nullable catalog_name/db_schema_name, test expects non-null")
45+
public void getObjectsColumns() {}
46+
47+
@Override
48+
@Disabled(
49+
"SQLite getObjects schema has nullable catalog_name/db_schema_name, test expects non-null")
50+
public void getObjectsCatalogs() {}
51+
52+
@Override
53+
@Disabled(
54+
"SQLite getObjects schema has nullable catalog_name/db_schema_name, test expects non-null")
55+
public void getObjectsCatalogsPattern() {}
56+
57+
@Override
58+
@Disabled(
59+
"SQLite getObjects schema has nullable catalog_name/db_schema_name, test expects non-null")
60+
public void getObjectsDbSchemas() {}
61+
62+
@Override
63+
@Disabled(
64+
"SQLite getObjects schema has nullable catalog_name/db_schema_name, test expects non-null")
65+
public void getObjectsTables() {}
66+
67+
@Override
68+
@Disabled("SQLite type affinity returns Int64 for all types, causing schema mismatch")
69+
public void getTableSchema() {}
70+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.arrow.adbc.driver.jni;
19+
20+
import org.apache.arrow.adbc.driver.testsuite.AbstractConnectionTest;
21+
import org.junit.jupiter.api.BeforeAll;
22+
23+
public class JniSqliteConnectionTest extends AbstractConnectionTest {
24+
@BeforeAll
25+
static void beforeAll() {
26+
quirks = new JniSqliteQuirks();
27+
}
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.arrow.adbc.driver.jni;
19+
20+
import java.util.HashMap;
21+
import java.util.Map;
22+
import org.apache.arrow.adbc.core.AdbcDatabase;
23+
import org.apache.arrow.adbc.core.AdbcException;
24+
import org.apache.arrow.adbc.driver.testsuite.SqlValidationQuirks;
25+
import org.apache.arrow.memory.BufferAllocator;
26+
27+
public class JniSqliteQuirks extends SqlValidationQuirks {
28+
@Override
29+
public AdbcDatabase initDatabase(BufferAllocator allocator) throws AdbcException {
30+
final Map<String, Object> parameters = new HashMap<>();
31+
JniDriver.PARAM_DRIVER.set(parameters, "adbc_driver_sqlite");
32+
return new JniDriver(allocator).open(parameters);
33+
}
34+
35+
@Override
36+
public String defaultCatalog() {
37+
return "main";
38+
}
39+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.arrow.adbc.driver.jni;
19+
20+
import org.apache.arrow.adbc.driver.testsuite.AbstractStatementTest;
21+
import org.junit.jupiter.api.BeforeAll;
22+
import org.junit.jupiter.api.Disabled;
23+
24+
class JniSqliteStatementTest extends AbstractStatementTest {
25+
@BeforeAll
26+
static void beforeAll() {
27+
quirks = new JniSqliteQuirks();
28+
}
29+
30+
@Override
31+
@Disabled("SQLite driver does not return expected ADBC status codes for schema mismatch")
32+
public void bulkIngestAppendConflict() {}
33+
34+
@Override
35+
@Disabled("SQLite driver returns INTERNAL instead of NOT_FOUND")
36+
public void bulkIngestAppendNotFound() {}
37+
38+
@Override
39+
@Disabled("SQLite driver returns INTERNAL instead of ALREADY_EXISTS")
40+
public void bulkIngestCreateConflict() {}
41+
42+
@Override
43+
@Disabled("Not yet implemented in JNI driver")
44+
public void executeSchema() {}
45+
46+
@Override
47+
@Disabled("Not yet implemented in JNI driver")
48+
public void executeSchemaPrepared() {}
49+
50+
@Override
51+
@Disabled("Not yet implemented in JNI driver")
52+
public void executeSchemaParams() {}
53+
54+
@Override
55+
@Disabled("Not yet implemented in JNI driver")
56+
public void getParameterSchema() {}
57+
58+
@Override
59+
@Disabled("SQLite promotes INT to BIGINT, causing strict schema equality check to fail")
60+
public void prepareQueryWithParameters() {}
61+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.arrow.adbc.driver.jni;
19+
20+
import org.apache.arrow.adbc.driver.testsuite.AbstractTransactionTest;
21+
import org.junit.jupiter.api.BeforeAll;
22+
import org.junit.jupiter.api.Disabled;
23+
24+
@Disabled("Transactions not yet implemented in JNI driver")
25+
public class JniSqliteTransactionTest extends AbstractTransactionTest {
26+
@BeforeAll
27+
static void beforeAll() {
28+
quirks = new JniSqliteQuirks();
29+
}
30+
}

0 commit comments

Comments
 (0)