Query

Data Models

pydantic model dsgrid.query.models.ProjectQueryModel[source]

Represents a user query on a Project.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.dataset.models.PivotedTableFormatModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>PivotedTableFormatModel</b></td></tr><tr><td>format_type</td><td port="format_type">Literal[TableFormatType.PIVOTED]</td></tr><tr><td>pivoted_dimension_type</td><td port="pivoted_dimension_type">DimensionType</td></tr></table>>,
      tooltip="dsgrid.dataset.models.PivotedTableFormatModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
   "dsgrid.dataset.models.UnpivotedTableFormatModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>UnpivotedTableFormatModel</b></td></tr><tr><td>format_type</td><td port="format_type">Literal[TableFormatType.UNPIVOTED]</td></tr></table>>,
      tooltip="dsgrid.dataset.models.UnpivotedTableFormatModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterBetweenColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>lower_bound</td><td port="lower_bound">Any</td></tr><tr><td>upper_bound</td><td port="upper_bound">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.BETWEEN_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column is \
between the lower bound and upper bound,&#xA;inclusive.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"\
timestamp\").between(\"2012-07-01 00:00:00\", \"2012-08-01 00:00:00\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column matches \
a Spark SQL operator.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"geography\").like(\"abc%\"))&#xA;\
df.filter(~F.col(\"sector\").startswith(\"com\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel&#xA;&#xA;Filters a table where a dimension column matches an expression.&#\
xA;&#xA;Example:&#xA;    DimensionFilterExpressionModel(&#xA;        dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_\
query_name=\"county\",&#xA;        operator=\"==\",&#xA;        value=\"06037\",&#xA;    ),&#xA;is equivalent to&#xA;    df.filter(\"county == '\
06037'\")&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionRawModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION_RAW]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel&#xA;&#xA;Filters a table where a dimension column matches an \
expression.&#xA;Uses the passed string with no modification.&#xA;&#xA;Example:&#xA;    DimensionFilterExpressionRawModel(&#xA;        \
dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_query_name=\"county\",&#xA;        value=\"== '06037'\",&#xA;    ),&#xA;\
is equivalent to&#xA;    df.filter(\"county == '06037'\")&#xA;&#xA;The difference between this class and DimensionFilterExpressionModel \
is that the latter&#xA;will attempt to add quotes as necessary.&#xA;"];
   "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SubsetDimensionFilterModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_names</td><td port="dimension_query_names">list[str]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUBSET]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel&#xA;&#xA;Filters base dimension records that match a subset dimension.&#\
xA;"];
   "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SupplementalDimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUPPLEMENTAL_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel&#xA;&#xA;Filters base dimension records that have \
a valid mapping to a supplemental dimension.&#xA;"];
   "dsgrid.query.models.AggregationModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>AggregationModel</b></td></tr><tr><td>aggregation_function</td><td port="aggregation_function">Any</td></tr><tr><td>dimensions</td><td port="dimensions">DimensionQueryNamesModel</td></tr></table>>,
      tooltip="dsgrid.query.models.AggregationModel&#xA;&#xA;Aggregate on one or more dimensions.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionQueryNamesModel</b></td></tr><tr><td>geography</td><td port="geography">list[Union[str, ColumnModel]]</td></tr><tr><td>metric</td><td port="metric">list[Union[str, ColumnModel]]</td></tr><tr><td>model_year</td><td port="model_year">list[Union[str, ColumnModel]]</td></tr><tr><td>scenario</td><td port="scenario">list[Union[str, ColumnModel]]</td></tr><tr><td>sector</td><td port="sector">list[Union[str, ColumnModel]]</td></tr><tr><td>subsector</td><td port="subsector">list[Union[str, ColumnModel]]</td></tr><tr><td>time</td><td port="time">list[Union[str, ColumnModel]]</td></tr><tr><td>weather_year</td><td port="weather_year">list[Union[str, ColumnModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.DimensionQueryNamesModel&#xA;&#xA;Defines the list of dimensions to which the value columns should be aggregated.&#\
xA;If a value is empty, that dimension will be aggregated and dropped from the table.&#xA;"];
   "dsgrid.query.models.AggregationModel":dimensions:e -> "dsgrid.query.models.DimensionQueryNamesModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ColumnModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ColumnModel</b></td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>function</td><td port="function">Any</td></tr><tr><td>alias</td><td port="alias">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.ColumnModel&#xA;&#xA;Defines one column in a SQL aggregation statement.&#xA;"];
   "dsgrid.query.models.DatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DatasetModel</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>source_datasets</td><td port="source_datasets">list[Union[StandaloneDatasetModel, ProjectionDatasetModel]]</td></tr><tr><td>expression</td><td port="expression">Optional[str]</td></tr><tr><td>params</td><td port="params">ProjectQueryDatasetParamsModel</td></tr></table>>,
      tooltip="dsgrid.query.models.DatasetModel&#xA;&#xA;Specifies the datasets to use in a project query.&#xA;"];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectQueryDatasetParamsModel</b></td></tr><tr><td>dimension_filters</td><td port="dimension_filters">list[Union[DimensionFilterExpressionModel, DimensionFilterExpressionRawModel, DimensionFilterColumnOperatorModel, DimensionFilterBetweenColumnOperatorModel, SubsetDimensionFilterModel, SupplementalDimensionFilterColumnOperatorModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectQueryDatasetParamsModel&#xA;&#xA;Parameters in a project query that only apply to datasets&#xA;"];
   "dsgrid.query.models.DatasetModel":params:e -> "dsgrid.query.models.ProjectQueryDatasetParamsModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectionDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectionDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.PROJECTION]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>initial_value_dataset_id</td><td port="initial_value_dataset_id">str</td></tr><tr><td>growth_rate_dataset_id</td><td port="growth_rate_dataset_id">str</td></tr><tr><td>construction_method</td><td port="construction_method">DatasetConstructionMethod</td></tr><tr><td>base_year</td><td port="base_year">Optional[int]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectionDatasetModel&#xA;&#xA;A dataset with growth rates that can be applied to a standalone dataset.&#xA;"];
   "dsgrid.query.models.DatasetModel":source_datasets:e -> "dsgrid.query.models.ProjectionDatasetModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.StandaloneDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>StandaloneDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.STANDALONE]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr></table>>,
      tooltip="dsgrid.query.models.StandaloneDatasetModel&#xA;&#xA;A dataset with energy use data.&#xA;"];
   "dsgrid.query.models.DatasetModel":source_datasets:e -> "dsgrid.query.models.StandaloneDatasetModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":geography:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":metric:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":model_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":scenario:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":sector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":subsector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":time:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":weather_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectQueryModel</b></td></tr><tr><td>name</td><td port="name">str</td></tr><tr><td>version</td><td port="version">str</td></tr><tr><td>project</td><td port="project">ProjectQueryParamsModel</td></tr><tr><td>result</td><td port="result">QueryResultParamsModel</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectQueryModel&#xA;&#xA;Represents a user query on a Project.&#xA;"];
   "dsgrid.query.models.ProjectQueryParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectQueryParamsModel</b></td></tr><tr><td>project_id</td><td port="project_id">str</td></tr><tr><td>dataset</td><td port="dataset">DatasetModel</td></tr><tr><td>excluded_dataset_ids</td><td port="excluded_dataset_ids">list[str]</td></tr><tr><td>include_dsgrid_dataset_components</td><td port="include_dsgrid_dataset_components">bool</td></tr><tr><td>version</td><td port="version">Optional[str]</td></tr><tr><td>spark_conf_per_dataset</td><td port="spark_conf_per_dataset">list[SparkConfByDataset]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectQueryParamsModel&#xA;&#xA;Defines how to transform a project into a CompositeDataset&#xA;"];
   "dsgrid.query.models.ProjectQueryModel":project:e -> "dsgrid.query.models.ProjectQueryParamsModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>QueryResultParamsModel</b></td></tr><tr><td>replace_ids_with_names</td><td port="replace_ids_with_names">bool</td></tr><tr><td>aggregations</td><td port="aggregations">list[AggregationModel]</td></tr><tr><td>aggregate_each_dataset</td><td port="aggregate_each_dataset">bool</td></tr><tr><td>reports</td><td port="reports">list[ReportInputModel]</td></tr><tr><td>column_type</td><td port="column_type">ColumnType</td></tr><tr><td>table_format</td><td port="table_format">Union[PivotedTableFormatModel, UnpivotedTableFormatModel]</td></tr><tr><td>output_format</td><td port="output_format">str</td></tr><tr><td>sort_columns</td><td port="sort_columns">list[str]</td></tr><tr><td>dimension_filters</td><td port="dimension_filters">list[Union[DimensionFilterExpressionModel, DimensionFilterExpressionRawModel, DimensionFilterColumnOperatorModel, DimensionFilterBetweenColumnOperatorModel, SubsetDimensionFilterModel, SupplementalDimensionFilterColumnOperatorModel]]</td></tr><tr><td>time_zone</td><td port="time_zone">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.QueryResultParamsModel&#xA;&#xA;Controls post-processing and storage of CompositeDatasets&#xA;"];
   "dsgrid.query.models.ProjectQueryModel":result:e -> "dsgrid.query.models.QueryResultParamsModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryParamsModel":dataset:e -> "dsgrid.query.models.DatasetModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.SparkConfByDataset"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SparkConfByDataset</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>conf</td><td port="conf">dict[str, Any]</td></tr></table>>,
      tooltip="dsgrid.query.models.SparkConfByDataset&#xA;&#xA;Defines a custom Spark configuration to use while running a query on a dataset.&#\
xA;"];
   "dsgrid.query.models.ProjectQueryParamsModel":spark_conf_per_dataset:e -> "dsgrid.query.models.SparkConfByDataset":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":table_format:e -> "dsgrid.dataset.models.PivotedTableFormatModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":table_format:e -> "dsgrid.dataset.models.UnpivotedTableFormatModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":aggregations:e -> "dsgrid.query.models.AggregationModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ReportInputModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ReportInputModel</b></td></tr><tr><td>report_type</td><td port="report_type">ReportType</td></tr><tr><td>inputs</td><td port="inputs">Any</td></tr></table>>,
      tooltip="dsgrid.query.models.ReportInputModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
   "dsgrid.query.models.QueryResultParamsModel":reports:e -> "dsgrid.query.models.ReportInputModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
