You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/26 06:22:22 UTC
[GitHub] [flink] fsk119 commented on a diff in pull request #20298: [FLINK-28152][sql-gateway][hive] Allow executing statement for the HiveServer2Endpoint
fsk119 commented on code in PR #20298:
URL: https://github.com/apache/flink/pull/20298#discussion_r929567090
##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/endpoint/hive/util/ThriftObjectConversions.java:
##########
@@ -51,25 +261,250 @@ public static TStatus toTStatus(Throwable t) {
// --------------------------------------------------------------------------------------------
- private static THandleIdentifier toTHandleIdentifier(HandleIdentifier identifier) {
+ private static THandleIdentifier toTHandleIdentifier(UUID publicId, UUID secretId) {
byte[] guid = new byte[16];
byte[] secret = new byte[16];
ByteBuffer guidBB = ByteBuffer.wrap(guid);
ByteBuffer secretBB = ByteBuffer.wrap(secret);
- guidBB.putLong(identifier.getPublicId().getMostSignificantBits());
- guidBB.putLong(identifier.getPublicId().getLeastSignificantBits());
- secretBB.putLong(identifier.getSecretId().getMostSignificantBits());
- secretBB.putLong(identifier.getSecretId().getLeastSignificantBits());
+ guidBB.putLong(publicId.getMostSignificantBits());
+ guidBB.putLong(publicId.getLeastSignificantBits());
+ secretBB.putLong(secretId.getMostSignificantBits());
+ secretBB.putLong(secretId.getLeastSignificantBits());
return new THandleIdentifier(ByteBuffer.wrap(guid), ByteBuffer.wrap(secret));
}
- private static HandleIdentifier toHandleIdentifier(THandleIdentifier tHandleId) {
- ByteBuffer bb = ByteBuffer.wrap(tHandleId.getGuid());
- UUID publicId = new UUID(bb.getLong(), bb.getLong());
- bb = ByteBuffer.wrap(tHandleId.getSecret());
- UUID secretId = new UUID(bb.getLong(), bb.getLong());
- return new HandleIdentifier(publicId, secretId);
+ @VisibleForTesting
+ public static TRowSet toColumnBasedSet(
+ List<LogicalType> fieldTypes,
+ List<RowData.FieldGetter> fieldGetters,
+ RowDataToStringConverter converter,
+ List<RowData> rows) {
+ int rowNum = rows.size();
+ // TODO: Support accurate start offset
+ TRowSet rowSet = new TRowSet(0, new ArrayList<>(rowNum));
+ for (int i = 0; i < fieldTypes.size(); i++) {
+ int index = i;
+ rowSet.addToColumns(
+ toTColumn(
+ fieldTypes.get(i),
+ fieldGetters.get(i),
+ row -> row.isNullAt(index),
+ row -> converter.convert(row, index),
+ rows));
+ }
+ return rowSet;
+ }
+
+ private static TColumn toTColumn(
+ LogicalType fieldType,
+ RowData.FieldGetter fieldGetter,
+ Function<RowData, Boolean> isNull,
+ Function<RowData, String> stringifiedValue,
+ List<RowData> rows) {
+ BitSet nulls = new BitSet();
+ switch (fieldType.getTypeRoot()) {
Review Comment:
I think the comment is not accurate in the TCLService.thrift. I read the implementation it actually convert the TIMESTAMP to STRING value.
[1] https://github.com/apache/hive/blob/1c3406ea598e0c2d866b20747602c1a01fa5a425/service/src/java/org/apache/hive/service/cli/ColumnValue.java#L140
[2] https://github.com/apache/hive/blob/1c3406ea598e0c2d866b20747602c1a01fa5a425/serde/src/java/org/apache/hadoop/hive/serde2/thrift/ColumnBuffer.java#L129
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org