接口 JdbcDialect
-
- 所有超级接口:
Serializable
- 所有已知实现类:
DB2Dialect,DmdbDialect,Gbase8aDialect,HiveDialect,InceptorDialect,IrisDialect,KingbaseDialect,MysqlDialect,OceanBaseMysqlDialect,OracleDialect,PhoenixDialect,PostgresDialect,PostgresLowDialect,RedshiftDialect,SapHanaDialect,SnowflakeDialect,SqliteDialect,SqlServerDialect,TablestoreDialect,TeradataDialect,VerticaDialect,XuguDialect
public interface JdbcDialect extends Serializable
Represents a dialect of SQL implemented by a particular JDBC system. Dialects should be immutable and stateless.
-
-
嵌套类概要
嵌套类 修饰符和类型 接口 说明 static classJdbcDialect.AlterType
-
字段概要
字段 修饰符和类型 字段 说明 static org.slf4j.Loggerlog
-
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default LongapproximateRowCntStatement(Connection connection, JdbcSourceTable table)Approximate total number of entries in the lookup table.default StringbuildAlterTableBasicSql(String alterOperation, String tableName)build the body of alter table sqldefault StringbuildAlterTableSql(String sourceDialectName, String sourceColumnType, String alterOperation, org.apache.seatunnel.api.table.catalog.Column newColumn, String tableName, String oldColumnName)build alter table sqldefault voidconnectionUrlParse(String url, Map<String,String> info, Map<String,String> defaultParameter)default StringconvertType(String columnName, String columnType)Cast column type e.g.default PreparedStatementcreatPreparedStatement(Connection connection, String queryTemplate, int fetchSize)Different dialects optimize their PreparedStatementdefault StringdecorateWithColumnNameAndType(String sourceDialectName, String sourceColumnType, String basicSql, String alterOperation, org.apache.seatunnel.api.table.catalog.Column newColumn, String oldColumnName, String columnType)decorate the sql with column name and typedefault StringdecorateWithComment(String basicSql, org.apache.seatunnel.api.table.converter.BasicTypeDefine typeBasicTypeDefine)decorate with commentdefault StringdecorateWithDefaultValue(String basicSql, org.apache.seatunnel.api.table.converter.BasicTypeDefine typeBasicTypeDefine)decorate with default valuedefault StringdecorateWithNullable(String basicSql, org.apache.seatunnel.api.table.converter.BasicTypeDefine typeBasicTypeDefine)decorate with nullabledefault Map<String,String>defaultParameter()StringdialectName()Get the name of jdbc dialect.default StringextractTableName(org.apache.seatunnel.api.table.catalog.TablePath tablePath)default StringgenerateAlterTableSql(String sourceDialectName, org.apache.seatunnel.api.table.event.AlterTableColumnEvent event, org.apache.seatunnel.api.table.catalog.TablePath sinkTablePath)generate alter table sqldefault StringgetDeleteStatement(String database, String tableName, String[] conditionFields)Constructs the dialects delete statement for a single row with the given condition.default StringgetFieldIde(String identifier, String fieldIde)default StringgetInsertIntoStatement(String database, String tableName, String[] fieldNames)Constructs the dialects insert statement for a single row.default JdbcConnectionProvidergetJdbcConnectionProvider(JdbcConnectionConfig jdbcConnectionConfig)JdbcDialectTypeMappergetJdbcDialectTypeMapper()get jdbc meta-information type to seatunnel data type mapper.default ResultSetMetaDatagetResultSetMetaData(Connection conn, String query)JdbcRowConvertergetRowConverter()Get converter that convert jdbc object to seatunnel internal object.default StringgetRowExistsStatement(String database, String tableName, String[] conditionFields)Generates a query to determine if a row exists in the table.default StringgetUpdateStatement(String database, String tableName, String[] fieldNames, String[] conditionFields, boolean isPrimaryKeyUpdated)Constructs the dialects update statement for a single row with the given condition.Optional<String>getUpsertStatement(String database, String tableName, String[] fieldNames, String[] uniqueKeyFields)Constructs the dialects upsert statement if supported; such as MySQL'sDUPLICATE KEY UPDATE, or PostgreSQL'sON CONFLICT... DO UPDATE SET...default StringhashModForField(String fieldName, int mod)default StringhashModForField(String nativeType, String fieldName, int mod)default booleanisSpecialDefaultValue(Object defaultValue)whether is special default value e.g. current_timestampdefault booleanneedsQuotesWithDefaultValue(String sqlType)whether quotes with default valuedefault org.apache.seatunnel.api.table.catalog.TablePathparse(String tablePath)default ObjectqueryNextChunkMax(Connection connection, JdbcSourceTable table, String columnName, int chunkSize, Object includedLowerBound)Query the maximum value of the next chunk, and the next chunk must be greater than or equal toincludedLowerBoundvalue [min_1, max_1), [min_2, max_2),...default StringquoteDatabaseIdentifier(String identifier)Quotes the identifier for database name or field namedefault StringquoteIdentifier(String identifier)Quotes the identifier for table name or field namedefault StringquotesDefaultValue(Object defaultValue)quotes default valuedefault voidrefreshTableSchemaBySchemaChangeEvent(String sourceDialectName, org.apache.seatunnel.api.table.event.AlterTableColumnEvent event, JdbcConnectionProvider jdbcConnectionProvider, org.apache.seatunnel.api.table.catalog.TablePath sinkTablePath)Refresh physical table schema by schema change eventdefault Object[]sampleDataFromColumn(Connection connection, JdbcSourceTable table, String columnName, int samplingRate, int fetchSize)Performs a sampling operation on the specified column of a table in a JDBC-connected database.default StringtableIdentifier(String database, String tableName)default StringtableIdentifier(org.apache.seatunnel.api.table.catalog.TablePath tablePath)
-
-
-
方法详细资料
-
dialectName
String dialectName()
Get the name of jdbc dialect.- 返回:
- the dialect name.
-
getRowConverter
JdbcRowConverter getRowConverter()
Get converter that convert jdbc object to seatunnel internal object.- 返回:
- a row converter for the database
-
getJdbcDialectTypeMapper
JdbcDialectTypeMapper getJdbcDialectTypeMapper()
get jdbc meta-information type to seatunnel data type mapper.- 返回:
- a type mapper for the database
-
quoteIdentifier
default String quoteIdentifier(String identifier)
Quotes the identifier for table name or field name
-
quoteDatabaseIdentifier
default String quoteDatabaseIdentifier(String identifier)
Quotes the identifier for database name or field name
-
getInsertIntoStatement
default String getInsertIntoStatement(String database, String tableName, String[] fieldNames)
Constructs the dialects insert statement for a single row. The returned string will be used as aPreparedStatement. Fields in the statement must be in the same order as thefieldNamesparameter.INSERT INTO table_name (column_name [, ...]) VALUES (value [, ...])- 返回:
- the dialects
INSERT INTOstatement.
-
getUpdateStatement
default String getUpdateStatement(String database, String tableName, String[] fieldNames, String[] conditionFields, boolean isPrimaryKeyUpdated)
Constructs the dialects update statement for a single row with the given condition. The returned string will be used as aPreparedStatement. Fields in the statement must be in the same order as thefieldNamesparameter.UPDATE table_name SET col = val [, ...] WHERE cond [AND ...]- 返回:
- the dialects
UPDATEstatement.
-
getDeleteStatement
default String getDeleteStatement(String database, String tableName, String[] conditionFields)
Constructs the dialects delete statement for a single row with the given condition. The returned string will be used as aPreparedStatement. Fields in the statement must be in the same order as thefieldNamesparameter.DELETE FROM table_name WHERE cond [AND ...]- 返回:
- the dialects
DELETEstatement.
-
getRowExistsStatement
default String getRowExistsStatement(String database, String tableName, String[] conditionFields)
Generates a query to determine if a row exists in the table. The returned string will be used as aPreparedStatement.SELECT 1 FROM table_name WHERE cond [AND ...]- 返回:
- the dialects
QUERYstatement.
-
getUpsertStatement
Optional<String> getUpsertStatement(String database, String tableName, String[] fieldNames, String[] uniqueKeyFields)
Constructs the dialects upsert statement if supported; such as MySQL'sDUPLICATE KEY UPDATE, or PostgreSQL'sON CONFLICT... DO UPDATE SET...If supported, the returned string will be used as a
PreparedStatement. Fields in the statement must be in the same order as thefieldNamesparameter.If the dialect does not support native upsert statements, the writer will fallback to
SELECT ROW Exists+UPDATE/INSERTwhich may have poor performance.- 返回:
- the dialects
UPSERTstatement orOptional.empty().
-
creatPreparedStatement
default PreparedStatement creatPreparedStatement(Connection connection, String queryTemplate, int fetchSize) throws SQLException
Different dialects optimize their PreparedStatement- 返回:
- The logic about optimize PreparedStatement
- 抛出:
SQLException
-
getResultSetMetaData
default ResultSetMetaData getResultSetMetaData(Connection conn, String query) throws SQLException
- 抛出:
SQLException
-
extractTableName
default String extractTableName(org.apache.seatunnel.api.table.catalog.TablePath tablePath)
-
connectionUrlParse
default void connectionUrlParse(String url, Map<String,String> info, Map<String,String> defaultParameter)
-
parse
default org.apache.seatunnel.api.table.catalog.TablePath parse(String tablePath)
-
tableIdentifier
default String tableIdentifier(org.apache.seatunnel.api.table.catalog.TablePath tablePath)
-
approximateRowCntStatement
default Long approximateRowCntStatement(Connection connection, JdbcSourceTable table) throws SQLException
Approximate total number of entries in the lookup table.- 参数:
connection- The JDBC connection object used to connect to the database.table- table info.- 返回:
- approximate row count statement.
- 抛出:
SQLException
-
sampleDataFromColumn
default Object[] sampleDataFromColumn(Connection connection, JdbcSourceTable table, String columnName, int samplingRate, int fetchSize) throws Exception
Performs a sampling operation on the specified column of a table in a JDBC-connected database.- 参数:
connection- The JDBC connection object used to connect to the database.table- The table in which the column resides.columnName- The name of the column to be sampled.samplingRate- samplingRate The inverse of the fraction of the data to be sampled from the column. For example, a value of 1000 would mean 1/1000 of the data will be sampled.- 返回:
- Returns a List of sampled data from the specified column.
- 抛出:
SQLException- If an SQL error occurs during the sampling operation.Exception
-
queryNextChunkMax
default Object queryNextChunkMax(Connection connection, JdbcSourceTable table, String columnName, int chunkSize, Object includedLowerBound) throws SQLException
Query the maximum value of the next chunk, and the next chunk must be greater than or equal toincludedLowerBoundvalue [min_1, max_1), [min_2, max_2),... [min_n, null). Each time this method is called it will return max1, max2...- 参数:
connection- JDBC connection.table- table info.columnName- column name.chunkSize- chunk size.includedLowerBound- the previous chunk end value.- 返回:
- next chunk end value.
- 抛出:
SQLException
-
getJdbcConnectionProvider
default JdbcConnectionProvider getJdbcConnectionProvider(JdbcConnectionConfig jdbcConnectionConfig)
-
convertType
default String convertType(String columnName, String columnType)
Cast column type e.g. CAST(column AS type)- 参数:
columnName-columnType-- 返回:
- the text of converted column type.
-
refreshTableSchemaBySchemaChangeEvent
default void refreshTableSchemaBySchemaChangeEvent(String sourceDialectName, org.apache.seatunnel.api.table.event.AlterTableColumnEvent event, JdbcConnectionProvider jdbcConnectionProvider, org.apache.seatunnel.api.table.catalog.TablePath sinkTablePath)
Refresh physical table schema by schema change event- 参数:
sourceDialectName- source dialect nameevent- schema change eventjdbcConnectionProvider- jdbc connection providersinkTablePath- sink table path
-
generateAlterTableSql
default String generateAlterTableSql(String sourceDialectName, org.apache.seatunnel.api.table.event.AlterTableColumnEvent event, org.apache.seatunnel.api.table.catalog.TablePath sinkTablePath)
generate alter table sql- 参数:
sourceDialectName- source dialect nameevent- schema change eventsinkTablePath- sink table path- 返回:
- alter table sql for sink table
-
buildAlterTableSql
default String buildAlterTableSql(String sourceDialectName, String sourceColumnType, String alterOperation, org.apache.seatunnel.api.table.catalog.Column newColumn, String tableName, String oldColumnName)
build alter table sql- 参数:
sourceDialectName- source dialect namesourceColumnType- source column typealterOperation- alter operation of ddlnewColumn- new column after ddltableName- table name of sink tableoldColumnName- old column name before ddl- 返回:
- alter table sql for sink table after schema change
-
buildAlterTableBasicSql
default String buildAlterTableBasicSql(String alterOperation, String tableName)
build the body of alter table sql- 参数:
alterOperation- alter operation of ddltableName- table name of sink table- 返回:
- basic sql of alter table for sink table
-
decorateWithColumnNameAndType
default String decorateWithColumnNameAndType(String sourceDialectName, String sourceColumnType, String basicSql, String alterOperation, org.apache.seatunnel.api.table.catalog.Column newColumn, String oldColumnName, String columnType)
decorate the sql with column name and type- 参数:
sourceDialectName- source dialect namesourceColumnType- source column typebasicSql- basic sql of alter table for sink tablealterOperation- alter operation of ddlnewColumn- new column after ddloldColumnName- old column name before ddlcolumnType- column type of new column- 返回:
- basic sql with column name and type of alter table for sink table
-
decorateWithNullable
default String decorateWithNullable(String basicSql, org.apache.seatunnel.api.table.converter.BasicTypeDefine typeBasicTypeDefine)
decorate with nullable- 参数:
basicSql- alter table sql for sink tabletypeBasicTypeDefine- type basic type define of new column- 返回:
- alter table sql with nullable for sink table
-
decorateWithDefaultValue
default String decorateWithDefaultValue(String basicSql, org.apache.seatunnel.api.table.converter.BasicTypeDefine typeBasicTypeDefine)
decorate with default value- 参数:
basicSql- alter table sql for sink tabletypeBasicTypeDefine- type basic type define of new column- 返回:
- alter table sql with default value for sink table
-
decorateWithComment
default String decorateWithComment(String basicSql, org.apache.seatunnel.api.table.converter.BasicTypeDefine typeBasicTypeDefine)
decorate with comment- 参数:
basicSql- alter table sql for sink tabletypeBasicTypeDefine- type basic type define of new column- 返回:
- alter table sql with comment for sink table
-
needsQuotesWithDefaultValue
default boolean needsQuotesWithDefaultValue(String sqlType)
whether quotes with default value- 参数:
sqlType- sql type of column- 返回:
- whether needs quotes with the type
-
isSpecialDefaultValue
default boolean isSpecialDefaultValue(Object defaultValue)
whether is special default value e.g. current_timestamp- 参数:
defaultValue- default value of column- 返回:
- whether is special default value e.g current_timestamp
-
-