Class CloudwatchTableResolver


  • public class CloudwatchTableResolver
    extends Object
    This class helps with resolving the differences in casing between cloudwatch log and Presto. Presto expects all databases, tables, and columns to be lower case. This class allows us to use cloudwatch logGroups and logStreams which may have captial letters in them without issue. It does so by caching LogStreams and LogStreams and doing a case insentive search over them. It will first try to do a targeted get to reduce the penalty for LogGroups and LogStreams which don't have capitalization. It also has an optimization for LAMBDA which is a common cause of capitalized LogStreams by doing a targeted replace for LAMBDA's pattern.
    • Constructor Detail

      • CloudwatchTableResolver

        public CloudwatchTableResolver​(ThrottlingInvoker invoker,
                                       com.amazonaws.services.logs.AWSLogs awsLogs,
                                       long maxSchemaCacheSize,
                                       long maxTableCacheSize)
        Constructs an instance of the table resolver.
        Parameters:
        invoker - The ThrottlingInvoker to use to handle throttling events.
        awsLogs - The AWSLogs client to use for cache misses.
        maxSchemaCacheSize - The max number of schemas to cache.
        maxTableCacheSize - The max tables to cache.
    • Method Detail

      • validateTable

        public CloudwatchTableName validateTable​(TableName tableName)
        Used to validate and convert the given TableName to a properly cased and qualified CloudwatchTableName.
        Parameters:
        tableName - The TableName to validate and convert.
        Returns:
        The CloudwatchTableName for the provided TableName or throws if the TableName could not be resolved to a CloudwatchTableName. This method mostly handles resolving case mismatches and ensuring the input is a valid entity in Cloudwatch.
      • validateSchema

        public String validateSchema​(String schema)
        Used to validate and convert the given schema name to a properly cased and qualified CloudwatchTableName.
        Parameters:
        schema - The TableName to validate and convert.
        Returns:
        The cloudwatch LogGroup (aka schema name) or throws if the schema name could not be resolved to a LogGroup. This method mostly handles resolving case mismatches and ensuring the input is a valid entity in Cloudwatch.