-
Notifications
You must be signed in to change notification settings - Fork 0
/
Athena.cfc
228 lines (216 loc) · 5.2 KB
/
Athena.cfc
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
component extends="types.Driver" implements="types.IDatasource" {
this.className="{class-name}";
this.bundleName="{bundle-name}";
this.dsn="{connstr}";
fields=[
field(
"Output Location",
"S3OutputLocation",
"",
true,
"Specifies the S3 location where Athena will store the results of the query. Example: s3://your-bucket/path/"
),
field(
"Region",
"AwsRegion",
"us-east-1",
true,
"Specifies the AWS region where your Athena instance resides."
),
field(
"Workgroup",
"Workgroup",
"primary",
false,
"Specifies the Athena workgroup to run the query in."
),
field(
"Result Reuse Enabled",
"ResultReuseEnabled",
"Yes,No",
false,
"Enables or disables the use of cached results to reduce query execution time and cost.",
"select"
),
field(
"Max Retries",
"MaxRetries",
"3",
false,
"Defines the maximum number of retry attempts if the connection fails."
),
field(
"Connection Timeout",
"ConnectionTimeout",
"30",
false,
"Defines the connection timeout in seconds."
),
field(
"Socket Timeout",
"SocketTimeout",
"60",
false,
"Defines the timeout (in seconds) for the socket connection to Athena."
),
field(
"Schema",
"Schema",
"",
false,
"Specifies the default schema (database) to use for the connection."
),
field(
"Authentication Type",
"AuthenticationType",
"IAM",
false,
"Specifies the authentication type for connecting to Athena (IAM, Default, Profile, AccessKey)."
),
field(
"AWS Profile",
"AwsProfile",
"default",
false,
"Specifies the AWS profile to use from the AWS credentials file."
),
field(
"Role ARN",
"RoleARN",
"",
false,
"Specifies the ARN of an IAM role to assume for Athena queries."
),
field(
"Role Session Name",
"RoleSessionName",
"",
false,
"Specifies the session name for the IAM role session when using RoleARN."
),
field(
"Role External ID",
"RoleExternalId",
"",
false,
"Specifies an external ID when assuming an IAM role, if required by the role's trust policy."
),
field(
"Enable Result Streaming",
"EnableResultStreaming",
"Yes,No",
false,
"Enables streaming of large query results to reduce memory usage.",
"select"
),
field(
"Metadata Cache TTL",
"MetadataCacheTTL",
"300",
false,
"Specifies the time-to-live (in seconds) for the metadata cache."
),
field(
"Use Result Set Streaming",
"UseResultSetStreaming",
"Yes,No",
false,
"Enables streaming of the result set to process large datasets row by row.",
"select",
2
),
field(
"Endpoint Override",
"EndpointOverride",
"",
false,
"Specifies a custom Athena endpoint for regional or private endpoints."
),
field(
"Log Level",
"LogLevel",
"DEBUG,INFO,WARN,ERROR",
false,
"Specifies the log level for the Athena JDBC driver (DEBUG, INFO, WARN, ERROR).",
"select",
2
),
field(
"Disable Certificate Validation",
"DisableCertificateValidation",
"Yes,No",
false,
"Disables SSL certificate validation (not recommended for production).",
"select",
2
),
field(
"SSL Enabled",
"SslEnabled",
"Yes,No",
false,
"Enables or disables SSL for the connection.",
"select",
1
)
];
data={};
public function customParameterSyntax() {
return {leadingdelimiter:';',delimiter:';',separator:'='};
}
/*
public boolean function literalTimestampWithTSOffset() {
return true;
}
*/
public void function onBeforeUpdate() {
var keysToDelete=[];
// get fields
var fields={};
loop array=getFields() item="f" {
fields[f.getName()]={req:f.getRequired(),def:f.getDefaultValue(),dis:f.getDisplayName()};
}
// remove the values that are using the defaukt values
loop struct=form index="local.kwp" item="v" {
if(find("custom_",kwp)==1) {
var k= mid(kwp,8);
if(structKeyExists(fields, k) && fields[k].def==v || isEmpty(trim(v)) ) {
arrayAppend(keysToDelete, kwp);
}
else form[kwp]=improve(v);
}
}
loop array=keysToDelete item="k" {
structDelete(form, k);
}
}
/**
* returns array of fields
*/
public array function getFields() {
return fields;
}
/**
* Returns the display name of the driver.
*/
public string function getName() {
return "Amazon Athena";
}
/**
* Returns the description for the driver.
*/
public string function getDescription() {
return "{description}";
}
/**
* return if String class match this
*/
public boolean function equals(required className, required dsn) {
return this.className EQ arguments.className;
}
public function improve(val) {
if("Yes"==val) return true;
if("No"==val) return false;
return val;
}
}