% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spec.R
\name{spec_utility}
\alias{spec_utility}
\alias{ggsql_metadata}
\alias{ggsql_sql}
\alias{ggsql_visual}
\alias{ggsql_layer_count}
\alias{ggsql_layer_data}
\alias{ggsql_stat_data}
\alias{ggsql_layer_sql}
\alias{ggsql_stat_sql}
\alias{ggsql_warnings}
\title{Utility functions for visualization specifications}
\usage{
ggsql_metadata(spec)

ggsql_sql(spec)

ggsql_visual(spec)

ggsql_layer_count(spec)

ggsql_layer_data(spec, index = 1L)

ggsql_stat_data(spec, index = 1L)

ggsql_layer_sql(spec, index = 1L)

ggsql_stat_sql(spec, index = 1L)

ggsql_warnings(spec)
}
\arguments{
\item{spec}{A \code{Spec} object as returned by \code{\link[=ggsql_execute]{ggsql_execute()}}}

\item{index}{Layer index}
}
\value{
\itemize{
\item \code{ggsql_metadata}: A list with elements \code{rows}, \code{columns}, and \code{layer_count}
\item \code{ggsql_sql}: A character string with the SQL portion of the query
\item \code{ggsql_visual}: A character string with the visual portion of the query
\item \code{ggsql_layer_count}: An integer giving the number of layers
\item \code{ggsql_layer_data}: A data frame, or \code{NULL} if no data is available for
this layer
\item \code{ggsql_stat_data}: A data frame, or \code{NULL} if the layer doesn't use a stat
transform
\item \code{ggsql_layer_sql}: A character string with the SQL query used by the layer
to fetch its data, or \code{NULL} if the layer doesn't have any data.
\item \code{ggsql_stat_sql}: A character string with the SQL query used by the layers
stat transform, or \code{NULL} if the layer doesn't have a stat transform.
\item \code{ggsql_warnings}: A data.frame with columns \code{message}, \code{line}, and \code{column}
giving the validation warnings for the spec
}
}
\description{
These functions allow you to extract various information from a \code{Spec} object
returned by \code{\link[=ggsql_execute]{ggsql_execute()}}.
}
\examples{
reader <- duckdb_reader()
ggsql_register(reader, mtcars, "cars")
spec <- ggsql_execute(reader,
  "SELECT * FROM cars VISUALISE mpg AS x DRAW histogram"
)

ggsql_metadata(spec)

ggsql_visual(spec)

}
