Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.databricks.jdbc.client.impl.thrift.commons;
import static com.databricks.jdbc.client.impl.helper.MetadataResultConstants.NULL_STRING;
import static com.databricks.jdbc.core.DatabricksTypeUtil.*;
import com.databricks.jdbc.client.DatabricksHttpException;
import com.databricks.jdbc.client.impl.thrift.generated.*;
import com.databricks.jdbc.client.sqlexec.ExternalLink;
import com.databricks.jdbc.commons.LogLevel;
import com.databricks.jdbc.commons.util.LoggingUtil;
import com.databricks.sdk.service.sql.ColumnInfoTypeName;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class DatabricksThriftHelper {
public static final List SUCCESS_STATUS_LIST =
List.of(TStatusCode.SUCCESS_STATUS, TStatusCode.SUCCESS_WITH_INFO_STATUS);
public static TNamespace getNamespace(String catalog, String schema) {
return new TNamespace().setCatalogName(catalog).setSchemaName(schema);
}
public static String byteBufferToString(ByteBuffer buffer) {
ByteBuffer newBuffer = buffer.duplicate(); // This is to avoid a BufferUnderflowException
long sigBits = newBuffer.getLong();
return new UUID(sigBits, sigBits).toString();
}
public static ExternalLink createExternalLink(TSparkArrowResultLink chunkInfo, long chunkIndex) {
return new ExternalLink()
.setExternalLink(chunkInfo.getFileLink())
.setChunkIndex(chunkIndex)
.setExpiration(Long.toString(chunkInfo.getExpiryTime()));
}
public static String getStatementId(TOperationHandle operationHandle) {
return byteBufferToString(operationHandle.getOperationId().guid);
}
public static void verifySuccessStatus(TStatusCode statusCode, String errorContext)
throws DatabricksHttpException {
if (!SUCCESS_STATUS_LIST.contains(statusCode)) {
String errorMessage = "Error thrift response received. " + errorContext;
LoggingUtil.log(LogLevel.ERROR, errorMessage);
throw new DatabricksHttpException(errorMessage);
}
}
public static int getColumnCount(TGetResultSetMetadataResp resultManifest) {
if (resultManifest == null || resultManifest.getSchema() == null) {
return 0;
}
return resultManifest.getSchema().getColumnsSize();
}
/**
* In metadata operations, a list of singleton lists is obtained. This function extracts metadata
* values from these TColumn lists based on the data type set in the column.
*
* @param columnList the TColumn from which to extract values
* @return a singleton list of metadata result
*/
public static List> extractValues(List columnList) {
if (columnList == null) {
return Collections.singletonList(Collections.emptyList());
}
List