Interface JdbcDialect

    • Method Detail

      • dialectName

        String dialectName()
        Get the name of jdbc dialect.
        Returns:
        the dialect name.
      • getRowConverter

        JdbcRowConverter getRowConverter​(org.apache.flink.table.types.logical.RowType rowType)
        Get converter that convert jdbc object and Flink internal object each other.
        Parameters:
        rowType - the given row type
        Returns:
        a row converter for the database
      • getLimitClause

        String getLimitClause​(long limit)
        Get limit clause to limit the number of emitted row from the jdbc source.
        Parameters:
        limit - number of row to emit. The value of the parameter should be non-negative.
        Returns:
        the limit clause.
      • validate

        void validate​(org.apache.flink.table.types.logical.RowType rowType)
               throws org.apache.flink.table.api.ValidationException
        Check if this dialect instance support a specific data type in table schema.
        Parameters:
        rowType - the physical table datatype of a row in the database table.
        Throws:
        org.apache.flink.table.api.ValidationException - in case of the table schema contains unsupported type.
      • defaultDriverName

        default Optional<String> defaultDriverName()
        Returns:
        the default driver class name, if user has not configured the driver class name, then this one will be used.
      • quoteIdentifier

        String quoteIdentifier​(String identifier)
        Quotes the identifier.

        Used to put quotes around the identifier if the column name is a reserved keyword or contains characters requiring quotes (e.g., space).

        Returns:
        the quoted identifier.
      • getUpsertStatement

        Optional<String> getUpsertStatement​(String tableName,
                                            String[] fieldNames,
                                            String[] uniqueKeyFields)
        Constructs the dialects upsert statement if supported; such as MySQL's DUPLICATE KEY UPDATE, or PostgreSQL's ON 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 the fieldNames parameter.

        If the dialect does not support native upsert statements, the writer will fallback to SELECT + UPDATE/INSERT which may have poor performance.

        Returns:
        The upsert statement if supported, otherwise None.
      • getRowExistsStatement

        String getRowExistsStatement​(String tableName,
                                     String[] conditionFields)
        Generates a query to determine if a row exists in the table. The returned string will be used as a PreparedStatement.

        By default, the dialect will fallback to a simple SELECT query.

      • getInsertIntoStatement

        String getInsertIntoStatement​(String tableName,
                                      String[] fieldNames)
        Generates a string that will be used as a PreparedStatement to insert a row into a database table. Fields in the statement must be in the same order as the fieldNames parameter.
        Returns:
        the dialects INSERT INTO statement.
      • getUpdateStatement

        String getUpdateStatement​(String tableName,
                                  String[] fieldNames,
                                  String[] conditionFields)
        Constructs the dialects update statement for a single row with the given condition. The returned string will be used as a PreparedStatement. Fields in the statement must be in the same order as the fieldNames parameter.
        Returns:
        A single row update statement.
      • getDeleteStatement

        String getDeleteStatement​(String tableName,
                                  String[] conditionFields)
        Constructs the dialects delete statement for a single row with the given condition. The returned string will be used as a PreparedStatement. Fields in the statement must be in the same order as the fieldNames parameter.
        Returns:
        A single row delete statement.
      • getSelectFromStatement

        String getSelectFromStatement​(String tableName,
                                      String[] selectFields,
                                      String[] conditionFields)
        Constructs the dialects select statement for fields with given conditions. The returned string will be used as a PreparedStatement. Fields in the statement must be in the same order as the fieldNames parameter.
        Returns:
        A select statement.
      • appendDefaultUrlProperties

        default String appendDefaultUrlProperties​(String url)
        Appends default JDBC properties to url for current dialect. Some database dialects will set default JDBC properties for performance or optimization consideration, such as MySQL dialect uses 'rewriteBatchedStatements=true' to enable execute multiple MySQL statements in batch mode.
        Returns:
        A JDBC url that has appended the default properties.