Skip to content

Commit

Permalink
Affirming the field metadata is empty when the configuration excludes…
Browse files Browse the repository at this point in the history
… field metadata.
  • Loading branch information
Mike Pigott committed Dec 8, 2018
1 parent 7b4527c commit 72d64cc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.apache.arrow.vector.TinyIntVector;
import org.apache.arrow.vector.VarBinaryVector;
import org.apache.arrow.vector.VarCharVector;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.types.pojo.Field;

/**
* This is a Helper class which has functionalities to read and assert the values from the given FieldVector object.
Expand Down Expand Up @@ -166,6 +168,17 @@ public static void assertNullValues(BaseValueVector vector, int rowCount) {
}
}

public static void assertFieldMetadataIsEmpty(VectorSchemaRoot schema) {
assertNotNull(schema);
assertNotNull(schema.getSchema());
assertNotNull(schema.getSchema().getFields());

for (Field field : schema.getSchema().getFields()) {
assertNotNull(field.getMetadata());
assertEquals(0, field.getMetadata().size());
}
}

public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest;
import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowTestHelper;
import org.apache.arrow.adapter.jdbc.Table;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.VarCharVector;
Expand Down Expand Up @@ -132,6 +133,8 @@ public void testJdbcToArroValues() throws SQLException, IOException {
* @param root VectorSchemaRoot for test
*/
public void testDataSets(VectorSchemaRoot root) {
JdbcToArrowTestHelper.assertFieldMetadataIsEmpty(root);

assertVarcharVectorValues((VarCharVector) root.getVector(CLOB), table.getRowCount(),
getCharArrayWithCharSet(table.getValues(), CLOB, StandardCharsets.UTF_8));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest;
import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowTestHelper;
import org.apache.arrow.adapter.jdbc.Table;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BigIntVector;
Expand Down Expand Up @@ -158,6 +159,8 @@ public void testJdbcToArroValues() throws SQLException, IOException {
* @param root VectorSchemaRoot for test
*/
public void testDataSets(VectorSchemaRoot root) {
JdbcToArrowTestHelper.assertFieldMetadataIsEmpty(root);

switch (table.getType()) {
case BIGINT:
assertBigIntVectorValues((BigIntVector) root.getVector(table.getVector()), table.getValues().length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest;
import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowTestHelper;
import org.apache.arrow.adapter.jdbc.Table;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BigIntVector;
Expand Down Expand Up @@ -116,6 +117,8 @@ public void testJdbcToArroValues() throws SQLException, IOException {
* @param root VectorSchemaRoot for test
*/
public void testDataSets(VectorSchemaRoot root) {
JdbcToArrowTestHelper.assertFieldMetadataIsEmpty(root);

switch (table.getType()) {
case NULL:
sqlToArrowTestNullValues(table.getVectors(), root, table.getRowCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest;
import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowTestHelper;
import org.apache.arrow.adapter.jdbc.Table;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BigIntVector;
Expand Down Expand Up @@ -149,6 +150,8 @@ public void testJdbcToArroValues() throws SQLException, IOException {
* @param root VectorSchemaRoot for test
*/
public void testDataSets(VectorSchemaRoot root) {
JdbcToArrowTestHelper.assertFieldMetadataIsEmpty(root);

assertBigIntVectorValues((BigIntVector) root.getVector(BIGINT), table.getRowCount(),
getLongValues(table.getValues(), BIGINT));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.arrow.adapter.jdbc.AbstractJdbcToArrowTest;
import org.apache.arrow.adapter.jdbc.JdbcToArrow;
import org.apache.arrow.adapter.jdbc.JdbcToArrowConfig;
import org.apache.arrow.adapter.jdbc.JdbcToArrowTestHelper;
import org.apache.arrow.adapter.jdbc.Table;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.DateMilliVector;
Expand Down Expand Up @@ -125,6 +126,8 @@ public void testJdbcToArroValues() throws SQLException, IOException {
* @param root VectorSchemaRoot for test
*/
public void testDataSets(VectorSchemaRoot root) {
JdbcToArrowTestHelper.assertFieldMetadataIsEmpty(root);

switch (table.getType()) {
case EST_DATE:
case GMT_DATE:
Expand Down

0 comments on commit 72d64cc

Please sign in to comment.