-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathprotocolVersion.ts
More file actions
95 lines (85 loc) · 4 KB
/
protocolVersion.ts
File metadata and controls
95 lines (85 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { TProtocolVersion } from '../../thrift/TCLIService_types';
/**
* Protocol version information from Thrift TCLIService
* Each version adds certain features to the Spark/Hive API
*
* Databricks only supports SPARK_CLI_SERVICE_PROTOCOL_V1 (0xA501) or higher
*/
/**
* Check if the current protocol version supports a specific feature
* @param serverProtocolVersion The protocol version received from server in TOpenSessionResp
* @param requiredVersion The minimum protocol version required for a feature
* @returns boolean indicating if the feature is supported
*/
export function isFeatureSupported(
serverProtocolVersion: TProtocolVersion | undefined | null,
requiredVersion: TProtocolVersion,
): boolean {
if (serverProtocolVersion === undefined || serverProtocolVersion === null) {
return false;
}
return serverProtocolVersion >= requiredVersion;
}
/**
* Check if parameterized queries are supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V8 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if parameterized queries are supported
*/
export function supportsParameterizedQueries(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V8);
}
/**
* Check if async metadata operations are supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V6 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if async metadata operations are supported
*/
export function supportsAsyncMetadataOperations(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V6);
}
/**
* Check if result persistence mode is supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V7 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if result persistence mode is supported
*/
export function supportsResultPersistenceMode(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V7);
}
/**
* Check if Arrow compression is supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V6 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if compressed Arrow batches are supported
*/
export function supportsArrowCompression(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V6);
}
/**
* Check if Arrow metadata is supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V5 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if Arrow metadata is supported
*/
export function supportsArrowMetadata(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V5);
}
/**
* Check if multiple catalogs are supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V4 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if multiple catalogs are supported
*/
export function supportsMultipleCatalogs(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V4);
}
/**
* Check if cloud object storage fetching is supported
* (Requires SPARK_CLI_SERVICE_PROTOCOL_V3 or higher)
* @param serverProtocolVersion The protocol version from server
* @returns boolean indicating if cloud fetching is supported
*/
export function supportsCloudFetch(serverProtocolVersion: TProtocolVersion | undefined | null): boolean {
return isFeatureSupported(serverProtocolVersion, TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V3);
}