field project: ProjectQueryParamsModel [Required]

Defines the datasets to use and how to transform them.

field result: QueryResultParamsModel = QueryResultParamsModel(replace_ids_with_names=False, aggregations=[], aggregate_each_dataset=False, reports=[], column_type=<ColumnType.DIMENSION_QUERY_NAMES: 'dimension_query_names'>, table_format=UnpivotedTableFormatModel(format_type=<TableFormatType.UNPIVOTED: 'unpivoted'>), output_format='parquet', sort_columns=[], dimension_filters=[], time_zone=None)

Controls the output results

serialize_cached_content() dict[str, Any][source]

Return a JSON-able representation of the model that can be used for caching purposes.

pydantic model dsgrid.query.models.ProjectQueryParamsModel[source]

Defines how to transform a project into a CompositeDataset

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterBetweenColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>lower_bound</td><td port="lower_bound">Any</td></tr><tr><td>upper_bound</td><td port="upper_bound">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.BETWEEN_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column is \
between the lower bound and upper bound,&#xA;inclusive.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"\
timestamp\").between(\"2012-07-01 00:00:00\", \"2012-08-01 00:00:00\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column matches \
a Spark SQL operator.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"geography\").like(\"abc%\"))&#xA;\
df.filter(~F.col(\"sector\").startswith(\"com\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel&#xA;&#xA;Filters a table where a dimension column matches an expression.&#\
xA;&#xA;Example:&#xA;    DimensionFilterExpressionModel(&#xA;        dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_\
query_name=\"county\",&#xA;        operator=\"==\",&#xA;        value=\"06037\",&#xA;    ),&#xA;is equivalent to&#xA;    df.filter(\"county == '\
06037'\")&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionRawModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION_RAW]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel&#xA;&#xA;Filters a table where a dimension column matches an \
expression.&#xA;Uses the passed string with no modification.&#xA;&#xA;Example:&#xA;    DimensionFilterExpressionRawModel(&#xA;        \
dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_query_name=\"county\",&#xA;        value=\"== '06037'\",&#xA;    ),&#xA;\
is equivalent to&#xA;    df.filter(\"county == '06037'\")&#xA;&#xA;The difference between this class and DimensionFilterExpressionModel \
is that the latter&#xA;will attempt to add quotes as necessary.&#xA;"];
   "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SubsetDimensionFilterModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_names</td><td port="dimension_query_names">list[str]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUBSET]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel&#xA;&#xA;Filters base dimension records that match a subset dimension.&#\
xA;"];
   "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SupplementalDimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUPPLEMENTAL_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel&#xA;&#xA;Filters base dimension records that have \
a valid mapping to a supplemental dimension.&#xA;"];
   "dsgrid.query.models.DatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DatasetModel</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>source_datasets</td><td port="source_datasets">list[Union[StandaloneDatasetModel, ProjectionDatasetModel]]</td></tr><tr><td>expression</td><td port="expression">Optional[str]</td></tr><tr><td>params</td><td port="params">ProjectQueryDatasetParamsModel</td></tr></table>>,
      tooltip="dsgrid.query.models.DatasetModel&#xA;&#xA;Specifies the datasets to use in a project query.&#xA;"];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectQueryDatasetParamsModel</b></td></tr><tr><td>dimension_filters</td><td port="dimension_filters">list[Union[DimensionFilterExpressionModel, DimensionFilterExpressionRawModel, DimensionFilterColumnOperatorModel, DimensionFilterBetweenColumnOperatorModel, SubsetDimensionFilterModel, SupplementalDimensionFilterColumnOperatorModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectQueryDatasetParamsModel&#xA;&#xA;Parameters in a project query that only apply to datasets&#xA;"];
   "dsgrid.query.models.DatasetModel":params:e -> "dsgrid.query.models.ProjectQueryDatasetParamsModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectionDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectionDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.PROJECTION]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>initial_value_dataset_id</td><td port="initial_value_dataset_id">str</td></tr><tr><td>growth_rate_dataset_id</td><td port="growth_rate_dataset_id">str</td></tr><tr><td>construction_method</td><td port="construction_method">DatasetConstructionMethod</td></tr><tr><td>base_year</td><td port="base_year">Optional[int]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectionDatasetModel&#xA;&#xA;A dataset with growth rates that can be applied to a standalone dataset.&#xA;"];
   "dsgrid.query.models.DatasetModel":source_datasets:e -> "dsgrid.query.models.ProjectionDatasetModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.StandaloneDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>StandaloneDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.STANDALONE]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr></table>>,
      tooltip="dsgrid.query.models.StandaloneDatasetModel&#xA;&#xA;A dataset with energy use data.&#xA;"];
   "dsgrid.query.models.DatasetModel":source_datasets:e -> "dsgrid.query.models.StandaloneDatasetModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectQueryParamsModel</b></td></tr><tr><td>project_id</td><td port="project_id">str</td></tr><tr><td>dataset</td><td port="dataset">DatasetModel</td></tr><tr><td>excluded_dataset_ids</td><td port="excluded_dataset_ids">list[str]</td></tr><tr><td>include_dsgrid_dataset_components</td><td port="include_dsgrid_dataset_components">bool</td></tr><tr><td>version</td><td port="version">Optional[str]</td></tr><tr><td>spark_conf_per_dataset</td><td port="spark_conf_per_dataset">list[SparkConfByDataset]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectQueryParamsModel&#xA;&#xA;Defines how to transform a project into a CompositeDataset&#xA;"];
   "dsgrid.query.models.ProjectQueryParamsModel":dataset:e -> "dsgrid.query.models.DatasetModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.SparkConfByDataset"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SparkConfByDataset</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>conf</td><td port="conf">dict[str, Any]</td></tr></table>>,
      tooltip="dsgrid.query.models.SparkConfByDataset&#xA;&#xA;Defines a custom Spark configuration to use while running a query on a dataset.&#\
xA;"];
   "dsgrid.query.models.ProjectQueryParamsModel":spark_conf_per_dataset:e -> "dsgrid.query.models.SparkConfByDataset":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
