public class MetadataAPIHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MetadataAPIHelper.BestRowIdenData
Data container for the getBestRowIdentifier() metadata operation.
|
static interface |
MetadataAPIHelper.enumFunc<T extends Enum<T>> |
protected static class |
MetadataAPIHelper.ForeignKeyColumnIndex
Enum representing the indices of columns in the result set of getImportedKeys/getExportedKeys.
|
static class |
MetadataAPIHelper.GetBestRowIdentifier_Metadata
Define return columns for JDBC API getBestRowIdentifier according to the spec
|
static class |
MetadataAPIHelper.GetCatalogs_Metadata |
static class |
MetadataAPIHelper.GetColumnPrivileges_Metadata
Define return columns for JDBC API getColumnPrivileges according to the spec
|
static class |
MetadataAPIHelper.GetColumns_Metadata |
static class |
MetadataAPIHelper.GetForeignKeys_Metadata
Define return columns for JDBC API getImportedKeys according to the spec
|
static class |
MetadataAPIHelper.GetFunctions_Metadata
Define return columns for JDBC API getFunctions according to the spec
|
static class |
MetadataAPIHelper.GetFunctionsColumns_Metadata
Define return columns for JDBC API getFunctionsColumns according to the spec
|
static class |
MetadataAPIHelper.GetPrimaryKeys_Metadata
Define return columns for JDBC API getPrimaryKeys according to the spec:
|
static class |
MetadataAPIHelper.GetProcedures_Metadata
Define return columns for JDBC API getProcedures according to the spec
|
static class |
MetadataAPIHelper.GetProceduresColumns_Metadata
Define return columns for JDBC API getProceduresColumns according to the spec
|
static class |
MetadataAPIHelper.GetSchemas_Metadata |
static class |
MetadataAPIHelper.GetTablePrivileges_Metadata
Define return columns for JDBC API getTablePrivileges according to the spec
|
static class |
MetadataAPIHelper.GetTables_Metadata |
static class |
MetadataAPIHelper.GetTableType_Metadata
Define return columns for JDBC API getTableType according to the spec
|
protected static class |
MetadataAPIHelper.ProcedureFunctionColumnData
Data container for procedure and function column metadata used by getProcedureColumns() and getFunctionColumns().
|
protected static class |
MetadataAPIHelper.RedshiftDataTypes |
static class |
MetadataAPIHelper.ShowColumnsInfo
Data container for column metadata returned by the SHOW COLUMNS command.
|
static class |
MetadataAPIHelper.ShowForeignKeysInfo
Data container for foreign key metadata returned by the SHOW CONSTRAINTS FOREIGN KEYS command.
|
static class |
MetadataAPIHelper.ShowFunctionsInfo
Data container for user-defined function metadata returned by the SHOW FUNCTIONS command.
|
static class |
MetadataAPIHelper.ShowGrantsInfo
Data container for privilege grant metadata returned by the SHOW GRANTS command.
|
static class |
MetadataAPIHelper.ShowParametersInfo
Data container for stored procedure parameter metadata returned by the SHOW PARAMETERS command.
|
static class |
MetadataAPIHelper.ShowPrimaryKeysInfo
Data container for primary key metadata returned by the SHOW CONSTRAINTS PRIMARY KEYS command.
|
static class |
MetadataAPIHelper.ShowProceduresInfo
Data container for stored procedure metadata returned by the SHOW PROCEDURES command.
|
static class |
MetadataAPIHelper.ShowSchemasInfo
Data container for schema metadata returned by the SHOW SCHEMAS command.
|
static class |
MetadataAPIHelper.ShowTablesInfo
Data container for table metadata returned by the SHOW TABLES command.
|
| Constructor and Description |
|---|
MetadataAPIHelper(RedshiftConnectionImpl connection) |
| Modifier and Type | Method and Description |
|---|---|
static String |
convertSqlLikeToRegex(String pattern)
Convert SQL LIKE pattern to regex pattern
|
protected PreparedStatement |
createMetaDataPreparedStatement(String sql) |
protected Statement |
createMetaDataStatement() |
protected Map.Entry<String,List<String>> |
createParameterizedQueryString(String argumentList,
String sqlBase,
String columnNamePattern)
Creates a parameterized SQL query string based on the argument list and base SQL statement.
|
protected ResultSet |
createRs(Field[] col,
List<Tuple> data) |
protected byte[] |
encodeStr(String str) |
protected String |
getAutoIncrement(String colDef) |
protected String |
getColumnLength(String rsType)
Gets the column length for a given Redshift data type
|
protected String |
getColumnSize(String rsType,
String character_maximum_length,
String numeric_precision) |
protected String |
getDecimalDigit(String rsType,
String numeric_scale,
int precision,
boolean customizePrecision) |
protected byte[][] |
getEmptyTuple(Field[] col,
int size) |
static <T extends Enum<T> & MetadataAPIHelper.enumFunc<T>> |
getField(Supplier<T[]> enumObject) |
protected static int |
getFunctionColumnType(String parameterType) |
protected static int |
getFunctionType(String returnType) |
protected static String |
getIsGrantable(Boolean admin_option)
Helper function to bridge the gap where SHOW return boolean but JDBC spec required YES/NO
|
protected String |
getNullable(String nullable) |
protected String |
getNumPrefixRadix(String rsType) |
protected static int |
getProcedureColumnType(String parameterType) |
protected static int |
getProcedureType(String returnType) |
protected String |
getRSType(String rsType) |
protected String |
getSpecificName(String name,
String argument) |
protected String |
getSQLType(String rsType) |
static boolean |
patternMatch(String str,
String pattern)
Pattern matching function similar to SQL LIKE operator.
|
protected ResultSet |
runQuery(String sql) |
protected static void |
sortForeignKeyTuples(List<Tuple> foreignKeyTuples,
boolean isImported)
Sorts a list of foreign key tuples based on specified criteria.
|
protected final RedshiftConnectionImpl connection
protected final Field[] GET_CATALOGS_COLS
protected final Field[] GET_SCHEMAS_COLS
protected final Field[] GET_TABLES_COLS
protected final Field[] GET_COLUMNS_COLS
protected final Field[] GET_PRIMARY_KEYS_COLS
protected final Field[] GET_FOREIGN_KEYS_COLS
protected final Field[] GET_BEST_ROW_IDENTIFIER_COLS
protected final Field[] GET_COLUMN_PRIVILEGES_COLS
protected final Field[] GET_TABLE_PRIVILEGES_COLS
protected final Field[] GET_PROCEDURES_COLS
protected final Field[] GET_PROCEDURES_COLUMNS_COLS
protected final Field[] GET_FUNCTIONS_COLS
protected final Field[] GET_FUNCTIONS_COLUMNS_COLS
protected final Field[] GET_TABLE_TYPE_COLS
protected final short IMPORTED_KEY_NO_ACTION
protected final short IMPORTED_KEY_NOT_DEFERRABLE
public static final String SHOW_DATABASES_DATABASE_NAME
public static final String SHOW_SCHEMAS_DATABASE_NAME
public static final String SHOW_SCHEMAS_SCHEMA_NAME
public static final String SHOW_TABLES_DATABASE_NAME
public static final String SHOW_TABLES_SCHEMA_NAME
public static final String SHOW_TABLES_TABLE_NAME
public static final String SHOW_TABLES_TABLE_TYPE
public static final String SHOW_TABLES_REMARKS
public static final String SHOW_TABLES_OWNER
public static final String SHOW_TABLES_LAST_ALTERED_TIME
public static final String SHOW_TABLES_LAST_MODIFIED_TIME
public static final String SHOW_TABLES_DIST_STYLE
public static final String SHOW_TABLES_TABLE_SUBTYPE
public static final String SHOW_COLUMNS_DATABASE_NAME
public static final String SHOW_COLUMNS_SCHEMA_NAME
public static final String SHOW_COLUMNS_TABLE_NAME
public static final String SHOW_COLUMNS_COLUMN_NAME
public static final String SHOW_COLUMNS_ORDINAL_POSITION
public static final String SHOW_COLUMNS_COLUMN_DEFAULT
public static final String SHOW_COLUMNS_IS_NULLABLE
public static final String SHOW_COLUMNS_DATA_TYPE
public static final String SHOW_COLUMNS_CHARACTER_MAXIMUM_LENGTH
public static final String SHOW_COLUMNS_NUMERIC_PRECISION
public static final String SHOW_COLUMNS_NUMERIC_SCALE
public static final String SHOW_COLUMNS_REMARKS
public static final String SHOW_COLUMNS_SORT_KEY_TYPE
public static final String SHOW_COLUMNS_SORT_KEY
public static final String SHOW_COLUMNS_DIST_KEY
public static final String SHOW_COLUMNS_ENCODING
public static final String SHOW_COLUMNS_COLLATION
public static final String SHOW_PRIMARY_KEYS_DATABASE_NAME
public static final String SHOW_PRIMARY_KEYS_SCHEMA_NAME
public static final String SHOW_PRIMARY_KEYS_TABLE_NAME
public static final String SHOW_PRIMARY_KEYS_COLUMN_NAME
public static final String SHOW_PRIMARY_KEYS_KEY_SEQ
public static final String SHOW_PRIMARY_KEYS_PK_NAME
public static final String SHOW_FOREIGN_KEYS_PK_DATABASE_NAME
public static final String SHOW_FOREIGN_KEYS_PK_SCHEMA_NAME
public static final String SHOW_FOREIGN_KEYS_PK_TABLE_NAME
public static final String SHOW_FOREIGN_KEYS_PK_COLUMN_NAME
public static final String SHOW_FOREIGN_KEYS_FK_DATABASE_NAME
public static final String SHOW_FOREIGN_KEYS_FK_SCHEMA_NAME
public static final String SHOW_FOREIGN_KEYS_FK_TABLE_NAME
public static final String SHOW_FOREIGN_KEYS_FK_COLUMN_NAME
public static final String SHOW_FOREIGN_KEYS_KEY_SEQ
public static final String SHOW_FOREIGN_KEYS_UPDATE_RULE
public static final String SHOW_FOREIGN_KEYS_DELETE_RULE
public static final String SHOW_FOREIGN_KEYS_FK_NAME
public static final String SHOW_FOREIGN_KEYS_PK_NAME
public static final String SHOW_FOREIGN_KEYS_DEFERRABILITY
public static final String SHOW_GRANT_DATABASE_NAME
public static final String SHOW_GRANT_SCHEMA_NAME
public static final String SHOW_GRANT_OBJECT_NAME
public static final String SHOW_GRANT_TABLE_NAME
public static final String SHOW_GRANT_COLUMN_NAME
public static final String SHOW_GRANT_GRANTOR
public static final String SHOW_GRANT_IDENTITY_NAME
public static final String SHOW_GRANT_PRIVILEGE_TYPE
public static final String SHOW_GRANT_ADMIN_OPTION
public static final String SHOW_PROCEDURES_DATABASE_NAME
public static final String SHOW_PROCEDURES_SCHEMA_NAME
public static final String SHOW_PROCEDURES_PROCEDURE_NAME
public static final String SHOW_PROCEDURES_RETURN_TYPE
public static final String SHOW_PROCEDURES_ARGUMENT_LIST
public static final String SHOW_FUNCTIONS_DATABASE_NAME
public static final String SHOW_FUNCTIONS_SCHEMA_NAME
public static final String SHOW_FUNCTIONS_FUNCTION_NAME
public static final String SHOW_FUNCTIONS_RETURN_TYPE
public static final String SHOW_FUNCTIONS_ARGUMENT_LIST
public static final String SHOW_PARAMETERS_DATABASE_NAME
public static final String SHOW_PARAMETERS_SCHEMA_NAME
public static final String SHOW_PARAMETERS_PROCEDURE_NAME
public static final String SHOW_PARAMETERS_FUNCTION_NAME
public static final String SHOW_PARAMETERS_PARAMETER_NAME
public static final String SHOW_PARAMETERS_ORDINAL_POSITION
public static final String SHOW_PARAMETERS_PARAMETER_TYPE
public static final String SHOW_PARAMETERS_DATA_TYPE
public static final String SHOW_PARAMETERS_CHARACTER_MAXIMUM_LENGTH
public static final String SHOW_PARAMETERS_NUMERIC_PRECISION
public static final String SHOW_PARAMETERS_NUMERIC_SCALE
protected final String SQL_PREP_SHOWDATABASES
protected final String SQL_PREP_SHOWSCHEMAS
protected final String SQL_PREP_SHOWSCHEMASLIKE
protected final String SQL_PREP_SHOWTABLES
protected final String SQL_PREP_SHOWTABLESLIKE
protected final String SQL_PREP_SHOWCOLUMNS
protected final String SQL_PREP_SHOWCOLUMNSLIKE
protected final String SQL_PREP_SHOWPRIMARYKEYS
protected final String SQL_PREP_SHOWFOREIGNKEYS
protected final String SQL_PREP_SHOWFOREIGNEXPORTEDKEYS
protected final String SQL_PREP_SHOWGRANTSCOLUMN
protected final String SQL_PREP_SHOWGRANTSCOLUMNLIKE
protected final String SQL_PREP_SHOWGRANTSTABLE
protected final String SQL_PREP_SHOWPROCEDURES
protected final String SQL_PREP_SHOWPROCEDURESLIKE
protected final String SQL_PREP_SHOWFUNCTIONS
protected final String SQL_PREP_SHOWFUNCTIONSLIKE
protected final String SQL_PREP_SHOWPARAMETERSPROCEDURE
protected final String SQL_PREP_SHOWPARAMETERSFUNCTION
protected final String SQL_SEMICOLON
protected final String SQL_LIKE
protected static final String DATETIME_PRECISION_PATTERN
protected static final String INTERVAL_PRECISION_PATTERN
protected static final String PRECISION_EXTRACTION_PATTERN
protected static final String PRECISION_REMOVAL_PATTERN
protected static final String TRAILING_SPACES_PATTERN
protected static final String RADIX_VALUE
protected static final String NULLABLE_UNKNOWN_VALUE
protected static final String EMPTY_REMARKS
protected static final String IS_NULLABLE_VALUE
protected static final String PSEUDO_COLUMN_VALUE
public MetadataAPIHelper(RedshiftConnectionImpl connection)
public static <T extends Enum<T> & MetadataAPIHelper.enumFunc<T>> Field[] getField(Supplier<T[]> enumObject)
protected Statement createMetaDataStatement() throws SQLException
SQLExceptionprotected PreparedStatement createMetaDataPreparedStatement(String sql) throws SQLException
SQLExceptionprotected ResultSet createRs(Field[] col, List<Tuple> data) throws SQLException
SQLExceptionprotected ResultSet runQuery(String sql) throws SQLException
SQLExceptionprotected byte[][] getEmptyTuple(Field[] col, int size) throws SQLException
SQLExceptionprotected byte[] encodeStr(String str) throws SQLException
SQLExceptionprotected String getRSType(String rsType) throws SQLException
SQLExceptionprotected String getSQLType(String rsType) throws SQLException
SQLExceptionprotected String getColumnSize(String rsType, String character_maximum_length, String numeric_precision)
protected String getColumnLength(String rsType)
rsType - The Redshift data typeprotected String getDecimalDigit(String rsType, String numeric_scale, int precision, boolean customizePrecision)
protected String getSpecificName(String name, String argument) throws SQLException
SQLExceptionprotected Map.Entry<String,List<String>> createParameterizedQueryString(String argumentList, String sqlBase, String columnNamePattern) throws SQLException
argumentList - Comma-separated string of argument types
(e.g. "integer, short, character varying")sqlBase - Base SQL statement to which parameters will be added
(e.g. "SHOW PARAMETERS OF PROCEDURE")columnNamePattern - Optional pattern for filtering column names.
If provided, adds LIKE clause instead of semicolonList<String>: List of argument types with whitespace strippedSQLExceptionprotected static int getProcedureType(String returnType)
protected static int getFunctionType(String returnType)
protected static int getProcedureColumnType(String parameterType)
protected static int getFunctionColumnType(String parameterType)
protected static void sortForeignKeyTuples(List<Tuple> foreignKeyTuples, boolean isImported)
foreignKeyTuples - The list of foreign key tuples to be sorted.isImported - Boolean flag indicating whether the keys are imported (true) or exported (false).
This affects which columns are used for comparison during sorting.
Each comparison is done using the compareBytes method.protected static String getIsGrantable(Boolean admin_option)
public static boolean patternMatch(String str, String pattern)
str - The input string to matchpattern - The pattern to match against, containing wildcards:
'%' - matches zero or more characters
'_' - matches exactly one characterCopyright © 2025 Amazon.com Inc.. All rights reserved.