From 7b4527c0c08ec49f2e3042b40763d95c7e2d1ffc Mon Sep 17 00:00:00 2001 From: Mike Pigott Date: Sat, 8 Dec 2018 16:39:37 -0500 Subject: [PATCH] Test for the include-metadata flag in the configuration. --- .../arrow/adapter/jdbc/JdbcToArrowConfig.java | 29 ++++++++++++++++++- .../arrow/adapter/jdbc/JdbcToArrowUtils.java | 2 +- .../adapter/jdbc/JdbcToArrowConfigTest.java | 20 +++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowConfig.java b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowConfig.java index ab78ae5ecd859..4c3ecbe898d1b 100644 --- a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowConfig.java +++ b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowConfig.java @@ -56,6 +56,15 @@ public JdbcToArrowConfig(BaseAllocator allocator, Calendar calendar) { this.includeMetadata = false; } + /** + * Constructs a new configuration from the provided allocator and calendar. The allocator + * is used when constructing the Arrow vectors from the ResultSet, and the calendar is used to define + * Arrow Timestamp fields, and to read time-based fields from the JDBC ResultSet. + * + * @param allocator The memory allocator to construct the Arrow vectors with. + * @param calendar The calendar to use when constructing Timestamp fields and reading time-based results. + * @param includeMetadata Whether to include JDBC field metadata in the Arrow Schema Field metadata. + */ public JdbcToArrowConfig(BaseAllocator allocator, Calendar calendar, boolean includeMetadata) { this(allocator, calendar); this.includeMetadata = includeMetadata; @@ -75,6 +84,7 @@ public Calendar getCalendar() { * Arrow schema, and reading time-based fields from the JDBC ResultSet. * * @param calendar the calendar to set. + * @return This instance of the JdbcToArrowConfig, for chaining. * @exception NullPointerExeption if calendar is null. */ public JdbcToArrowConfig setCalendar(Calendar calendar) { @@ -95,6 +105,7 @@ public BaseAllocator getAllocator() { * Sets the memory allocator to use when construting the Arrow vectors from the ResultSet. * * @param allocator the allocator to set. + * @return This instance of the JdbcToArrowConfig, for chaining. * @exception NullPointerException if allocator is null. */ public JdbcToArrowConfig setAllocator(BaseAllocator allocator) { @@ -103,10 +114,26 @@ public JdbcToArrowConfig setAllocator(BaseAllocator allocator) { return this; } - public boolean includeMetadata() { + /** + * Whether to include JDBC ResultSet field metadata in the Arrow Schema field metadata. + * + * @return true to include field metadata, false to exclude it. + */ + public boolean getIncludeMetadata() { return includeMetadata; } + /** + * Sets whether to include JDBC ResultSet field metadata in the Arrow Schema field metadata. + * + * @param includeMetadata Whether to include or exclude JDBC metadata in the Arrow Schema field metadata. + * @return This instance of the JdbcToArrowConfig, for chaining. + */ + public JdbcToArrowConfig setIncludeMetadata(boolean includeMetadata) { + this.includeMetadata = includeMetadata; + return this; + } + /** * Whether this configuration is valid. The configuration is valid when: *