python_modules/libraries/dagster-gcp/dagster_gcp/configs.py
def define_bigquery_query_config():
    '''See:
    https://googleapis.github.io/google-cloud-python/latest/bigquery/generated/google.cloud.bigquery.job.QueryJobConfig.html
    '''
    sf = _define_shared_fields()

    allow_large_results = Field(
        Bool,
        description='''Allow large query results tables (legacy SQL, only)
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.allowLargeResults
        ''',
        is_optional=True,
    )

    default_dataset = Field(
        Dataset,
        description='''the default dataset to use for unqualified table names in the query or None
        if not set. The default_dataset setter accepts a str of the fully-qualified dataset ID in
        standard SQL format. The value must included a project ID and dataset ID separated by ".".
        For example: your-project.your_dataset.
        See https://g.co/cloud/bigquery/docs/reference/v2/jobs#configuration.query.defaultDataset
        ''',
        is_optional=True,
    )

    destination = Field(
        Table,
        description='''table where results are written or None if not set. The destination setter
        accepts a str of the fully-qualified table ID in standard SQL format. The value must
        included a project ID, dataset ID, and table ID, each separated by ".". For example:
        your-project.your_dataset.your_table.
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.destinationTable
        ''',
        is_optional=True,
    )

    dry_run = Field(
        Bool,
        description='''True if this query should be a dry run to estimate costs.
        See https://g.co/cloud/bigquery/docs/reference/v2/jobs#configuration.dryRun
        ''',
        is_optional=True,
    )

    flatten_results = Field(
        Bool,
        description='''Flatten nested/repeated fields in results. (Legacy SQL only)
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.flattenResults
        ''',
        is_optional=True,
    )

    maximum_billing_tier = Field(
        Int,
        description='''Deprecated. Changes the billing tier to allow high-compute queries.
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.maximumBillingTier
        ''',
        is_optional=True,
    )

    maximum_bytes_billed = Field(
        Int,
        description='''Maximum bytes to be billed for this job or None if not set.

        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.maximumBytesBilled
        ''',
        is_optional=True,
    )

    priority = Field(
        BQPriority,
        description='''Priority of the query.
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.priority
        ''',
        is_optional=True,
    )

    query_parameters = Field(
        List(String),
        description='''list of parameters for parameterized query (empty by default)
        See: https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.queryParameters
        ''',
        is_optional=True,
    )

    # TODO:
    # Type:	Dict[str, google.cloud.bigquery.external_config.ExternalConfig]
    # table_definitions = Field(
    #     PermissiveDict(),
    #     description='''Definitions for external tables or None if not set.
    #     See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions
    #     ''',
    #     is_optional=True,
    # )

    # TODO: Need to add this
    # Type:	List[google.cloud.bigquery.query.UDFResource]
    # udf_resources = Field(
    #     String,
    #     description='''user defined function resources (empty by default)
    #     See: https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.userDefinedFunctionResources
    #     ''',
    #     is_optional=True
    # )

    use_legacy_sql = Field(
        Bool,
        description='''Use legacy SQL syntax.
        See https://g.co/cloud/bigquery/docs/reference/v2/jobs#configuration.query.useLegacySql
        ''',
        is_optional=True,
    )

    use_query_cache = Field(
        Bool,
        description='''Look for the query result in the cache.
        See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.useQueryCache
        ''',
        is_optional=True,
    )

    return Field(
        Dict(
            fields={
                'query_job_config': Field(
                    Dict(
                        fields={
                            'allow_large_results': allow_large_results,
                            'clustering_fields': sf['clustering_fields'],
                            'create_disposition': sf['create_disposition'],
                            'default_dataset': default_dataset,
                            'destination': destination,
                            'destination_encryption_configuration': sf[
                                'destination_encryption_configuration'
                            ],
                            'dry_run': dry_run,
                            'flatten_results': flatten_results,
                            # TODO: labels
                            'maximum_billing_tier': maximum_billing_tier,
                            'maximum_bytes_billed': maximum_bytes_billed,
                            'priority': priority,
                            'query_parameters': query_parameters,
                            # TODO: table_definitions
                            'schema_update_options': sf['schema_update_options'],
                            'time_partitioning': sf['time_partitioning'],
                            # TODO: udf_resources
                            'use_legacy_sql': use_legacy_sql,
                            'use_query_cache': use_query_cache,
                            'write_disposition': sf['write_disposition'],
                        }
                    )
                )
            }
        ),
        description='BigQuery query configuration',
    )
