Схема объекта Environment
Вы можете использовать объект environment для запросов и сравнения состояний определения (intended) и применения (applied) для узлов (models, seeds, snapshots, models и других) в вашем dbt‑проекте. Например, вы указываете environmentId, чтобы получить больше информации о конкретной модели (или другом типе узла) в данном окружении.
В разделе Example queries показаны некоторые поля, которые можно запрашивать с помощью объекта environment. Обратитесь к разделу Fields, чтобы посмотреть полную схему, содержащую все возможные поля, доступные для запросов.
Аргументы
При выполнении запроса environment вы можете использовать следующие аргументы.
Fetching data...
Примеры запросов
Вы можете использовать id вашего production‑окружения:
query Example {
environment(id: 834){ # Get the latest state of the production environment
applied { # The state of an executed node as it exists as an object in the database
models(first: 100){ # Pagination to ensure manageable response for large projects
edges { node {
uniqueId, name, description, rawCode, compiledCode, # Basic properties
database, schema, alias, # Table/view identifier (can also filter by)
executionInfo {executeCompletedAt, executionTime}, # Metadata from when the model was built
tests {name, executionInfo{lastRunStatus, lastRunError}}, # Latest test results
catalog {columns {name, description, type}, stats {label, value}}, # Catalog info
ancestors(types:[Source]) {name, ...on SourceAppliedStateNode {freshness{maxLoadedAt, freshnessStatus}}}, # Source freshness }
children {name, resourceType}}} # Immediate dependencies in lineage
totalCount } # Number of models in the project
}
definition { # The logical state of a given project node given its most recent manifest generated
models(first: 100, filter:{access:public}){ # Filter on model access (or other properties)
edges { node {
rawCode, # Compare to see if/how the model has changed since the last build
jobDefinitionId, runGeneratedAt, # When the code was last compiled or run
contractEnforced, group, version}}} # Model governance
}
}
В связи с выводом из использования типа данных Int для поля id, ниже приведён пример его замены на BigInt:
query ($environmentId: BigInt!, $first: Int!) {
environment(id: $environmentId) {
applied {
models(first: $first) {
edges {
node {
uniqueId
executionInfo {
lastRunId
}
}
}
}
}
}
}
В связи с выводом из использования modelByEnvironment, ниже приведён пример его замены на environment:
query ($environmentId: BigInt!, $uniqueId: String) {
environment(id: $environmentId) {
applied {
modelHistoricalRuns(uniqueId: $uniqueId) {
uniqueId
executionTime
executeCompletedAt
}
}
}
}
Поля
При выполнении запроса environment вы можете использовать следующие поля.
Fetching data...
Подробности о запросах к полю applied объекта environment можно найти здесь:
Applied
Подробности о запросах к полю definition объекта environment можно найти здесь:
Definition