java.lang.Object
org.apache.arrow.adapter.jdbc.JdbcToArrowUtils
Class that does most of the work to convert JDBC ResultSet data into Arrow columnar format Vector
 objects.
- Since:
- 0.10.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic ArrowTypegetArrowTypeFromJdbcType(JdbcFieldInfo fieldInfo, Calendar calendar) Converts the provided JDBC type to its respectiveArrowTypecounterpart.static JdbcConsumergetConsumer(ArrowType arrowType, int columnIndex, boolean nullable, FieldVector vector, JdbcToArrowConfig config) Default function used for JdbcConsumerFactory.static CalendarReturns the instance of a {java.util.Calendar} with the UTC time zone and root locale.static SchemajdbcToArrowSchema(ParameterMetaData parameterMetaData, Calendar calendar) Create ArrowSchemaobject for the given JDBCResultSetMetaData.static SchemajdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar) Create ArrowSchemaobject for the given JDBCResultSetMetaData.static SchemajdbcToArrowSchema(ResultSetMetaData rsmd, JdbcToArrowConfig config) Create ArrowSchemaobject for the given JDBCResultSetMetaData.static voidjdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, Calendar calendar) Iterate the given JDBCResultSetobject to fetch the data and transpose it to populate the given Arrow Vector objects.static voidjdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, JdbcToArrowConfig config) Iterate the given JDBCResultSetobject to fetch the data and transpose it to populate the given Arrow Vector objects.static Function<JdbcFieldInfo,ArrowType> reportUnsupportedTypesAsOpaque(Function<JdbcFieldInfo, ArrowType> typeConverter, String vendorName) Wrap a JDBC to Arrow type converter such thatUnsupportedOperationExceptionbecomesOpaqueType.
- 
Constructor Details- 
JdbcToArrowUtilspublic JdbcToArrowUtils()
 
- 
- 
Method Details- 
getUtcCalendarReturns the instance of a {java.util.Calendar} with the UTC time zone and root locale.
- 
jdbcToArrowSchemapublic static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar) throws SQLException Create ArrowSchemaobject for the given JDBCResultSetMetaData.- Parameters:
- 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.
- Returns:
- Schema
- Throws:
- SQLException- on error
 
- 
jdbcToArrowSchemapublic static Schema jdbcToArrowSchema(ParameterMetaData parameterMetaData, Calendar calendar) throws SQLException Create ArrowSchemaobject for the given JDBCResultSetMetaData.- Parameters:
- 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.
- Returns:
- Schema
- Throws:
- SQLException- on error
 
- 
getArrowTypeFromJdbcTypeConverts the provided JDBC type to its respectiveArrowTypecounterpart.- Parameters:
- fieldInfo- the- JdbcFieldInfowith information about the original JDBC type.
- calendar- the- Calendarto use for datetime data types.
- Returns:
- a new ArrowType.
 
- 
reportUnsupportedTypesAsOpaquepublic static Function<JdbcFieldInfo,ArrowType> reportUnsupportedTypesAsOpaque(Function<JdbcFieldInfo, ArrowType> typeConverter, String vendorName) Wrap a JDBC to Arrow type converter such thatUnsupportedOperationExceptionbecomesOpaqueType.- Parameters:
- typeConverter- The type converter to wrap.
- vendorName- The database name to report as the Opaque type's vendor name.
 
- 
jdbcToArrowSchemapublic static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, JdbcToArrowConfig config) throws SQLException Create ArrowSchemaobject for the given JDBCResultSetMetaData.If JdbcToArrowConfig.shouldIncludeMetadata()returnstrue, the following fields will be added to theFieldType.getMetadata():- Constants.SQL_CATALOG_NAME_KEYrepresenting- ResultSetMetaData.getCatalogName(int)
- Constants.SQL_TABLE_NAME_KEYrepresenting- ResultSetMetaData.getTableName(int)
- Constants.SQL_COLUMN_NAME_KEYrepresenting- ResultSetMetaData.getColumnLabel(int)
- Constants.SQL_TYPE_KEYrepresenting- 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. TheJdbcToArrowConfig.getArraySubTypeByColumnIndex(int)method will be checked first, followed by theJdbcToArrowConfig.getArraySubTypeByColumnName(String)method.- Parameters:
- rsmd- The ResultSetMetaData containing the results, to read the JDBC metadata from.
- config- The configuration to use when constructing the schema.
- Returns:
- Schema
- Throws:
- SQLException- on error
- IllegalArgumentException- if- rsmdcontains an- Types.ARRAYbut the- configdoes not have a sub-type definition for it.
 
- 
jdbcToArrowVectorspublic static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, Calendar calendar) throws SQLException, IOException Iterate the given JDBCResultSetobject to fetch the data and transpose it to populate the given Arrow Vector objects.- Parameters:
- rs- ResultSet to use to fetch the data from underlying database
- root- Arrow- VectorSchemaRootobject to populate
- calendar- The calendar to use when reading- Date,- Time, or- Timestampdata types from the- ResultSet, or- nullif not converting.
- Throws:
- SQLException- on error
- IOException
 
- 
jdbcToArrowVectorspublic static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, JdbcToArrowConfig config) throws SQLException, IOException Iterate the given JDBCResultSetobject to fetch the data and transpose it to populate the given Arrow Vector objects.- Parameters:
- rs- ResultSet to use to fetch the data from underlying database
- root- Arrow- VectorSchemaRootobject to populate
- config- The configuration to use when reading the data.
- Throws:
- SQLException- on error
- JdbcConsumerException- on error from VectorConsumer
- IOException
 
- 
getConsumerpublic static JdbcConsumer getConsumer(ArrowType arrowType, int columnIndex, boolean nullable, FieldVector vector, JdbcToArrowConfig config) Default function used for JdbcConsumerFactory. This function gets a JdbcConsumer for the given column based on the Arrow type and provided vector.- Parameters:
- arrowType- Arrow type for the column.
- columnIndex- Column index to fetch from the ResultSet
- nullable- Whether the value is nullable or not
- vector- Vector to store the consumed value
- config- Associated JdbcToArrowConfig, used mainly for the Calendar.
- Returns:
- JdbcConsumer
 
 
-