GetTablesCommand

Retrieves the definitions of some or all of the tables in a given Database.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { GlueClient, GetTablesCommand } from "@aws-sdk/client-glue"; // ES Modules import
// const { GlueClient, GetTablesCommand } = require("@aws-sdk/client-glue"); // CommonJS import
const client = new GlueClient(config);
const input = { // GetTablesRequest
  CatalogId: "STRING_VALUE",
  DatabaseName: "STRING_VALUE", // required
  Expression: "STRING_VALUE",
  NextToken: "STRING_VALUE",
  MaxResults: Number("int"),
  TransactionId: "STRING_VALUE",
  QueryAsOfTime: new Date("TIMESTAMP"),
  IncludeStatusDetails: true || false,
  AttributesToGet: [ // TableAttributesList
    "NAME" || "TABLE_TYPE",
  ],
};
const command = new GetTablesCommand(input);
const response = await client.send(command);
// { // GetTablesResponse
//   TableList: [ // TableList
//     { // Table
//       Name: "STRING_VALUE", // required
//       DatabaseName: "STRING_VALUE",
//       Description: "STRING_VALUE",
//       Owner: "STRING_VALUE",
//       CreateTime: new Date("TIMESTAMP"),
//       UpdateTime: new Date("TIMESTAMP"),
//       LastAccessTime: new Date("TIMESTAMP"),
//       LastAnalyzedTime: new Date("TIMESTAMP"),
//       Retention: Number("int"),
//       StorageDescriptor: { // StorageDescriptor
//         Columns: [ // ColumnList
//           { // Column
//             Name: "STRING_VALUE", // required
//             Type: "STRING_VALUE",
//             Comment: "STRING_VALUE",
//             Parameters: { // ParametersMap
//               "<keys>": "STRING_VALUE",
//             },
//           },
//         ],
//         Location: "STRING_VALUE",
//         AdditionalLocations: [ // LocationStringList
//           "STRING_VALUE",
//         ],
//         InputFormat: "STRING_VALUE",
//         OutputFormat: "STRING_VALUE",
//         Compressed: true || false,
//         NumberOfBuckets: Number("int"),
//         SerdeInfo: { // SerDeInfo
//           Name: "STRING_VALUE",
//           SerializationLibrary: "STRING_VALUE",
//           Parameters: {
//             "<keys>": "STRING_VALUE",
//           },
//         },
//         BucketColumns: [ // NameStringList
//           "STRING_VALUE",
//         ],
//         SortColumns: [ // OrderList
//           { // Order
//             Column: "STRING_VALUE", // required
//             SortOrder: Number("int"), // required
//           },
//         ],
//         Parameters: "<ParametersMap>",
//         SkewedInfo: { // SkewedInfo
//           SkewedColumnNames: [
//             "STRING_VALUE",
//           ],
//           SkewedColumnValues: [ // ColumnValueStringList
//             "STRING_VALUE",
//           ],
//           SkewedColumnValueLocationMaps: { // LocationMap
//             "<keys>": "STRING_VALUE",
//           },
//         },
//         StoredAsSubDirectories: true || false,
//         SchemaReference: { // SchemaReference
//           SchemaId: { // SchemaId
//             SchemaArn: "STRING_VALUE",
//             SchemaName: "STRING_VALUE",
//             RegistryName: "STRING_VALUE",
//           },
//           SchemaVersionId: "STRING_VALUE",
//           SchemaVersionNumber: Number("long"),
//         },
//       },
//       PartitionKeys: [
//         {
//           Name: "STRING_VALUE", // required
//           Type: "STRING_VALUE",
//           Comment: "STRING_VALUE",
//           Parameters: "<ParametersMap>",
//         },
//       ],
//       ViewOriginalText: "STRING_VALUE",
//       ViewExpandedText: "STRING_VALUE",
//       TableType: "STRING_VALUE",
//       Parameters: "<ParametersMap>",
//       CreatedBy: "STRING_VALUE",
//       IsRegisteredWithLakeFormation: true || false,
//       TargetTable: { // TableIdentifier
//         CatalogId: "STRING_VALUE",
//         DatabaseName: "STRING_VALUE",
//         Name: "STRING_VALUE",
//         Region: "STRING_VALUE",
//       },
//       CatalogId: "STRING_VALUE",
//       VersionId: "STRING_VALUE",
//       FederatedTable: { // FederatedTable
//         Identifier: "STRING_VALUE",
//         DatabaseIdentifier: "STRING_VALUE",
//         ConnectionName: "STRING_VALUE",
//       },
//       ViewDefinition: { // ViewDefinition
//         IsProtected: true || false,
//         Definer: "STRING_VALUE",
//         SubObjects: [ // ViewSubObjectsList
//           "STRING_VALUE",
//         ],
//         Representations: [ // ViewRepresentationList
//           { // ViewRepresentation
//             Dialect: "REDSHIFT" || "ATHENA" || "SPARK",
//             DialectVersion: "STRING_VALUE",
//             ViewOriginalText: "STRING_VALUE",
//             ViewExpandedText: "STRING_VALUE",
//             ValidationConnection: "STRING_VALUE",
//             IsStale: true || false,
//           },
//         ],
//       },
//       IsMultiDialectView: true || false,
//       Status: { // TableStatus
//         RequestedBy: "STRING_VALUE",
//         UpdatedBy: "STRING_VALUE",
//         RequestTime: new Date("TIMESTAMP"),
//         UpdateTime: new Date("TIMESTAMP"),
//         Action: "UPDATE" || "CREATE",
//         State: "QUEUED" || "IN_PROGRESS" || "SUCCESS" || "STOPPED" || "FAILED",
//         Error: { // ErrorDetail
//           ErrorCode: "STRING_VALUE",
//           ErrorMessage: "STRING_VALUE",
//         },
//         Details: { // StatusDetails
//           RequestedChange: {
//             Name: "STRING_VALUE", // required
//             DatabaseName: "STRING_VALUE",
//             Description: "STRING_VALUE",
//             Owner: "STRING_VALUE",
//             CreateTime: new Date("TIMESTAMP"),
//             UpdateTime: new Date("TIMESTAMP"),
//             LastAccessTime: new Date("TIMESTAMP"),
//             LastAnalyzedTime: new Date("TIMESTAMP"),
//             Retention: Number("int"),
//             StorageDescriptor: {
//               Columns: "<ColumnList>",
//               Location: "STRING_VALUE",
//               AdditionalLocations: [
//                 "STRING_VALUE",
//               ],
//               InputFormat: "STRING_VALUE",
//               OutputFormat: "STRING_VALUE",
//               Compressed: true || false,
//               NumberOfBuckets: Number("int"),
//               SerdeInfo: {
//                 Name: "STRING_VALUE",
//                 SerializationLibrary: "STRING_VALUE",
//                 Parameters: "<ParametersMap>",
//               },
//               BucketColumns: "<NameStringList>",
//               SortColumns: [
//                 {
//                   Column: "STRING_VALUE", // required
//                   SortOrder: Number("int"), // required
//                 },
//               ],
//               Parameters: "<ParametersMap>",
//               SkewedInfo: {
//                 SkewedColumnNames: "<NameStringList>",
//                 SkewedColumnValues: [
//                   "STRING_VALUE",
//                 ],
//                 SkewedColumnValueLocationMaps: {
//                   "<keys>": "STRING_VALUE",
//                 },
//               },
//               StoredAsSubDirectories: true || false,
//               SchemaReference: {
//                 SchemaId: {
//                   SchemaArn: "STRING_VALUE",
//                   SchemaName: "STRING_VALUE",
//                   RegistryName: "STRING_VALUE",
//                 },
//                 SchemaVersionId: "STRING_VALUE",
//                 SchemaVersionNumber: Number("long"),
//               },
//             },
//             PartitionKeys: "<ColumnList>",
//             ViewOriginalText: "STRING_VALUE",
//             ViewExpandedText: "STRING_VALUE",
//             TableType: "STRING_VALUE",
//             Parameters: "<ParametersMap>",
//             CreatedBy: "STRING_VALUE",
//             IsRegisteredWithLakeFormation: true || false,
//             TargetTable: {
//               CatalogId: "STRING_VALUE",
//               DatabaseName: "STRING_VALUE",
//               Name: "STRING_VALUE",
//               Region: "STRING_VALUE",
//             },
//             CatalogId: "STRING_VALUE",
//             VersionId: "STRING_VALUE",
//             FederatedTable: {
//               Identifier: "STRING_VALUE",
//               DatabaseIdentifier: "STRING_VALUE",
//               ConnectionName: "STRING_VALUE",
//             },
//             ViewDefinition: {
//               IsProtected: true || false,
//               Definer: "STRING_VALUE",
//               SubObjects: [
//                 "STRING_VALUE",
//               ],
//               Representations: [
//                 {
//                   Dialect: "REDSHIFT" || "ATHENA" || "SPARK",
//                   DialectVersion: "STRING_VALUE",
//                   ViewOriginalText: "STRING_VALUE",
//                   ViewExpandedText: "STRING_VALUE",
//                   ValidationConnection: "STRING_VALUE",
//                   IsStale: true || false,
//                 },
//               ],
//             },
//             IsMultiDialectView: true || false,
//             Status: {
//               RequestedBy: "STRING_VALUE",
//               UpdatedBy: "STRING_VALUE",
//               RequestTime: new Date("TIMESTAMP"),
//               UpdateTime: new Date("TIMESTAMP"),
//               Action: "UPDATE" || "CREATE",
//               State: "QUEUED" || "IN_PROGRESS" || "SUCCESS" || "STOPPED" || "FAILED",
//               Error: {
//                 ErrorCode: "STRING_VALUE",
//                 ErrorMessage: "STRING_VALUE",
//               },
//               Details: {
//                 RequestedChange: "<Table>",
//                 ViewValidations: [ // ViewValidationList
//                   { // ViewValidation
//                     Dialect: "REDSHIFT" || "ATHENA" || "SPARK",
//                     DialectVersion: "STRING_VALUE",
//                     ViewValidationText: "STRING_VALUE",
//                     UpdateTime: new Date("TIMESTAMP"),
//                     State: "QUEUED" || "IN_PROGRESS" || "SUCCESS" || "STOPPED" || "FAILED",
//                     Error: "<ErrorDetail>",
//                   },
//                 ],
//               },
//             },
//           },
//           ViewValidations: [
//             {
//               Dialect: "REDSHIFT" || "ATHENA" || "SPARK",
//               DialectVersion: "STRING_VALUE",
//               ViewValidationText: "STRING_VALUE",
//               UpdateTime: new Date("TIMESTAMP"),
//               State: "QUEUED" || "IN_PROGRESS" || "SUCCESS" || "STOPPED" || "FAILED",
//               Error: "<ErrorDetail>",
//             },
//           ],
//         },
//       },
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

