Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following basic flink data types are supported to convert to sql data type in this FLIP, and more types can be supported as needed in the future.

Flink Data Type

Java Sql Data Type

Java Data Type

CharType/VarCharType

CHAR/VARCHAR

String

BooleanType

BOOLEAN

Boolean

TinyIntType

TINYINT

Byte

SmallIntType

SMALLINT

Short

IntType

INTEGER

Int

BigIntType

BIGINT

Long

FloatType

FLOAT

Float

DoubleType

DOUBLE

Double

DecimalType

DECIMAL

BigDecimal

BinaryType/VarBinaryType

BINARY/VARBINARY

byte[]

DateType

DATE

Date

TimeType

TIME

Time

TimestampType

TIMESTAMP

Timestamp

LocalZonedTimestapType

ZonedTimestampType

TIMESTAMP_WITH_TIMEZONE

ZonedDateTime

LocalZonedTimestampType

TIMESTAMP_LZT(Not in java.sql.Types)

Instant

ArrayType

ARRAY

Array

RowType

ROW(Not in java.sql.Types)

Row(Flink Row Data)

MapType

MAP

Map<K, V>

Public Interface

There are many methods in Jdbc Driver, while this FLIP only implement the basic methods first and more methods will be implemented later when they are needed. 

...

  1. Don't support transaction such as commit, rollback
  2. Don't support prepare statement, prepare call and etc operations
  3. Don't support management operations such as savepoint and etc

Exception Handling

When an error occurs, Flink Jdbc Driver mainly throws the following exceptions

SQLState ClassSQLState SubClassReasonExceptionOperations
22000 to 02H according to different errorsDescription of data conversion errorSQLDataExceptionGet data error from ResultSet in methods getXXX
0A000Specific feature is not supportedSQLFeatureNotSupportedExceptionAll unimplemented methods will throw this exception
58004The exception or error message from GatewaySQLNonTransientExceptionGateway throws an exception or returns an error message when executing the query
08006The session is not exist in Gateway and client need to create new connection to itSQLNonTransientConnectionExceptionGateway is restarted and the client need to create new connection

We can continue to subdivide and throw different exceptions according to the error information returned by the Gateway in Flink Jdbc Driver in the future



[1] https://github.com/ververica/flink-sql-gateway

...