def define_bigquery_query_config():
    '''See:
    https://googleapis.github.io/google-cloud-python/latest/bigquery/generated/google.cloud.bigquery.job.QueryJobConfig.html
    '''
    sf = _define_shared_fields()

    allow_large_results = Field(
        Bool,
        description='''Allow large query results tables (legacy SQL, only)
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.allowLargeResults
        ''',
        is_optional=True,
    )

    default_dataset = Field(
        Dataset,
        description='''the default dataset to use for unqualified table names in the query or None
        if not set. The default_dataset setter accepts a str of the fully-qualified dataset ID in
        standard SQL format. The value must included a project ID and dataset ID separated by ".".
        For example: your-project.your_dataset.
        See https://g.co/cloud/bigquery/docs/reference/v2/jobs#configuration.query.defaultDataset
        ''',
        is_optional=True,
    )

    destination = Field(
        Table,
        description='''table where results are written or None if not set. The destination setter
        accepts a str of the fully-qualified table ID in standard SQL format. The value must
        included a project ID, dataset ID, and table ID, each separated by ".". For example:
        your-project.your_dataset.your_table.
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.destinationTable
        ''',
        is_optional=True,
    )

    dry_run = Field(
        Bool,
        description='''True if this query should be a dry run to estimate costs.
        See https://g.co/cloud/bigquery/docs/reference/v2/jobs#configuration.dryRun
        ''',
        is_optional=True,
    )

    flatten_results = Field(
        Bool,
        description='''Flatten nested/repeated fields in results. (Legacy SQL only)
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.flattenResults
        ''',
        is_optional=True,
    )

    maximum_billing_tier = Field(
        Int,
        description='''Deprecated. Changes the billing tier to allow high-compute queries.
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.maximumBillingTier
        ''',
        is_optional=True,
    )

    maximum_bytes_billed = Field(
        Int,
        description='''Maximum bytes to be billed for this job or None if not set.

        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.maximumBytesBilled
        ''',
        is_optional=True,
    )

    priority = Field(
        BQPriority,
        description='''Priority of the query.
        See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.priority
        ''',
        is_optional=True,
    )

    query_parameters = Field(
        List(String),
        description='''list of parameters for parameterized query (empty by default)
        See: https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.queryParameters
        ''',
        is_optional=True,
    )

    # TODO:
    # Type:	Dict[str, google.cloud.bigquery.external_config.ExternalConfig]
    # table_definitions = Field(
    #     PermissiveDict(),
    #     description='''Definitions for external tables or None if not set.
    #     See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions
    #     ''',
    #     is_optional=True,
    # )

    # TODO: Need to add this
    # Type:	List[google.cloud.bigquery.query.UDFResource]
    # udf_resources = Field(
    #     String,
    #     description='''user defined function resources (empty by default)
    #     See: https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.userDefinedFunctionResources
    #     ''',
    #     is_optional=True
    # )

    use_legacy_sql = Field(
        Bool,
        description='''Use legacy SQL syntax.
        See https://g.co/cloud/bigquery/docs/reference/v2/jobs#configuration.query.useLegacySql
        ''',
        is_optional=True,
    )

    use_query_cache = Field(
        Bool,
        description='''Look for the query result in the cache.
        See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.useQueryCache
        ''',
        is_optional=True,
    )

    return Field(
        Dict(
            fields={
                'query_job_config': Field(
                    Dict(
                        fields={
                            'allow_large_results': allow_large_results,
                            'clustering_fields': sf['clustering_fields'],
                            'create_disposition': sf['create_disposition'],
                            'default_dataset': default_dataset,
                            'destination': destination,
                            'destination_encryption_configuration': sf[
                                'destination_encryption_configuration'
                            ],
                            'dry_run': dry_run,
                            'flatten_results': flatten_results,
                            # TODO: labels
                            'maximum_billing_tier': maximum_billing_tier,
                            'maximum_bytes_billed': maximum_bytes_billed,
                            'priority': priority,
                            'query_parameters': query_parameters,
                            # TODO: table_definitions
                            'schema_update_options': sf['schema_update_options'],
                            'time_partitioning': sf['time_partitioning'],
                            # TODO: udf_resources
                            'use_legacy_sql': use_legacy_sql,
                            'use_query_cache': use_query_cache,
                            'write_disposition': sf['write_disposition'],
                        }
                    )
                )
            }
        ),
        description='BigQuery query configuration',
    )
See:
    https://googleapis.github.io/google-cloud-python/latest/bigquery/generated/google.cloud.bigquery.job.QueryJobConfig.html