Validators:
field dataset: DatasetModel [Required]

Definition of the dataset to create.

Validated by:
field excluded_dataset_ids: list[str] = []

Datasets to exclude from query

Validated by:
field include_dsgrid_dataset_components: bool = False
Validated by:
field project_id: str [Required]

Project ID for query

Validated by:
field spark_conf_per_dataset: list[SparkConfByDataset] = []

Apply these Spark configuration settings while a dataset is being processed.

Validated by:
field version: str | None = None

Version of project or dataset on which the query is based. Should not be set by the user

Validated by:
validator check_unsupported_fields  »  all fields[source]
get_spark_conf(dataset_id) dict[str, Any][source]

Return the Spark settings to apply while processing dataset_id.

pydantic model dsgrid.query.models.QueryResultParamsModel[source]

Controls post-processing and storage of CompositeDatasets

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.dataset.models.PivotedTableFormatModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>PivotedTableFormatModel</b></td></tr><tr><td>format_type</td><td port="format_type">Literal[TableFormatType.PIVOTED]</td></tr><tr><td>pivoted_dimension_type</td><td port="pivoted_dimension_type">DimensionType</td></tr></table>>,
      tooltip="dsgrid.dataset.models.PivotedTableFormatModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
   "dsgrid.dataset.models.UnpivotedTableFormatModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>UnpivotedTableFormatModel</b></td></tr><tr><td>format_type</td><td port="format_type">Literal[TableFormatType.UNPIVOTED]</td></tr></table>>,
      tooltip="dsgrid.dataset.models.UnpivotedTableFormatModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterBetweenColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>lower_bound</td><td port="lower_bound">Any</td></tr><tr><td>upper_bound</td><td port="upper_bound">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.BETWEEN_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column is \
between the lower bound and upper bound,&#xA;inclusive.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"\
timestamp\").between(\"2012-07-01 00:00:00\", \"2012-08-01 00:00:00\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column matches \
a Spark SQL operator.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"geography\").like(\"abc%\"))&#xA;\
df.filter(~F.col(\"sector\").startswith(\"com\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel&#xA;&#xA;Filters a table where a dimension column matches an expression.&#\
xA;&#xA;Example:&#xA;    DimensionFilterExpressionModel(&#xA;        dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_\
query_name=\"county\",&#xA;        operator=\"==\",&#xA;        value=\"06037\",&#xA;    ),&#xA;is equivalent to&#xA;    df.filter(\"county == '\
06037'\")&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionRawModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION_RAW]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel&#xA;&#xA;Filters a table where a dimension column matches an \
expression.&#xA;Uses the passed string with no modification.&#xA;&#xA;Example:&#xA;    DimensionFilterExpressionRawModel(&#xA;        \
dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_query_name=\"county\",&#xA;        value=\"== '06037'\",&#xA;    ),&#xA;\
is equivalent to&#xA;    df.filter(\"county == '06037'\")&#xA;&#xA;The difference between this class and DimensionFilterExpressionModel \
is that the latter&#xA;will attempt to add quotes as necessary.&#xA;"];
   "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SubsetDimensionFilterModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_names</td><td port="dimension_query_names">list[str]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUBSET]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel&#xA;&#xA;Filters base dimension records that match a subset dimension.&#\
xA;"];
   "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SupplementalDimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUPPLEMENTAL_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel&#xA;&#xA;Filters base dimension records that have \
a valid mapping to a supplemental dimension.&#xA;"];
   "dsgrid.query.models.AggregationModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>AggregationModel</b></td></tr><tr><td>aggregation_function</td><td port="aggregation_function">Any</td></tr><tr><td>dimensions</td><td port="dimensions">DimensionQueryNamesModel</td></tr></table>>,
      tooltip="dsgrid.query.models.AggregationModel&#xA;&#xA;Aggregate on one or more dimensions.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionQueryNamesModel</b></td></tr><tr><td>geography</td><td port="geography">list[Union[str, ColumnModel]]</td></tr><tr><td>metric</td><td port="metric">list[Union[str, ColumnModel]]</td></tr><tr><td>model_year</td><td port="model_year">list[Union[str, ColumnModel]]</td></tr><tr><td>scenario</td><td port="scenario">list[Union[str, ColumnModel]]</td></tr><tr><td>sector</td><td port="sector">list[Union[str, ColumnModel]]</td></tr><tr><td>subsector</td><td port="subsector">list[Union[str, ColumnModel]]</td></tr><tr><td>time</td><td port="time">list[Union[str, ColumnModel]]</td></tr><tr><td>weather_year</td><td port="weather_year">list[Union[str, ColumnModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.DimensionQueryNamesModel&#xA;&#xA;Defines the list of dimensions to which the value columns should be aggregated.&#\
xA;If a value is empty, that dimension will be aggregated and dropped from the table.&#xA;"];
   "dsgrid.query.models.AggregationModel":dimensions:e -> "dsgrid.query.models.DimensionQueryNamesModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ColumnModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ColumnModel</b></td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>function</td><td port="function">Any</td></tr><tr><td>alias</td><td port="alias">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.ColumnModel&#xA;&#xA;Defines one column in a SQL aggregation statement.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel":geography:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":metric:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":model_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":scenario:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":sector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":subsector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":time:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":weather_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>QueryResultParamsModel</b></td></tr><tr><td>replace_ids_with_names</td><td port="replace_ids_with_names">bool</td></tr><tr><td>aggregations</td><td port="aggregations">list[AggregationModel]</td></tr><tr><td>aggregate_each_dataset</td><td port="aggregate_each_dataset">bool</td></tr><tr><td>reports</td><td port="reports">list[ReportInputModel]</td></tr><tr><td>column_type</td><td port="column_type">ColumnType</td></tr><tr><td>table_format</td><td port="table_format">Union[PivotedTableFormatModel, UnpivotedTableFormatModel]</td></tr><tr><td>output_format</td><td port="output_format">str</td></tr><tr><td>sort_columns</td><td port="sort_columns">list[str]</td></tr><tr><td>dimension_filters</td><td port="dimension_filters">list[Union[DimensionFilterExpressionModel, DimensionFilterExpressionRawModel, DimensionFilterColumnOperatorModel, DimensionFilterBetweenColumnOperatorModel, SubsetDimensionFilterModel, SupplementalDimensionFilterColumnOperatorModel]]</td></tr><tr><td>time_zone</td><td port="time_zone">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.QueryResultParamsModel&#xA;&#xA;Controls post-processing and storage of CompositeDatasets&#xA;"];
   "dsgrid.query.models.QueryResultParamsModel":table_format:e -> "dsgrid.dataset.models.PivotedTableFormatModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":table_format:e -> "dsgrid.dataset.models.UnpivotedTableFormatModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.QueryResultParamsModel":aggregations:e -> "dsgrid.query.models.AggregationModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ReportInputModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ReportInputModel</b></td></tr><tr><td>report_type</td><td port="report_type">ReportType</td></tr><tr><td>inputs</td><td port="inputs">Any</td></tr></table>>,
      tooltip="dsgrid.query.models.ReportInputModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
   "dsgrid.query.models.QueryResultParamsModel":reports:e -> "dsgrid.query.models.ReportInputModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
