lidavidm commented on code in PR #474:
URL: https://github.com/apache/arrow-adbc/pull/474#discussion_r1117261052
##########
java/driver/validation/src/main/java/org/apache/arrow/adbc/driver/testsuite/SqlTestUtil.java:
##########
@@ -69,4 +69,140 @@ public Schema ingestTableIntsStrs(
}
return schema;
}
+
+ /** Load a table with composite primary key */
+ public Schema ingestTableWithConstraints(
+ BufferAllocator allocator, AdbcConnection connection, String tableName)
throws Exception {
+ tableName = quirks.caseFoldTableName(tableName);
+ final Schema schema =
+ new Schema(
+ Arrays.asList(
+ Field.notNullable(
+ quirks.caseFoldColumnName("INTS"), new ArrowType.Int(32,
/*signed=*/ true)),
+ Field.nullable(quirks.caseFoldColumnName("INTS2"), new
ArrowType.Int(32, true))));
+ try (final VectorSchemaRoot root = VectorSchemaRoot.create(schema,
allocator)) {
+ final IntVector ints = (IntVector) root.getVector(0);
+ final IntVector strs = (IntVector) root.getVector(1);
+
+ ints.allocateNew(4);
+ ints.setSafe(0, 0);
+ ints.setSafe(1, 1);
+ ints.setSafe(2, 2);
+ ints.setSafe(3, 3);
+ strs.allocateNew(4);
+ strs.setSafe(0, 10);
+ strs.setSafe(1, 11);
+ strs.setSafe(2, 12);
+ strs.setSafe(3, 13);
+ root.setRowCount(4);
+ try (final AdbcStatement stmt = connection.bulkIngest(tableName,
BulkIngestMode.CREATE)) {
+ stmt.bind(root);
+ stmt.executeUpdate();
+ }
+
+ try (final AdbcStatement stmt = connection.createStatement()) {
+ stmt.setSqlQuery("ALTER TABLE " + tableName + " ALTER COLUMN INTS SET
NOT NULL");
Review Comment:
Maybe make it a default method of SqlValidationQuirks to generate this
statement given a table and column name
##########
java/driver/validation/src/main/java/org/apache/arrow/adbc/driver/testsuite/SqlTestUtil.java:
##########
@@ -69,4 +69,140 @@ public Schema ingestTableIntsStrs(
}
return schema;
}
+
+ /** Load a table with composite primary key */
+ public Schema ingestTableWithConstraints(
+ BufferAllocator allocator, AdbcConnection connection, String tableName)
throws Exception {
+ tableName = quirks.caseFoldTableName(tableName);
+ final Schema schema =
+ new Schema(
+ Arrays.asList(
+ Field.notNullable(
+ quirks.caseFoldColumnName("INTS"), new ArrowType.Int(32,
/*signed=*/ true)),
+ Field.nullable(quirks.caseFoldColumnName("INTS2"), new
ArrowType.Int(32, true))));
+ try (final VectorSchemaRoot root = VectorSchemaRoot.create(schema,
allocator)) {
+ final IntVector ints = (IntVector) root.getVector(0);
+ final IntVector strs = (IntVector) root.getVector(1);
+
+ ints.allocateNew(4);
+ ints.setSafe(0, 0);
+ ints.setSafe(1, 1);
+ ints.setSafe(2, 2);
+ ints.setSafe(3, 3);
+ strs.allocateNew(4);
+ strs.setSafe(0, 10);
+ strs.setSafe(1, 11);
+ strs.setSafe(2, 12);
+ strs.setSafe(3, 13);
+ root.setRowCount(4);
+ try (final AdbcStatement stmt = connection.bulkIngest(tableName,
BulkIngestMode.CREATE)) {
+ stmt.bind(root);
+ stmt.executeUpdate();
+ }
+
+ try (final AdbcStatement stmt = connection.createStatement()) {
+ stmt.setSqlQuery("ALTER TABLE " + tableName + " ALTER COLUMN INTS SET
NOT NULL");
+ stmt.executeUpdate();
+ }
+
+ try (final AdbcStatement stmt = connection.createStatement()) {
+ stmt.setSqlQuery("ALTER TABLE " + tableName + " ALTER COLUMN INTS2 SET
NOT NULL");
+ stmt.executeUpdate();
+ }
+
+ try (final AdbcStatement stmt = connection.createStatement()) {
+ stmt.setSqlQuery(
Review Comment:
Ditto for this, and the other DDL queries
##########
java/driver/jdbc/src/main/java/org/apache/arrow/adbc/driver/jdbc/ObjectMetadataBuilder.java:
##########
@@ -21,11 +21,10 @@
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
Review Comment:
nit: I'd prefer to avoid star imports if possible
--
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]