Skip to content

Commit

Permalink
[FLINK-35691][table] Fix cluster info displayed incorrectly on SqlCli…
Browse files Browse the repository at this point in the history
…ent when RowFormat is PLAIN_TEXT
  • Loading branch information
lsyldliu committed Jun 26, 2024
1 parent e2f0665 commit 5fb9052
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.core.execution.JobClient;
import org.apache.flink.table.api.TableException;
import org.apache.flink.table.data.GenericArrayData;
import org.apache.flink.table.data.GenericMapData;
import org.apache.flink.table.data.GenericRowData;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.data.StringData;
Expand All @@ -30,8 +32,10 @@
import org.apache.flink.types.Row;
import org.apache.flink.util.CloseableIterator;

import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/** Create result provider from a static set of data using external types. */
@Internal
Expand All @@ -51,6 +55,20 @@ public class StaticResultProvider implements ResultProvider {
results[i] = "TRUE";
} else if (Boolean.FALSE.equals(value)) {
results[i] = "FALSE";
} else if (value instanceof GenericMapData) {
// TODO: This is a temporary solution, the long-term solution is to use
// RowDataToStringConverterImpl
GenericMapData mapData = (GenericMapData) value;
if (mapData.size() == 0) {
results[i] = PrintStyle.NULL_VALUE;
} else {
Object[] keyArr =
((GenericArrayData) mapData.keyArray()).toObjectArray();
results[i] =
Arrays.stream(keyArr)
.map(key -> key + "=" + mapData.get(key))
.collect(Collectors.joining(", ", "{", "}"));
}
} else {
results[i] = value == null ? PrintStyle.NULL_VALUE : "" + value;
}
Expand Down

0 comments on commit 5fb9052

Please sign in to comment.