Validators:
field aggregate_each_dataset: bool = False

If True, aggregate each dataset before applying the expression to create one overall dataset. This parameter must be set to True for queries that will be adding or subtracting datasets with different dimensionality. Defaults to False, which corresponds to the default behavior of performing one aggregation on the overall dataset. WARNING: For a standard query that performs a union of datasets, setting this value to True could produce rows with duplicate dimension combinations, especially if one or more dimensions are also dropped.

Validated by:
field aggregations: list[AggregationModel] = []

Defines how to aggregate dimensions

Validated by:
field column_type: ColumnType = ColumnType.DIMENSION_QUERY_NAMES

Whether to make the result table columns dimension types. Default behavior is to use dimension query names. In order to register a result table as a derived dataset, this must be set to dimension_types.

Validated by:
field dimension_filters: list[Annotated[DimensionFilterExpressionModel | DimensionFilterExpressionRawModel | DimensionFilterColumnOperatorModel | DimensionFilterBetweenColumnOperatorModel | SubsetDimensionFilterModel | SupplementalDimensionFilterColumnOperatorModel, FieldInfo(annotation=NoneType, required=True, discriminator='filter_type')]] = []

Filters to apply to the result. Must contain columns in the result.

Validated by:
field output_format: str = 'parquet'

Output file format: csv or parquet

