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 JdbcConsumer |
getConsumer(ArrowType arrowType,
int columnIndex,
boolean nullable,
FieldVector vector,
JdbcToArrowConfig config)
Default function used for JdbcConsumerFactory.
|
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.SchemaSQLException - 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.SchemaSQLException - 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.SchemaSQLException - 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 errorIOExceptionpublic 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 errorJdbcConsumerException - on error from VectorConsumerIOExceptionpublic static JdbcConsumer getConsumer(ArrowType arrowType, int columnIndex, boolean nullable, FieldVector vector, JdbcToArrowConfig config)
arrowType - Arrow type for the column.columnIndex - Column index to fetch from the ResultSetnullable - Whether the value is nullable or notvector - Vector to store the consumed valueconfig - Associated JdbcToArrowConfig, used mainly for the Calendar.JdbcConsumerCopyright © 2024 The Apache Software Foundation. All rights reserved.