getPartitions method
Retrieves information about the partitions in a table.
May throw EntityNotFoundException. May throw InvalidInputException. May throw OperationTimeoutException. May throw InternalServiceException. May throw GlueEncryptionException.
Parameter databaseName
:
The name of the catalog database where the partitions reside.
Parameter tableName
:
The name of the partitions' table.
Parameter catalogId
:
The ID of the Data Catalog where the partitions in question reside. If
none is provided, the AWS account ID is used by default.
Parameter expression
:
An expression that filters the partitions to be returned.
The expression uses SQL syntax similar to the SQL WHERE
filter clause. The SQL statement parser JSQLParser parses
the expression.
Operators: The following are the operators that you can use in the
Expression
API call:
- =
-
Checks whether the values of the two operands are equal; if yes, then the
condition becomes true.
Example: Assume 'variable a' holds 10 and 'variable b' holds 20.
(a = b) is not true.
- < >
-
Checks whether the values of two operands are equal; if the values are not
equal, then the condition becomes true.
Example: (a < > b) is true.
- >
-
Checks whether the value of the left operand is greater than the value of
the right operand; if yes, then the condition becomes true.
Example: (a > b) is not true.
- <
-
Checks whether the value of the left operand is less than the value of the
right operand; if yes, then the condition becomes true.
Example: (a < b) is true.
- >=
-
Checks whether the value of the left operand is greater than or equal to
the value of the right operand; if yes, then the condition becomes true.
Example: (a >= b) is not true.
- <=
-
Checks whether the value of the left operand is less than or equal to the
value of the right operand; if yes, then the condition becomes true.
Example: (a <= b) is true.
- AND, OR, IN, BETWEEN, LIKE, NOT, IS NULL
- Logical operators.
-
string
-
date
-
timestamp
-
int
-
bigint
-
long
-
tinyint
-
smallint
-
decimal
The following list shows the valid operators on each type. When you define
a crawler, the partitionKey
type is created as a
STRING
, to be compatible with the catalog partitions.
Sample API Call:
Parameter maxResults
:
The maximum number of partitions to return in a single response.
Parameter nextToken
:
A continuation token, if this is not the first call to retrieve these
partitions.
Parameter segment
:
The segment of the table's partitions to scan in this request.
Implementation
Future<GetPartitionsResponse> getPartitions({
required String databaseName,
required String tableName,
String? catalogId,
String? expression,
int? maxResults,
String? nextToken,
Segment? segment,
}) async {
ArgumentError.checkNotNull(databaseName, 'databaseName');
_s.validateStringLength(
'databaseName',
databaseName,
1,
255,
isRequired: true,
);
ArgumentError.checkNotNull(tableName, 'tableName');
_s.validateStringLength(
'tableName',
tableName,
1,
255,
isRequired: true,
);
_s.validateStringLength(
'catalogId',
catalogId,
1,
255,
);
_s.validateStringLength(
'expression',
expression,
0,
2048,
);
_s.validateNumRange(
'maxResults',
maxResults,
1,
1000,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSGlue.GetPartitions'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'DatabaseName': databaseName,
'TableName': tableName,
if (catalogId != null) 'CatalogId': catalogId,
if (expression != null) 'Expression': expression,
if (maxResults != null) 'MaxResults': maxResults,
if (nextToken != null) 'NextToken': nextToken,
if (segment != null) 'Segment': segment,
},
);
return GetPartitionsResponse.fromJson(jsonResponse.body);
}