Validated by:
field replace_ids_with_names: bool = False

Replace dimension record IDs with their names in result tables.

Validated by:
field reports: list[ReportInputModel] = []

Run these pre-defined reports on the result.

Validated by:
field sort_columns: list[str] = []

Sort the results by these dimension query names.

Validated by:
field table_format: Annotated[PivotedTableFormatModel | UnpivotedTableFormatModel, FieldInfo(annotation=NoneType, required=True, title='table_format', description='Defines the format of the value columns of the result table.', discriminator='format_type')] = UnpivotedTableFormatModel(format_type=<TableFormatType.UNPIVOTED: 'unpivoted'>)

Defines the format of the value columns of the result table.

Validated by:
field time_zone: str | None = None

Convert the results to this time zone.

Validated by:
validator check_column_type  »  all fields[source]
validator check_format  »  output_format[source]
validator check_pivot_dimension_type  »  all fields[source]
pydantic model dsgrid.query.models.DatasetModel[source]

Specifies the datasets to use in a project query.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterBetweenColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>lower_bound</td><td port="lower_bound">Any</td></tr><tr><td>upper_bound</td><td port="upper_bound">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.BETWEEN_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column is \
between the lower bound and upper bound,&#xA;inclusive.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"\
timestamp\").between(\"2012-07-01 00:00:00\", \"2012-08-01 00:00:00\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column matches \
a Spark SQL operator.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"geography\").like(\"abc%\"))&#xA;\
df.filter(~F.col(\"sector\").startswith(\"com\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel&#xA;&#xA;Filters a table where a dimension column matches an expression.&#\
xA;&#xA;Example:&#xA;    DimensionFilterExpressionModel(&#xA;        dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_\
query_name=\"county\",&#xA;        operator=\"==\",&#xA;        value=\"06037\",&#xA;    ),&#xA;is equivalent to&#xA;    df.filter(\"county == '\
06037'\")&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionRawModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION_RAW]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel&#xA;&#xA;Filters a table where a dimension column matches an \
expression.&#xA;Uses the passed string with no modification.&#xA;&#xA;Example:&#xA;    DimensionFilterExpressionRawModel(&#xA;        \
dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_query_name=\"county\",&#xA;        value=\"== '06037'\",&#xA;    ),&#xA;\
is equivalent to&#xA;    df.filter(\"county == '06037'\")&#xA;&#xA;The difference between this class and DimensionFilterExpressionModel \
is that the latter&#xA;will attempt to add quotes as necessary.&#xA;"];
   "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SubsetDimensionFilterModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_names</td><td port="dimension_query_names">list[str]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUBSET]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel&#xA;&#xA;Filters base dimension records that match a subset dimension.&#\
xA;"];
   "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SupplementalDimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUPPLEMENTAL_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel&#xA;&#xA;Filters base dimension records that have \
a valid mapping to a supplemental dimension.&#xA;"];
   "dsgrid.query.models.DatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DatasetModel</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>source_datasets</td><td port="source_datasets">list[Union[StandaloneDatasetModel, ProjectionDatasetModel]]</td></tr><tr><td>expression</td><td port="expression">Optional[str]</td></tr><tr><td>params</td><td port="params">ProjectQueryDatasetParamsModel</td></tr></table>>,
      tooltip="dsgrid.query.models.DatasetModel&#xA;&#xA;Specifies the datasets to use in a project query.&#xA;"];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectQueryDatasetParamsModel</b></td></tr><tr><td>dimension_filters</td><td port="dimension_filters">list[Union[DimensionFilterExpressionModel, DimensionFilterExpressionRawModel, DimensionFilterColumnOperatorModel, DimensionFilterBetweenColumnOperatorModel, SubsetDimensionFilterModel, SupplementalDimensionFilterColumnOperatorModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectQueryDatasetParamsModel&#xA;&#xA;Parameters in a project query that only apply to datasets&#xA;"];
   "dsgrid.query.models.DatasetModel":params:e -> "dsgrid.query.models.ProjectQueryDatasetParamsModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectionDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectionDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.PROJECTION]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>initial_value_dataset_id</td><td port="initial_value_dataset_id">str</td></tr><tr><td>growth_rate_dataset_id</td><td port="growth_rate_dataset_id">str</td></tr><tr><td>construction_method</td><td port="construction_method">DatasetConstructionMethod</td></tr><tr><td>base_year</td><td port="base_year">Optional[int]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectionDatasetModel&#xA;&#xA;A dataset with growth rates that can be applied to a standalone dataset.&#xA;"];
   "dsgrid.query.models.DatasetModel":source_datasets:e -> "dsgrid.query.models.ProjectionDatasetModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.StandaloneDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>StandaloneDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.STANDALONE]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr></table>>,
      tooltip="dsgrid.query.models.StandaloneDatasetModel&#xA;&#xA;A dataset with energy use data.&#xA;"];
   "dsgrid.query.models.DatasetModel":source_datasets:e -> "dsgrid.query.models.StandaloneDatasetModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.ProjectQueryDatasetParamsModel":dimension_filters:e -> "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
