Implementation:Risingwavelabs Risingwave RedShiftDialect
Appearance
| Property | Value |
|---|---|
| Component | risingwave-sink-jdbc |
| Language | Java |
| Package | com.risingwave.connector.jdbc |
| Extends | PostgresDialect |
| Lines | 66 |
| Source | RedShiftDialect.java |
Overview
RedShiftDialect extends PostgresDialect to provide Amazon Redshift-specific behavior for the RisingWave JDBC sink connector. Since Redshift is based on PostgreSQL, this dialect inherits most of its SQL generation and type binding from the parent class, but explicitly disables operations that Redshift does not support in this context:
- Upsert: Both
getUpsertStatementandbindUpsertStatementthrowUnsupportedOperationException. Redshift sinks are intended to be used in append-only mode viaBatchAppendOnlyJDBCSink. - Delete:
bindDeleteStatementthrowsUnsupportedOperationException, as the append-only sink does not perform row-level deletes. - JSONB handling: Overrides the parent's
set_jsonbmethod to usesetStringinstead ofPGobject, since Redshift does not support the PostgreSQL-nativePGobjecttype for JSONB.
Code Reference
Source Location
java/connector-node/risingwave-sink-jdbc/src/main/java/com/risingwave/connector/jdbc/RedShiftDialect.java
Signature
public class RedShiftDialect extends PostgresDialect {
public RedShiftDialect(List<Integer> columnSqlTypes, List<Integer> pkIndices);
@Override public Optional<String> getUpsertStatement(
SchemaTableName schemaTableName, TableSchema tableSchema, List<String> primaryKeyFields);
@Override public void bindUpsertStatement(
PreparedStatement stmt, Connection conn, TableSchema tableSchema, SinkRow row) throws SQLException;
@Override public void bindDeleteStatement(
PreparedStatement stmt, TableSchema tableSchema, SinkRow row) throws SQLException;
@Override public void set_jsonb(
int placeholderIdx, int columnIdx, PreparedStatement stmt, SinkRow row) throws SQLException;
}
Imports
import com.risingwave.connector.api.TableSchema;
import com.risingwave.connector.api.sink.SinkRow;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Optional;
I/O Contract
Constructor Input
| Parameter | Type | Description |
|---|---|---|
| columnSqlTypes | List<Integer> | JDBC SQL type codes for all columns (passed to parent constructor) |
| pkIndices | List<Integer> | Indices of primary key columns (passed to parent constructor) |
Overridden Methods
| Method | Behavior |
|---|---|
| getUpsertStatement | Throws UnsupportedOperationException -- Redshift does not support upsert
|
| bindUpsertStatement | Throws UnsupportedOperationException -- Redshift does not support upsert
|
| bindDeleteStatement | Throws UnsupportedOperationException -- Redshift does not support DELETE in this context
|
| set_jsonb | Uses stmt.setString(placeholderIdx, (String) row.get(columnIdx)) instead of PGobject
|
Inherited Methods
All other methods are inherited from PostgresDialect, including:
createSchemaTableNamegetNormalizedTableName(with optional schema qualification)quoteIdentifier(double-quote style)getInsertIntoStatementgetDeleteStatementbindInsertIntoStatement(with Redshift-specific JSONB handling via overriddenset_jsonb)
Usage Examples
// Create Redshift dialect
RedShiftDialect dialect = new RedShiftDialect(columnSqlTypes, pkIndices);
// Generate INSERT (inherited from PostgresDialect)
SchemaTableName stn = dialect.createSchemaTableName("public", "events");
String insertSql = dialect.getInsertIntoStatement(stn, fieldNames);
// Bind and execute
PreparedStatement stmt = conn.prepareStatement(insertSql);
dialect.bindInsertIntoStatement(stmt, conn, tableSchema, row);
stmt.executeUpdate();
// Upsert is NOT supported
// dialect.getUpsertStatement(stn, tableSchema, pks); // throws UnsupportedOperationException
Related Pages
- Implementation:Risingwavelabs_Risingwave_PostgresDialect -- Parent class providing the base PostgreSQL dialect
- Implementation:Risingwavelabs_Risingwave_JdbcDialect_Interface -- Interface defining the dialect contract
- Implementation:Risingwavelabs_Risingwave_JdbcUtils -- Resolves this dialect for
jdbc:redshiftURLs - Implementation:Risingwavelabs_Risingwave_BatchAppendOnlyJDBCSink -- Sink writer used for Redshift targets (append-only mode)
- Implementation:Risingwavelabs_Risingwave_JDBCSinkConfig -- Configuration with
batch.insert.rowsfor Redshift batch optimization
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment