Inspect

The inspect hook allows you to retrieve metadata about files, directories, or database objects from any supported connection. This is particularly useful for validating existence, checking properties, or monitoring changes.

Configuration

- type: inspect
  location: connection_name/path_or_object  # Required: Location string (database or storage)
  recursive: true/false                    # Optional: For files, get nested file stats
  on_failure: abort                        # Optional: abort/warn/quiet/skip
  id: my_id                               # Optional: Generated if not provided

Properties

Property
Required
Description

location

Yes

The location string. Can be a database location (e.g., postgres/public.table_name) or storage location (e.g., aws_s3/bucket/path/file.txt)

recursive

No

For file systems: whether to get total count/size of nested files

on_failure

No

What to do if the inspection fails (abort/warn/quiet/skip)

Location Examples

  • Database: postgres/public.users, mysql_db/analytics.events, snowflake/DATABASE.SCHEMA.TABLE

  • Storage: aws_s3/bucket/data/file.csv, local//tmp/data/file.json, gcs/bucket/folder/

Output

File System Objects

When inspecting files or directories, the hook returns:

Database Objects

When inspecting database tables, the hook returns:

Accessing Output Data

You can access these values in subsequent hooks using JMESPath syntax:

File System Data

  • {state.hook_id.exists} - Whether the path exists

  • {state.hook_id.size} - File size in bytes

  • {state.hook_id.is_dir} - Whether it's a directory

  • {state.hook_id.created_at} - Creation timestamp

  • {state.hook_id.updated_at} - Last modified timestamp

Database Data

  • {state.hook_id.exists} - Whether the table exists

  • {state.hook_id.column_names} - Array of column names

  • {state.hook_id.column_map.column_name.type} - Specific column type

  • {state.hook_id.fdqn} - Fully qualified table name

Examples

Database Examples

Verify Table Exists

Check if a required table exists:

Validate Table Schema

Ensure required columns exist and check column properties:

Check Column Types

Validate specific column data types:

File System Examples

Verify File Existence

Check if a required file exists before processing:

Check File Properties

Ensure a file meets requirements:

Directory Inspection with Recursive Stats

Get total file count and size in a directory:

File Age Check

Skip processing if file is too old:

Notes

  • Database Locations: Use the format connection_name/database.schema.table or connection_name/schema.table depending on your database

  • Storage Locations: Use the format connection_name/path/to/file or connection_name/path/to/directory/

  • File Systems: Not all filesystems provide all metadata fields

  • File Systems: Timestamps may be zero if not supported by the filesystem

  • File Systems: Directory sizes are typically reported as 0 unless recursive: true

  • Databases: Column precision and scale are only populated for decimal/numeric types

  • General: The hook will not fail if the path/object is invalid; it returns exists: false

  • General: Use appropriate connection types (file connections for files, database connections for tables)

Last updated

Was this helpful?