Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.facebook.presto.plugin.jdbc.DriverConnectionFactory;
import com.facebook.presto.plugin.jdbc.JdbcConnectorId;
import com.facebook.presto.plugin.jdbc.JdbcIdentity;
import com.facebook.presto.plugin.jdbc.JdbcTypeHandle;
import com.facebook.presto.plugin.jdbc.ReadMapping;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.SchemaTableName;
Expand All @@ -28,8 +30,10 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Optional;

import static com.facebook.presto.plugin.jdbc.JdbcErrorCode.JDBC_ERROR;
import static com.facebook.presto.plugin.jdbc.StandardReadMappings.varbinaryReadMapping;
import static java.lang.String.format;

public class RedshiftClient
Expand Down Expand Up @@ -66,4 +70,17 @@ protected void renameTable(JdbcIdentity identity, String catalogName, SchemaTabl
throw new PrestoException(JDBC_ERROR, e);
}
}

// Maps "binary varying" (Redshift driver >= 2.1.0.32) to VARBINARY.
@Override
public Optional<ReadMapping> toPrestoType(ConnectorSession session, JdbcTypeHandle typeHandle)
{
String typeName = typeHandle.getJdbcTypeName();

if (typeName.equalsIgnoreCase("binary varying")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining that this is dependent on the version of the driver, as is included in this PR?

Copy link
Contributor Author

@adkharat adkharat Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdcmeehan 1 line comment added.

or do you want me to add comment in Javadoc-style format

/**
 * Maps Redshift VARBYTE columns to Presto VARBINARY.
 * <p>
 * Redshift JDBC driver version ≥ 2.1.0.32 reports VARBYTE as JDBC type 1111 (Types.OTHER)
 * with type name "binary varying", whereas older versions (e.g., 2.1.0.28) report it
 * as type -4 (Types.LONGVARBINARY) with type name "varbyte".
 * This mapping ensures compatibility with newer driver versions.
 */

return Optional.of(varbinaryReadMapping());
}

return super.toPrestoType(session, typeHandle);
}
}
Loading