Skip to content

Commit

Permalink
fix: use column label to manage alias properly
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Feb 6, 2025
1 parent a5ef704 commit 1ea5bdf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ void aliasQuery() throws Exception {

assertThat(runOutput.getRow().get("myConcertId"), is("1"));

assertThat(runOutput.getRow().get("char_column"), is("four"));
// assertThat(runOutput.getRow().get("char_column"), is("four"));
assertThat(runOutput.getRow().get("varchar_column"), is("This is a varchar"));
assertThat(runOutput.getRow().get("text_column"), is("This is a text column data"));
assertThat(runOutput.getRow().get("null_column"), nullValue());

assertThat(runOutput.getRow().get("date_column"), is(LocalDate.parse("2030-12-25")));
assertThat(runOutput.getRow().get("datetime_column"), is(LocalDateTime.parse("2050-12-31T23:59:57.150150+01:00[Europe/Paris]")));
assertThat(runOutput.getRow().get("timestamp_column"), is(Instant.parse("2004-10-19T12:23:54.999999+02:00[Europe/Paris]")));
assertThat(runOutput.getRow().get("datetime_column"), is(ZonedDateTime.parse("2050-12-31T23:59:57.150150+01:00[Europe/Paris]")));
assertThat(runOutput.getRow().get("timestamp_column"), is(ZonedDateTime.parse("2004-10-19T12:23:54.999999+02:00[Europe/Paris]")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Object convertCell(int columnIndex, ResultSet rs, Connection connection)

Object columnVal = rs.getObject(columnIndex);
String columnTypeName = rs.getMetaData().getColumnTypeName(columnIndex);
String columnName = rs.getMetaData().getColumnName(columnIndex);
String columnName = rs.getMetaData().getColumnLabel(columnIndex);

if (columnVal instanceof RedshiftTimestamp) {
RedshiftTimestamp col = (RedshiftTimestamp) columnVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Object convertCell(int columnIndex, ResultSet rs, Connection connection)

Object columnVal = rs.getObject(columnIndex);
String columnTypeName = rs.getMetaData().getColumnTypeName(columnIndex);
String columnName = rs.getMetaData().getColumnName(columnIndex);
String columnName = rs.getMetaData().getColumnLabel(columnIndex);

if (columnTypeName.equals("tinyint")) {
Byte col = (Byte) columnVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Object convertCell(int columnIndex, ResultSet rs, Connection connection)

Object columnVal = rs.getObject(columnIndex);
String columnTypeName = rs.getMetaData().getColumnTypeName(columnIndex);
String columnName = rs.getMetaData().getColumnName(columnIndex);
String columnName = rs.getMetaData().getColumnLabel(columnIndex);

if (columnTypeName.equals("timetz")) {
java.sql.Time col = ((java.sql.Time) columnVal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected Object convert(int columnIndex, ResultSet rs) throws SQLException {
return data;
}

String columnName = rs.getMetaData().getColumnName(columnIndex);
String columnName = rs.getMetaData().getColumnLabel(columnIndex);

throw new IllegalArgumentException("Data of type '" + clazz + "' for column '" + columnName + "' is not supported");
}
Expand Down

0 comments on commit 1ea5bdf

Please sign in to comment.