Validators:
field dataset_id: str [Required]

Identifier for the resulting dataset

field expression: str | None = None

Expression to combine datasets. Default is to take a union of all datasets.

Validated by:
field params: ProjectQueryDatasetParamsModel = ProjectQueryDatasetParamsModel(dimension_filters=[])

Parameters affecting datasets. Used for caching intermediate tables.

field source_datasets: list[Annotated[StandaloneDatasetModel | ProjectionDatasetModel, FieldInfo(annotation=NoneType, required=True, discriminator='dataset_type')]] [Required]

Datasets from which to read. Each must be of type DatasetBaseModel.

validator handle_expression  »  expression[source]
pydantic model dsgrid.query.models.StandaloneDatasetModel[source]

A dataset with energy use data.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.StandaloneDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>StandaloneDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.STANDALONE]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr></table>>,
      tooltip="dsgrid.query.models.StandaloneDatasetModel&#xA;&#xA;A dataset with energy use data.&#xA;"];
}
Fields:
field dataset_id: str [Required]

Dataset identifier

field dataset_type: Literal[DatasetType.STANDALONE] = DatasetType.STANDALONE
get_dataset_id() str[source]

Return the primary dataset ID.

Return type:

str

pydantic model dsgrid.query.models.ProjectionDatasetModel[source]

A dataset with growth rates that can be applied to a standalone dataset.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.ProjectionDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ProjectionDatasetModel</b></td></tr><tr><td>dataset_type</td><td port="dataset_type">Literal[DatasetType.PROJECTION]</td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>initial_value_dataset_id</td><td port="initial_value_dataset_id">str</td></tr><tr><td>growth_rate_dataset_id</td><td port="growth_rate_dataset_id">str</td></tr><tr><td>construction_method</td><td port="construction_method">DatasetConstructionMethod</td></tr><tr><td>base_year</td><td port="base_year">Optional[int]</td></tr></table>>,
      tooltip="dsgrid.query.models.ProjectionDatasetModel&#xA;&#xA;A dataset with growth rates that can be applied to a standalone dataset.&#xA;"];
}
Fields:
field base_year: int | None = None

Base year of the dataset to use in growth rate application. Must be a year defined in the principal dataset’s model year dimension. If None, there must be only one model year in that dimension and it will be used.

field construction_method: DatasetConstructionMethod = DatasetConstructionMethod.EXPONENTIAL_GROWTH

Specifier for the code that applies the growth rate to the principal dataset

field dataset_id: str [Required]

Identifier for the resulting dataset

field dataset_type: Literal[DatasetType.PROJECTION] = DatasetType.PROJECTION
field growth_rate_dataset_id: str [Required]

Growth rate dataset identifier to apply to the principal dataset

field initial_value_dataset_id: str [Required]

Principal dataset identifier

get_dataset_id() str[source]

Return the primary dataset ID.

Return type:

str

pydantic model dsgrid.query.models.AggregationModel[source]

Aggregate on one or more dimensions.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.AggregationModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>AggregationModel</b></td></tr><tr><td>aggregation_function</td><td port="aggregation_function">Any</td></tr><tr><td>dimensions</td><td port="dimensions">DimensionQueryNamesModel</td></tr></table>>,
      tooltip="dsgrid.query.models.AggregationModel&#xA;&#xA;Aggregate on one or more dimensions.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionQueryNamesModel</b></td></tr><tr><td>geography</td><td port="geography">list[Union[str, ColumnModel]]</td></tr><tr><td>metric</td><td port="metric">list[Union[str, ColumnModel]]</td></tr><tr><td>model_year</td><td port="model_year">list[Union[str, ColumnModel]]</td></tr><tr><td>scenario</td><td port="scenario">list[Union[str, ColumnModel]]</td></tr><tr><td>sector</td><td port="sector">list[Union[str, ColumnModel]]</td></tr><tr><td>subsector</td><td port="subsector">list[Union[str, ColumnModel]]</td></tr><tr><td>time</td><td port="time">list[Union[str, ColumnModel]]</td></tr><tr><td>weather_year</td><td port="weather_year">list[Union[str, ColumnModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.DimensionQueryNamesModel&#xA;&#xA;Defines the list of dimensions to which the value columns should be aggregated.&#\
xA;If a value is empty, that dimension will be aggregated and dropped from the table.&#xA;"];
   "dsgrid.query.models.AggregationModel":dimensions:e -> "dsgrid.query.models.DimensionQueryNamesModel":_root:w   [arrowhead=noneteetee,
      arrowtail=nonenone];
   "dsgrid.query.models.ColumnModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ColumnModel</b></td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>function</td><td port="function">Any</td></tr><tr><td>alias</td><td port="alias">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.ColumnModel&#xA;&#xA;Defines one column in a SQL aggregation statement.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel":geography:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":metric:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":model_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":scenario:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":sector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":subsector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":time:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":weather_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
Validators:
field aggregation_function: Any = None

Must be a function name in pyspark.sql.functions

