29
29
public class JdbcToArrowConfigBuilder {
30
30
private Calendar calendar ;
31
31
private BaseAllocator allocator ;
32
+ private boolean includeMetadata ;
32
33
33
34
/**
34
35
* Default constructor for the <code>JdbcToArrowConfigBuilder}</code>.
@@ -38,6 +39,7 @@ public class JdbcToArrowConfigBuilder {
38
39
public JdbcToArrowConfigBuilder () {
39
40
this .allocator = null ;
40
41
this .calendar = null ;
42
+ this .includeMetadata = false ;
41
43
}
42
44
43
45
/**
@@ -63,6 +65,32 @@ public JdbcToArrowConfigBuilder(BaseAllocator allocator, Calendar calendar) {
63
65
64
66
this .allocator = allocator ;
65
67
this .calendar = calendar ;
68
+ this .includeMetadata = false ;
69
+ }
70
+
71
+ /**
72
+ * Constructor for the <code>JdbcToArrowConfigBuilder</code>. Both the
73
+ * allocator and calendar are required. A {@link NullPointerException}
74
+ * will be thrown if either of those arguments is <code>null</code>.
75
+ * <p>
76
+ * The allocator is used to construct Arrow vectors from the JDBC ResultSet.
77
+ * The calendar is used to determine the time zone of {@link java.sql.Timestamp}
78
+ * fields and convert {@link java.sql.Date}, {@link java.sql.Time}, and
79
+ * {@link java.sql.Timestamp} fields to a single, common time zone when reading
80
+ * from the result set.
81
+ * </p>
82
+ * <p>
83
+ * The <code>includeMetadata</code> argument, if <code>true</code> will cause
84
+ * various information about each database field to be added to the Vector
85
+ * Schema's field metadata.
86
+ * </p>
87
+ *
88
+ * @param allocator The Arrow Vector memory allocator.
89
+ * @param calendar The calendar to use when constructing timestamp fields.
90
+ */
91
+ public JdbcToArrowConfigBuilder (BaseAllocator allocator , Calendar calendar , boolean includeMetadata ) {
92
+ this (allocator , calendar );
93
+ this .includeMetadata = includeMetadata ;
66
94
}
67
95
68
96
/**
@@ -90,6 +118,17 @@ public JdbcToArrowConfigBuilder setCalendar(Calendar calendar) {
90
118
return this ;
91
119
}
92
120
121
+ /**
122
+ * Sets whether to include JDBC ResultSet field metadata in the Arrow Schema field metadata.
123
+ *
124
+ * @param includeMetadata Whether to include or exclude JDBC metadata in the Arrow Schema field metadata.
125
+ * @return This instance of the <code>JdbcToArrowConfig</code>, for chaining.
126
+ */
127
+ public JdbcToArrowConfigBuilder setIncludeMetadata (boolean includeMetadata ) {
128
+ this .includeMetadata = includeMetadata ;
129
+ return this ;
130
+ }
131
+
93
132
/**
94
133
* This builds the {@link JdbcToArrowConfig} from the provided
95
134
* {@link BaseAllocator} and {@link Calendar}.
@@ -98,6 +137,6 @@ public JdbcToArrowConfigBuilder setCalendar(Calendar calendar) {
98
137
* @throws NullPointerException if either the allocator or calendar was not set.
99
138
*/
100
139
public JdbcToArrowConfig build () {
101
- return new JdbcToArrowConfig (allocator , calendar , false );
140
+ return new JdbcToArrowConfig (allocator , calendar , includeMetadata );
102
141
}
103
142
}
0 commit comments