in src/main/java/software/aws/neptune/common/gremlindatamodel/resultset/ResultSetGetColumns.java [154:204]
public ResultSetGetColumns(final Statement statement, final GremlinSchema gremlinSchema,
final ResultSetInfoWithoutRows resultSetInfoWithoutRows)
throws SQLException {
super(statement, resultSetInfoWithoutRows.getColumns(), resultSetInfoWithoutRows.getRowCount());
for (final GremlinTableBase gremlinTableBase : gremlinSchema.getAllTables()) {
int i = 1;
for (final Map.Entry<String, GremlinProperty> property : gremlinTableBase.getColumns().entrySet()) {
// Add defaults.
final Map<String, Object> map = new HashMap<>(CONVERSION_MAP);
// Set table name.
map.put("TABLE_NAME", gremlinTableBase.getLabel());
// Get column type.
final String dataType = property.getValue().getType();
map.put("TYPE_NAME", dataType);
final Optional<? extends Class<?>> javaClassOptional =
GREMLIN_STRING_TYPE_TO_JAVA_TYPE_CONVERTER_MAP.
entrySet().stream().
filter(d -> d.getKey().equalsIgnoreCase(dataType)).
map(Map.Entry::getValue).
findFirst();
final Class<?> javaClass = javaClassOptional.isPresent() ? javaClassOptional.get() : String.class;
map.put("CHAR_OCTET_LENGTH", (javaClass == String.class) ? Integer.MAX_VALUE : null);
final int jdbcType = JavaToJdbcTypeConverter.CLASS_TO_JDBC_ORDINAL
.getOrDefault(javaClass, JdbcType.VARCHAR.getJdbcCode());
map.put("DATA_TYPE", jdbcType);
map.put("SQL_DATA_TYPE", jdbcType);
map.put("COLUMN_NAME", property.getKey());
map.put("NULLABLE", DatabaseMetaData.columnNullable);
map.put("IS_NULLABLE", "YES");
// TODO: These need to be verified for Tableau.
map.put("DECIMAL_DIGITS", null);
map.put("NUM_PREC_RADIX", 10);
map.put("ORDINAL_POSITION", i++);
// TODO AN-839: Fix COLUMN_SIZE.
map.put("COLUMN_SIZE", 10);
if (!map.keySet().equals(new HashSet<>(ORDERED_COLUMNS))) {
throw SqlError.createSQLException(
LOGGER,
SqlState.DATA_TYPE_TRANSFORM_VIOLATION,
SqlError.UNSUPPORTED_TYPE, map.keySet().toString());
}
rows.add(map);
}
}
}