GetTablesCommand Input

See GetTablesCommandInput for more details

Parameter
Type
Description
DatabaseName
Required
string | undefined

The database in the catalog whose tables to list. For Hive compatibility, this name is entirely lowercase.

AttributesToGet
TableAttributes[] | undefined

Specifies the table fields returned by the GetTables call. This parameter doesn’t accept an empty list. The request must include NAME.

The following are the valid combinations of values:

  • NAME - Names of all tables in the database.

  • NAME, TABLE_TYPE - Names of all tables and the table types.

CatalogId
string | undefined

The ID of the Data Catalog where the tables reside. If none is provided, the Amazon Web Services account ID is used by default.

Expression
string | undefined

A regular expression pattern. If present, only those tables whose names match the pattern are returned.

IncludeStatusDetails
boolean | undefined

Specifies whether to include status details related to a request to create or update an Glue Data Catalog view.

MaxResults
number | undefined

The maximum number of tables to return in a single response.

NextToken
string | undefined

A continuation token, included if this is a continuation call.

QueryAsOfTime
Date | undefined

The time as of when to read the table contents. If not set, the most recent transaction commit time will be used. Cannot be specified along with TransactionId.

TransactionId
string | undefined

The transaction ID at which to read the table contents.

GetTablesCommand Output

See GetTablesCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
NextToken
string | undefined

A continuation token, present if the current list segment is not the last.

TableList
Table[] | undefined

A list of the requested Table objects.

Throws

Name
Fault
Details
EntityNotFoundException
client

A specified entity does not exist

FederationSourceException
client

A federation source failed.

FederationSourceRetryableException
client

A federation source failed, but the operation may be retried.

GlueEncryptionException
client

An encryption operation failed.

InternalServiceException
server

An internal service error occurred.

InvalidInputException
client

The input provided was not valid.

OperationTimeoutException
client

The operation timed out.

GlueServiceException
Base exception class for all service exceptions from Glue service.