Validated by:
field dimensions: DimensionQueryNamesModel [Required]

Dimensions on which to aggregate

Validated by:
validator check_aggregation_function  »  aggregation_function[source]
validator check_for_metric  »  dimensions[source]
iter_dimensions_to_keep()[source]

Yield the dimension type and ColumnModel for each dimension to keep.

list_dropped_dimensions()[source]

Return a list of dimension types that will be dropped by the aggregation.

serialize_aggregation_function(function, _)[source]
pydantic model dsgrid.query.models.ColumnModel[source]

Defines one column in a SQL aggregation statement.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.ColumnModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ColumnModel</b></td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>function</td><td port="function">Any</td></tr><tr><td>alias</td><td port="alias">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.ColumnModel&#xA;&#xA;Defines one column in a SQL aggregation statement.&#xA;"];
}
Fields:
Validators:
field alias: str | None = None

Name of the resulting column.

Validated by:
field dimension_query_name: str [Required]
field function: Any = None

Function or name of function in pyspark.sql.functions.

Validated by:
get_column_name()[source]
validator handle_alias  »  alias[source]
validator handle_function  »  function[source]
serialize_function(function, _)[source]
pydantic model dsgrid.query.models.DimensionQueryNamesModel[source]

Defines the list of dimensions to which the value columns should be aggregated. If a value is empty, that dimension will be aggregated and dropped from the table.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.ColumnModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ColumnModel</b></td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>function</td><td port="function">Any</td></tr><tr><td>alias</td><td port="alias">Optional[str]</td></tr></table>>,
      tooltip="dsgrid.query.models.ColumnModel&#xA;&#xA;Defines one column in a SQL aggregation statement.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionQueryNamesModel</b></td></tr><tr><td>geography</td><td port="geography">list[Union[str, ColumnModel]]</td></tr><tr><td>metric</td><td port="metric">list[Union[str, ColumnModel]]</td></tr><tr><td>model_year</td><td port="model_year">list[Union[str, ColumnModel]]</td></tr><tr><td>scenario</td><td port="scenario">list[Union[str, ColumnModel]]</td></tr><tr><td>sector</td><td port="sector">list[Union[str, ColumnModel]]</td></tr><tr><td>subsector</td><td port="subsector">list[Union[str, ColumnModel]]</td></tr><tr><td>time</td><td port="time">list[Union[str, ColumnModel]]</td></tr><tr><td>weather_year</td><td port="weather_year">list[Union[str, ColumnModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.DimensionQueryNamesModel&#xA;&#xA;Defines the list of dimensions to which the value columns should be aggregated.&#\
xA;If a value is empty, that dimension will be aggregated and dropped from the table.&#xA;"];
   "dsgrid.query.models.DimensionQueryNamesModel":geography:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":metric:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":model_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":scenario:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":sector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":subsector:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":time:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.DimensionQueryNamesModel":weather_year:e -> "dsgrid.query.models.ColumnModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
Validators:
field geography: list[str | ColumnModel] [Required]
Validated by:
field metric: list[str | ColumnModel] [Required]
Validated by:
field model_year: list[str | ColumnModel] [Required]
Validated by:
field scenario: list[str | ColumnModel] [Required]
Validated by:
field sector: list[str | ColumnModel] [Required]
Validated by:
field subsector: list[str | ColumnModel] [Required]
Validated by:
field time: list[str | ColumnModel] [Required]
Validated by:
field weather_year: list[str | ColumnModel] [Required]
Validated by:
validator fix_columns  »  all fields[source]
pydantic model dsgrid.query.models.FilteredDatasetModel[source]

Filters to apply to a dataset

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterBetweenColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>lower_bound</td><td port="lower_bound">Any</td></tr><tr><td>upper_bound</td><td port="upper_bound">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.BETWEEN_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column is \
between the lower bound and upper bound,&#xA;inclusive.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"\
timestamp\").between(\"2012-07-01 00:00:00\", \"2012-08-01 00:00:00\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel&#xA;&#xA;Filters a table where a dimension column matches \
a Spark SQL operator.&#xA;&#xA;Examples:&#xA;import pyspark.sql.functions as F&#xA;df.filter(F.col(\"geography\").like(\"abc%\"))&#xA;\
df.filter(~F.col(\"sector\").startswith(\"com\"))&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel&#xA;&#xA;Filters a table where a dimension column matches an expression.&#\
xA;&#xA;Example:&#xA;    DimensionFilterExpressionModel(&#xA;        dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_\
query_name=\"county\",&#xA;        operator=\"==\",&#xA;        value=\"06037\",&#xA;    ),&#xA;is equivalent to&#xA;    df.filter(\"county == '\
06037'\")&#xA;"];
   "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>DimensionFilterExpressionRawModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Union[str, int, float]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.EXPRESSION_RAW]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel&#xA;&#xA;Filters a table where a dimension column matches an \
expression.&#xA;Uses the passed string with no modification.&#xA;&#xA;Example:&#xA;    DimensionFilterExpressionRawModel(&#xA;        \
dimension_type=DimensionType.GEOGRAPHY,&#xA;        dimension_query_name=\"county\",&#xA;        value=\"== '06037'\",&#xA;    ),&#xA;\
is equivalent to&#xA;    df.filter(\"county == '06037'\")&#xA;&#xA;The difference between this class and DimensionFilterExpressionModel \
is that the latter&#xA;will attempt to add quotes as necessary.&#xA;"];
   "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SubsetDimensionFilterModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_names</td><td port="dimension_query_names">list[str]</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUBSET]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel&#xA;&#xA;Filters base dimension records that match a subset dimension.&#\
xA;"];
   "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SupplementalDimensionFilterColumnOperatorModel</b></td></tr><tr><td>dimension_type</td><td port="dimension_type">DimensionType</td></tr><tr><td>column</td><td port="column">str</td></tr><tr><td>dimension_query_name</td><td port="dimension_query_name">str</td></tr><tr><td>value</td><td port="value">Any</td></tr><tr><td>operator</td><td port="operator">str</td></tr><tr><td>negate</td><td port="negate">bool</td></tr><tr><td>filter_type</td><td port="filter_type">Literal[DimensionFilterType.SUPPLEMENTAL_COLUMN_OPERATOR]</td></tr></table>>,
      tooltip="dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel&#xA;&#xA;Filters base dimension records that have \
a valid mapping to a supplemental dimension.&#xA;"];
   "dsgrid.query.models.FilteredDatasetModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>FilteredDatasetModel</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>filters</td><td port="filters">list[Union[DimensionFilterExpressionModel, DimensionFilterExpressionRawModel, DimensionFilterColumnOperatorModel, DimensionFilterBetweenColumnOperatorModel, SubsetDimensionFilterModel, SupplementalDimensionFilterColumnOperatorModel]]</td></tr></table>>,
      tooltip="dsgrid.query.models.FilteredDatasetModel&#xA;&#xA;Filters to apply to a dataset&#xA;"];
   "dsgrid.query.models.FilteredDatasetModel":filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterBetweenColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.FilteredDatasetModel":filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.FilteredDatasetModel":filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.FilteredDatasetModel":filters:e -> "dsgrid.dimension.dimension_filters.DimensionFilterExpressionRawModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.FilteredDatasetModel":filters:e -> "dsgrid.dimension.dimension_filters.SubsetDimensionFilterModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
   "dsgrid.query.models.FilteredDatasetModel":filters:e -> "dsgrid.dimension.dimension_filters.SupplementalDimensionFilterColumnOperatorModel":_root:w   [arrowhead=crownone,
      arrowtail=nonenone];
}
Fields:
field dataset_id: str [Required]

