Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
248 commits
Select commit Hold shift + click to select a range
7409fb4
[FlightRPC] Flight SQL POC
Aug 22, 2020
4d4082d
FlightSQL.proto formatting feedback
Sep 1, 2020
ec981a2
Alter GetSQLCapabilies to GetSQLInfo pattern
Sep 2, 2020
4edf6b7
Rename "getSQLCapabilities" to "getSQLInfo" in FlightSQLProducer
Sep 2, 2020
54e6dfe
Address code review comments (1)
tifflhl Jan 22, 2021
3aab4a7
Update FlightSqlProducer to conform to new design.
kylep-dremio Jul 5, 2021
aacaee0
Correct the dense_union type for schema return of SQL info.
kylep-dremio Jul 6, 2021
090631f
Additional CR changes.
kylep-dremio Jul 6, 2021
f813b5f
Add support for primary and foreign keys.
kylep-dremio Jul 7, 2021
1619811
Fix broken Maven build
Jul 9, 2021
d0f8a97
Clear broken code for readability -- this will be useful for fixing t…
Jul 9, 2021
cc7cc3d
Fix code style issues such as excessive usage of static imports
Jul 12, 2021
f39e372
Add Hamcrest as a root-level dependency
Jul 12, 2021
d4d0b58
Replace me.alexpanov:free-port-finder with org.codehaus.mojo:build-he…
Jul 12, 2021
7cce16a
Remove unnecessary singletonList in tests
Jul 12, 2021
139f62b
Remove unnecessary overridden method from FlightSqlExample
Jul 12, 2021
52ebd2d
Replace static initializer block with @BeforeClass in tests
Jul 12, 2021
9f28ddd
Remove unnecessary overridden method from FlightSqlExample
Jul 12, 2021
7bcab26
Clean-up: remove boilerplate code by replacing with tools provided by…
Jul 12, 2021
6b62c13
Update tests
Jul 12, 2021
41fe35d
Fix bad assertion in tests for simple prepared statement
Jul 13, 2021
a4a5863
Update Javadoc; warn about premature closing of resources
Jul 13, 2021
6665829
Start re-implementation of tests for CommandGetTables
Jul 13, 2021
44f7ed5
Add TODOs for future refactor
Jul 13, 2021
c4c9e61
Update FlightSqlExample for code reusability
Jul 13, 2021
8661761
Create test for GetCatalogs
Jul 14, 2021
6273519
Add test for GetTableTypes
Jul 14, 2021
65424b9
Split up tests for FlightSqlExample
Jul 14, 2021
d82990d
Add test for GetSchemas
Jul 14, 2021
89918e7
Update tests for GetTables
Jul 14, 2021
40498cc
Fix test for GetTables
Jul 15, 2021
cafcd6f
Fix broken Maven build
Jul 15, 2021
429fb4d
Fix checkstyle violations
Jul 15, 2021
c5144f4
Remove unused fields
Jul 15, 2021
a1fb496
Enable support for includeSchema in GetTables
Jul 15, 2021
992c4ba
Remove unused static import
Jul 15, 2021
d5915ef
Fix broken tests
Jul 15, 2021
fd6c7c5
Update tests for GetTables -- start refactor to use proper schemas
Jul 16, 2021
fb1376e
WIP: Work on getTablesRoot
rafael-telles Jul 16, 2021
6e62f37
WIP: Fix GetTables for no schema queries
Jul 16, 2021
d357998
WIP: Fix bug where GetTables returns null if includeSchema
Jul 16, 2021
f810563
WIP: test cases for GetTables
Jul 16, 2021
d37f4e6
Fix tests for GetTables -- shows correct schema
Jul 17, 2021
91a4083
Fix checkstyle and dependency management errors
Jul 17, 2021
ea4f620
Add precision and scale to GetTables' schema
Jul 19, 2021
817d2bf
Remove boilerplate code for creating a new Schema by reusing default …
Jul 19, 2021
6574db5
Remove unnecessary comments in code
Jul 19, 2021
425b381
Add TODO note to remove work from FlightSqlExample's constructor
Jul 19, 2021
05c24b4
Make default JDBC converter private with getter for decoupling and sa…
Jul 19, 2021
ee4b6dc
Remove unneeded static imports
Jul 19, 2021
211192f
Fix checkstyle violations
Jul 19, 2021
2239d11
Remove unnecessary null-check for ResultSet#getInt
Jul 19, 2021
2112805
Auto-close resources used for GetTables
Jul 19, 2021
dcdc114
Add Javadoc for FlightSqlExample#getVectorsFromData
Jul 19, 2021
0f6c5a6
Update Javadoc for FlightSqlExample#getArrowTypeFromJdbcType
Jul 19, 2021
4a8f0f6
Fix checkstyle violations
Jul 19, 2021
ba72219
Replace package-protected modifier with private
Jul 19, 2021
b07de66
WIP: Working on fixing data consistency issue where catalog is null i…
Jul 20, 2021
d222c73
Fix resource leaks for GetTables and CreatePreparedStatement
Jul 20, 2021
f484a56
Implement FlightSqlExample's GetPrimaryKey command
rafael-telles Jul 21, 2021
9cf4582
Avoid handling empty strings as null on CommandGetPrimaryKeys
rafael-telles Jul 21, 2021
c95eccf
Properly handle SQLException on CommandGetPrimaryKeys
rafael-telles Jul 21, 2021
4011d09
Refactor duplicate code on getFlightInfo* methods
rafael-telles Jul 21, 2021
01024de
Fix wrong ResultSet getter method on getStreamPrimaryKeys
rafael-telles Jul 21, 2021
0ff6da1
WIP: Add support for GetCatalogs: GetFlightInfoCatalogs
Jul 19, 2021
d036e23
WIP: Add support for GetCatalogs: GetStreamCatalogs
Jul 19, 2021
4616c06
WIP: Start GetSchemas
Jul 19, 2021
fc525a7
WIP: Add support for GetTableTypes: getFlightInfoTableTypes
Jul 19, 2021
5ba01e7
WIP: Add support for GetTableTypes: getStreamTableTypes
Jul 19, 2021
449d31a
WIP: Add support for GetSqlInfo: getSchemaSqlInfo
Jul 19, 2021
7af0a93
Replace package-protected modifier with private
Jul 19, 2021
28cacc8
WIP: Working on fixing data consistency issue where catalog is null i…
Jul 20, 2021
dec516f
Fix rebase conflicts
Jul 20, 2021
78bd669
Extract helper method for retrieving schemas for GetTables
Jul 21, 2021
55e8df0
Extract helper method for retrieving schemas for GetCatalogs
Jul 21, 2021
7db5449
Extract helper method for retrieving schemas for GetTableTypes
Jul 21, 2021
d65370e
Extract helper method for retrieving schemas for GetSchemas
Jul 21, 2021
2e14550
Fix checkstyle violations
Jul 21, 2021
b11aa3d
Fix GetCatalogs tests
Jul 21, 2021
812223d
Add support for null catalogs @ GetTables
Jul 21, 2021
71197d1
Minor refactor: apply DRY principle to repeated methods
Jul 21, 2021
31174a3
Ignore broken tests
Jul 21, 2021
d9818ea
Fix broken tests for CreatePreparedStatement
Jul 21, 2021
70e4110
Minor refactor: reuse available helper methods
Jul 21, 2021
10d052b
Extract calendar used by TestFlightSql
Jul 21, 2021
4cfa308
Fix Schema generation not setting an unknown column type to nullable
Jul 22, 2021
fcc5837
Change FlightSqlProducer from abstract class to interface
Jul 22, 2021
e37aac3
Update FlightSql protobuf to allow nullable values as parameters for …
Jul 22, 2021
155654e
Clean up code by moving JDBC-to-Arrow conversions methods to utility …
Jul 22, 2021
6186e4f
Replace FlightSqlExample#buildSchema with helper methods
Jul 22, 2021
363f03d
Refactor tests due to creation of new column of primaryKey
jcralmeida Jul 20, 2021
c6c7eec
Start separating commandForeignKey into two new commands
jcralmeida Jul 21, 2021
4e98787
Remove unnecessary parameters from ExportedKeys
jcralmeida Jul 22, 2021
2989fdc
Refactor to use the new CommandGetExportedKeys
jcralmeida Jul 22, 2021
3e16cca
Remove star import
jcralmeida Jul 22, 2021
573b4ab
create a test for getExportKeys command
jcralmeida Jul 22, 2021
03fa69e
Refactor other tests to reflect the new table created for foreign key…
jcralmeida Jul 22, 2021
c579e52
Refactor null values and error dealing
jcralmeida Jul 22, 2021
d13d4e3
Refactor variable name on proto message and methods
jcralmeida Jul 22, 2021
303e512
Deal with null values when using getInt
jcralmeida Jul 22, 2021
664f043
Fix wrong usage of wasNull()
rafael-telles Jul 22, 2021
bf580e8
Use StringValue instead of primitive string on CommandGetExportedKeys…
rafael-telles Jul 22, 2021
de9ddbd
Fix CheckStyle issues
rafael-telles Jul 22, 2021
ef1721e
Fix commentary on proto and getExportedKeys method
jcralmeida Jul 22, 2021
7f183c3
Refactor creation of vectors for CommangGetExportedKeys
jcralmeida Jul 22, 2021
4664ca7
Refactor commands to use StringValue whenever is necessary
jcralmeida Jul 22, 2021
f0b634a
Change order of the vectors of FlightSqlExample
jcralmeida Jul 22, 2021
9f4fdcc
Change empty string to null value
jcralmeida Jul 22, 2021
bbad34a
make method saveToVectors deal with IntVector
jcralmeida Jul 22, 2021
d885d40
Rename method getSchemaForeignKeys
jcralmeida Jul 23, 2021
2eb7315
add retrieval of resulSet to try-with-resources
jcralmeida Jul 23, 2021
fb7fa00
Change assertion of list from greater than 0 to equal to 1
jcralmeida Jul 23, 2021
18971c5
Implement CommandGetImportedKeys
rafael-telles Jul 23, 2021
1e88534
Fix JavaDoc for CommandGetImportedKeys methods
rafael-telles Jul 23, 2021
8053836
Add Imported and Exported keys schemas to Schemas class
rafael-telles Jul 23, 2021
18a2c14
Fix checkstyle violations
Jul 23, 2021
4a12774
Update FlightSQL GetSqlInfo: switch info from String to int for perfo…
Jul 23, 2021
f660b9e
Update GetSqlInfo: separate each section of options by 500
Jul 23, 2021
5c4264a
Make info args nullable for FlightSqlClient#getSqlInfo
Jul 26, 2021
5fb7100
Update getSqlInfo to use constant integers to represent info names
Jul 26, 2021
225774d
Minor refactor: remove unused methods
Jul 26, 2021
4ad654e
WIP [Broken]: Expand tests for GetSqlInfo to check required args
Jul 28, 2021
4587d97
Fix GetSqlInfo tests
Jul 28, 2021
b41ac74
Implement FlightSqlClient.executeUpdate
rafael-telles Jul 26, 2021
73727f3
Improve testExecuteUpdate
rafael-telles Jul 26, 2021
9fa3520
Fix AutoClosables.close usage
rafael-telles Jul 28, 2021
dc64ab5
Fix TestFlightSql.testExecuteUpdate to not hang on tests
rafael-telles Jul 28, 2021
02df453
Refactor prepareStatement to use Cache Object
jcralmeida Jul 26, 2021
5a0b71d
Remove prepareStatementCacheKey class
jcralmeida Jul 26, 2021
4fd4ed5
Rename variable randomUUID
jcralmeida Jul 26, 2021
9d44a9a
Remove unused FlightSQLExample.proto
jcralmeida Jul 26, 2021
dcb045a
Fix checkstyle violations
Jul 26, 2021
7fb25a4
Fix typo
jcralmeida Jul 28, 2021
f948e07
Remove unnecessary extra space
jcralmeida Jul 28, 2021
e4893e6
Refactor the code to not use string when getting from cache
jcralmeida Jul 28, 2021
c2b0d82
Nit: fix checkstyle
jcralmeida Jul 28, 2021
c9abb32
Nit: fix checkstyle
jcralmeida Jul 28, 2021
45e263d
Add support for querying results upon creating statement
Jul 27, 2021
0bde81a
Fix conflicts between tests for creating a new statement and checking…
Jul 27, 2021
9989e27
Add UUID to Statements instead of empty identifier as to avoid confli…
Jul 27, 2021
d7a87e7
Minor refactor: remove unused fields @ FlightSqlUtils
Jul 27, 2021
58cf326
Ensure connection is closed for Statement queries
Jul 27, 2021
e1305e5
Replace String identifier for queries with ByteString defaults
Jul 28, 2021
d453272
Fix wrong StreamListener usages and multiple instances of RootAllocators
rafael-telles Jul 29, 2021
5782fef
Fix pom.xml for flight-sql
rafael-telles Aug 2, 2021
c801346
[FlightRPC] Flight SQL POC
Aug 22, 2020
b3af505
Fix checkstyle violations
Jul 23, 2021
71781ec
Minor refactor: remove unused methods
Jul 26, 2021
b74ab17
Fix wrong StreamListener usages and multiple instances of RootAllocators
rafael-telles Jul 29, 2021
1aa639e
Refactor prepareStatement to use Cache Object
jcralmeida Jul 26, 2021
d939326
Refactor the code to not use string when getting from cache
jcralmeida Jul 28, 2021
455208b
initial progress at update on preparedstatment
jcralmeida Jul 27, 2021
41f4cb7
Add new imports
jcralmeida Jul 27, 2021
5aff106
Refactor executeUpdate test
jcralmeida Jul 27, 2021
5241907
Change executeUpdate parameters
jcralmeida Jul 27, 2021
fdd3573
add logic to executeUpdate from preparedStatement
jcralmeida Jul 27, 2021
74e16ce
Nit: fix typo on putListener
jcralmeida Jul 28, 2021
1c5b435
Add while loop at flightStream and deal with errors
jcralmeida Jul 28, 2021
27930f3
Refactor test from update at PreparedStatement
jcralmeida Jul 28, 2021
3218db5
Add creation of Vector in a try with resources
jcralmeida Jul 28, 2021
e9d2936
Fix checkstyle
jcralmeida Jul 28, 2021
ef23515
Fix checkstyle
jcralmeida Jul 28, 2021
d90059e
Change preparedStatementLoadingCache to get from a ByteString
jcralmeida Jul 28, 2021
f56c598
Add missing param to the java doc from executeUpdate Method
jcralmeida Jul 30, 2021
827fc5b
Small refactor when getting preparedStatement due to rebase
jcralmeida Jul 30, 2021
3264877
Deal with errors properly
jcralmeida Jul 30, 2021
4bdf3f3
Remove fail code used to force error
jcralmeida Aug 2, 2021
0bca0c7
Insert preparedStatement into a try-with-resources
jcralmeida Aug 2, 2021
9b8a0bd
Remove unnecessary old files
jcralmeida Aug 2, 2021
63d2425
remove vectorRoot from execute and create a setter
jcralmeida Aug 6, 2021
5ef5b09
Create a validation for when vectorRoot is present
jcralmeida Aug 6, 2021
26f9ec1
Modify execute preparedStatement flow
jcralmeida Aug 6, 2021
e14a487
Remove ignore from tests
jcralmeida Aug 6, 2021
59c96c7
Fix leaking connections on connection pool
rafael-telles Aug 6, 2021
7c69c87
Add a new test for preparedUpdate without binding parameter
jcralmeida Aug 6, 2021
0c39ca2
Deal with query with parameter in the preparedStatement
jcralmeida Aug 6, 2021
4c50b95
Fix checkstyle at FlightSqlClient class
jcralmeida Aug 6, 2021
9840558
Add a method to clear the parameters from the prepared statement object
jcralmeida Aug 6, 2021
2a3836d
Refactor the setters from prepared statement and add calendar types t…
jcralmeida Aug 6, 2021
b6fb92d
Treat exception in executeUpdate as SQLException
jcralmeida Aug 9, 2021
9a28e51
Fix Arrow versions on new pom.xml files
rafael-telles Aug 10, 2021
e162272
Fix rebase issues with FlightSql.proto
rafael-telles Aug 10, 2021
36f5fb7
Fix missing code on adapter/jdbc/JdbcToArrowUtils.java due to rebase …
rafael-telles Aug 10, 2021
2499ee8
Fix wrong PreparedStatement cache invalidation
rafael-telles Aug 10, 2021
0ce1e99
[WIP] FlightSQL Ratification based on Community Comments (#73)
Aug 17, 2021
b2ac91a
FlightSQL Ratification based on Community Comments (round 2) (#85)
rafael-telles Aug 18, 2021
ca78460
Fix missing client_execution_handle on CommandStatementQuery (#86)
rafael-telles Aug 18, 2021
7028593
Remove unused imports on FlightSqlClient
rafael-telles Aug 19, 2021
6a52ebe
Split CommandStatementQuery in 2 messages, one for Command and other …
rafael-telles Aug 19, 2021
505996c
Fix leaking Connections on FlightSqlExample
rafael-telles Aug 20, 2021
24383b8
Remove unused variable of cache
jcralmeida Aug 20, 2021
6dc4624
Add note to treat query as opaque
jcralmeida Aug 20, 2021
d1f0df1
Add argument ticket to the getStreamStatement methods
jcralmeida Aug 20, 2021
61110d9
Flight SQL Ratification Based On Community Feedback #5 (#91)
rafael-telles Aug 24, 2021
733cc30
Added arrow-format to flight-sql pom
vfraga Aug 24, 2021
74dc795
Rearrange FlightSqlProducer#getStreamStatement arguments order
rafael-telles Aug 24, 2021
7805e71
Flight SQL - Declare Protobuf enums (#93)
rafael-telles Aug 25, 2021
26482f6
Flight SQL Ratification Based On Community Feedback #6 (#94)
vfraga Aug 25, 2021
8939ee6
Flight SQL Ratification Based On Community Feedback #7 (#98)
rafael-telles Aug 26, 2021
1b10f60
Allow FlightSqlClient#getSqlInfo accept SqlInfo enum arguments (#99)
rafael-telles Aug 26, 2021
3a1ab63
Fix missing generated sources on built flight-sql jar (#101)
rafael-telles Aug 26, 2021
a1390f2
Bump protobuf version
Aug 31, 2021
46b4bce
Update CommandGetPrimaryKey from FlightSql.proto (#110)
vfraga Sep 2, 2021
9d4a41e
Flight SQL Ratification Based On Community Feedback #8 (#113)
rafael-telles Sep 2, 2021
4262f8b
Fix maven build from different directories (#114)
rafael-telles Sep 3, 2021
7c50815
Redo AutoCloseable
Sep 15, 2021
edba84d
Remove redundant Ticket arguments from getStream* methods (#125)
rafael-telles Sep 16, 2021
206822d
Add more data to GetSqlInfo for FlightSql.proto
Sep 15, 2021
d34bf7a
Add missing comment for SQL_ALL_TABLES_ARE_SELECTABLE
Sep 20, 2021
05377a8
Enrich FlightSQL documentation in protobuf definition file
Sep 20, 2021
45dd21e
Change int32 bitmask to int128 bitmask for GetSqlInfo
Sep 22, 2021
926ab2a
Add test cases for bitshifting operations required for filtering out …
Sep 22, 2021
bbcaa9c
Make GetSqlInfo return uint64 bitmask as one of the dense union fields
Sep 24, 2021
6c676a9
Add boolean value to dense union @ GetSqlInfo
Sep 24, 2021
d4883ea
Rewrite some of the documentation for FlightSql.proto and redefine so…
Sep 27, 2021
abf57d7
Replace CSV string with string list for GetSqlInfo
Sep 27, 2021
a535542
Fix FlightSQL protobuf documentation
Sep 29, 2021
78a6df4
Replace uint32 fields with int64 in GetSqlInfo
Sep 29, 2021
8a57e95
Fix Schema serialization and deserialization on Flight SQL methods
rafael-telles Oct 5, 2021
68c1a46
Fix Flight SQL Dependency problems
vfraga Oct 12, 2021
b315cae
Remove unused imports on FlightSqlExample
rafael-telles Oct 12, 2021
311bf36
[FlightSQL] Add missing method for creating bitmask from GetSqlInfo o…
Oct 12, 2021
e30bb4c
Propagate grpc version to arrow-flight/pom.xml
rafael-telles Oct 12, 2021
30cad1b
Add Flight SQL Client Demo App to Flight SQL Package (#134)
vfraga Oct 12, 2021
a4de98d
Fix CheckStyle issues
rafael-telles Oct 13, 2021
c5e9865
[FlightSQL] Add enum for and map vector for supportsConvert (#171)
JrJuscelino Oct 18, 2021
089b11d
Add CommandGetCrossReference on FlightSql.proto
rafael-telles Oct 18, 2021
268ca19
Add getCrossReference method to sqlClient
jcralmeida Oct 18, 2021
1dac11e
Add CrossReference methods to SqlProducer
jcralmeida Oct 18, 2021
250e2c0
Implement cross-reference logic on server
jcralmeida Oct 18, 2021
fb6026d
Add a test to cross-reference command from flight-sql
jcralmeida Oct 18, 2021
b56ff0a
Refactor schemas retrieval from imported, exported keys and cross-ref…
jcralmeida Oct 18, 2021
f6f0188
Add documentation to cross reference fields on proto file
jcralmeida Oct 18, 2021
215beeb
Typo on message CommandGetCrossReference
jcralmeida Oct 18, 2021
eb39c6b
Refactor variable name from CrossReference
jcralmeida Oct 18, 2021
afed318
Remove getter and use static variable for Schemas
jcralmeida Oct 18, 2021
d5614b5
Fix test failures after rebase
rafael-telles Oct 18, 2021
9ffd2a7
Fix supportsConvert docs on FlightSql.proto
JrJuscelino Oct 19, 2021
0c2d19d
Fix some decos on FlightSql.proto
JrJuscelino Oct 19, 2021
e7b8239
Implement SqlInfoProvider helper class (#176)
rafael-telles Oct 25, 2021
b619be8
Add SqlOuterJoinSupportLevel to SqlInfoBuilder
vfraga Oct 27, 2021
dc468bc
Fix checkstyle
vfraga Oct 27, 2021
d5cc2bc
Fix rebase issues
vfraga Oct 28, 2021
d165ea7
Increase Arrow Flight SQL Version in POM
vfraga Oct 28, 2021
0920e45
Fix Maven Build after rebase with master
vfraga Oct 28, 2021
6ddfe7c
[Java] Address Comments from ratification. (#222)
jcralmeida Dec 3, 2021
f828df6
Update FlightSql.proto docstrings
rafael-telles Dec 6, 2021
36656e3
Fix Subqueries SqlInfo in Protobuf and SqlInfoBuilder (#223)
vfraga Dec 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,336 changes: 1,336 additions & 0 deletions format/FlightSql.proto

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@

package org.apache.arrow.adapter.jdbc;

import static org.apache.arrow.vector.types.FloatingPointPrecision.DOUBLE;
import static org.apache.arrow.vector.types.FloatingPointPrecision.SINGLE;

import java.sql.Types;
import java.util.Calendar;
import java.util.Map;
import java.util.function.Function;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.util.Preconditions;
import org.apache.arrow.vector.types.DateUnit;
import org.apache.arrow.vector.types.TimeUnit;
import org.apache.arrow.vector.types.pojo.ArrowType;

/**
Expand All @@ -55,16 +49,14 @@
*/
public final class JdbcToArrowConfig {

public static final int DEFAULT_TARGET_BATCH_SIZE = 1024;
public static final int NO_LIMIT_BATCH_SIZE = -1;
private final Calendar calendar;
private final BufferAllocator allocator;
private final boolean includeMetadata;
private final boolean reuseVectorSchemaRoot;
private final Map<Integer, JdbcFieldInfo> arraySubTypesByColumnIndex;
private final Map<String, JdbcFieldInfo> arraySubTypesByColumnName;

public static final int DEFAULT_TARGET_BATCH_SIZE = 1024;
public static final int NO_LIMIT_BATCH_SIZE = -1;

/**
* The maximum rowCount to read each time when partially convert data.
* Default value is 1024 and -1 means disable partial read.
Expand All @@ -82,7 +74,7 @@ public final class JdbcToArrowConfig {
/**
* Constructs a new configuration from the provided allocator and calendar. The <code>allocator</code>
* 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 <code>ResultSet</code>.
* Arrow Timestamp fields, and to read time-based fields from the JDBC <code>ResultSet</code>.
*
* @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.
Expand All @@ -99,7 +91,7 @@ public final class JdbcToArrowConfig {
/**
* Constructs a new configuration from the provided allocator and calendar. The <code>allocator</code>
* 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 <code>ResultSet</code>.
* Arrow Timestamp fields, and to read time-based fields from the JDBC <code>ResultSet</code>.
*
* @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.
Expand Down Expand Up @@ -134,6 +126,8 @@ public final class JdbcToArrowConfig {
* <li>TIMESTAMP --> ArrowType.Timestamp(TimeUnit.MILLISECOND, calendar timezone)</li>
* <li>CLOB --> ArrowType.Utf8</li>
* <li>BLOB --> ArrowType.Binary</li>
* <li>ARRAY --> ArrowType.List</li>
* <li>STRUCT --> ArrowType.Struct</li>
* <li>NULL --> ArrowType.Null</li>
* </ul>
*/
Expand All @@ -157,64 +151,7 @@ public final class JdbcToArrowConfig {

// set up type converter
this.jdbcToArrowTypeConverter = jdbcToArrowTypeConverter != null ? jdbcToArrowTypeConverter :
fieldInfo -> {
final String timezone;
if (calendar != null) {
timezone = calendar.getTimeZone().getID();
} else {
timezone = null;
}

switch (fieldInfo.getJdbcType()) {
case Types.BOOLEAN:
case Types.BIT:
return new ArrowType.Bool();
case Types.TINYINT:
return new ArrowType.Int(8, true);
case Types.SMALLINT:
return new ArrowType.Int(16, true);
case Types.INTEGER:
return new ArrowType.Int(32, true);
case Types.BIGINT:
return new ArrowType.Int(64, true);
case Types.NUMERIC:
case Types.DECIMAL:
int precision = fieldInfo.getPrecision();
int scale = fieldInfo.getScale();
return new ArrowType.Decimal(precision, scale, 128);
case Types.REAL:
case Types.FLOAT:
return new ArrowType.FloatingPoint(SINGLE);
case Types.DOUBLE:
return new ArrowType.FloatingPoint(DOUBLE);
case Types.CHAR:
case Types.NCHAR:
case Types.VARCHAR:
case Types.NVARCHAR:
case Types.LONGVARCHAR:
case Types.LONGNVARCHAR:
case Types.CLOB:
return new ArrowType.Utf8();
case Types.DATE:
return new ArrowType.Date(DateUnit.DAY);
case Types.TIME:
return new ArrowType.Time(TimeUnit.MILLISECOND, 32);
case Types.TIMESTAMP:
return new ArrowType.Timestamp(TimeUnit.MILLISECOND, timezone);
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.BLOB:
return new ArrowType.Binary();
case Types.ARRAY:
return new ArrowType.List();
case Types.NULL:
return new ArrowType.Null();
default:
// no-op, shouldn't get here
return null;
}
};
jdbcFieldInfo -> JdbcToArrowUtils.getArrowTypeFromJdbcType(jdbcFieldInfo, calendar);
}

/**
Expand All @@ -230,6 +167,7 @@ public Calendar getCalendar() {

/**
* The Arrow memory allocator.
*
* @return the allocator.
*/
public BufferAllocator getAllocator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@

package org.apache.arrow.adapter.jdbc;

import static org.apache.arrow.vector.types.FloatingPointPrecision.DOUBLE;
import static org.apache.arrow.vector.types.FloatingPointPrecision.SINGLE;

import java.io.IOException;
import java.sql.Date;
import java.sql.ParameterMetaData;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
Expand Down Expand Up @@ -70,6 +75,8 @@
import org.apache.arrow.vector.VarCharVector;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.complex.ListVector;
import org.apache.arrow.vector.types.DateUnit;
import org.apache.arrow.vector.types.TimeUnit;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
Expand Down Expand Up @@ -106,6 +113,101 @@ public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar
return jdbcToArrowSchema(rsmd, new JdbcToArrowConfig(new RootAllocator(0), calendar));
}

/**
* Create Arrow {@link Schema} object for the given JDBC {@link ResultSetMetaData}.
*
* @param parameterMetaData The ResultSetMetaData containing the results, to read the JDBC metadata from.
* @param calendar The calendar to use the time zone field of, to construct Timestamp fields from.
* @return {@link Schema}
* @throws SQLException on error
*/
public static Schema jdbcToArrowSchema(final ParameterMetaData parameterMetaData, final Calendar calendar)
throws SQLException {
Preconditions.checkNotNull(calendar, "Calendar object can't be null");
Preconditions.checkNotNull(parameterMetaData);
final List<Field> parameterFields = new ArrayList<>(parameterMetaData.getParameterCount());
for (int parameterCounter = 1; parameterCounter <= parameterMetaData.getParameterCount();
parameterCounter++) {
final int jdbcDataType = parameterMetaData.getParameterType(parameterCounter);
final int jdbcIsNullable = parameterMetaData.isNullable(parameterCounter);
final boolean arrowIsNullable = jdbcIsNullable != ParameterMetaData.parameterNoNulls;
final int precision = parameterMetaData.getPrecision(parameterCounter);
final int scale = parameterMetaData.getScale(parameterCounter);
final ArrowType arrowType = getArrowTypeFromJdbcType(new JdbcFieldInfo(jdbcDataType, precision, scale), calendar);
final FieldType fieldType = new FieldType(arrowIsNullable, arrowType, /*dictionary=*/null);
parameterFields.add(new Field(null, fieldType, null));
}

return new Schema(parameterFields);
}

/**
* Converts the provided JDBC type to its respective {@link ArrowType} counterpart.
*
* @param fieldInfo the {@link JdbcFieldInfo} with information about the original JDBC type.
* @param calendar the {@link Calendar} to use for datetime data types.
* @return a new {@link ArrowType}.
*/
public static ArrowType getArrowTypeFromJdbcType(final JdbcFieldInfo fieldInfo, final Calendar calendar) {
switch (fieldInfo.getJdbcType()) {
case Types.BOOLEAN:
case Types.BIT:
return new ArrowType.Bool();
case Types.TINYINT:
return new ArrowType.Int(8, true);
case Types.SMALLINT:
return new ArrowType.Int(16, true);
case Types.INTEGER:
return new ArrowType.Int(32, true);
case Types.BIGINT:
return new ArrowType.Int(64, true);
case Types.NUMERIC:
case Types.DECIMAL:
int precision = fieldInfo.getPrecision();
int scale = fieldInfo.getScale();
return new ArrowType.Decimal(precision, scale, 128);
case Types.REAL:
case Types.FLOAT:
return new ArrowType.FloatingPoint(SINGLE);
case Types.DOUBLE:
return new ArrowType.FloatingPoint(DOUBLE);
case Types.CHAR:
case Types.NCHAR:
case Types.VARCHAR:
case Types.NVARCHAR:
case Types.LONGVARCHAR:
case Types.LONGNVARCHAR:
case Types.CLOB:
return new ArrowType.Utf8();
case Types.DATE:
return new ArrowType.Date(DateUnit.DAY);
case Types.TIME:
return new ArrowType.Time(TimeUnit.MILLISECOND, 32);
case Types.TIMESTAMP:
final String timezone;
if (calendar != null) {
timezone = calendar.getTimeZone().getID();
} else {
timezone = null;
}
return new ArrowType.Timestamp(TimeUnit.MILLISECOND, timezone);
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.BLOB:
return new ArrowType.Binary();
case Types.ARRAY:
return new ArrowType.List();
case Types.NULL:
return new ArrowType.Null();
case Types.STRUCT:
return new ArrowType.Struct();
default:
// no-op, shouldn't get here
return null;
}
}

/**
* Create Arrow {@link Schema} object for the given JDBC {@link java.sql.ResultSetMetaData}.
*
Expand Down
6 changes: 2 additions & 4 deletions java/flight/flight-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>arrow-flight</artifactId>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-java-root</artifactId>
<version>7.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>flight-core</artifactId>
Expand All @@ -24,8 +24,6 @@
<packaging>jar</packaging>

<properties>
<dep.grpc.version>1.41.0</dep.grpc.version>
<dep.protobuf.version>3.7.1</dep.protobuf.version>
<forkCount>1</forkCount>
</properties>

Expand Down
6 changes: 2 additions & 4 deletions java/flight/flight-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>arrow-java-root</artifactId>
<artifactId>arrow-flight</artifactId>
<groupId>org.apache.arrow</groupId>
<version>7.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,8 +24,6 @@
<packaging>jar</packaging>

<properties>
<dep.grpc.version>1.41.0</dep.grpc.version>
<dep.protobuf.version>3.7.1</dep.protobuf.version>
<forkCount>1</forkCount>
</properties>

Expand Down
Loading