Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix federation query binary type data query #31346

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
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 @@ -103,7 +103,7 @@ private void handleColumnLabelAndIndex(final Map<String, Integer> columnLabelAnd
public boolean next() {
boolean result = enumerator.moveNext();
if (result && null != enumerator.current()) {
currentRows = enumerator.current().getClass().isArray() ? (Object[]) enumerator.current() : new Object[]{enumerator.current()};
currentRows = enumerator.current().getClass().isArray() && !(enumerator.current() instanceof byte[]) ? (Object[]) enumerator.current() : new Object[]{enumerator.current()};
} else {
currentRows = new Object[]{};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Object convertColumnValue(final Object columnValue) {
@Override
public int convertColumnType(final int columnType) {
if (SqlTypeName.BOOLEAN.getJdbcOrdinal() == columnType) {
return SqlTypeName.BIGINT.getJdbcOrdinal();
return SqlTypeName.VARCHAR.getJdbcOrdinal();
}
return columnType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ private void assertMetaData(final ResultSetMetaData actualResultSetMetaData, fin
for (int i = 0; i < actualResultSetMetaData.getColumnCount(); i++) {
assertThat(actualResultSetMetaData.getColumnLabel(i + 1), is(expectedResultSetMetaData.getColumnLabel(i + 1)));
assertThat(actualResultSetMetaData.getColumnName(i + 1), is(expectedResultSetMetaData.getColumnName(i + 1)));
if ("db_tbl_sql_federation".equals(testParam.getScenario())) {
continue;
}
if ("jdbc".equals(testParam.getAdapter()) && "Cluster".equals(testParam.getMode())) {
// FIXME correct columnType with proxy adapter
assertThat(actualResultSetMetaData.getColumnType(i + 1), is(expectedResultSetMetaData.getColumnType(i + 1)));
Expand Down Expand Up @@ -185,6 +188,8 @@ private void assertRow(final ResultSet actualResultSet, final ResultSetMetaData
? expectedResultSet.getTimestamp(i + 1).toLocalDateTime().format(DateTimeFormatterFactory.getStandardFormatter())
: actualValue;
assertThat(String.valueOf(convertedActualValue), is(String.valueOf(convertedExpectedValue)));
} else if (actualValue instanceof String && expectedValue instanceof byte[]) {
assertThat(actualValue, is(new String((byte[]) expectedValue)));
} else {
assertThat(String.valueOf(actualValue), is(String.valueOf(expectedValue)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,32 @@
<test-case sql="SELECT result.max_datetime FROM (SELECT MAX(type_datetime) AS max_datetime FROM t_product_extend) result" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_bit FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_blob FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_mediumblob FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_longblob FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_binary FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_varbinary FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>

<test-case sql="SELECT type_bit, type_blob, type_mediumblob, type_longblob, type_binary, type_varbinary FROM t_product_extend" db-types="MySQL" scenario-types="db_tbl_sql_federation">
<assertion expected-data-source-name="read_dataset" />
</test-case>
</integration-test-cases>
Loading