Dataset ID

field filters: list[Annotated[DimensionFilterExpressionModel | DimensionFilterExpressionRawModel | DimensionFilterColumnOperatorModel | DimensionFilterBetweenColumnOperatorModel | SubsetDimensionFilterModel | SupplementalDimensionFilterColumnOperatorModel, FieldInfo(annotation=NoneType, required=True, discriminator='filter_type')]] [Required]
pydantic model dsgrid.query.models.ReportInputModel[source]

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.ReportInputModel"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ReportInputModel</b></td></tr><tr><td>report_type</td><td port="report_type">ReportType</td></tr><tr><td>inputs</td><td port="inputs">Any</td></tr></table>>,
      tooltip="dsgrid.query.models.ReportInputModel&#xA;&#xA;Base data model for all dsgrid data models&#xA;"];
}
Fields:
field inputs: Any = None
field report_type: ReportType [Required]
pydantic model dsgrid.query.models.SparkConfByDataset[source]

Defines a custom Spark configuration to use while running a query on a dataset.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

digraph "Entity Relationship Diagram created by erdantic" {
   graph [fontcolor=gray66,
      fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=9,
      nodesep=0.5,
      rankdir=LR,
      ranksep=1.5
   ];
   node [fontname="Times New Roman,Times,Liberation Serif,serif",
      fontsize=14,
      label="\N",
      shape=plain
   ];
   edge [dir=both];
   "dsgrid.query.models.SparkConfByDataset"   [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>SparkConfByDataset</b></td></tr><tr><td>dataset_id</td><td port="dataset_id">str</td></tr><tr><td>conf</td><td port="conf">dict[str, Any]</td></tr></table>>,
      tooltip="dsgrid.query.models.SparkConfByDataset&#xA;&#xA;Defines a custom Spark configuration to use while running a query on a dataset.&#\
xA;"];
}
Fields:
field conf: dict[str, Any] [Required]
field dataset_id: str [Required]
class dsgrid.query.models.ColumnType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Defines what the columns of a dataset table represent.

class dsgrid.query.models.DatasetType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Defines the type of a dataset in a query.

class dsgrid.query.models.ReportType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Pre-defined reports

Submission

class dsgrid.query.query_submitter.ProjectQuerySubmitter(project: Project, *args, **kwargs)[source]

Submits queries for a project.

submit(**kwargs)

Submit a query for execution

Examples

from dsgrid.dimension.base_models import DimensionType
from dsgrid.registry.registry_manager import RegistryManager
from dsgrid.registry.registry_database import DatabaseConnection
from dsgrid.query.models import (
    AggregationModel,
    DatasetModel,
    DimensionQueryNamesModel,
    ProjectQueryParamsModel,
    ProjectQueryModel,
    QueryResultParamsModel,
    StandaloneDatasetModel,
)
from dsgrid.query.query_submitter import ProjectQuerySubmitter

manager = RegistryManager.load(
    DatabaseConnection(
        hostname="dsgrid-registry.hpc.nrel.gov",
        database="standard-scenarios",
    ),
    offline_mode=True
)
project = manager.project_manager.load_project("dsgrid_conus_2022")
query = ProjectQueryModel(
    name="Total Electricity Use By State and Sector",
    project=ProjectQueryParamsModel(
        project_id="dsgrid_conus_2022",
        dataset=DatasetModel(
            dataset_id="electricity_use",
            source_datasets=[
                StandaloneDatasetModel(dataset_id="comstock_conus_2022_projected"),
                StandaloneDatasetModel(dataset_id="resstock_conus_2022_projected"),
                StandaloneDatasetModel(dataset_id="tempo_conus_2022_mapped"),
            ],
        ),
    ),
    result=QueryResultParamsModel(
        aggregations=[
            AggregationModel(
                dimensions=DimensionQueryNamesModel(
                    geography=["state"],
                    metric=["electricity_collapsed"],
                    model_year=[],
                    scenario=[],
                    sector=["sector"],
                    subsector=[],
                    time=[],
                    weather_year=[],
                ),
                aggregation_function="sum",
            ),
        ],
    ),
)