public class JdbcToArrowUtils extends Object
Constructor and Description |
---|
JdbcToArrowUtils() |
Modifier and Type | Method and Description |
---|---|
static ArrowType |
getArrowTypeFromJdbcType(JdbcFieldInfo fieldInfo,
Calendar calendar)
Converts the provided JDBC type to its respective
ArrowType counterpart. |
static Calendar |
getUtcCalendar()
Returns the instance of a {java.util.Calendar} with the UTC time zone and root locale.
|
static Schema |
jdbcToArrowSchema(ParameterMetaData parameterMetaData,
Calendar calendar)
Create Arrow
Schema object for the given JDBC ResultSetMetaData . |
static Schema |
jdbcToArrowSchema(ResultSetMetaData rsmd,
Calendar calendar)
Create Arrow
Schema object for the given JDBC ResultSetMetaData . |
static Schema |
jdbcToArrowSchema(ResultSetMetaData rsmd,
JdbcToArrowConfig config)
Create Arrow
Schema object for the given JDBC ResultSetMetaData . |
static void |
jdbcToArrowVectors(ResultSet rs,
VectorSchemaRoot root,
Calendar calendar)
Iterate the given JDBC
ResultSet object to fetch the data and transpose it to populate
the given Arrow Vector objects. |
static void |
jdbcToArrowVectors(ResultSet rs,
VectorSchemaRoot root,
JdbcToArrowConfig config)
Iterate the given JDBC
ResultSet object to fetch the data and transpose it to populate
the given Arrow Vector objects. |
public static Calendar getUtcCalendar()
public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar) throws SQLException
Schema
object for the given JDBC ResultSetMetaData
.rsmd
- The ResultSetMetaData containing the results, to read the JDBC metadata from.calendar
- The calendar to use the time zone field of, to construct Timestamp fields from.Schema
SQLException
- on errorpublic static Schema jdbcToArrowSchema(ParameterMetaData parameterMetaData, Calendar calendar) throws SQLException
Schema
object for the given JDBC ResultSetMetaData
.parameterMetaData
- The ResultSetMetaData containing the results, to read the JDBC metadata from.calendar
- The calendar to use the time zone field of, to construct Timestamp fields from.Schema
SQLException
- on errorpublic static ArrowType getArrowTypeFromJdbcType(JdbcFieldInfo fieldInfo, Calendar calendar)
ArrowType
counterpart.fieldInfo
- the JdbcFieldInfo
with information about the original JDBC type.calendar
- the Calendar
to use for datetime data types.ArrowType
.public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, JdbcToArrowConfig config) throws SQLException
Schema
object for the given JDBC ResultSetMetaData
.
If JdbcToArrowConfig.shouldIncludeMetadata()
returns true
, the following fields
will be added to the FieldType.getMetadata()
:
Constants.SQL_CATALOG_NAME_KEY
representing ResultSetMetaData.getCatalogName(int)
Constants.SQL_TABLE_NAME_KEY
representing ResultSetMetaData.getTableName(int)
Constants.SQL_COLUMN_NAME_KEY
representing ResultSetMetaData.getColumnLabel(int)
Constants.SQL_TYPE_KEY
representing ResultSetMetaData.getColumnTypeName(int)
If any columns are of type Types.ARRAY
, the configuration object will be used to look up
the array sub-type field. The JdbcToArrowConfig.getArraySubTypeByColumnIndex(int)
method will be
checked first, followed by the JdbcToArrowConfig.getArraySubTypeByColumnName(String)
method.
rsmd
- The ResultSetMetaData containing the results, to read the JDBC metadata from.config
- The configuration to use when constructing the schema.Schema
SQLException
- on errorIllegalArgumentException
- if rsmd
contains an Types.ARRAY
but the
config
does not have a sub-type definition for it.public static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, Calendar calendar) throws SQLException, IOException
ResultSet
object to fetch the data and transpose it to populate
the given Arrow Vector objects.rs
- ResultSet to use to fetch the data from underlying databaseroot
- Arrow VectorSchemaRoot
object to populatecalendar
- The calendar to use when reading Date
, Time
, or Timestamp
data types from the ResultSet
, or null
if not converting.SQLException
- on errorIOException
public static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, JdbcToArrowConfig config) throws SQLException, IOException
ResultSet
object to fetch the data and transpose it to populate
the given Arrow Vector objects.rs
- ResultSet to use to fetch the data from underlying databaseroot
- Arrow VectorSchemaRoot
object to populateconfig
- The configuration to use when reading the data.SQLException
- on errorIOException
Copyright © 2023 The Apache Software Foundation. All rights reserved.