How to use Boto3 to get the details of a classifier from AWS Glue Data catalog?

AWS Glue Data Catalog allows you to store and manage metadata for your data assets. Classifiers in AWS Glue determine the schema of your data. You can use the boto3 library to retrieve detailed information about existing classifiers programmatically.

Problem Statement

Use boto3 library in Python to get details of a classifier from AWS Glue Data catalog. For example, get the details of a classifier - 'xml-test'.

Approach/Algorithm

Step 1 ? Import boto3 and botocore exceptions to handle exceptions.

Step 2 ? Pass the parameter classifier_name whose details are to be checked.

Step 3 ? Create an AWS session using boto3 library. Make sure region_name is mentioned in default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.

Step 4 ? Create an AWS client for glue.

Step 5 ? Call get_classifier and pass the classifier_name as Name parameter.

Step 6 ? It will fetch the details of the classifier.

Step 7 ? Handle the generic exception if something went wrong while checking the job.

Example

Use the following code to get details of a classifier from AWS Glue Data catalog ?

import boto3
from botocore.exceptions import ClientError

def get_classifier_details(classifier_name):
    session = boto3.session.Session()
    glue_client = session.client('glue')
    try:
        response = glue_client.get_classifier(Name=classifier_name)
        return response
    except ClientError as e:
        raise Exception("boto3 client error in get_classifier_details: " + e.__str__())
    except Exception as e:
        raise Exception("Unexpected error in get_classifier_details: " + e.__str__())

print(get_classifier_details("xml-test"))

Output

{'Classifier': {'GrokClassifier': {'Name': 'xml-test', 'Classification':
'xml', 'CreationTime': datetime.datetime(2018, 6, 21, 4, 7, 4,
tzinfo=tzlocal()), 'LastUpdated': datetime.datetime(2018, 6, 21, 4, 7,
11, tzinfo=tzlocal()), 'Version': 2, 'GrokPattern': 'SYSLOGTIMESTAMP
%{MONTH} +%{MONTHDAY} %{TIME}'}}, 'ResponseMetadata': {'RequestId':
'c291cce2-.......-3552077ddefd', 'HTTPStatusCode': 200, 'HTTPHeaders':
{'date': 'Sun, 21 Feb 2021 07:58:09 GMT', 'content-type':
'application/x-amz-json-1.1', 'content-length': '218', 'connection':
'keep-alive', 'x-amzn-requestid': 'c291cce2-......-3552077ddefd'},
'RetryAttempts': 0}}

Key Points

The response includes important classifier details:

  • Name ? Unique identifier for the classifier
  • Classification ? Data format type (xml, csv, json, etc.)
  • CreationTime ? When the classifier was created
  • Version ? Current version of the classifier
  • GrokPattern ? Pattern used for parsing data (for Grok classifiers)

Conclusion

Using boto3's get_classifier() method, you can easily retrieve detailed information about AWS Glue classifiers. This is useful for monitoring, debugging, and managing your data catalog metadata programmatically.

Updated on: 2026-03-25T18:16:50+05:30

300 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements