diff --git a/package.json b/package.json index e06b677c..5f656e07 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@types/tmp": "0.1.0", "@types/uuid": "^3.4.4", "codecov": "^3.5.0", - "discovery-tsd": "^0.1.0", + "discovery-tsd": "^0.2.0", "eslint": "^6.0.0", "eslint-config-prettier": "^6.0.0", "eslint-plugin-node": "^10.0.0", diff --git a/src/types.d.ts b/src/types.d.ts index 95411223..11cc8ecc 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -3,229 +3,303 @@ */ declare namespace bigquery { /** - * Evaluation metrics for binary classification/classifier models. + * Aggregate metrics for classification/classifier models. For multi-class + * models, the metrics are either macro-averaged or micro-averaged. When + * macro-averaged, the metrics are calculated for each label and then an + * unweighted average is taken of those values. When micro-averaged, the + * metric is calculated globally by counting the total number of correctly + * predicted rows. */ - type IBinaryClassificationMetrics = { + type IAggregateClassificationMetrics = { /** - * Label representing the positive class. + * Accuracy is the fraction of predictions given the correct label. For + * multiclass this is a micro-averaged metric. */ - positiveLabel?: string; + accuracy?: number; /** - * Binary confusion matrix at multiple thresholds. + * The F1 score is an average of recall and precision. For multiclass + * this is a macro-averaged metric. */ - binaryConfusionMatrixList?: Array; + f1Score?: number; /** - * Aggregate classification metrics. + * Logarithmic Loss. For multiclass this is a macro-averaged metric. */ - aggregateClassificationMetrics?: IAggregateClassificationMetrics; + logLoss?: number; /** - * Label representing the negative class. + * Precision is the fraction of actual positive predictions that had + * positive actual labels. For multiclass this is a macro-averaged + * metric treating each class as a binary classifier. */ - negativeLabel?: string; - }; - - type IClustering = { + precision?: number; /** - * [Repeated] One or more fields on which data should be clustered. Only top-level, non-repeated, simple-type fields are supported. When you cluster a table using multiple columns, the order of columns you specify is important. The order of the specified columns determines the sort order of the data. + * Recall is the fraction of actual positive labels that were given a + * positive prediction. For multiclass this is a macro-averaged metric. */ - fields?: Array; + recall?: number; + /** + * Area Under a ROC Curve. For multiclass this is a macro-averaged + * metric. + */ + rocAuc?: number; + /** + * Threshold at which the metrics are computed. For binary + * classification models this is the positive class threshold. + * For multi-class classfication models this is the confidence + * threshold. + */ + threshold?: number; }; - type IBqmlTrainingRun = { + /** + * Input/output argument of a function or a stored procedure. + */ + type IArgument = { /** - * [Output-only, Beta] Training options used by this training run. These options are mutable for subsequent training runs. Default values are explicitly stored for options not specified in the input query of the first training run. For subsequent training runs, any option not explicitly specified in the input query will be copied from the previous training run. + * Optional. Defaults to FIXED_TYPE. */ - trainingOptions?: { - earlyStop?: boolean; - l1Reg?: number; - maxIteration?: string; - learnRate?: number; - minRelProgress?: number; - l2Reg?: number; - warmStart?: boolean; - learnRateStrategy?: string; - lineSearchInitLearnRate?: number; - }; + argumentKind?: 'ARGUMENT_KIND_UNSPECIFIED' | 'FIXED_TYPE' | 'ANY_TYPE'; /** - * [Output-only, Beta] Different state applicable for a training run. IN PROGRESS: Training run is in progress. FAILED: Training run ended due to a non-retryable failure. SUCCEEDED: Training run successfully completed. CANCELLED: Training run cancelled by the user. + * Required unless argument_kind = ANY_TYPE. */ - state?: string; + dataType?: IStandardSqlDataType; /** - * [Output-only, Beta] List of each iteration results. + * Optional. Specifies whether the argument is input or output. + * Can be set for procedures only. */ - iterationResults?: Array; + mode?: 'MODE_UNSPECIFIED' | 'IN' | 'OUT' | 'INOUT'; /** - * [Output-only, Beta] Training run start time in milliseconds since the epoch. + * Optional. The name of this argument. Can be absent for function return argument. */ - startTime?: string; + name?: string; }; - type IBigtableColumnFamily = { + type IBigQueryModelTraining = { /** - * [Optional] The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. This can be overridden for a specific column by listing that column in 'columns' and specifying an encoding for it. + * [Output-only, Beta] Index of current ML training iteration. Updated during create model query job to show job progress. */ - encoding?: string; + currentIteration?: number; /** - * [Optional] Lists of columns that should be exposed as individual fields as opposed to a list of (column name, value) pairs. All columns whose qualifier matches a qualifier in this list can be accessed as .. Other columns can be accessed as a list through .Column field. + * [Output-only, Beta] Expected number of iterations for the create model query job specified as num_iterations in the input query. The actual total number of iterations may be less than this number due to early stop. */ - columns?: Array; + expectedTotalIterations?: string; + }; + + type IBigtableColumn = { /** - * [Optional] The type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. This can be overridden for a specific column by listing that column in 'columns' and specifying a type for it. + * [Optional] The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. 'encoding' can also be set at the column family level. However, the setting at this level takes precedence if 'encoding' is set at both levels. */ - type?: string; + encoding?: string; /** - * Identifier of the column family. + * [Optional] If the qualifier is not a valid BigQuery field identifier i.e. does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as the column field name and is used as field name in queries. */ - familyId?: string; + fieldName?: string; /** - * [Optional] If this is set only the latest version of value are exposed for all columns in this column family. This can be overridden for a specific column by listing that column in 'columns' and specifying a different setting for that column. + * [Optional] If this is set, only the latest version of value in this column are exposed. 'onlyReadLatest' can also be set at the column family level. However, the setting at this level takes precedence if 'onlyReadLatest' is set at both levels. */ onlyReadLatest?: boolean; - }; - - type IRangePartitioning = { /** - * [TrustedTester] [Required] Defines the ranges for range partitioning. + * [Required] Qualifier of the column. Columns in the parent column family that has this exact qualifier are exposed as . field. If the qualifier is valid UTF-8 string, it can be specified in the qualifier_string field. Otherwise, a base-64 encoded value must be set to qualifier_encoded. The column field name is the same as the column qualifier. However, if the qualifier is not a valid BigQuery field identifier i.e. does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as field_name. */ - range?: { - /** - * [TrustedTester] [Required] The end of range partitioning, exclusive. - */ - end?: string; - /** - * [TrustedTester] [Required] The width of each interval. - */ - interval?: string; - /** - * [TrustedTester] [Required] The start of range partitioning, inclusive. - */ - start?: string; - }; + qualifierEncoded?: string; + qualifierString?: string; /** - * [TrustedTester] [Required] The table is partitioned by this field. The field must be a top-level NULLABLE/REQUIRED field. The only supported type is INTEGER/INT64. + * [Optional] The type to convert the value in cells of this column. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. 'type' can also be set at the column family level. However, the setting at this level takes precedence if 'type' is set at both levels. */ - field?: string; + type?: string; }; - type IJobConfigurationLoad = { - /** - * [Optional] Specifies a string that represents a null value in a CSV file. For example, if you specify "\N", BigQuery interprets "\N" as a null value when loading a CSV file. The default value is the empty string. If you set this property to a custom value, BigQuery throws an error if an empty string is present for all data types except for STRING and BYTE. For STRING and BYTE columns, BigQuery interprets the empty string as an empty value. - */ - nullMarker?: string; + type IBigtableColumnFamily = { /** - * [Optional] The schema for the destination table. The schema can be omitted if the destination table already exists, or if you're loading data from Google Cloud Datastore. + * [Optional] Lists of columns that should be exposed as individual fields as opposed to a list of (column name, value) pairs. All columns whose qualifier matches a qualifier in this list can be accessed as .. Other columns can be accessed as a list through .Column field. */ - schema?: ITableSchema; + columns?: Array; /** - * [Deprecated] The format of the schemaInline property. + * [Optional] The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. This can be overridden for a specific column by listing that column in 'columns' and specifying an encoding for it. */ - schemaInlineFormat?: string; + encoding?: string; /** - * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. + * Identifier of the column family. */ - quote?: string; + familyId?: string; /** - * [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_APPEND. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. + * [Optional] If this is set only the latest version of value are exposed for all columns in this column family. This can be overridden for a specific column by listing that column in 'columns' and specifying a different setting for that column. */ - writeDisposition?: string; + onlyReadLatest?: boolean; /** - * [Beta] [Optional] Properties with which to create the destination table if it is new. + * [Optional] The type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. This can be overridden for a specific column by listing that column in 'columns' and specifying a type for it. */ - destinationTableProperties?: IDestinationTableProperties; + type?: string; + }; + + type IBigtableOptions = { /** - * [Optional] The format of the data files. For CSV files, specify "CSV". For datastore backups, specify "DATASTORE_BACKUP". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro, specify "AVRO". For parquet, specify "PARQUET". For orc, specify "ORC". The default value is CSV. + * [Optional] List of column families to expose in the table schema along with their types. This list restricts the column families that can be referenced in queries and specifies their value types. You can use this list to do type conversions - see the 'type' field for more details. If you leave this list empty, all column families are present in the table schema and their values are read as BYTES. During a query only the column families referenced in that query are read from Bigtable. */ - sourceFormat?: string; + columnFamilies?: Array; /** - * [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names + * [Optional] If field is true, then the column families that are not specified in columnFamilies list are not exposed in the table schema. Otherwise, they are read with BYTES type values. The default value is false. */ - ignoreUnknownValues?: boolean; + ignoreUnspecifiedColumnFamilies?: boolean; /** - * [Required] The destination table to load the data into. + * [Optional] If field is true, then the rowkey column families will be read and converted to string. Otherwise they are read with BYTES type values and users need to manually cast them with CAST if necessary. The default value is false. */ - destinationTable?: ITableReference; + readRowkeyAsString?: boolean; + }; + + /** + * Evaluation metrics for binary classification/classifier models. + */ + type IBinaryClassificationMetrics = { /** - * [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split using the values of the quote and fieldDelimiter properties. + * Aggregate classification metrics. */ - encoding?: string; + aggregateClassificationMetrics?: IAggregateClassificationMetrics; /** - * [Beta] Clustering specification for the destination table. Must be specified with time-based partitioning, data in the table will be first partitioned and subsequently clustered. + * Binary confusion matrix at multiple thresholds. */ - clustering?: IClustering; + binaryConfusionMatrixList?: Array; /** - * [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. + * Label representing the negative class. */ - createDisposition?: string; + negativeLabel?: string; /** - * [Optional, Trusted Tester] If hive partitioning is enabled, which mode to use. Two modes are supported: - AUTO: automatically infer partition key name(s) and type(s). - STRINGS: automatic infer partition key name(s). All types are strings. Not all storage formats support hive partitioning -- requesting hive partitioning on an unsupported format will lead to an error. + * Label representing the positive class. */ - hivePartitioningMode?: string; + positiveLabel?: string; + }; + + /** + * Confusion matrix for binary classification models. + */ + type IBinaryConfusionMatrix = { /** - * [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If the number of bad records exceeds this value, an invalid error is returned in the job result. This is only valid for CSV and JSON. The default value is 0, which requires that all records are valid. + * The fraction of predictions given the correct label. */ - maxBadRecords?: number; + accuracy?: number; /** - * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the '*' wildcard character is not allowed. + * The equally weighted average of recall and precision. */ - sourceUris?: Array; + f1Score?: number; /** - * [Optional] Accept rows that are missing trailing optional columns. The missing values are treated as nulls. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. Only applicable to CSV, ignored for other formats. + * Number of false samples predicted as false. */ - allowJaggedRows?: boolean; + falseNegatives?: string; /** - * [Optional] The separator for fields in a CSV file. The separator can be any ISO-8859-1 single-byte character. To use a character in the range 128-255, you must encode the character as UTF8. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). + * Number of false samples predicted as true. */ - fieldDelimiter?: string; + falsePositives?: string; /** - * If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level properties. If no properties are specified, BigQuery loads all properties. If any named property isn't found in the Cloud Datastore backup, an invalid error is returned in the job result. + * Threshold value used when computing each of the following metric. */ - projectionFields?: Array; + positiveClassThreshold?: number; /** - * Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false. + * The fraction of actual positive predictions that had positive actual + * labels. */ - allowQuotedNewlines?: boolean; + precision?: number; /** - * [Optional, Trusted Tester] Options to configure hive partitioning support. + * The fraction of actual positive labels that were given a positive + * prediction. */ - hivePartitioningOptions?: IHivePartitioningOptions; + recall?: number; /** - * [Optional] If sourceFormat is set to "AVRO", indicates whether to enable interpreting logical types into their corresponding types (ie. TIMESTAMP), instead of only using their raw types (ie. INTEGER). + * Number of true samples predicted as false. */ - useAvroLogicalTypes?: boolean; + trueNegatives?: string; /** - * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when loading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. + * Number of true samples predicted as true. */ - skipLeadingRows?: number; + truePositives?: string; + }; + + type IBqmlIterationResult = { /** - * Time-based partitioning specification for the destination table. Only one of timePartitioning and rangePartitioning should be specified. + * [Output-only, Beta] Time taken to run the training iteration in milliseconds. */ - timePartitioning?: ITimePartitioning; + durationMs?: string; /** - * [Optional] Indicates if we should automatically infer the options and schema for CSV and JSON sources. + * [Output-only, Beta] Eval loss computed on the eval data at the end of the iteration. The eval loss is used for early stopping to avoid overfitting. No eval loss if eval_split_method option is specified as no_split or auto_split with input data size less than 500 rows. */ - autodetect?: boolean; + evalLoss?: number; /** - * Custom encryption configuration (e.g., Cloud KMS keys). + * [Output-only, Beta] Index of the ML training iteration, starting from zero for each training run. */ - destinationEncryptionConfiguration?: IEncryptionConfiguration; + index?: number; /** - * Allows the schema of the destination table to be updated as a side effect of the load job if a schema is autodetected or supplied in the job configuration. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable. + * [Output-only, Beta] Learning rate used for this iteration, it varies for different training iterations if learn_rate_strategy option is not constant. */ - schemaUpdateOptions?: Array; + learnRate?: number; /** - * [Deprecated] The inline schema. For CSV schemas, specify as "Field1:Type1[,Field2:Type2]*". For example, "foo:STRING, bar:INTEGER, baz:FLOAT". + * [Output-only, Beta] Training loss computed on the training data at the end of the iteration. The training loss function is defined by model type. */ - schemaInline?: string; + trainingLoss?: number; + }; + + type IBqmlTrainingRun = { /** - * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. + * [Output-only, Beta] List of each iteration results. */ - rangePartitioning?: IRangePartitioning; + iterationResults?: Array; + /** + * [Output-only, Beta] Training run start time in milliseconds since the epoch. + */ + startTime?: string; + /** + * [Output-only, Beta] Different state applicable for a training run. IN PROGRESS: Training run is in progress. FAILED: Training run ended due to a non-retryable failure. SUCCEEDED: Training run successfully completed. CANCELLED: Training run cancelled by the user. + */ + state?: string; + /** + * [Output-only, Beta] Training options used by this training run. These options are mutable for subsequent training runs. Default values are explicitly stored for options not specified in the input query of the first training run. For subsequent training runs, any option not explicitly specified in the input query will be copied from the previous training run. + */ + trainingOptions?: { + earlyStop?: boolean; + l1Reg?: number; + l2Reg?: number; + learnRate?: number; + learnRateStrategy?: string; + lineSearchInitLearnRate?: number; + maxIteration?: string; + minRelProgress?: number; + warmStart?: boolean; + }; + }; + + /** + * Representative value of a categorical feature. + */ + type ICategoricalValue = { + /** + * Counts of all categories for the categorical feature. If there are + * more than ten categories, we return top ten (by count) and return + * one more CategoryCount with category "_OTHER_" and count as + * aggregate counts of remaining categories. + */ + categoryCounts?: Array; + }; + + /** + * Represents the count of a single category within the cluster. + */ + type ICategoryCount = { + /** + * The name of category. + */ + category?: string; + /** + * The count of training samples matching the category within the + * cluster. + */ + count?: string; }; /** * Message containing the information about one cluster. */ type ICluster = { + /** + * Centroid id. + */ + centroidId?: string; /** * Count of training data rows that were assigned to this cluster. */ @@ -234,1168 +308,1099 @@ declare namespace bigquery { * Values of highly variant features for this cluster. */ featureValues?: Array; + }; + + /** + * Information about a single cluster for clustering model. + */ + type IClusterInfo = { /** * Centroid id. */ centroidId?: string; - }; - - type IExternalDataConfiguration = { /** - * [Optional] Additional options if sourceFormat is set to GOOGLE_SHEETS. + * Cluster radius, the average distance from centroid + * to each point assigned to the cluster. */ - googleSheetsOptions?: IGoogleSheetsOptions; + clusterRadius?: number; /** - * Try to detect schema and format options automatically. Any option specified explicitly will be honored. + * Cluster size, the total number of points assigned to the cluster. */ - autodetect?: boolean; + clusterSize?: string; + }; + + type IClustering = { /** - * [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names Google Cloud Bigtable: This setting is ignored. Google Cloud Datastore backups: This setting is ignored. Avro: This setting is ignored. + * [Repeated] One or more fields on which data should be clustered. Only top-level, non-repeated, simple-type fields are supported. When you cluster a table using multiple columns, the order of columns you specify is important. The order of the specified columns determines the sort order of the data. */ - ignoreUnknownValues?: boolean; + fields?: Array; + }; + + /** + * Evaluation metrics for clustering models. + */ + type IClusteringMetrics = { /** - * [Required] The data format. For CSV files, specify "CSV". For Google sheets, specify "GOOGLE_SHEETS". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro files, specify "AVRO". For Google Cloud Datastore backups, specify "DATASTORE_BACKUP". [Beta] For Google Cloud Bigtable, specify "BIGTABLE". + * [Beta] Information for all clusters. */ - sourceFormat?: string; + clusters?: Array; /** - * [Optional] The compression type of the data source. Possible values include GZIP and NONE. The default value is NONE. This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups and Avro formats. + * Davies-Bouldin index. */ - compression?: string; + daviesBouldinIndex?: number; /** - * [Optional, Trusted Tester] If hive partitioning is enabled, which mode to use. Two modes are supported: - AUTO: automatically infer partition key name(s) and type(s). - STRINGS: automatic infer partition key name(s). All types are strings. Not all storage formats support hive partitioning -- requesting hive partitioning on an unsupported format will lead to an error. Note: this setting is in the process of being deprecated in favor of hivePartitioningOptions. + * Mean of squared distances between each sample to its cluster centroid. */ - hivePartitioningMode?: string; + meanSquaredDistance?: number; + }; + + /** + * Confusion matrix for multi-class classification models. + */ + type IConfusionMatrix = { /** - * [Optional] The maximum number of bad records that BigQuery can ignore when reading data. If the number of bad records exceeds this value, an invalid error is returned in the job result. This is only valid for CSV, JSON, and Google Sheets. The default value is 0, which requires that all records are valid. This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups and Avro formats. + * Confidence threshold used when computing the entries of the + * confusion matrix. */ - maxBadRecords?: number; + confidenceThreshold?: number; /** - * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly one URI can be specified. Also, the '*' wildcard character is not allowed. + * One row per actual label. */ - sourceUris?: Array; + rows?: Array; + }; + + type ICsvOptions = { /** - * Additional properties to set if sourceFormat is set to CSV. + * [Optional] Indicates if BigQuery should accept rows that are missing trailing optional columns. If true, BigQuery treats missing trailing columns as null values. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. */ - csvOptions?: ICsvOptions; + allowJaggedRows?: boolean; /** - * [Optional] Additional options if sourceFormat is set to BIGTABLE. + * [Optional] Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false. */ - bigtableOptions?: IBigtableOptions; + allowQuotedNewlines?: boolean; /** - * [Optional] The schema for the data. Schema is required for CSV and JSON formats. Schema is disallowed for Google Cloud Bigtable, Cloud Datastore backups, and Avro formats. + * [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split using the values of the quote and fieldDelimiter properties. */ - schema?: ITableSchema; + encoding?: string; /** - * [Optional, Trusted Tester] Options to configure hive partitioning support. + * [Optional] The separator for fields in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). */ - hivePartitioningOptions?: IHivePartitioningOptions; - }; - - type IGoogleSheetsOptions = { + fieldDelimiter?: string; /** - * [Optional] Range of a sheet to query from. Only used when non-empty. Typical format: sheet_name!top_left_cell_id:bottom_right_cell_id For example: sheet1!A1:B20 + * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. */ - range?: string; + quote?: string; /** - * [Optional] The number of rows at the top of a sheet that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows that should be skipped. When autodetect is on, behavior is the following: * skipLeadingRows unspecified - Autodetect tries to detect headers in the first row. If they are not detected, the row is read as data. Otherwise data is read starting from the second row. * skipLeadingRows is 0 - Instructs autodetect that there are no headers and data should be read starting from the first row. * skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect headers in row N. If headers are not detected, row N is just skipped. Otherwise row N is used to extract column names for the detected schema. + * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. */ skipLeadingRows?: string; }; - type ITableDataInsertAllRequest = { + type IDataset = { /** - * The rows to insert. + * [Optional] An array of objects that define dataset access for one or more entities. You can set this property when inserting or updating a dataset in order to control who is allowed to access the data. If unspecified at dataset creation time, BigQuery adds default dataset access for the following entities: access.specialGroup: projectReaders; access.role: READER; access.specialGroup: projectWriters; access.role: WRITER; access.specialGroup: projectOwners; access.role: OWNER; access.userByEmail: [dataset creator email]; access.role: OWNER; */ - rows?: Array<{ + access?: Array<{ /** - * [Optional] A unique ID for each row. BigQuery uses this property to detect duplicate insertion requests on a best-effort basis. + * [Pick one] A domain to grant access to. Any users signed in with the domain specified will be granted the specified access. Example: "example.com". Maps to IAM policy member "domain:DOMAIN". */ - insertId?: string; + domain?: string; /** - * [Required] A JSON object that contains a row of data. The object's properties and values must match the destination table's schema. + * [Pick one] An email address of a Google Group to grant access to. Maps to IAM policy member "group:GROUP". */ - json?: IJsonObject; + groupByEmail?: string; + /** + * [Pick one] Some other type of member that appears in the IAM Policy but isn't a user, group, domain, or special group. + */ + iamMember?: string; + /** + * [Required] An IAM role ID that should be granted to the user, group, or domain specified in this access entry. The following legacy mappings will be applied: OWNER roles/bigquery.dataOwner WRITER roles/bigquery.dataEditor READER roles/bigquery.dataViewer This field will accept any of the above formats, but will return only the legacy format. For example, if you set this field to "roles/bigquery.dataOwner", it will be returned back as "OWNER". + */ + role?: string; + /** + * [Pick one] A special group to grant access to. Possible values include: projectOwners: Owners of the enclosing project. projectReaders: Readers of the enclosing project. projectWriters: Writers of the enclosing project. allAuthenticatedUsers: All authenticated BigQuery users. Maps to similarly-named IAM members. + */ + specialGroup?: string; + /** + * [Pick one] An email address of a user to grant access to. For example: fred@example.com. Maps to IAM policy member "user:EMAIL" or "serviceAccount:EMAIL". + */ + userByEmail?: string; + /** + * [Pick one] A view from a different dataset to grant access to. Queries executed against that view will have read access to tables in this dataset. The role field is not required when this field is set. If that view is updated by any user, access to the view needs to be granted again via an update operation. + */ + view?: ITableReference; }>; /** - * The resource type of the response. + * [Output-only] The time when this dataset was created, in milliseconds since the epoch. */ - kind?: string; + creationTime?: string; /** - * If specified, treats the destination table as a base template, and inserts the rows into an instance table named "{destination}{templateSuffix}". BigQuery will manage creation of the instance table, using the schema of the base template table. See https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables for considerations when working with templates tables. + * [Required] A reference that identifies the dataset. */ - templateSuffix?: string; + datasetReference?: IDatasetReference; + defaultEncryptionConfiguration?: IEncryptionConfiguration; /** - * [Optional] Accept rows that contain values that do not match the schema. The unknown values are ignored. Default is false, which treats unknown values as errors. + * [Optional] The default partition expiration for all partitioned tables in the dataset, in milliseconds. Once this property is set, all newly-created partitioned tables in the dataset will have an expirationMs property in the timePartitioning settings set to this value, and changing the value will only affect new tables, not existing ones. The storage in a partition will have an expiration time of its partition time plus this value. Setting this property overrides the use of defaultTableExpirationMs for partitioned tables: only one of defaultTableExpirationMs and defaultPartitionExpirationMs will be used for any new partitioned table. If you provide an explicit timePartitioning.expirationMs when creating or updating a partitioned table, that value takes precedence over the default partition expiration time indicated by this property. */ - ignoreUnknownValues?: boolean; + defaultPartitionExpirationMs?: string; /** - * [Optional] Insert all valid rows of a request, even if invalid rows exist. The default value is false, which causes the entire request to fail if any invalid rows exist. + * [Optional] The default lifetime of all tables in the dataset, in milliseconds. The minimum value is 3600000 milliseconds (one hour). Once this property is set, all newly-created tables in the dataset will have an expirationTime property set to the creation time plus the value in this property, and changing the value will only affect new tables, not existing ones. When the expirationTime for a given table is reached, that table will be deleted automatically. If a table's expirationTime is modified or removed before the table expires, or if you provide an explicit expirationTime when creating a table, that value takes precedence over the default expiration time indicated by this property. */ - skipInvalidRows?: boolean; - }; - - type ITableList = { + defaultTableExpirationMs?: string; /** - * A token to request the next page of results. + * [Optional] A user-friendly description of the dataset. */ - nextPageToken?: string; + description?: string; /** - * The total number of tables in the dataset. + * [Output-only] A hash of the resource. */ - totalItems?: number; + etag?: string; /** - * The type of list. + * [Optional] A descriptive name for the dataset. + */ + friendlyName?: string; + /** + * [Output-only] The fully-qualified unique name of the dataset in the format projectId:datasetId. The dataset name without the project name is given in the datasetId field. When creating a new dataset, leave this field blank, and instead specify the datasetId field. + */ + id?: string; + /** + * [Output-only] The resource type. */ kind?: string; /** - * Tables in the requested dataset. + * The labels associated with this dataset. You can use these to organize and group your datasets. You can set this property when inserting or updating a dataset. See Creating and Updating Dataset Labels for more information. */ - tables?: Array<{ + labels?: { [key: string]: string }; + /** + * [Output-only] The date when this dataset or any of its tables was last modified, in milliseconds since the epoch. + */ + lastModifiedTime?: string; + /** + * The geographic location where the dataset should reside. The default value is US. See details at https://cloud.google.com/bigquery/docs/locations. + */ + location?: string; + /** + * [Output-only] A URL that can be used to access the resource again. You can use this URL in Get or Update requests to the resource. + */ + selfLink?: string; + }; + + type IDatasetList = { + /** + * An array of the dataset resources in the project. Each resource contains basic information. For full information about a particular dataset resource, use the Datasets: get method. This property is omitted when there are no datasets in the project. + */ + datasets?: Array<{ /** - * The type of table. Possible values are: TABLE, VIEW. + * The dataset reference. Use this property to access specific parts of the dataset's ID, such as project ID or dataset ID. */ - type?: string; + datasetReference?: IDatasetReference; /** - * [Beta] Clustering specification for this table, if configured. + * A descriptive name for the dataset, if one exists. */ - clustering?: IClustering; + friendlyName?: string; /** - * [Optional] The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. + * The fully-qualified, unique, opaque ID of the dataset. */ - expirationTime?: string; + id?: string; /** - * An opaque ID of the table - */ - id?: string; - /** - * A reference uniquely identifying the table. - */ - tableReference?: ITableReference; - /** - * The user-friendly name for this table. - */ - friendlyName?: string; - /** - * The time-based partitioning specification for this table, if configured. - */ - timePartitioning?: ITimePartitioning; - /** - * The resource type. + * The resource type. This property always returns the value "bigquery#dataset". */ kind?: string; /** - * Additional details for a view. - */ - view?: { - /** - * True if view is defined in legacy SQL dialect, false if in standard SQL. - */ - useLegacySql?: boolean; - }; - /** - * The time when this table was created, in milliseconds since the epoch. + * The labels associated with this dataset. You can use these to organize and group your datasets. */ - creationTime?: string; + labels?: { [key: string]: string }; /** - * The labels associated with this table. You can use these to organize and group your tables. + * The geographic location where the data resides. */ - labels?: { [key: string]: string }; + location?: string; }>; /** - * A hash of this page of results. + * A hash value of the results page. You can use this property to determine if the page has changed since the last request. */ etag?: string; - }; - - type IBigtableColumn = { - /** - * [Optional] The type to convert the value in cells of this column. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. 'type' can also be set at the column family level. However, the setting at this level takes precedence if 'type' is set at both levels. - */ - type?: string; - /** - * [Required] Qualifier of the column. Columns in the parent column family that has this exact qualifier are exposed as . field. If the qualifier is valid UTF-8 string, it can be specified in the qualifier_string field. Otherwise, a base-64 encoded value must be set to qualifier_encoded. The column field name is the same as the column qualifier. However, if the qualifier is not a valid BigQuery field identifier i.e. does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as field_name. - */ - qualifierEncoded?: string; /** - * [Optional] If this is set, only the latest version of value in this column are exposed. 'onlyReadLatest' can also be set at the column family level. However, the setting at this level takes precedence if 'onlyReadLatest' is set at both levels. - */ - onlyReadLatest?: boolean; - /** - * [Optional] If the qualifier is not a valid BigQuery field identifier i.e. does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as the column field name and is used as field name in queries. + * The list type. This property always returns the value "bigquery#datasetList". */ - fieldName?: string; - qualifierString?: string; + kind?: string; /** - * [Optional] The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. 'encoding' can also be set at the column family level. However, the setting at this level takes precedence if 'encoding' is set at both levels. + * A token that can be used to request the next results page. This property is omitted on the final results page. */ - encoding?: string; + nextPageToken?: string; }; - type ITableFieldSchema = { - /** - * [Required] The field name. The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter or underscore. The maximum length is 128 characters. - */ - name?: string; + type IDatasetReference = { /** - * [Required] The field data type. Possible values include STRING, BYTES, INTEGER, INT64 (same as INTEGER), FLOAT, FLOAT64 (same as FLOAT), BOOLEAN, BOOL (same as BOOLEAN), TIMESTAMP, DATE, TIME, DATETIME, RECORD (where RECORD indicates that the field contains a nested schema) or STRUCT (same as RECORD). + * [Required] A unique ID for this dataset, without the project name. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. */ - type?: string; + datasetId?: string; /** - * [Optional] The field mode. Possible values include NULLABLE, REQUIRED and REPEATED. The default value is NULLABLE. + * [Optional] The ID of the project containing this dataset. */ - mode?: string; + projectId?: string; + }; + + type IDestinationTableProperties = { /** - * [Optional] The categories attached to this field, used for field-level access control. + * [Optional] The description for the destination table. This will only be used if the destination table is newly created. If the table already exists and a value different than the current description is provided, the job will fail. */ - categories?: { - /** - * A list of category resource names. For example, "projects/1/taxonomies/2/categories/3". At most 5 categories are allowed. - */ - names?: Array; - }; + description?: string; /** - * [Optional] The field description. The maximum length is 1,024 characters. + * [Optional] The friendly name for the destination table. This will only be used if the destination table is newly created. If the table already exists and a value different than the current friendly name is provided, the job will fail. */ - description?: string; + friendlyName?: string; /** - * [Optional] Describes the nested schema fields if the type property is set to RECORD. + * [Optional] The labels associated with this table. You can use these to organize and group your tables. This will only be used if the destination table is newly created. If the table already exists and labels are different than the current labels are provided, the job will fail. */ - fields?: Array; + labels?: { [key: string]: string }; }; - type IBqmlIterationResult = { + type IEncryptionConfiguration = { /** - * [Output-only, Beta] Time taken to run the training iteration in milliseconds. + * [Optional] Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. The BigQuery Service Account associated with your project requires access to this encryption key. */ - durationMs?: string; + kmsKeyName?: string; + }; + + /** + * A single entry in the confusion matrix. + */ + type IEntry = { /** - * [Output-only, Beta] Training loss computed on the training data at the end of the iteration. The training loss function is defined by model type. + * Number of items being predicted as this label. */ - trainingLoss?: number; + itemCount?: string; /** - * [Output-only, Beta] Eval loss computed on the eval data at the end of the iteration. The eval loss is used for early stopping to avoid overfitting. No eval loss if eval_split_method option is specified as no_split or auto_split with input data size less than 500 rows. + * The predicted label. For confidence_threshold > 0, we will + * also add an entry indicating the number of items under the + * confidence threshold. */ - evalLoss?: number; + predictedLabel?: string; + }; + + type IErrorProto = { /** - * [Output-only, Beta] Index of the ML training iteration, starting from zero for each training run. + * Debugging information. This property is internal to Google and should not be used. */ - index?: number; + debugInfo?: string; /** - * [Output-only, Beta] Learning rate used for this iteration, it varies for different training iterations if learn_rate_strategy option is not constant. + * Specifies where the error occurred, if present. */ - learnRate?: number; - }; - - type ITableDataInsertAllResponse = { + location?: string; /** - * An array of errors for rows that were not inserted. + * A human-readable description of the error. */ - insertErrors?: Array<{ - /** - * Error information for the row indicated by the index property. - */ - errors?: Array; - /** - * The index of the row that error applies to. - */ - index?: number; - }>; + message?: string; /** - * The resource type of the response. + * A short error code that summarizes the error. */ - kind?: string; + reason?: string; }; /** - * Evaluation metrics for clustering models. + * Evaluation metrics of a model. These are either computed on all training + * data or just the eval data based on whether eval data was used during + * training. These are not present for imported models. */ - type IClusteringMetrics = { - /** - * Mean of squared distances between each sample to its cluster centroid. - */ - meanSquaredDistance?: number; + type IEvaluationMetrics = { /** - * Davies-Bouldin index. + * Populated for binary classification/classifier models. */ - daviesBouldinIndex?: number; + binaryClassificationMetrics?: IBinaryClassificationMetrics; /** - * [Beta] Information for all clusters. + * Populated for clustering models. */ - clusters?: Array; - }; - - type IGetServiceAccountResponse = { + clusteringMetrics?: IClusteringMetrics; /** - * The service account email address. + * Populated for multi-class classification/classifier models. */ - email?: string; + multiClassClassificationMetrics?: IMultiClassClassificationMetrics; /** - * The resource type of the response. + * Populated for regression models and explicit feedback type matrix + * factorization models. */ - kind?: string; + regressionMetrics?: IRegressionMetrics; }; - type IDataset = { + type IExplainQueryStage = { /** - * [Output-only] A URL that can be used to access the resource again. You can use this URL in Get or Update requests to the resource. + * Number of parallel input segments completed. */ - selfLink?: string; + completedParallelInputs?: string; /** - * [Optional] The default partition expiration for all partitioned tables in the dataset, in milliseconds. Once this property is set, all newly-created partitioned tables in the dataset will have an expirationMs property in the timePartitioning settings set to this value, and changing the value will only affect new tables, not existing ones. The storage in a partition will have an expiration time of its partition time plus this value. Setting this property overrides the use of defaultTableExpirationMs for partitioned tables: only one of defaultTableExpirationMs and defaultPartitionExpirationMs will be used for any new partitioned table. If you provide an explicit timePartitioning.expirationMs when creating or updating a partitioned table, that value takes precedence over the default partition expiration time indicated by this property. + * Milliseconds the average shard spent on CPU-bound tasks. */ - defaultPartitionExpirationMs?: string; + computeMsAvg?: string; /** - * [Optional] An array of objects that define dataset access for one or more entities. You can set this property when inserting or updating a dataset in order to control who is allowed to access the data. If unspecified at dataset creation time, BigQuery adds default dataset access for the following entities: access.specialGroup: projectReaders; access.role: READER; access.specialGroup: projectWriters; access.role: WRITER; access.specialGroup: projectOwners; access.role: OWNER; access.userByEmail: [dataset creator email]; access.role: OWNER; + * Milliseconds the slowest shard spent on CPU-bound tasks. */ - access?: Array<{ - /** - * [Pick one] An email address of a user to grant access to. For example: fred@example.com. Maps to IAM policy member "user:EMAIL" or "serviceAccount:EMAIL". - */ - userByEmail?: string; - /** - * [Pick one] A domain to grant access to. Any users signed in with the domain specified will be granted the specified access. Example: "example.com". Maps to IAM policy member "domain:DOMAIN". - */ - domain?: string; - /** - * [Pick one] Some other type of member that appears in the IAM Policy but isn't a user, group, domain, or special group. - */ - iamMember?: string; - /** - * [Pick one] A special group to grant access to. Possible values include: projectOwners: Owners of the enclosing project. projectReaders: Readers of the enclosing project. projectWriters: Writers of the enclosing project. allAuthenticatedUsers: All authenticated BigQuery users. Maps to similarly-named IAM members. - */ - specialGroup?: string; - /** - * [Required] An IAM role ID that should be granted to the user, group, or domain specified in this access entry. The following legacy mappings will be applied: OWNER roles/bigquery.dataOwner WRITER roles/bigquery.dataEditor READER roles/bigquery.dataViewer This field will accept any of the above formats, but will return only the legacy format. For example, if you set this field to "roles/bigquery.dataOwner", it will be returned back as "OWNER". - */ - role?: string; - /** - * [Pick one] A view from a different dataset to grant access to. Queries executed against that view will have read access to tables in this dataset. The role field is not required when this field is set. If that view is updated by any user, access to the view needs to be granted again via an update operation. - */ - view?: ITableReference; - /** - * [Pick one] An email address of a Google Group to grant access to. Maps to IAM policy member "group:GROUP". - */ - groupByEmail?: string; - }>; + computeMsMax?: string; /** - * [Optional] A user-friendly description of the dataset. + * Relative amount of time the average shard spent on CPU-bound tasks. */ - description?: string; + computeRatioAvg?: number; /** - * [Output-only] The resource type. + * Relative amount of time the slowest shard spent on CPU-bound tasks. */ - kind?: string; + computeRatioMax?: number; /** - * [Optional] The default lifetime of all tables in the dataset, in milliseconds. The minimum value is 3600000 milliseconds (one hour). Once this property is set, all newly-created tables in the dataset will have an expirationTime property set to the creation time plus the value in this property, and changing the value will only affect new tables, not existing ones. When the expirationTime for a given table is reached, that table will be deleted automatically. If a table's expirationTime is modified or removed before the table expires, or if you provide an explicit expirationTime when creating a table, that value takes precedence over the default expiration time indicated by this property. + * Stage end time represented as milliseconds since epoch. */ - defaultTableExpirationMs?: string; + endMs?: string; /** - * [Output-only] A hash of the resource. + * Unique ID for stage within plan. */ - etag?: string; + id?: string; /** - * [Output-only] The time when this dataset was created, in milliseconds since the epoch. + * IDs for stages that are inputs to this stage. */ - creationTime?: string; + inputStages?: Array; /** - * [Required] A reference that identifies the dataset. + * Human-readable name for stage. */ - datasetReference?: IDatasetReference; + name?: string; /** - * [Output-only] The fully-qualified unique name of the dataset in the format projectId:datasetId. The dataset name without the project name is given in the datasetId field. When creating a new dataset, leave this field blank, and instead specify the datasetId field. + * Number of parallel input segments to be processed. */ - id?: string; + parallelInputs?: string; /** - * The geographic location where the dataset should reside. The default value is US. See details at https://cloud.google.com/bigquery/docs/locations. + * Milliseconds the average shard spent reading input. */ - location?: string; + readMsAvg?: string; /** - * [Optional] A descriptive name for the dataset. + * Milliseconds the slowest shard spent reading input. */ - friendlyName?: string; + readMsMax?: string; /** - * [Output-only] The date when this dataset or any of its tables was last modified, in milliseconds since the epoch. + * Relative amount of time the average shard spent reading input. */ - lastModifiedTime?: string; + readRatioAvg?: number; /** - * The labels associated with this dataset. You can use these to organize and group your datasets. You can set this property when inserting or updating a dataset. See Creating and Updating Dataset Labels for more information. + * Relative amount of time the slowest shard spent reading input. */ - labels?: { [key: string]: string }; - defaultEncryptionConfiguration?: IEncryptionConfiguration; - }; - - type IModelDefinition = { + readRatioMax?: number; /** - * [Output-only, Beta] Model options used for the first training run. These options are immutable for subsequent training runs. Default values are used for any options not specified in the input query. + * Number of records read into the stage. */ - modelOptions?: { - labels?: Array; - lossType?: string; - modelType?: string; - }; + recordsRead?: string; /** - * [Output-only, Beta] Information about ml training runs, each training run comprises of multiple iterations and there may be multiple training runs for the model if warm start is used or if a user decides to continue a previously cancelled query. + * Number of records written by the stage. */ - trainingRuns?: Array; - }; - - type IDatasetReference = { + recordsWritten?: string; /** - * [Required] A unique ID for this dataset, without the project name. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. + * Total number of bytes written to shuffle. */ - datasetId?: string; + shuffleOutputBytes?: string; /** - * [Optional] The ID of the project containing this dataset. + * Total number of bytes written to shuffle and spilled to disk. */ - projectId?: string; - }; - - type IJobStatus = { + shuffleOutputBytesSpilled?: string; /** - * [Output-only] The first errors encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful. + * Stage start time represented as milliseconds since epoch. */ - errors?: Array; + startMs?: string; /** - * [Output-only] Running state of the job. + * Current status for the stage. */ - state?: string; + status?: string; /** - * [Output-only] Final error result of the job. If present, indicates that the job has completed and was unsuccessful. + * List of operations within the stage in dependency order (approximately chronological). */ - errorResult?: IErrorProto; - }; - - type IJobStatistics3 = { + steps?: Array; /** - * [Output-only] Number of source files in a load job. + * Milliseconds the average shard spent waiting to be scheduled. */ - inputFiles?: string; + waitMsAvg?: string; /** - * [Output-only] Number of rows imported in a load job. Note that while an import job is in the running state, this value may change. + * Milliseconds the slowest shard spent waiting to be scheduled. */ - outputRows?: string; + waitMsMax?: string; /** - * [Output-only] Size of the loaded data in bytes. Note that while a load job is in the running state, this value may change. + * Relative amount of time the average shard spent waiting to be scheduled. */ - outputBytes?: string; + waitRatioAvg?: number; /** - * [Output-only] The number of bad records encountered. Note that if the job has failed because of more bad records encountered than the maximum allowed in the load job configuration, then this number can be less than the total number of bad records present in the input data. + * Relative amount of time the slowest shard spent waiting to be scheduled. */ - badRecords?: string; + waitRatioMax?: number; /** - * [Output-only] Number of bytes of source data in a load job. + * Milliseconds the average shard spent on writing output. */ - inputFileBytes?: string; - }; - - type IListModelsResponse = { + writeMsAvg?: string; /** - * A token to request the next page of results. + * Milliseconds the slowest shard spent on writing output. */ - nextPageToken?: string; + writeMsMax?: string; /** - * Models in the requested dataset. Only the following fields are populated: - * model_reference, model_type, creation_time, last_modified_time and - * labels. + * Relative amount of time the average shard spent on writing output. */ - models?: Array; + writeRatioAvg?: number; + /** + * Relative amount of time the slowest shard spent on writing output. + */ + writeRatioMax?: number; }; - type IHivePartitioningOptions = { + type IExplainQueryStep = { /** - * [Optional, Trusted Tester] When hive partition detection is requested, a common prefix for all source uris should be supplied. The prefix must end immediately before the partition key encoding begins. For example, consider files following this data layout. gs://bucket/path_to_table/dt=2019-01-01/country=BR/id=7/file.avro gs://bucket/path_to_table/dt=2018-12-31/country=CA/id=3/file.avro When hive partitioning is requested with either AUTO or STRINGS detection, the common prefix can be either of gs://bucket/path_to_table or gs://bucket/path_to_table/ (trailing slash does not matter). + * Machine-readable operation type. */ - sourceUriPrefix?: string; + kind?: string; /** - * [Optional, Trusted Tester] When set, what mode of hive partitioning to use when reading data. Two modes are supported. (1) AUTO: automatically infer partition key name(s) and type(s). (2) STRINGS: automatically infer partition key name(s). All types are interpreted as strings. Not all storage formats support hive partitioning. Requesting hive partitioning on an unsupported format will lead to an error. Currently supported types include: AVRO, CSV, JSON, ORC and Parquet. + * Human-readable stage descriptions. */ - mode?: string; + substeps?: Array; }; - /** - * Represents the count of a single category within the cluster. - */ - type ICategoryCount = { + type IExternalDataConfiguration = { /** - * The name of category. + * Try to detect schema and format options automatically. Any option specified explicitly will be honored. */ - category?: string; + autodetect?: boolean; /** - * The count of training samples matching the category within the - * cluster. + * [Optional] Additional options if sourceFormat is set to BIGTABLE. */ - count?: string; - }; - - /** - * Evaluation metrics of a model. These are either computed on all training - * data or just the eval data based on whether eval data was used during - * training. These are not present for imported models. - */ - type IEvaluationMetrics = { + bigtableOptions?: IBigtableOptions; /** - * Populated for binary classification/classifier models. + * [Optional] The compression type of the data source. Possible values include GZIP and NONE. The default value is NONE. This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups and Avro formats. */ - binaryClassificationMetrics?: IBinaryClassificationMetrics; + compression?: string; /** - * Populated for regression models and explicit feedback type matrix - * factorization models. + * Additional properties to set if sourceFormat is set to CSV. */ - regressionMetrics?: IRegressionMetrics; + csvOptions?: ICsvOptions; /** - * Populated for multi-class classification/classifier models. + * [Optional] Additional options if sourceFormat is set to GOOGLE_SHEETS. */ - multiClassClassificationMetrics?: IMultiClassClassificationMetrics; + googleSheetsOptions?: IGoogleSheetsOptions; /** - * Populated for clustering models. + * [Optional, Trusted Tester] If hive partitioning is enabled, which mode to use. Two modes are supported: - AUTO: automatically infer partition key name(s) and type(s). - STRINGS: automatic infer partition key name(s). All types are strings. Not all storage formats support hive partitioning -- requesting hive partitioning on an unsupported format will lead to an error. Note: this setting is in the process of being deprecated in favor of hivePartitioningOptions. */ - clusteringMetrics?: IClusteringMetrics; - }; - - /** - * A field or a column. - */ - type IStandardSqlField = { + hivePartitioningMode?: string; /** - * Optional. The type of this parameter. Absent if not explicitly - * specified (e.g., CREATE FUNCTION statement can omit the return type; - * in this case the output parameter does not have this "type" field). + * [Optional, Trusted Tester] Options to configure hive partitioning support. */ - type?: IStandardSqlDataType; + hivePartitioningOptions?: IHivePartitioningOptions; /** - * Optional. The name of this field. Can be absent for struct fields. + * [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names Google Cloud Bigtable: This setting is ignored. Google Cloud Datastore backups: This setting is ignored. Avro: This setting is ignored. */ - name?: string; - }; - - type IStreamingbuffer = { + ignoreUnknownValues?: boolean; /** - * [Output-only] A lower-bound estimate of the number of rows currently in the streaming buffer. + * [Optional] The maximum number of bad records that BigQuery can ignore when reading data. If the number of bad records exceeds this value, an invalid error is returned in the job result. This is only valid for CSV, JSON, and Google Sheets. The default value is 0, which requires that all records are valid. This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups and Avro formats. */ - estimatedRows?: string; + maxBadRecords?: number; /** - * [Output-only] Contains the timestamp of the oldest entry in the streaming buffer, in milliseconds since the epoch, if the streaming buffer is available. + * [Optional] The schema for the data. Schema is required for CSV and JSON formats. Schema is disallowed for Google Cloud Bigtable, Cloud Datastore backups, and Avro formats. */ - oldestEntryTime?: string; + schema?: ITableSchema; /** - * [Output-only] A lower-bound estimate of the number of bytes currently in the streaming buffer. + * [Required] The data format. For CSV files, specify "CSV". For Google sheets, specify "GOOGLE_SHEETS". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro files, specify "AVRO". For Google Cloud Datastore backups, specify "DATASTORE_BACKUP". [Beta] For Google Cloud Bigtable, specify "BIGTABLE". */ - estimatedBytes?: string; + sourceFormat?: string; + /** + * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly one URI can be specified. Also, the '*' wildcard character is not allowed. + */ + sourceUris?: Array; }; /** - * A single entry in the confusion matrix. + * Representative value of a single feature within the cluster. */ - type IEntry = { + type IFeatureValue = { /** - * Number of items being predicted as this label. + * The categorical feature value. */ - itemCount?: string; + categoricalValue?: ICategoricalValue; /** - * The predicted label. For confidence_threshold > 0, we will - * also add an entry indicating the number of items under the - * confidence threshold. + * The feature column name. */ - predictedLabel?: string; + featureColumn?: string; + /** + * The numerical feature value. This is the centroid value for this + * feature. + */ + numericalValue?: number; }; - type ITable = { + type IGetQueryResultsResponse = { /** - * [Optional] Describes the data format, location, and other properties of a table stored outside of BigQuery. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. + * Whether the query result was fetched from the query cache. */ - externalDataConfiguration?: IExternalDataConfiguration; + cacheHit?: boolean; /** - * [Output-only, Beta] Present iff this table represents a ML model. Describes the training information for the model, and it is required to run 'PREDICT' queries. + * [Output-only] The first errors or warnings encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful. */ - model?: IModelDefinition; + errors?: Array; /** - * [Output-only] A URL that can be used to access this resource again. + * A hash of this response. */ - selfLink?: string; + etag?: string; /** - * [Optional] The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. The defaultTableExpirationMs property of the encapsulating dataset can be used to set a default expirationTime on newly created tables. + * Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available. */ - expirationTime?: string; + jobComplete?: boolean; /** - * [Optional] A user-friendly description of this table. + * Reference to the BigQuery Job that was created to run the query. This field will be present even if the original request timed out, in which case GetQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (GetQueryResults). */ - description?: string; + jobReference?: IJobReference; /** - * [Output-only] The type of the resource. + * The resource type of the response. */ kind?: string; /** - * [Output-only] The time when this table was created, in milliseconds since the epoch. + * [Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. */ - creationTime?: string; + numDmlAffectedRows?: string; /** - * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. + * A token used for paging results. */ - rangePartitioning?: IRangePartitioning; + pageToken?: string; /** - * [Optional] Describes the schema of this table. + * An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. Present only when the query completes successfully. */ - schema?: ITableSchema; + rows?: Array; /** - * [Output-only] An opaque ID uniquely identifying the table. + * The schema of the results. Present only when the query completes successfully. */ - id?: string; + schema?: ITableSchema; /** - * [Beta] [Optional] If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified. + * The total number of bytes processed for this query. */ - requirePartitionFilter?: boolean; + totalBytesProcessed?: string; /** - * [Required] Reference describing the ID of this table. + * The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results. Present only when the query completes successfully. */ - tableReference?: ITableReference; + totalRows?: string; + }; + + type IGetServiceAccountResponse = { /** - * [Optional] Materialized view definition. + * The service account email address. */ - materializedView?: IMaterializedViewDefinition; + email?: string; /** - * [Output-only] The time when this table was last modified, in milliseconds since the epoch. + * The resource type of the response. */ - lastModifiedTime?: string; + kind?: string; + }; + + type IGoogleSheetsOptions = { /** - * [Output-only] The number of rows of data in this table, excluding any data in the streaming buffer. + * [Optional] Range of a sheet to query from. Only used when non-empty. Typical format: sheet_name!top_left_cell_id:bottom_right_cell_id For example: sheet1!A1:B20 */ - numRows?: string; + range?: string; /** - * [Beta] Clustering specification for the table. Must be specified with partitioning, data in the table will be first partitioned and subsequently clustered. + * [Optional] The number of rows at the top of a sheet that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows that should be skipped. When autodetect is on, behavior is the following: * skipLeadingRows unspecified - Autodetect tries to detect headers in the first row. If they are not detected, the row is read as data. Otherwise data is read starting from the second row. * skipLeadingRows is 0 - Instructs autodetect that there are no headers and data should be read starting from the first row. * skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect headers in row N. If headers are not detected, row N is just skipped. Otherwise row N is used to extract column names for the detected schema. */ - clustering?: IClustering; + skipLeadingRows?: string; + }; + + type IHivePartitioningOptions = { /** - * [Output-only] Describes the table type. The following values are supported: TABLE: A normal BigQuery table. VIEW: A virtual table defined by a SQL query. [TrustedTester] MATERIALIZED_VIEW: SQL query whose result is persisted. EXTERNAL: A table that references data stored in an external storage system, such as Google Cloud Storage. The default value is TABLE. + * [Optional, Trusted Tester] When set, what mode of hive partitioning to use when reading data. Two modes are supported. (1) AUTO: automatically infer partition key name(s) and type(s). (2) STRINGS: automatically infer partition key name(s). All types are interpreted as strings. Not all storage formats support hive partitioning. Requesting hive partitioning on an unsupported format will lead to an error. Currently supported types include: AVRO, CSV, JSON, ORC and Parquet. */ - type?: string; + mode?: string; /** - * [Output-only] The number of bytes in the table that are considered "long-term storage". + * [Optional, Trusted Tester] When hive partition detection is requested, a common prefix for all source uris should be supplied. The prefix must end immediately before the partition key encoding begins. For example, consider files following this data layout. gs://bucket/path_to_table/dt=2019-01-01/country=BR/id=7/file.avro gs://bucket/path_to_table/dt=2018-12-31/country=CA/id=3/file.avro When hive partitioning is requested with either AUTO or STRINGS detection, the common prefix can be either of gs://bucket/path_to_table or gs://bucket/path_to_table/ (trailing slash does not matter). */ - numLongTermBytes?: string; + sourceUriPrefix?: string; + }; + + /** + * Information about a single iteration of the training run. + */ + type IIterationResult = { /** - * [Optional] The view definition. + * Information about top clusters for clustering models. */ - view?: IViewDefinition; + clusterInfos?: Array; /** - * [Output-only] A hash of the table metadata. Used to ensure there were no concurrent modifications to the resource when attempting an update. Not guaranteed to change when the table contents or the fields numRows, numBytes, numLongTermBytes or lastModifiedTime change. + * Time taken to run the iteration in milliseconds. */ - etag?: string; + durationMs?: string; /** - * Custom encryption configuration (e.g., Cloud KMS keys). + * Loss computed on the eval data at the end of iteration. */ - encryptionConfiguration?: IEncryptionConfiguration; + evalLoss?: number; /** - * [Output-only] Contains information regarding this table's streaming buffer, if one is present. This field will be absent if the table is not being streamed to or if there is no data in the streaming buffer. + * Index of the iteration, 0 based. */ - streamingBuffer?: IStreamingbuffer; + index?: number; /** - * [Output-only] The geographic location where the table resides. This value is inherited from the dataset. + * Learn rate used for this iteration. */ - location?: string; + learnRate?: number; /** - * [Output-only] The size of this table in bytes, excluding any data in the streaming buffer. + * Loss computed on the training data at the end of iteration. */ - numBytes?: string; + trainingLoss?: number; + }; + + type IJob = { /** - * Time-based partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. + * [Required] Describes the job configuration. */ - timePartitioning?: ITimePartitioning; + configuration?: IJobConfiguration; /** - * [Optional] A descriptive name for this table. + * [Output-only] A hash of this resource. */ - friendlyName?: string; + etag?: string; /** - * The labels associated with this table. You can use these to organize and group your tables. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. + * [Output-only] Opaque ID field of the job */ - labels?: { [key: string]: string }; + id?: string; /** - * [Output-only] [TrustedTester] The physical size of this table in bytes, excluding any data in the streaming buffer. This includes compression and storage used for time travel. + * [Optional] Reference describing the unique-per-user name of the job. */ - numPhysicalBytes?: string; - }; - - /** - * Confusion matrix for multi-class classification models. - */ - type IConfusionMatrix = { + jobReference?: IJobReference; /** - * Confidence threshold used when computing the entries of the - * confusion matrix. + * [Output-only] The type of the resource. */ - confidenceThreshold?: number; + kind?: string; /** - * One row per actual label. + * [Output-only] A URL that can be used to access this resource again. */ - rows?: Array; - }; - - type ITableCell = { v?: any }; - - type IMaterializedViewDefinition = { + selfLink?: string; /** - * [Output-only] [TrustedTester] The time when this materialized view was last modified, in milliseconds since the epoch. + * [Output-only] Information about the job, including starting time and ending time of the job. */ - lastRefreshTime?: string; + statistics?: IJobStatistics; /** - * [Required] A query whose result is persisted. + * [Output-only] The status of this job. Examine this value when polling an asynchronous job to see if the job is complete. */ - query?: string; - }; - - type IQueryParameterValue = { + status?: IJobStatus; /** - * [Optional] The value of this value, if a simple scalar type. + * [Output-only] Email address of the user who ran the job. */ - value?: string; + user_email?: string; + }; + + type IJobCancelResponse = { /** - * [Optional] The struct field values, in order of the struct type's declaration. + * The final state of the job. */ - structValues?: { [key: string]: IQueryParameterValue }; + job?: IJob; /** - * [Optional] The array values, if this is an array type. + * The resource type of the response. */ - arrayValues?: Array; + kind?: string; }; - type ITableReference = { + type IJobConfiguration = { /** - * [Required] The ID of the dataset containing this table. + * [Pick one] Copies a table. */ - datasetId?: string; + copy?: IJobConfigurationTableCopy; /** - * [Required] The ID of the table. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. + * [Optional] If set, don't actually run this job. A valid query will return a mostly empty response with some processing statistics, while an invalid query will return the same error it would if it wasn't a dry run. Behavior of non-query jobs is undefined. */ - tableId?: string; + dryRun?: boolean; /** - * [Required] The ID of the project containing this table. + * [Pick one] Configures an extract job. */ - projectId?: string; - }; - - type IModel = { + extract?: IJobConfigurationExtract; /** - * Output only. Input feature columns that were used to train this model. + * [Optional] Job timeout in milliseconds. If this time limit is exceeded, BigQuery may attempt to terminate the job. */ - featureColumns?: Array; + jobTimeoutMs?: string; /** - * [Optional] The time when this model expires, in milliseconds since the - * epoch. If not present, the model will persist indefinitely. Expired models - * will be deleted and their storage reclaimed. The defaultTableExpirationMs - * property of the encapsulating dataset can be used to set a default - * expirationTime on newly created models. + * [Output-only] The type of the job. Can be QUERY, LOAD, EXTRACT, COPY or UNKNOWN. */ - expirationTime?: string; + jobType?: string; /** - * Output only. Information for all training runs in increasing order of - * start_time. + * The labels associated with this job. You can use these to organize and group your jobs. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. */ - trainingRuns?: Array; + labels?: { [key: string]: string }; /** - * Required. Unique identifier for this model. + * [Pick one] Configures a load job. */ - modelReference?: IModelReference; + load?: IJobConfigurationLoad; /** - * [Optional] A user-friendly description of this model. + * [Pick one] Configures a query job. */ - description?: string; + query?: IJobConfigurationQuery; + }; + + type IJobConfigurationExtract = { /** - * Output only. A hash of this resource. + * [Optional] The compression type to use for exported files. Possible values include GZIP, DEFLATE, SNAPPY, and NONE. The default value is NONE. DEFLATE and SNAPPY are only supported for Avro. */ - etag?: string; + compression?: string; /** - * Output only. The time when this model was created, in millisecs since the - * epoch. + * [Optional] The exported file format. Possible values include CSV, NEWLINE_DELIMITED_JSON and AVRO. The default value is CSV. Tables with nested or repeated fields cannot be exported as CSV. */ - creationTime?: string; + destinationFormat?: string; /** - * Custom encryption configuration (e.g., Cloud KMS keys). This shows the - * encryption configuration of the model data while stored in BigQuery - * storage. + * [Pick one] DEPRECATED: Use destinationUris instead, passing only one URI as necessary. The fully-qualified Google Cloud Storage URI where the extracted table should be written. */ - encryptionConfiguration?: IEncryptionConfiguration; + destinationUri?: string; /** - * Output only. The geographic location where the model resides. This value - * is inherited from the dataset. + * [Pick one] A list of fully-qualified Google Cloud Storage URIs where the extracted table should be written. */ - location?: string; + destinationUris?: Array; /** - * [Optional] A descriptive name for this model. + * [Optional] Delimiter to use between fields in the exported data. Default is ',' */ - friendlyName?: string; + fieldDelimiter?: string; /** - * Output only. The time when this model was last modified, in millisecs - * since the epoch. + * [Optional] Whether to print out a header row in the results. Default is true. */ - lastModifiedTime?: string; + printHeader?: boolean; /** - * [Optional] The labels associated with this model. You can use these to - * organize and group your models. Label keys and values can be no longer - * than 63 characters, can only contain lowercase letters, numeric - * characters, underscores and dashes. International characters are allowed. - * Label values are optional. Label keys must start with a letter and each - * label in the list must have a different key. + * A reference to the model being exported. */ - labels?: { [key: string]: string }; + sourceModel?: IModelReference; /** - * Output only. Type of the model resource. + * A reference to the table being exported. */ - modelType?: - | 'MODEL_TYPE_UNSPECIFIED' - | 'LINEAR_REGRESSION' - | 'LOGISTIC_REGRESSION' - | 'KMEANS' - | 'TENSORFLOW'; + sourceTable?: ITableReference; /** - * Output only. Label columns that were used to train this model. - * The output of the model will have a "predicted_" prefix to these columns. + * [Optional] If destinationFormat is set to "AVRO", this flag indicates whether to enable extracting applicable column types (such as TIMESTAMP) to their corresponding AVRO logical types (timestamp-micros), instead of only using their raw types (avro-long). */ - labelColumns?: Array; + useAvroLogicalTypes?: boolean; }; - type IStandardSqlStructType = { fields?: Array }; - - /** - * The type of a variable, e.g., a function argument. - * Examples: - * INT64: {type_kind="INT64"} - * ARRAY: {type_kind="ARRAY", array_element_type="STRING"} - * STRUCT>: - * {type_kind="STRUCT", - * struct_type={fields=[ - * {name="x", type={type_kind="STRING"}}, - * {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} - * ]}} - */ - type IStandardSqlDataType = { + type IJobConfigurationLoad = { /** - * Required. The top level type of this field. - * Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). + * [Optional] Accept rows that are missing trailing optional columns. The missing values are treated as nulls. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. Only applicable to CSV, ignored for other formats. */ - typeKind?: - | 'TYPE_KIND_UNSPECIFIED' - | 'INT64' - | 'BOOL' - | 'FLOAT64' - | 'STRING' - | 'BYTES' - | 'TIMESTAMP' - | 'DATE' - | 'TIME' - | 'DATETIME' - | 'GEOGRAPHY' - | 'NUMERIC' - | 'ARRAY' - | 'STRUCT'; + allowJaggedRows?: boolean; /** - * The fields of this struct, in order, if type_kind = "STRUCT". + * Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false. */ - structType?: IStandardSqlStructType; + allowQuotedNewlines?: boolean; /** - * The type of the array's elements, if type_kind = "ARRAY". + * [Optional] Indicates if we should automatically infer the options and schema for CSV and JSON sources. */ - arrayElementType?: IStandardSqlDataType; - }; - - type IJobStatistics4 = { + autodetect?: boolean; /** - * [Output-only] Number of files per destination URI or URI pattern specified in the extract configuration. These values will be in the same order as the URIs specified in the 'destinationUris' field. + * [Beta] Clustering specification for the destination table. Must be specified with time-based partitioning, data in the table will be first partitioned and subsequently clustered. */ - destinationUriFileCounts?: Array; + clustering?: IClustering; /** - * [Output-only] Number of user bytes extracted into the result. This is the byte count as computed by BigQuery for billing purposes. + * [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. */ - inputBytes?: string; - }; - - type IModelReference = { + createDisposition?: string; /** - * [Required] The ID of the project containing this model. + * Custom encryption configuration (e.g., Cloud KMS keys). */ - projectId?: string; + destinationEncryptionConfiguration?: IEncryptionConfiguration; /** - * [Required] The ID of the dataset containing this model. + * [Required] The destination table to load the data into. */ - datasetId?: string; + destinationTable?: ITableReference; /** - * [Required] The ID of the model. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. + * [Beta] [Optional] Properties with which to create the destination table if it is new. */ - modelId?: string; - }; - - type ICsvOptions = { + destinationTableProperties?: IDestinationTableProperties; /** * [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split using the values of the quote and fieldDelimiter properties. */ encoding?: string; /** - * [Optional] Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false. + * [Optional] The separator for fields in a CSV file. The separator can be any ISO-8859-1 single-byte character. To use a character in the range 128-255, you must encode the character as UTF8. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). */ - allowQuotedNewlines?: boolean; + fieldDelimiter?: string; /** - * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. + * [Optional, Trusted Tester] If hive partitioning is enabled, which mode to use. Two modes are supported: - AUTO: automatically infer partition key name(s) and type(s). - STRINGS: automatic infer partition key name(s). All types are strings. Not all storage formats support hive partitioning -- requesting hive partitioning on an unsupported format will lead to an error. */ - quote?: string; + hivePartitioningMode?: string; /** - * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. + * [Optional, Trusted Tester] Options to configure hive partitioning support. */ - skipLeadingRows?: string; + hivePartitioningOptions?: IHivePartitioningOptions; /** - * [Optional] Indicates if BigQuery should accept rows that are missing trailing optional columns. If true, BigQuery treats missing trailing columns as null values. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. + * [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names */ - allowJaggedRows?: boolean; + ignoreUnknownValues?: boolean; /** - * [Optional] The separator for fields in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). + * [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If the number of bad records exceeds this value, an invalid error is returned in the job result. This is only valid for CSV and JSON. The default value is 0, which requires that all records are valid. */ - fieldDelimiter?: string; - }; - - type IJobConfigurationExtract = { + maxBadRecords?: number; /** - * [Optional] Delimiter to use between fields in the exported data. Default is ',' + * [Optional] Specifies a string that represents a null value in a CSV file. For example, if you specify "\N", BigQuery interprets "\N" as a null value when loading a CSV file. The default value is the empty string. If you set this property to a custom value, BigQuery throws an error if an empty string is present for all data types except for STRING and BYTE. For STRING and BYTE columns, BigQuery interprets the empty string as an empty value. */ - fieldDelimiter?: string; + nullMarker?: string; /** - * [Pick one] DEPRECATED: Use destinationUris instead, passing only one URI as necessary. The fully-qualified Google Cloud Storage URI where the extracted table should be written. + * If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level properties. If no properties are specified, BigQuery loads all properties. If any named property isn't found in the Cloud Datastore backup, an invalid error is returned in the job result. */ - destinationUri?: string; + projectionFields?: Array; /** - * [Optional] Whether to print out a header row in the results. Default is true. + * [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. */ - printHeader?: boolean; + quote?: string; /** - * [Optional] The compression type to use for exported files. Possible values include GZIP, DEFLATE, SNAPPY, and NONE. The default value is NONE. DEFLATE and SNAPPY are only supported for Avro. + * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. */ - compression?: string; + rangePartitioning?: IRangePartitioning; /** - * [Pick one] A list of fully-qualified Google Cloud Storage URIs where the extracted table should be written. + * [Optional] The schema for the destination table. The schema can be omitted if the destination table already exists, or if you're loading data from Google Cloud Datastore. */ - destinationUris?: Array; + schema?: ITableSchema; /** - * [Optional] The exported file format. Possible values include CSV, NEWLINE_DELIMITED_JSON and AVRO. The default value is CSV. Tables with nested or repeated fields cannot be exported as CSV. + * [Deprecated] The inline schema. For CSV schemas, specify as "Field1:Type1[,Field2:Type2]*". For example, "foo:STRING, bar:INTEGER, baz:FLOAT". */ - destinationFormat?: string; + schemaInline?: string; /** - * A reference to the model being exported. + * [Deprecated] The format of the schemaInline property. */ - sourceModel?: IModelReference; + schemaInlineFormat?: string; /** - * [Optional] If destinationFormat is set to "AVRO", this flag indicates whether to enable extracting applicable column types (such as TIMESTAMP) to their corresponding AVRO logical types (timestamp-micros), instead of only using their raw types (avro-long). + * Allows the schema of the destination table to be updated as a side effect of the load job if a schema is autodetected or supplied in the job configuration. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable. */ - useAvroLogicalTypes?: boolean; + schemaUpdateOptions?: Array; /** - * A reference to the table being exported. + * [Optional] The number of rows at the top of a CSV file that BigQuery will skip when loading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. */ - sourceTable?: ITableReference; - }; - - type IJobReference = { + skipLeadingRows?: number; /** - * The geographic location of the job. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. + * [Optional] The format of the data files. For CSV files, specify "CSV". For datastore backups, specify "DATASTORE_BACKUP". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro, specify "AVRO". For parquet, specify "PARQUET". For orc, specify "ORC". The default value is CSV. */ - location?: string; + sourceFormat?: string; /** - * [Required] The ID of the job. The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or dashes (-). The maximum length is 1,024 characters. + * [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the '*' wildcard character is not allowed. */ - jobId?: string; + sourceUris?: Array; /** - * [Required] The ID of the project containing this job. + * Time-based partitioning specification for the destination table. Only one of timePartitioning and rangePartitioning should be specified. */ - projectId?: string; + timePartitioning?: ITimePartitioning; + /** + * [Optional] If sourceFormat is set to "AVRO", indicates whether to enable interpreting logical types into their corresponding types (ie. TIMESTAMP), instead of only using their raw types (ie. INTEGER). + */ + useAvroLogicalTypes?: boolean; + /** + * [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_APPEND. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. + */ + writeDisposition?: string; }; type IJobConfigurationQuery = { /** - * Query parameters for standard SQL queries. - */ - queryParameters?: Array; - /** - * Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the value of flattenResults is ignored; query will be run as if flattenResults is false. + * [Optional] If true and query uses legacy SQL dialect, allows the query to produce arbitrarily large result tables at a slight cost in performance. Requires destinationTable to be set. For standard SQL queries, this flag is ignored and large results are always allowed. However, you must still set destinationTable when result size exceeds the allowed maximum response size. */ - useLegacySql?: boolean; + allowLargeResults?: boolean; /** * [Beta] Clustering specification for the destination table. Must be specified with time-based partitioning, data in the table will be first partitioned and subsequently clustered. */ clustering?: IClustering; - /** - * Custom encryption configuration (e.g., Cloud KMS keys). - */ - destinationEncryptionConfiguration?: IEncryptionConfiguration; /** * [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. */ createDisposition?: string; /** - * [Optional] Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit will fail (without incurring a charge). If unspecified, this will be set to your project default. + * [Optional] Specifies the default dataset to use for unqualified table names in the query. Note that this does not alter behavior of unqualified dataset names. */ - maximumBytesBilled?: string; + defaultDataset?: IDatasetReference; /** - * Allows the schema of the destination table to be updated as a side effect of the query job. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable. + * Custom encryption configuration (e.g., Cloud KMS keys). */ - schemaUpdateOptions?: Array; + destinationEncryptionConfiguration?: IEncryptionConfiguration; /** - * [Optional] Specifies a priority for the query. Possible values include INTERACTIVE and BATCH. The default value is INTERACTIVE. + * [Optional] Describes the table where the query results should be stored. If not present, a new table will be created to store the results. This property must be set for large results that exceed the maximum response size. */ - priority?: string; + destinationTable?: ITableReference; /** - * [Optional] If true and query uses legacy SQL dialect, allows the query to produce arbitrarily large result tables at a slight cost in performance. Requires destinationTable to be set. For standard SQL queries, this flag is ignored and large results are always allowed. However, you must still set destinationTable when result size exceeds the allowed maximum response size. + * [Optional] If true and query uses legacy SQL dialect, flattens all nested and repeated fields in the query results. allowLargeResults must be true if this is set to false. For standard SQL queries, this flag is ignored and results are never flattened. */ - allowLargeResults?: boolean; + flattenResults?: boolean; /** - * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. + * [Optional] Limits the billing tier for this job. Queries that have resource usage beyond this tier will fail (without incurring a charge). If unspecified, this will be set to your project default. */ - rangePartitioning?: IRangePartitioning; + maximumBillingTier?: number; + /** + * [Optional] Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit will fail (without incurring a charge). If unspecified, this will be set to your project default. + */ + maximumBytesBilled?: string; /** * Standard SQL only. Set to POSITIONAL to use positional (?) query parameters or to NAMED to use named (@myparam) query parameters in this query. */ parameterMode?: string; /** - * [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. Moreover, the query cache is only available when a query does not have a destination table specified. The default value is true. + * [Deprecated] This property is deprecated. */ - useQueryCache?: boolean; + preserveNulls?: boolean; /** - * [Optional] If true and query uses legacy SQL dialect, flattens all nested and repeated fields in the query results. allowLargeResults must be true if this is set to false. For standard SQL queries, this flag is ignored and results are never flattened. + * [Optional] Specifies a priority for the query. Possible values include INTERACTIVE and BATCH. The default value is INTERACTIVE. */ - flattenResults?: boolean; + priority?: string; /** - * [Optional] If querying an external data source outside of BigQuery, describes the data format, location and other properties of the data source. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. + * [Required] SQL query text to execute. The useLegacySql field can be used to indicate whether the query uses legacy SQL or standard SQL. */ - tableDefinitions?: { [key: string]: IExternalDataConfiguration }; + query?: string; /** - * [Optional] Specifies the default dataset to use for unqualified table names in the query. Note that this does not alter behavior of unqualified dataset names. + * Query parameters for standard SQL queries. */ - defaultDataset?: IDatasetReference; + queryParameters?: Array; /** - * [Optional] Limits the billing tier for this job. Queries that have resource usage beyond this tier will fail (without incurring a charge). If unspecified, this will be set to your project default. + * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. */ - maximumBillingTier?: number; + rangePartitioning?: IRangePartitioning; /** - * [Deprecated] This property is deprecated. + * Allows the schema of the destination table to be updated as a side effect of the query job. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable. */ - preserveNulls?: boolean; + schemaUpdateOptions?: Array; + /** + * [Optional] If querying an external data source outside of BigQuery, describes the data format, location and other properties of the data source. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. + */ + tableDefinitions?: { [key: string]: IExternalDataConfiguration }; /** * Time-based partitioning specification for the destination table. Only one of timePartitioning and rangePartitioning should be specified. */ timePartitioning?: ITimePartitioning; /** - * [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data and uses the schema from the query result. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. + * Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the value of flattenResults is ignored; query will be run as if flattenResults is false. */ - writeDisposition?: string; + useLegacySql?: boolean; /** - * [Required] SQL query text to execute. The useLegacySql field can be used to indicate whether the query uses legacy SQL or standard SQL. + * [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. Moreover, the query cache is only available when a query does not have a destination table specified. The default value is true. */ - query?: string; + useQueryCache?: boolean; /** * Describes user-defined function resources used in the query. */ userDefinedFunctionResources?: Array; /** - * [Optional] Describes the table where the query results should be stored. If not present, a new table will be created to store the results. This property must be set for large results that exceed the maximum response size. + * [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data and uses the schema from the query result. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. */ - destinationTable?: ITableReference; + writeDisposition?: string; }; - /** - * Information about a single cluster for clustering model. - */ - type IClusterInfo = { + type IJobConfigurationTableCopy = { /** - * Cluster radius, the average distance from centroid - * to each point assigned to the cluster. + * [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. */ - clusterRadius?: number; + createDisposition?: string; /** - * Cluster size, the total number of points assigned to the cluster. + * Custom encryption configuration (e.g., Cloud KMS keys). */ - clusterSize?: string; + destinationEncryptionConfiguration?: IEncryptionConfiguration; /** - * Centroid id. + * [Required] The destination table */ - centroidId?: string; - }; - - /** - * Representative value of a single feature within the cluster. - */ - type IFeatureValue = { + destinationTable?: ITableReference; /** - * The numerical feature value. This is the centroid value for this - * feature. + * [Pick one] Source table to copy. */ - numericalValue?: number; + sourceTable?: ITableReference; /** - * The feature column name. + * [Pick one] Source tables to copy. */ - featureColumn?: string; + sourceTables?: Array; /** - * The categorical feature value. + * [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. */ - categoricalValue?: ICategoricalValue; + writeDisposition?: string; }; - type IQueryParameterType = { - /** - * [Optional] The type of the array's elements, if this is an array. - */ - arrayType?: IQueryParameterType; + type IJobList = { /** - * [Required] The top level type of this field. + * A hash of this page of results. */ - type?: string; + etag?: string; /** - * [Optional] The types of the fields of this struct, in order, if this is a struct. + * List of jobs that were requested. */ - structTypes?: Array<{ + jobs?: Array<{ /** - * [Optional] The name of this field. + * [Full-projection-only] Specifies the job configuration. */ - name?: string; + configuration?: IJobConfiguration; /** - * [Optional] Human-oriented description of the field. + * A result object that will be present only if the job has failed. */ - description?: string; + errorResult?: IErrorProto; /** - * [Required] The type of this field. + * Unique opaque ID of the job. */ - type?: IQueryParameterType; - }>; - }; - - type ITimePartitioning = { - /** - * [Beta] [Optional] If not set, the table is partitioned by pseudo column, referenced via either '_PARTITIONTIME' as TIMESTAMP type, or '_PARTITIONDATE' as DATE type. If field is specified, the table is instead partitioned by this field. The field must be a top-level TIMESTAMP or DATE field. Its mode must be NULLABLE or REQUIRED. - */ - field?: string; - /** - * [Optional] Number of milliseconds for which to keep the storage for partitions in the table. The storage in a partition will have an expiration time of its partition time plus this value. - */ - expirationMs?: string; - /** - * [Required] The only type supported is DAY, which will generate one partition per day. - */ - type?: string; - requirePartitionFilter?: boolean; - }; - - type IViewDefinition = { + id?: string; + /** + * Job reference uniquely identifying the job. + */ + jobReference?: IJobReference; + /** + * The resource type. + */ + kind?: string; + /** + * Running state of the job. When the state is DONE, errorResult can be checked to determine whether the job succeeded or failed. + */ + state?: string; + /** + * [Output-only] Information about the job, including starting time and ending time of the job. + */ + statistics?: IJobStatistics; + /** + * [Full-projection-only] Describes the state of the job. + */ + status?: IJobStatus; + /** + * [Full-projection-only] Email address of the user who ran the job. + */ + user_email?: string; + }>; /** - * Specifies whether to use BigQuery's legacy SQL for this view. The default value is true. If set to false, the view will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ Queries and views that reference this view must use the same flag value. + * The resource type of the response. */ - useLegacySql?: boolean; + kind?: string; /** - * [Required] A query that BigQuery executes when the view is referenced. + * A token to request the next page of results. */ - query?: string; + nextPageToken?: string; + }; + + type IJobReference = { /** - * Describes user-defined function resources used in the query. + * [Required] The ID of the job. The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or dashes (-). The maximum length is 1,024 characters. */ - userDefinedFunctionResources?: Array; + jobId?: string; + /** + * The geographic location of the job. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. + */ + location?: string; + /** + * [Required] The ID of the project containing this job. + */ + projectId?: string; }; type IJobStatistics = { + /** + * [TrustedTester] [Output-only] Job progress (0.0 -> 1.0) for LOAD and EXTRACT jobs. + */ + completionRatio?: number; /** * [Output-only] Creation time of this job, in milliseconds since the epoch. This field will be present on all jobs. */ creationTime?: string; + /** + * [Output-only] End time of this job, in milliseconds since the epoch. This field will be present whenever a job is in the DONE state. + */ + endTime?: string; + /** + * [Output-only] Statistics for an extract job. + */ + extract?: IJobStatistics4; + /** + * [Output-only] Statistics for a load job. + */ + load?: IJobStatistics3; + /** + * [Output-only] Number of child jobs executed. + */ + numChildJobs?: string; + /** + * [Output-only] If this is a child job, the id of the parent. + */ + parentJobId?: string; + /** + * [Output-only] Statistics for a query job. + */ + query?: IJobStatistics2; + /** + * [Output-only] Quotas which delayed this job's start time. + */ + quotaDeferments?: Array; /** * [Output-only] Job resource usage breakdown by reservation. */ @@ -1410,1386 +1415,1375 @@ declare namespace bigquery { slotMs?: string; }>; /** - * [Output-only] Statistics for a load job. - */ - load?: IJobStatistics3; - /** - * [Output-only] Statistics for an extract job. + * [Output-only] Name of the primary reservation assigned to this job. Note that this could be different than reservations reported in the reservation usage field if parent reservations were used to execute this job. */ - extract?: IJobStatistics4; + reservation_id?: string; /** - * [Output-only] End time of this job, in milliseconds since the epoch. This field will be present whenever a job is in the DONE state. + * [Output-only] Start time of this job, in milliseconds since the epoch. This field will be present when the job transitions from the PENDING state to either RUNNING or DONE. */ - endTime?: string; + startTime?: string; /** - * [TrustedTester] [Output-only] Job progress (0.0 -> 1.0) for LOAD and EXTRACT jobs. + * [Output-only] [Deprecated] Use the bytes processed in the query statistics instead. */ - completionRatio?: number; + totalBytesProcessed?: string; /** - * [Output-only] Start time of this job, in milliseconds since the epoch. This field will be present when the job transitions from the PENDING state to either RUNNING or DONE. + * [Output-only] Slot-milliseconds for the job. */ - startTime?: string; + totalSlotMs?: string; + }; + + type IJobStatistics2 = { /** - * [Output-only] Statistics for a query job. + * [Output-only] Billing tier for the job. */ - query?: IJobStatistics2; + billingTier?: number; /** - * [Output-only] [Deprecated] Use the bytes processed in the query statistics instead. + * [Output-only] Whether the query result was fetched from the query cache. */ - totalBytesProcessed?: string; + cacheHit?: boolean; /** - * [Output-only] Number of child jobs executed. + * The DDL operation performed, possibly dependent on the pre-existence of the DDL target. Possible values (new values might be added in the future): "CREATE": The query created the DDL target. "SKIP": No-op. Example cases: the query is CREATE TABLE IF NOT EXISTS while the table already exists, or the query is DROP TABLE IF EXISTS while the table does not exist. "REPLACE": The query replaced the DDL target. Example case: the query is CREATE OR REPLACE TABLE, and the table already exists. "DROP": The query deleted the DDL target. */ - numChildJobs?: string; + ddlOperationPerformed?: string; /** - * [Output-only] Slot-milliseconds for the job. + * The DDL target routine. Present only for CREATE/DROP FUNCTION/PROCEDURE queries. */ - totalSlotMs?: string; + ddlTargetRoutine?: IRoutineReference; /** - * [Output-only] Name of the primary reservation assigned to this job. Note that this could be different than reservations reported in the reservation usage field if parent reservations were used to execute this job. + * The DDL target table. Present only for CREATE/DROP TABLE/VIEW queries. */ - reservation_id?: string; + ddlTargetTable?: ITableReference; /** - * [Output-only] If this is a child job, the id of the parent. + * [Output-only] The original estimate of bytes processed for the job. */ - parentJobId?: string; + estimatedBytesProcessed?: string; /** - * [Output-only] Quotas which delayed this job's start time. + * [Output-only, Beta] Information about create model query job progress. */ - quotaDeferments?: Array; - }; - - type IBigQueryModelTraining = { + modelTraining?: IBigQueryModelTraining; /** - * [Output-only, Beta] Index of current ML training iteration. Updated during create model query job to show job progress. + * [Output-only, Beta] Deprecated; do not use. */ - currentIteration?: number; + modelTrainingCurrentIteration?: number; /** - * [Output-only, Beta] Expected number of iterations for the create model query job specified as num_iterations in the input query. The actual total number of iterations may be less than this number due to early stop. + * [Output-only, Beta] Deprecated; do not use. */ - expectedTotalIterations?: string; - }; - - /** - * BigQuery-specific metadata about a location. This will be set on - * google.cloud.location.Location.metadata in Cloud Location API - * responses. - */ - type ILocationMetadata = { + modelTrainingExpectedTotalIteration?: string; /** - * The legacy BigQuery location ID, e.g. “EU” for the “europe” location. - * This is for any API consumers that need the legacy “US” and “EU” locations. + * [Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. */ - legacyLocationId?: string; - }; - - type IProjectList = { + numDmlAffectedRows?: string; /** - * The total number of projects in the list. + * [Output-only] Describes execution plan for the query. */ - totalItems?: number; + queryPlan?: Array; /** - * The type of list. + * [Output-only] Referenced routines (persistent user-defined functions and stored procedures) for the job. */ - kind?: string; + referencedRoutines?: Array; /** - * A hash of the page of results + * [Output-only] Referenced tables for the job. Queries that reference more than 50 tables will not have a complete list. */ - etag?: string; + referencedTables?: Array; /** - * Projects to which you have at least READ access. + * [Output-only] Job resource usage breakdown by reservation. */ - projects?: Array<{ - /** - * A descriptive name for this project. - */ - friendlyName?: string; - /** - * The numeric ID of this project. - */ - numericId?: string; - /** - * The resource type. - */ - kind?: string; + reservationUsage?: Array<{ /** - * An opaque ID of this project. + * [Output-only] Reservation name or "unreserved" for on-demand resources usage. */ - id?: string; + name?: string; /** - * A unique reference to this project. + * [Output-only] Slot-milliseconds the job spent in the given reservation. */ - projectReference?: IProjectReference; + slotMs?: string; }>; /** - * A token to request the next page of results. + * [Output-only] The schema of the results. Present only for successful dry run of non-legacy SQL queries. */ - nextPageToken?: string; - }; - - /** - * A single row in the confusion matrix. - */ - type IRow = { + schema?: ITableSchema; /** - * The original label of this row. + * The type of query statement, if valid. Possible values (new values might be added in the future): "SELECT": SELECT query. "INSERT": INSERT query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "UPDATE": UPDATE query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "DELETE": DELETE query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "MERGE": MERGE query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "ALTER_TABLE": ALTER TABLE query. "ALTER_VIEW": ALTER VIEW query. "CREATE_FUNCTION": CREATE FUNCTION query. "CREATE_MODEL": CREATE [OR REPLACE] MODEL ... AS SELECT ... . "CREATE_PROCEDURE": CREATE PROCEDURE query. "CREATE_TABLE": CREATE [OR REPLACE] TABLE without AS SELECT. "CREATE_TABLE_AS_SELECT": CREATE [OR REPLACE] TABLE ... AS SELECT ... . "CREATE_VIEW": CREATE [OR REPLACE] VIEW ... AS SELECT ... . "DROP_FUNCTION" : DROP FUNCTION query. "DROP_PROCEDURE": DROP PROCEDURE query. "DROP_TABLE": DROP TABLE query. "DROP_VIEW": DROP VIEW query. */ - actualLabel?: string; + statementType?: string; /** - * Info describing predicted label distribution. + * [Output-only] [Beta] Describes a timeline of job execution. */ - entries?: Array; - }; - - /** - * Evaluation metrics for regression and explicit feedback type matrix - * factorization models. - */ - type IRegressionMetrics = { + timeline?: Array; /** - * R^2 score. + * [Output-only] Total bytes billed for the job. */ - rSquared?: number; + totalBytesBilled?: string; /** - * Median absolute error. + * [Output-only] Total bytes processed for the job. */ - medianAbsoluteError?: number; + totalBytesProcessed?: string; /** - * Mean squared log error. + * [Output-only] For dry-run jobs, totalBytesProcessed is an estimate and this field specifies the accuracy of the estimate. Possible values can be: UNKNOWN: accuracy of the estimate is unknown. PRECISE: estimate is precise. LOWER_BOUND: estimate is lower bound of what the query would cost. UPPER_BOUND: estimate is upper bound of what the query would cost. */ - meanSquaredLogError?: number; + totalBytesProcessedAccuracy?: string; /** - * Mean absolute error. + * [Output-only] Total number of partitions processed from all partitioned tables referenced in the job. */ - meanAbsoluteError?: number; + totalPartitionsProcessed?: string; /** - * Mean squared error. + * [Output-only] Slot-milliseconds for the job. */ - meanSquaredError?: number; + totalSlotMs?: string; + /** + * Standard SQL only: list of undeclared query parameters detected during a dry run validation. + */ + undeclaredQueryParameters?: Array; }; - type IJsonValue = any; - - type IRoutineReference = { + type IJobStatistics3 = { /** - * [Required] The ID of the project containing this routine. + * [Output-only] The number of bad records encountered. Note that if the job has failed because of more bad records encountered than the maximum allowed in the load job configuration, then this number can be less than the total number of bad records present in the input data. */ - projectId?: string; + badRecords?: string; /** - * [Required] The ID of the dataset containing this routine. + * [Output-only] Number of bytes of source data in a load job. */ - datasetId?: string; + inputFileBytes?: string; /** - * [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters. - */ - routineId?: string; - }; - - type IGetQueryResultsResponse = { - /** - * An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. Present only when the query completes successfully. - */ - rows?: Array; - /** - * A token used for paging results. + * [Output-only] Number of source files in a load job. */ - pageToken?: string; + inputFiles?: string; /** - * The resource type of the response. + * [Output-only] Size of the loaded data in bytes. Note that while a load job is in the running state, this value may change. */ - kind?: string; + outputBytes?: string; /** - * A hash of this response. + * [Output-only] Number of rows imported in a load job. Note that while an import job is in the running state, this value may change. */ - etag?: string; + outputRows?: string; + }; + + type IJobStatistics4 = { /** - * Reference to the BigQuery Job that was created to run the query. This field will be present even if the original request timed out, in which case GetQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (GetQueryResults). + * [Output-only] Number of files per destination URI or URI pattern specified in the extract configuration. These values will be in the same order as the URIs specified in the 'destinationUris' field. */ - jobReference?: IJobReference; + destinationUriFileCounts?: Array; /** - * Whether the query result was fetched from the query cache. + * [Output-only] Number of user bytes extracted into the result. This is the byte count as computed by BigQuery for billing purposes. */ - cacheHit?: boolean; + inputBytes?: string; + }; + + type IJobStatus = { /** - * The schema of the results. Present only when the query completes successfully. + * [Output-only] Final error result of the job. If present, indicates that the job has completed and was unsuccessful. */ - schema?: ITableSchema; + errorResult?: IErrorProto; /** - * [Output-only] The first errors or warnings encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful. + * [Output-only] The first errors encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful. */ errors?: Array; /** - * The total number of bytes processed for this query. - */ - totalBytesProcessed?: string; - /** - * [Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. - */ - numDmlAffectedRows?: string; - /** - * Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available. - */ - jobComplete?: boolean; - /** - * The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results. Present only when the query completes successfully. + * [Output-only] Running state of the job. */ - totalRows?: string; + state?: string; }; - type IJobList = { + /** + * Represents a single JSON object. + */ + type IJsonObject = { [key: string]: IJsonValue }; + + type IJsonValue = any; + + type IListModelsResponse = { /** - * A hash of this page of results. + * Models in the requested dataset. Only the following fields are populated: + * model_reference, model_type, creation_time, last_modified_time and + * labels. */ - etag?: string; + models?: Array; /** - * List of jobs that were requested. + * A token to request the next page of results. */ - jobs?: Array<{ - /** - * Job reference uniquely identifying the job. - */ - jobReference?: IJobReference; - /** - * [Full-projection-only] Describes the state of the job. - */ - status?: IJobStatus; - /** - * Running state of the job. When the state is DONE, errorResult can be checked to determine whether the job succeeded or failed. - */ - state?: string; - /** - * [Output-only] Information about the job, including starting time and ending time of the job. - */ - statistics?: IJobStatistics; - /** - * Unique opaque ID of the job. - */ - id?: string; - /** - * [Full-projection-only] Specifies the job configuration. - */ - configuration?: IJobConfiguration; - /** - * [Full-projection-only] Email address of the user who ran the job. - */ - user_email?: string; - /** - * The resource type. - */ - kind?: string; - /** - * A result object that will be present only if the job has failed. - */ - errorResult?: IErrorProto; - }>; + nextPageToken?: string; + }; + + type IListRoutinesResponse = { /** * A token to request the next page of results. */ nextPageToken?: string; /** - * The resource type of the response. + * Routines in the requested dataset. Only the following fields are populated: + * etag, project_id, dataset_id, routine_id, routine_type, creation_time, + * last_modified_time, language. */ - kind?: string; + routines?: Array; }; /** - * Information about a single iteration of the training run. + * BigQuery-specific metadata about a location. This will be set on + * google.cloud.location.Location.metadata in Cloud Location API + * responses. */ - type IIterationResult = { - /** - * Information about top clusters for clustering models. - */ - clusterInfos?: Array; - /** - * Loss computed on the training data at the end of iteration. - */ - trainingLoss?: number; - /** - * Loss computed on the eval data at the end of iteration. - */ - evalLoss?: number; + type ILocationMetadata = { /** - * Index of the iteration, 0 based. + * The legacy BigQuery location ID, e.g. “EU” for the “europe” location. + * This is for any API consumers that need the legacy “US” and “EU” locations. */ - index?: number; + legacyLocationId?: string; + }; + + type IMaterializedViewDefinition = { /** - * Learn rate used for this iteration. + * [Output-only] [TrustedTester] The time when this materialized view was last modified, in milliseconds since the epoch. */ - learnRate?: number; + lastRefreshTime?: string; /** - * Time taken to run the iteration in milliseconds. + * [Required] A query whose result is persisted. */ - durationMs?: string; + query?: string; }; - type ITableDataList = { - /** - * Rows of results. - */ - rows?: Array; + type IModel = { /** - * A token used for paging results. Providing this token instead of the startIndex parameter can help you retrieve stable results when an underlying table is changing. + * Output only. The time when this model was created, in millisecs since the epoch. */ - pageToken?: string; + creationTime?: string; /** - * The resource type of the response. + * Optional. A user-friendly description of this model. */ - kind?: string; + description?: string; /** - * The total number of rows in the complete table. + * Custom encryption configuration (e.g., Cloud KMS keys). This shows the + * encryption configuration of the model data while stored in BigQuery + * storage. */ - totalRows?: string; + encryptionConfiguration?: IEncryptionConfiguration; /** - * A hash of this page of results. + * Output only. A hash of this resource. */ etag?: string; - }; - - type IJobStatistics2 = { /** - * [Output-only] Total number of partitions processed from all partitioned tables referenced in the job. + * Optional. The time when this model expires, in milliseconds since the epoch. + * If not present, the model will persist indefinitely. Expired models + * will be deleted and their storage reclaimed. The defaultTableExpirationMs + * property of the encapsulating dataset can be used to set a default + * expirationTime on newly created models. */ - totalPartitionsProcessed?: string; + expirationTime?: string; /** - * The DDL target table. Present only for CREATE/DROP TABLE/VIEW queries. + * Output only. Input feature columns that were used to train this model. */ - ddlTargetTable?: ITableReference; + featureColumns?: Array; /** - * [Output-only] The schema of the results. Present only for successful dry run of non-legacy SQL queries. + * Optional. A descriptive name for this model. */ - schema?: ITableSchema; + friendlyName?: string; /** - * [Output-only, Beta] Deprecated; do not use. + * Output only. Label columns that were used to train this model. + * The output of the model will have a "predicted_" prefix to these columns. */ - modelTrainingExpectedTotalIteration?: string; + labelColumns?: Array; /** - * [Output-only] The original estimate of bytes processed for the job. + * The labels associated with this model. You can use these to organize + * and group your models. Label keys and values can be no longer + * than 63 characters, can only contain lowercase letters, numeric + * characters, underscores and dashes. International characters are allowed. + * Label values are optional. Label keys must start with a letter and each + * label in the list must have a different key. */ - estimatedBytesProcessed?: string; + labels?: { [key: string]: string }; /** - * [Output-only] Referenced tables for the job. Queries that reference more than 50 tables will not have a complete list. + * Output only. The time when this model was last modified, in millisecs since the epoch. */ - referencedTables?: Array; + lastModifiedTime?: string; /** - * [Output-only, Beta] Deprecated; do not use. + * Output only. The geographic location where the model resides. This value + * is inherited from the dataset. */ - modelTrainingCurrentIteration?: number; + location?: string; /** - * [Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. + * Required. Unique identifier for this model. */ - numDmlAffectedRows?: string; + modelReference?: IModelReference; /** - * [Output-only] Total bytes processed for the job. + * Output only. Type of the model resource. */ - totalBytesProcessed?: string; + modelType?: + | 'MODEL_TYPE_UNSPECIFIED' + | 'LINEAR_REGRESSION' + | 'LOGISTIC_REGRESSION' + | 'KMEANS' + | 'TENSORFLOW'; /** - * [Output-only] Billing tier for the job. + * Output only. Information for all training runs in increasing order of start_time. */ - billingTier?: number; + trainingRuns?: Array; + }; + + type IModelDefinition = { /** - * The DDL operation performed, possibly dependent on the pre-existence of the DDL target. Possible values (new values might be added in the future): "CREATE": The query created the DDL target. "SKIP": No-op. Example cases: the query is CREATE TABLE IF NOT EXISTS while the table already exists, or the query is DROP TABLE IF EXISTS while the table does not exist. "REPLACE": The query replaced the DDL target. Example case: the query is CREATE OR REPLACE TABLE, and the table already exists. "DROP": The query deleted the DDL target. + * [Output-only, Beta] Model options used for the first training run. These options are immutable for subsequent training runs. Default values are used for any options not specified in the input query. */ - ddlOperationPerformed?: string; + modelOptions?: { + labels?: Array; + lossType?: string; + modelType?: string; + }; /** - * The type of query statement, if valid. Possible values (new values might be added in the future): "SELECT": SELECT query. "INSERT": INSERT query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "UPDATE": UPDATE query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "DELETE": DELETE query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "MERGE": MERGE query; see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language. "ALTER_TABLE": ALTER TABLE query. "ALTER_VIEW": ALTER VIEW query. "CREATE_FUNCTION": CREATE FUNCTION query. "CREATE_MODEL": CREATE [OR REPLACE] MODEL ... AS SELECT ... . "CREATE_PROCEDURE": CREATE PROCEDURE query. "CREATE_TABLE": CREATE [OR REPLACE] TABLE without AS SELECT. "CREATE_TABLE_AS_SELECT": CREATE [OR REPLACE] TABLE ... AS SELECT ... . "CREATE_VIEW": CREATE [OR REPLACE] VIEW ... AS SELECT ... . "DROP_FUNCTION" : DROP FUNCTION query. "DROP_PROCEDURE": DROP PROCEDURE query. "DROP_TABLE": DROP TABLE query. "DROP_VIEW": DROP VIEW query. + * [Output-only, Beta] Information about ml training runs, each training run comprises of multiple iterations and there may be multiple training runs for the model if warm start is used or if a user decides to continue a previously cancelled query. */ - statementType?: string; + trainingRuns?: Array; + }; + + type IModelReference = { /** - * [Output-only] Slot-milliseconds for the job. + * [Required] The ID of the dataset containing this model. */ - totalSlotMs?: string; + datasetId?: string; /** - * [Output-only] Total bytes billed for the job. + * [Required] The ID of the model. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. */ - totalBytesBilled?: string; + modelId?: string; /** - * [Output-only] For dry-run jobs, totalBytesProcessed is an estimate and this field specifies the accuracy of the estimate. Possible values can be: UNKNOWN: accuracy of the estimate is unknown. PRECISE: estimate is precise. LOWER_BOUND: estimate is lower bound of what the query would cost. UPPER_BOUND: estimate is upper bound of what the query would cost. + * [Required] The ID of the project containing this model. */ - totalBytesProcessedAccuracy?: string; + projectId?: string; + }; + + /** + * Evaluation metrics for multi-class classification/classifier models. + */ + type IMultiClassClassificationMetrics = { /** - * [Output-only, Beta] Information about create model query job progress. + * Aggregate classification metrics. */ - modelTraining?: IBigQueryModelTraining; + aggregateClassificationMetrics?: IAggregateClassificationMetrics; /** - * [Output-only] Referenced routines (persistent user-defined functions and stored procedures) for the job. + * Confusion matrix at different thresholds. */ - referencedRoutines?: Array; + confusionMatrixList?: Array; + }; + + type IProjectList = { /** - * [Output-only] [Beta] Describes a timeline of job execution. + * A hash of the page of results */ - timeline?: Array; + etag?: string; /** - * [Output-only] Whether the query result was fetched from the query cache. + * The type of list. */ - cacheHit?: boolean; + kind?: string; /** - * [Output-only] Job resource usage breakdown by reservation. + * A token to request the next page of results. */ - reservationUsage?: Array<{ + nextPageToken?: string; + /** + * Projects to which you have at least READ access. + */ + projects?: Array<{ /** - * [Output-only] Slot-milliseconds the job spent in the given reservation. + * A descriptive name for this project. */ - slotMs?: string; + friendlyName?: string; /** - * [Output-only] Reservation name or "unreserved" for on-demand resources usage. + * An opaque ID of this project. */ - name?: string; + id?: string; + /** + * The resource type. + */ + kind?: string; + /** + * The numeric ID of this project. + */ + numericId?: string; + /** + * A unique reference to this project. + */ + projectReference?: IProjectReference; }>; /** - * Standard SQL only: list of undeclared query parameters detected during a dry run validation. - */ - undeclaredQueryParameters?: Array; - /** - * The DDL target routine. Present only for CREATE/DROP FUNCTION/PROCEDURE queries. - */ - ddlTargetRoutine?: IRoutineReference; - /** - * [Output-only] Describes execution plan for the query. + * The total number of projects in the list. */ - queryPlan?: Array; + totalItems?: number; }; - /** - * Representative value of a categorical feature. - */ - type ICategoricalValue = { + type IProjectReference = { /** - * Counts of all categories for the categorical feature. If there are - * more than ten categories, we return top ten (by count) and return - * one more CategoryCount with category "_OTHER_" and count as - * aggregate counts of remaining categories. + * [Required] ID of the project. Can be either the numeric ID or the assigned ID of the project. */ - categoryCounts?: Array; + projectId?: string; }; - type IJobCancelResponse = { + type IQueryParameter = { /** - * The resource type of the response. + * [Optional] If unset, this is a positional parameter. Otherwise, should be unique within a query. */ - kind?: string; + name?: string; /** - * The final state of the job. + * [Required] The type of this parameter. */ - job?: IJob; - }; - - type IProjectReference = { + parameterType?: IQueryParameterType; /** - * [Required] ID of the project. Can be either the numeric ID or the assigned ID of the project. + * [Required] The value of this parameter. */ - projectId?: string; + parameterValue?: IQueryParameterValue; }; - type IQueryResponse = { + type IQueryParameterType = { /** - * An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. + * [Optional] The type of the array's elements, if this is an array. */ - rows?: Array; + arrayType?: IQueryParameterType; /** - * [Output-only] The first errors or warnings encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful. + * [Optional] The types of the fields of this struct, in order, if this is a struct. */ - errors?: Array; + structTypes?: Array<{ + /** + * [Optional] Human-oriented description of the field. + */ + description?: string; + /** + * [Optional] The name of this field. + */ + name?: string; + /** + * [Required] The type of this field. + */ + type?: IQueryParameterType; + }>; /** - * A token used for paging results. + * [Required] The top level type of this field. */ - pageToken?: string; + type?: string; + }; + + type IQueryParameterValue = { /** - * The resource type. + * [Optional] The array values, if this is an array type. */ - kind?: string; + arrayValues?: Array; /** - * Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available. + * [Optional] The struct field values, in order of the struct type's declaration. */ - jobComplete?: boolean; + structValues?: { [key: string]: IQueryParameterValue }; /** - * [Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. + * [Optional] The value of this value, if a simple scalar type. */ - numDmlAffectedRows?: string; + value?: string; + }; + + type IQueryRequest = { /** - * The total number of bytes processed for this query. If this query was a dry run, this is the number of bytes that would be processed if the query were run. + * [Optional] Specifies the default datasetId and projectId to assume for any unqualified table names in the query. If not set, all table names in the query string must be qualified in the format 'datasetId.tableId'. */ - totalBytesProcessed?: string; + defaultDataset?: IDatasetReference; /** - * The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results. + * [Optional] If set to true, BigQuery doesn't run the job. Instead, if the query is valid, BigQuery returns statistics about the job such as how many bytes would be processed. If the query is invalid, an error returns. The default value is false. */ - totalRows?: string; + dryRun?: boolean; /** - * Reference to the Job that was created to run the query. This field will be present even if the original request timed out, in which case GetQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (GetQueryResults). + * The resource type of the request. */ - jobReference?: IJobReference; + kind?: string; /** - * Whether the query result was fetched from the query cache. + * The geographic location where the job should run. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. */ - cacheHit?: boolean; + location?: string; /** - * The schema of the results. Present only when the query completes successfully. + * [Optional] The maximum number of rows of data to return per page of results. Setting this flag to a small value such as 1000 and then paging through results might improve reliability when the query result set is large. In addition to this limit, responses are also limited to 10 MB. By default, there is no maximum row count, and only the byte limit applies. */ - schema?: ITableSchema; - }; - - type IExplainQueryStage = { + maxResults?: number; /** - * Milliseconds the slowest shard spent reading input. + * Standard SQL only. Set to POSITIONAL to use positional (?) query parameters or to NAMED to use named (@myparam) query parameters in this query. */ - readMsMax?: string; + parameterMode?: string; /** - * Total number of bytes written to shuffle. + * [Deprecated] This property is deprecated. */ - shuffleOutputBytes?: string; + preserveNulls?: boolean; /** - * Number of parallel input segments to be processed. + * [Required] A query string, following the BigQuery query syntax, of the query to execute. Example: "SELECT count(f1) FROM [myProjectId:myDatasetId.myTableId]". */ - parallelInputs?: string; + query?: string; /** - * Current status for the stage. + * Query parameters for Standard SQL queries. */ - status?: string; + queryParameters?: Array; /** - * Human-readable name for stage. + * [Optional] How long to wait for the query to complete, in milliseconds, before the request times out and returns. Note that this is only a timeout for the request, not the query. If the query takes longer to run than the timeout value, the call returns without any results and with the 'jobComplete' flag set to false. You can call GetQueryResults() to wait for the query to complete and read the results. The default value is 10000 milliseconds (10 seconds). */ - name?: string; + timeoutMs?: number; /** - * Relative amount of time the slowest shard spent on CPU-bound tasks. + * Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the value of flattenResults is ignored; query will be run as if flattenResults is false. */ - computeRatioMax?: number; + useLegacySql?: boolean; /** - * List of operations within the stage in dependency order (approximately chronological). + * [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. The default value is true. */ - steps?: Array; + useQueryCache?: boolean; + }; + + type IQueryResponse = { /** - * Stage start time represented as milliseconds since epoch. + * Whether the query result was fetched from the query cache. */ - startMs?: string; + cacheHit?: boolean; /** - * Milliseconds the slowest shard spent on writing output. + * [Output-only] The first errors or warnings encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful. */ - writeMsMax?: string; + errors?: Array; /** - * Total number of bytes written to shuffle and spilled to disk. + * Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available. */ - shuffleOutputBytesSpilled?: string; + jobComplete?: boolean; /** - * Milliseconds the average shard spent reading input. + * Reference to the Job that was created to run the query. This field will be present even if the original request timed out, in which case GetQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (GetQueryResults). */ - readMsAvg?: string; + jobReference?: IJobReference; /** - * Milliseconds the average shard spent waiting to be scheduled. + * The resource type. */ - waitMsAvg?: string; + kind?: string; /** - * Number of records read into the stage. + * [Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. */ - recordsRead?: string; + numDmlAffectedRows?: string; /** - * Milliseconds the average shard spent on writing output. + * A token used for paging results. */ - writeMsAvg?: string; + pageToken?: string; /** - * Relative amount of time the slowest shard spent waiting to be scheduled. + * An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. */ - waitRatioMax?: number; + rows?: Array; /** - * Milliseconds the slowest shard spent waiting to be scheduled. + * The schema of the results. Present only when the query completes successfully. */ - waitMsMax?: string; + schema?: ITableSchema; /** - * Relative amount of time the average shard spent on writing output. + * The total number of bytes processed for this query. If this query was a dry run, this is the number of bytes that would be processed if the query were run. */ - writeRatioAvg?: number; + totalBytesProcessed?: string; /** - * Relative amount of time the average shard spent on CPU-bound tasks. + * The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results. */ - computeRatioAvg?: number; + totalRows?: string; + }; + + type IQueryTimelineSample = { /** - * Number of parallel input segments completed. + * Total number of units currently being processed by workers. This does not correspond directly to slot usage. This is the largest value observed since the last sample. */ - completedParallelInputs?: string; + activeUnits?: string; /** - * Relative amount of time the average shard spent waiting to be scheduled. + * Total parallel units of work completed by this query. */ - waitRatioAvg?: number; + completedUnits?: string; /** - * Number of records written by the stage. + * Milliseconds elapsed since the start of query execution. */ - recordsWritten?: string; + elapsedMs?: string; /** - * Relative amount of time the slowest shard spent reading input. - */ - readRatioMax?: number; - /** - * Relative amount of time the average shard spent reading input. - */ - readRatioAvg?: number; - /** - * Unique ID for stage within plan. - */ - id?: string; - /** - * Stage end time represented as milliseconds since epoch. - */ - endMs?: string; - /** - * Relative amount of time the slowest shard spent on writing output. + * Total parallel units of work remaining for the active stages. */ - writeRatioMax?: number; + pendingUnits?: string; /** - * Milliseconds the average shard spent on CPU-bound tasks. + * Cumulative slot-ms consumed by the query. */ - computeMsAvg?: string; + totalSlotMs?: string; + }; + + type IRangePartitioning = { /** - * IDs for stages that are inputs to this stage. + * [TrustedTester] [Required] The table is partitioned by this field. The field must be a top-level NULLABLE/REQUIRED field. The only supported type is INTEGER/INT64. */ - inputStages?: Array; + field?: string; /** - * Milliseconds the slowest shard spent on CPU-bound tasks. + * [TrustedTester] [Required] Defines the ranges for range partitioning. */ - computeMsMax?: string; + range?: { + /** + * [TrustedTester] [Required] The end of range partitioning, exclusive. + */ + end?: string; + /** + * [TrustedTester] [Required] The width of each interval. + */ + interval?: string; + /** + * [TrustedTester] [Required] The start of range partitioning, inclusive. + */ + start?: string; + }; }; - type IJob = { + /** + * Evaluation metrics for regression and explicit feedback type matrix + * factorization models. + */ + type IRegressionMetrics = { /** - * [Output-only] The status of this job. Examine this value when polling an asynchronous job to see if the job is complete. + * Mean absolute error. */ - status?: IJobStatus; + meanAbsoluteError?: number; /** - * [Output-only] Information about the job, including starting time and ending time of the job. + * Mean squared error. */ - statistics?: IJobStatistics; + meanSquaredError?: number; /** - * [Output-only] A URL that can be used to access this resource again. + * Mean squared log error. */ - selfLink?: string; + meanSquaredLogError?: number; /** - * [Output-only] Opaque ID field of the job + * Median absolute error. */ - id?: string; + medianAbsoluteError?: number; /** - * [Required] Describes the job configuration. + * R^2 score. */ - configuration?: IJobConfiguration; + rSquared?: number; + }; + + /** + * A user-defined function or a stored procedure. + */ + type IRoutine = { /** - * [Output-only] Email address of the user who ran the job. + * Optional. */ - user_email?: string; + arguments?: Array; /** - * [Output-only] The type of the resource. + * Output only. The time when this routine was created, in milliseconds since + * the epoch. */ - kind?: string; + creationTime?: string; /** - * [Output-only] A hash of this resource. + * Required. The body of the routine. + * + * For functions, this is the expression in the AS clause. + * + * If language=SQL, it is the substring inside (but excluding) the + * parentheses. For example, for the function created with the following + * statement: + * + * `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` + * + * The definition_body is `concat(x, "\n", y)` (\n is not replaced with + * linebreak). + * + * If language=JAVASCRIPT, it is the evaluated string in the AS clause. + * For example, for the function created with the following statement: + * + * `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` + * + * The definition_body is + * + * `return "\n";\n` + * + * Note that both \n are replaced with linebreaks. */ - etag?: string; + definitionBody?: string; /** - * [Optional] Reference describing the unique-per-user name of the job. + * Optional. [Experimental] The description of the routine if defined. */ - jobReference?: IJobReference; - }; - - type IEncryptionConfiguration = { + description?: string; /** - * [Optional] Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. The BigQuery Service Account associated with your project requires access to this encryption key. + * Output only. A hash of this resource. */ - kmsKeyName?: string; - }; - - type IBigtableOptions = { + etag?: string; /** - * [Optional] If field is true, then the rowkey column families will be read and converted to string. Otherwise they are read with BYTES type values and users need to manually cast them with CAST if necessary. The default value is false. + * Optional. If language = "JAVASCRIPT", this field stores the path of the + * imported JAVASCRIPT libraries. */ - readRowkeyAsString?: boolean; + importedLibraries?: Array; /** - * [Optional] List of column families to expose in the table schema along with their types. This list restricts the column families that can be referenced in queries and specifies their value types. You can use this list to do type conversions - see the 'type' field for more details. If you leave this list empty, all column families are present in the table schema and their values are read as BYTES. During a query only the column families referenced in that query are read from Bigtable. + * Optional. Defaults to "SQL". */ - columnFamilies?: Array; + language?: 'LANGUAGE_UNSPECIFIED' | 'SQL' | 'JAVASCRIPT'; /** - * [Optional] If field is true, then the column families that are not specified in columnFamilies list are not exposed in the table schema. Otherwise, they are read with BYTES type values. The default value is false. + * Output only. The time when this routine was last modified, in milliseconds + * since the epoch. */ - ignoreUnspecifiedColumnFamilies?: boolean; - }; - - type ITableSchema = { + lastModifiedTime?: string; /** - * Describes the fields in a table. + * Optional if language = "SQL"; required otherwise. + * + * If absent, the return type is inferred from definition_body at query time + * in each query that references this routine. If present, then the evaluated + * result will be cast to the specified returned type at query time. + * + * For example, for the functions created with the following statements: + * + * * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` + * + * * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` + * + * * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` + * + * The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and + * is absent for `Increment` (inferred as FLOAT64 at query time). + * + * Suppose the function `Add` is replaced by + * `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` + * + * Then the inferred return type of `Increment` is automatically changed to + * INT64 at query time, while the return type of `Decrement` remains FLOAT64. */ - fields?: Array; - }; - - type IListRoutinesResponse = { + returnType?: IStandardSqlDataType; /** - * Routines in the requested dataset. Only the following fields are populated: - * etag, project_id, dataset_id, routine_id, routine_type, creation_time, - * last_modified_time, language. + * Required. Reference describing the ID of this routine. */ - routines?: Array; + routineReference?: IRoutineReference; /** - * A token to request the next page of results. + * Required. The type of routine. */ - nextPageToken?: string; + routineType?: 'ROUTINE_TYPE_UNSPECIFIED' | 'SCALAR_FUNCTION' | 'PROCEDURE'; }; - type IDestinationTableProperties = { + type IRoutineReference = { /** - * [Optional] The friendly name for the destination table. This will only be used if the destination table is newly created. If the table already exists and a value different than the current friendly name is provided, the job will fail. + * [Required] The ID of the dataset containing this routine. */ - friendlyName?: string; + datasetId?: string; /** - * [Optional] The description for the destination table. This will only be used if the destination table is newly created. If the table already exists and a value different than the current description is provided, the job will fail. + * [Required] The ID of the project containing this routine. */ - description?: string; + projectId?: string; /** - * [Optional] The labels associated with this table. You can use these to organize and group your tables. This will only be used if the destination table is newly created. If the table already exists and labels are different than the current labels are provided, the job will fail. + * [Required] The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters. */ - labels?: { [key: string]: string }; + routineId?: string; }; - type ITrainingOptions = { - /** - * Optimization strategy for training linear regression models. - */ - optimizationStrategy?: - | 'OPTIMIZATION_STRATEGY_UNSPECIFIED' - | 'BATCH_GRADIENT_DESCENT' - | 'NORMAL_EQUATION'; - /** - * Learning rate in training. Used only for iterative training algorithms. - */ - learnRate?: number; - /** - * The column to split data with. This column won't be used as a - * feature. - * 1. When data_split_method is CUSTOM, the corresponding column should - * be boolean. The rows with true value tag are eval data, and the false - * are training data. - * 2. When data_split_method is SEQ, the first DATA_SPLIT_EVAL_FRACTION - * rows (from smallest to largest) in the corresponding column are used - * as training data, and the rest are eval data. It respects the order - * in Orderable data types: - * https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#data-type-properties - */ - dataSplitColumn?: string; - /** - * The maximum number of iterations in training. Used only for iterative - * training algorithms. - */ - maxIterations?: string; - /** - * Weights associated with each label class, for rebalancing the - * training data. Only applicable for classification models. - */ - labelClassWeights?: { [key: string]: number }; - /** - * L2 regularization coefficient. - */ - l2Regularization?: number; - /** - * Whether to stop early when the loss doesn't improve significantly - * any more (compared to min_relative_progress). Used only for iterative - * training algorithms. - */ - earlyStop?: boolean; + /** + * A single row in the confusion matrix. + */ + type IRow = { /** - * The fraction of evaluation data over the whole input data. The rest - * of data will be used as training data. The format should be double. - * Accurate to two decimal places. - * Default value is 0.2. + * The original label of this row. */ - dataSplitEvalFraction?: number; + actualLabel?: string; /** - * [Beta] Google Cloud Storage URI from which the model was imported. Only - * applicable for imported models. + * Info describing predicted label distribution. */ - modelUri?: string; + entries?: Array; + }; + + /** + * The type of a variable, e.g., a function argument. + * Examples: + * INT64: {type_kind="INT64"} + * ARRAY: {type_kind="ARRAY", array_element_type="STRING"} + * STRUCT>: + * {type_kind="STRUCT", + * struct_type={fields=[ + * {name="x", type={type_kind="STRING"}}, + * {name="y", type={type_kind="ARRAY", array_element_type="DATE"}} + * ]}} + */ + type IStandardSqlDataType = { /** - * When early_stop is true, stops training when accuracy improvement is - * less than 'min_relative_progress'. Used only for iterative training - * algorithms. + * The type of the array's elements, if type_kind = "ARRAY". */ - minRelativeProgress?: number; + arrayElementType?: IStandardSqlDataType; /** - * Specifies the initial learning rate for the line search learn rate - * strategy. + * The fields of this struct, in order, if type_kind = "STRUCT". */ - initialLearnRate?: number; + structType?: IStandardSqlStructType; /** - * The column used to provide the initial centroids for kmeans algorithm - * when kmeans_initialization_method is CUSTOM. + * Required. The top level type of this field. + * Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY"). */ - kmeansInitializationColumn?: string; + typeKind?: + | 'TYPE_KIND_UNSPECIFIED' + | 'INT64' + | 'BOOL' + | 'FLOAT64' + | 'STRING' + | 'BYTES' + | 'TIMESTAMP' + | 'DATE' + | 'TIME' + | 'DATETIME' + | 'GEOGRAPHY' + | 'NUMERIC' + | 'ARRAY' + | 'STRUCT'; + }; + + /** + * A field or a column. + */ + type IStandardSqlField = { /** - * Name of input label columns in training data. + * Optional. The name of this field. Can be absent for struct fields. */ - inputLabelColumns?: Array; + name?: string; /** - * Number of clusters for clustering models. + * Optional. The type of this parameter. Absent if not explicitly + * specified (e.g., CREATE FUNCTION statement can omit the return type; + * in this case the output parameter does not have this "type" field). */ - numClusters?: string; + type?: IStandardSqlDataType; + }; + + type IStandardSqlStructType = { fields?: Array }; + + type IStreamingbuffer = { /** - * Whether to train a model from the last checkpoint. + * [Output-only] A lower-bound estimate of the number of bytes currently in the streaming buffer. */ - warmStart?: boolean; + estimatedBytes?: string; /** - * The strategy to determine learn rate for the current iteration. + * [Output-only] A lower-bound estimate of the number of rows currently in the streaming buffer. */ - learnRateStrategy?: - | 'LEARN_RATE_STRATEGY_UNSPECIFIED' - | 'LINE_SEARCH' - | 'CONSTANT'; + estimatedRows?: string; /** - * The data split type for training and evaluation, e.g. RANDOM. + * [Output-only] Contains the timestamp of the oldest entry in the streaming buffer, in milliseconds since the epoch, if the streaming buffer is available. */ - dataSplitMethod?: - | 'DATA_SPLIT_METHOD_UNSPECIFIED' - | 'RANDOM' - | 'CUSTOM' - | 'SEQUENTIAL' - | 'NO_SPLIT' - | 'AUTO_SPLIT'; + oldestEntryTime?: string; + }; + + type ITable = { /** - * Type of loss function used during training run. + * [Beta] Clustering specification for the table. Must be specified with partitioning, data in the table will be first partitioned and subsequently clustered. */ - lossType?: 'LOSS_TYPE_UNSPECIFIED' | 'MEAN_SQUARED_LOSS' | 'MEAN_LOG_LOSS'; + clustering?: IClustering; /** - * L1 regularization coefficient. + * [Output-only] The time when this table was created, in milliseconds since the epoch. */ - l1Regularization?: number; + creationTime?: string; /** - * The method used to initialize the centroids for kmeans algorithm. + * [Optional] A user-friendly description of this table. */ - kmeansInitializationMethod?: - | 'KMEANS_INITIALIZATION_METHOD_UNSPECIFIED' - | 'RANDOM' - | 'CUSTOM'; + description?: string; /** - * Distance type for clustering models. + * Custom encryption configuration (e.g., Cloud KMS keys). */ - distanceType?: 'DISTANCE_TYPE_UNSPECIFIED' | 'EUCLIDEAN' | 'COSINE'; - }; - - /** - * Information about a single training query run for the model. - */ - type ITrainingRun = { + encryptionConfiguration?: IEncryptionConfiguration; /** - * The start time of this training run. + * [Output-only] A hash of the table metadata. Used to ensure there were no concurrent modifications to the resource when attempting an update. Not guaranteed to change when the table contents or the fields numRows, numBytes, numLongTermBytes or lastModifiedTime change. */ - startTime?: string; + etag?: string; /** - * Output of each iteration run, results.size() <= max_iterations. + * [Optional] The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. The defaultTableExpirationMs property of the encapsulating dataset can be used to set a default expirationTime on newly created tables. */ - results?: Array; + expirationTime?: string; /** - * The evaluation metrics over training/eval data that were computed at the - * end of training. + * [Optional] Describes the data format, location, and other properties of a table stored outside of BigQuery. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. */ - evaluationMetrics?: IEvaluationMetrics; + externalDataConfiguration?: IExternalDataConfiguration; /** - * Options that were used for this training run, includes - * user specified and default options that were used. + * [Optional] A descriptive name for this table. */ - trainingOptions?: ITrainingOptions; - }; - - /** - * A user-defined function or a stored procedure. - */ - type IRoutine = { + friendlyName?: string; /** - * Optional if language = "SQL"; required otherwise. - * - * If absent, the return type is inferred from definition_body at query time - * in each query that references this routine. If present, then the evaluated - * result will be cast to the specified returned type at query time. - * - * For example, for the functions created with the following statements: - * - * * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` - * - * * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` - * - * * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` - * - * The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and - * is absent for `Increment` (inferred as FLOAT64 at query time). - * - * Suppose the function `Add` is replaced by - * `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` - * - * Then the inferred return type of `Increment` is automatically changed to - * INT64 at query time, while the return type of `Decrement` remains FLOAT64. + * [Output-only] An opaque ID uniquely identifying the table. */ - returnType?: IStandardSqlDataType; + id?: string; /** - * Optional. Defaults to "SQL". + * [Output-only] The type of the resource. */ - language?: 'LANGUAGE_UNSPECIFIED' | 'SQL' | 'JAVASCRIPT'; + kind?: string; /** - * Output only. The time when this routine was last modified, in milliseconds - * since the epoch. + * The labels associated with this table. You can use these to organize and group your tables. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. */ - lastModifiedTime?: string; + labels?: { [key: string]: string }; /** - * Required. The body of the routine. - * - * For functions, this is the expression in the AS clause. - * - * If language=SQL, it is the substring inside (but excluding) the - * parentheses. For example, for the function created with the following - * statement: - * - * `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` - * - * The definition_body is `concat(x, "\n", y)` (\n is not replaced with - * linebreak). - * - * If language=JAVASCRIPT, it is the evaluated string in the AS clause. - * For example, for the function created with the following statement: - * - * `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` - * - * The definition_body is - * - * `return "\n";\n` - * - * Note that both \n are replaced with linebreaks. + * [Output-only] The time when this table was last modified, in milliseconds since the epoch. */ - definitionBody?: string; + lastModifiedTime?: string; /** - * Output only. A hash of this resource. + * [Output-only] The geographic location where the table resides. This value is inherited from the dataset. */ - etag?: string; + location?: string; /** - * Output only. The time when this routine was created, in milliseconds since - * the epoch. + * [Optional] Materialized view definition. */ - creationTime?: string; + materializedView?: IMaterializedViewDefinition; /** - * Required. + * [Output-only, Beta] Present iff this table represents a ML model. Describes the training information for the model, and it is required to run 'PREDICT' queries. */ - routineType?: 'ROUTINE_TYPE_UNSPECIFIED' | 'SCALAR_FUNCTION' | 'PROCEDURE'; + model?: IModelDefinition; /** - * Required. Reference describing the ID of this routine. + * [Output-only] The size of this table in bytes, excluding any data in the streaming buffer. */ - routineReference?: IRoutineReference; + numBytes?: string; /** - * Optional. + * [Output-only] The number of bytes in the table that are considered "long-term storage". */ - arguments?: Array; + numLongTermBytes?: string; /** - * Optional. If language = "JAVASCRIPT", this field stores the path of the - * imported JAVASCRIPT libraries. + * [Output-only] [TrustedTester] The physical size of this table in bytes, excluding any data in the streaming buffer. This includes compression and storage used for time travel. */ - importedLibraries?: Array; - }; - - type IJobConfiguration = { + numPhysicalBytes?: string; /** - * [Pick one] Copies a table. + * [Output-only] The number of rows of data in this table, excluding any data in the streaming buffer. */ - copy?: IJobConfigurationTableCopy; + numRows?: string; /** - * [Optional] Job timeout in milliseconds. If this time limit is exceeded, BigQuery may attempt to terminate the job. + * [TrustedTester] Range partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. */ - jobTimeoutMs?: string; + rangePartitioning?: IRangePartitioning; /** - * [Pick one] Configures a query job. + * [Beta] [Optional] If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified. */ - query?: IJobConfigurationQuery; + requirePartitionFilter?: boolean; /** - * [Pick one] Configures a load job. + * [Optional] Describes the schema of this table. */ - load?: IJobConfigurationLoad; + schema?: ITableSchema; /** - * The labels associated with this job. You can use these to organize and group your jobs. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. + * [Output-only] A URL that can be used to access this resource again. */ - labels?: { [key: string]: string }; + selfLink?: string; /** - * [Optional] If set, don't actually run this job. A valid query will return a mostly empty response with some processing statistics, while an invalid query will return the same error it would if it wasn't a dry run. Behavior of non-query jobs is undefined. + * [Output-only] Contains information regarding this table's streaming buffer, if one is present. This field will be absent if the table is not being streamed to or if there is no data in the streaming buffer. */ - dryRun?: boolean; + streamingBuffer?: IStreamingbuffer; /** - * [Output-only] The type of the job. Can be QUERY, LOAD, EXTRACT, COPY or UNKNOWN. + * [Required] Reference describing the ID of this table. */ - jobType?: string; + tableReference?: ITableReference; /** - * [Pick one] Configures an extract job. + * Time-based partitioning specification for this table. Only one of timePartitioning and rangePartitioning should be specified. */ - extract?: IJobConfigurationExtract; - }; - - type IUserDefinedFunctionResource = { + timePartitioning?: ITimePartitioning; /** - * [Pick one] A code resource to load from a Google Cloud Storage URI (gs://bucket/path). + * [Output-only] Describes the table type. The following values are supported: TABLE: A normal BigQuery table. VIEW: A virtual table defined by a SQL query. [TrustedTester] MATERIALIZED_VIEW: SQL query whose result is persisted. EXTERNAL: A table that references data stored in an external storage system, such as Google Cloud Storage. The default value is TABLE. */ - resourceUri?: string; + type?: string; /** - * [Pick one] An inline resource that contains code for a user-defined function (UDF). Providing a inline code resource is equivalent to providing a URI for a file containing the same code. + * [Optional] The view definition. */ - inlineCode?: string; + view?: IViewDefinition; }; - /** - * Represents a single JSON object. - */ - type IJsonObject = { [key: string]: IJsonValue }; + type ITableCell = { v?: any }; - /** - * Aggregate metrics for classification/classifier models. For multi-class - * models, the metrics are either macro-averaged or micro-averaged. When - * macro-averaged, the metrics are calculated for each label and then an - * unweighted average is taken of those values. When micro-averaged, the - * metric is calculated globally by counting the total number of correctly - * predicted rows. - */ - type IAggregateClassificationMetrics = { + type ITableDataInsertAllRequest = { /** - * Accuracy is the fraction of predictions given the correct label. For - * multiclass this is a micro-averaged metric. + * [Optional] Accept rows that contain values that do not match the schema. The unknown values are ignored. Default is false, which treats unknown values as errors. */ - accuracy?: number; + ignoreUnknownValues?: boolean; /** - * Recall is the fraction of actual positive labels that were given a - * positive prediction. For multiclass this is a macro-averaged metric. + * The resource type of the response. */ - recall?: number; + kind?: string; /** - * Threshold at which the metrics are computed. For binary - * classification models this is the positive class threshold. - * For multi-class classfication models this is the confidence - * threshold. + * The rows to insert. */ - threshold?: number; + rows?: Array<{ + /** + * [Optional] A unique ID for each row. BigQuery uses this property to detect duplicate insertion requests on a best-effort basis. + */ + insertId?: string; + /** + * [Required] A JSON object that contains a row of data. The object's properties and values must match the destination table's schema. + */ + json?: IJsonObject; + }>; /** - * Area Under a ROC Curve. For multiclass this is a macro-averaged - * metric. + * [Optional] Insert all valid rows of a request, even if invalid rows exist. The default value is false, which causes the entire request to fail if any invalid rows exist. */ - rocAuc?: number; + skipInvalidRows?: boolean; /** - * Logarithmic Loss. For multiclass this is a macro-averaged metric. + * If specified, treats the destination table as a base template, and inserts the rows into an instance table named "{destination}{templateSuffix}". BigQuery will manage creation of the instance table, using the schema of the base template table. See https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables for considerations when working with templates tables. */ - logLoss?: number; + templateSuffix?: string; + }; + + type ITableDataInsertAllResponse = { /** - * The F1 score is an average of recall and precision. For multiclass - * this is a macro-averaged metric. + * An array of errors for rows that were not inserted. */ - f1Score?: number; + insertErrors?: Array<{ + /** + * Error information for the row indicated by the index property. + */ + errors?: Array; + /** + * The index of the row that error applies to. + */ + index?: number; + }>; /** - * Precision is the fraction of actual positive predictions that had - * positive actual labels. For multiclass this is a macro-averaged - * metric treating each class as a binary classifier. + * The resource type of the response. */ - precision?: number; + kind?: string; }; - type IExplainQueryStep = { + type ITableDataList = { /** - * Human-readable stage descriptions. + * A hash of this page of results. */ - substeps?: Array; + etag?: string; /** - * Machine-readable operation type. + * The resource type of the response. */ kind?: string; + /** + * A token used for paging results. Providing this token instead of the startIndex parameter can help you retrieve stable results when an underlying table is changing. + */ + pageToken?: string; + /** + * Rows of results. + */ + rows?: Array; + /** + * The total number of rows in the complete table. + */ + totalRows?: string; }; - /** - * Input/output argument of a function or a stored procedure. - */ - type IArgument = { + type ITableFieldSchema = { /** - * Optional. Defaults to FIXED_TYPE. + * [Optional] The categories attached to this field, used for field-level access control. */ - argumentKind?: 'ARGUMENT_KIND_UNSPECIFIED' | 'FIXED_TYPE' | 'ANY_TYPE'; + categories?: { + /** + * A list of category resource names. For example, "projects/1/taxonomies/2/categories/3". At most 5 categories are allowed. + */ + names?: Array; + }; /** - * Optional. Specifies whether the argument is input or output. - * Can be set for procedures only. + * [Optional] The field description. The maximum length is 1,024 characters. */ - mode?: 'MODE_UNSPECIFIED' | 'IN' | 'OUT' | 'INOUT'; + description?: string; /** - * Required unless argument_kind = ANY_TYPE. + * [Optional] Describes the nested schema fields if the type property is set to RECORD. */ - dataType?: IStandardSqlDataType; + fields?: Array; /** - * Optional. The name of this argument. Can be absent for function return - * argument. + * [Optional] The field mode. Possible values include NULLABLE, REQUIRED and REPEATED. The default value is NULLABLE. */ - name?: string; - }; - - type IQueryParameter = { + mode?: string; /** - * [Optional] If unset, this is a positional parameter. Otherwise, should be unique within a query. + * [Required] The field name. The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter or underscore. The maximum length is 128 characters. */ name?: string; /** - * [Required] The type of this parameter. - */ - parameterType?: IQueryParameterType; - /** - * [Required] The value of this parameter. + * [Required] The field data type. Possible values include STRING, BYTES, INTEGER, INT64 (same as INTEGER), FLOAT, FLOAT64 (same as FLOAT), BOOLEAN, BOOL (same as BOOLEAN), TIMESTAMP, DATE, TIME, DATETIME, RECORD (where RECORD indicates that the field contains a nested schema) or STRUCT (same as RECORD). */ - parameterValue?: IQueryParameterValue; + type?: string; }; - type IDatasetList = { + type ITableList = { /** - * The list type. This property always returns the value "bigquery#datasetList". + * A hash of this page of results. + */ + etag?: string; + /** + * The type of list. */ kind?: string; /** - * A hash value of the results page. You can use this property to determine if the page has changed since the last request. + * A token to request the next page of results. */ - etag?: string; + nextPageToken?: string; /** - * An array of the dataset resources in the project. Each resource contains basic information. For full information about a particular dataset resource, use the Datasets: get method. This property is omitted when there are no datasets in the project. + * Tables in the requested dataset. */ - datasets?: Array<{ + tables?: Array<{ /** - * The geographic location where the data resides. + * [Beta] Clustering specification for this table, if configured. */ - location?: string; + clustering?: IClustering; /** - * A descriptive name for the dataset, if one exists. + * The time when this table was created, in milliseconds since the epoch. + */ + creationTime?: string; + /** + * [Optional] The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. + */ + expirationTime?: string; + /** + * The user-friendly name for this table. */ friendlyName?: string; /** - * The resource type. This property always returns the value "bigquery#dataset". + * An opaque ID of the table + */ + id?: string; + /** + * The resource type. */ kind?: string; /** - * The labels associated with this dataset. You can use these to organize and group your datasets. + * The labels associated with this table. You can use these to organize and group your tables. */ labels?: { [key: string]: string }; /** - * The dataset reference. Use this property to access specific parts of the dataset's ID, such as project ID or dataset ID. + * A reference uniquely identifying the table. */ - datasetReference?: IDatasetReference; + tableReference?: ITableReference; /** - * The fully-qualified, unique, opaque ID of the dataset. + * The time-based partitioning specification for this table, if configured. */ - id?: string; + timePartitioning?: ITimePartitioning; + /** + * The type of table. Possible values are: TABLE, VIEW. + */ + type?: string; + /** + * Additional details for a view. + */ + view?: { + /** + * True if view is defined in legacy SQL dialect, false if in standard SQL. + */ + useLegacySql?: boolean; + }; }>; /** - * A token that can be used to request the next results page. This property is omitted on the final results page. + * The total number of tables in the dataset. */ - nextPageToken?: string; + totalItems?: number; }; - type IJobConfigurationTableCopy = { - /** - * [Pick one] Source table to copy. - */ - sourceTable?: ITableReference; - /** - * [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. - */ - writeDisposition?: string; + type ITableReference = { /** - * [Required] The destination table + * [Required] The ID of the dataset containing this table. */ - destinationTable?: ITableReference; + datasetId?: string; /** - * Custom encryption configuration (e.g., Cloud KMS keys). + * [Required] The ID of the project containing this table. */ - destinationEncryptionConfiguration?: IEncryptionConfiguration; + projectId?: string; /** - * [Pick one] Source tables to copy. + * [Required] The ID of the table. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. */ - sourceTables?: Array; + tableId?: string; + }; + + type ITableRow = { /** - * [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. + * Represents a single row in the result set, consisting of one or more fields. */ - createDisposition?: string; + f?: Array; }; - /** - * Confusion matrix for binary classification models. - */ - type IBinaryConfusionMatrix = { + type ITableSchema = { /** - * Threshold value used when computing each of the following metric. + * Describes the fields in a table. */ - positiveClassThreshold?: number; + fields?: Array; + }; + + type ITimePartitioning = { /** - * The fraction of predictions given the correct label. + * [Optional] Number of milliseconds for which to keep the storage for partitions in the table. The storage in a partition will have an expiration time of its partition time plus this value. */ - accuracy?: number; + expirationMs?: string; /** - * Number of true samples predicted as true. + * [Beta] [Optional] If not set, the table is partitioned by pseudo column, referenced via either '_PARTITIONTIME' as TIMESTAMP type, or '_PARTITIONDATE' as DATE type. If field is specified, the table is instead partitioned by this field. The field must be a top-level TIMESTAMP or DATE field. Its mode must be NULLABLE or REQUIRED. */ - truePositives?: string; + field?: string; + requirePartitionFilter?: boolean; /** - * The fraction of actual positive labels that were given a positive - * prediction. + * [Required] The only type supported is DAY, which will generate one partition per day. */ - recall?: number; + type?: string; + }; + + type ITrainingOptions = { /** - * Number of false samples predicted as false. + * The column to split data with. This column won't be used as a + * feature. + * 1. When data_split_method is CUSTOM, the corresponding column should + * be boolean. The rows with true value tag are eval data, and the false + * are training data. + * 2. When data_split_method is SEQ, the first DATA_SPLIT_EVAL_FRACTION + * rows (from smallest to largest) in the corresponding column are used + * as training data, and the rest are eval data. It respects the order + * in Orderable data types: + * https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#data-type-properties */ - falseNegatives?: string; + dataSplitColumn?: string; /** - * Number of false samples predicted as true. + * The fraction of evaluation data over the whole input data. The rest + * of data will be used as training data. The format should be double. + * Accurate to two decimal places. + * Default value is 0.2. */ - falsePositives?: string; + dataSplitEvalFraction?: number; /** - * Number of true samples predicted as false. + * The data split type for training and evaluation, e.g. RANDOM. */ - trueNegatives?: string; + dataSplitMethod?: + | 'DATA_SPLIT_METHOD_UNSPECIFIED' + | 'RANDOM' + | 'CUSTOM' + | 'SEQUENTIAL' + | 'NO_SPLIT' + | 'AUTO_SPLIT'; /** - * The equally weighted average of recall and precision. + * Distance type for clustering models. */ - f1Score?: number; + distanceType?: 'DISTANCE_TYPE_UNSPECIFIED' | 'EUCLIDEAN' | 'COSINE'; /** - * The fraction of actual positive predictions that had positive actual - * labels. + * Whether to stop early when the loss doesn't improve significantly + * any more (compared to min_relative_progress). Used only for iterative + * training algorithms. */ - precision?: number; - }; - - type ITableRow = { + earlyStop?: boolean; /** - * Represents a single row in the result set, consisting of one or more fields. + * Specifies the initial learning rate for the line search learn rate + * strategy. */ - f?: Array; - }; - - type IQueryTimelineSample = { + initialLearnRate?: number; /** - * Total number of units currently being processed by workers. This does not correspond directly to slot usage. This is the largest value observed since the last sample. + * Name of input label columns in training data. */ - activeUnits?: string; + inputLabelColumns?: Array; /** - * Total parallel units of work completed by this query. + * The column used to provide the initial centroids for kmeans algorithm + * when kmeans_initialization_method is CUSTOM. */ - completedUnits?: string; + kmeansInitializationColumn?: string; /** - * Milliseconds elapsed since the start of query execution. + * The method used to initialize the centroids for kmeans algorithm. */ - elapsedMs?: string; + kmeansInitializationMethod?: + | 'KMEANS_INITIALIZATION_METHOD_UNSPECIFIED' + | 'RANDOM' + | 'CUSTOM'; /** - * Total parallel units of work remaining for the active stages. + * L1 regularization coefficient. */ - pendingUnits?: string; + l1Regularization?: number; /** - * Cumulative slot-ms consumed by the query. + * L2 regularization coefficient. */ - totalSlotMs?: string; - }; - - /** - * Evaluation metrics for multi-class classification/classifier models. - */ - type IMultiClassClassificationMetrics = { + l2Regularization?: number; /** - * Aggregate classification metrics. + * Weights associated with each label class, for rebalancing the + * training data. Only applicable for classification models. */ - aggregateClassificationMetrics?: IAggregateClassificationMetrics; + labelClassWeights?: { [key: string]: number }; /** - * Confusion matrix at different thresholds. + * Learning rate in training. Used only for iterative training algorithms. */ - confusionMatrixList?: Array; - }; - - type IQueryRequest = { + learnRate?: number; /** - * The geographic location where the job should run. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. + * The strategy to determine learn rate for the current iteration. */ - location?: string; + learnRateStrategy?: + | 'LEARN_RATE_STRATEGY_UNSPECIFIED' + | 'LINE_SEARCH' + | 'CONSTANT'; /** - * [Deprecated] This property is deprecated. + * Type of loss function used during training run. */ - preserveNulls?: boolean; + lossType?: 'LOSS_TYPE_UNSPECIFIED' | 'MEAN_SQUARED_LOSS' | 'MEAN_LOG_LOSS'; /** - * [Optional] The maximum number of rows of data to return per page of results. Setting this flag to a small value such as 1000 and then paging through results might improve reliability when the query result set is large. In addition to this limit, responses are also limited to 10 MB. By default, there is no maximum row count, and only the byte limit applies. + * The maximum number of iterations in training. Used only for iterative + * training algorithms. */ - maxResults?: number; + maxIterations?: string; /** - * [Required] A query string, following the BigQuery query syntax, of the query to execute. Example: "SELECT count(f1) FROM [myProjectId:myDatasetId.myTableId]". + * When early_stop is true, stops training when accuracy improvement is + * less than 'min_relative_progress'. Used only for iterative training + * algorithms. */ - query?: string; + minRelativeProgress?: number; /** - * [Optional] If set to true, BigQuery doesn't run the job. Instead, if the query is valid, BigQuery returns statistics about the job such as how many bytes would be processed. If the query is invalid, an error returns. The default value is false. + * [Beta] Google Cloud Storage URI from which the model was imported. Only + * applicable for imported models. */ - dryRun?: boolean; + modelUri?: string; /** - * Query parameters for Standard SQL queries. + * Number of clusters for clustering models. */ - queryParameters?: Array; + numClusters?: string; /** - * Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the value of flattenResults is ignored; query will be run as if flattenResults is false. + * Optimization strategy for training linear regression models. */ - useLegacySql?: boolean; + optimizationStrategy?: + | 'OPTIMIZATION_STRATEGY_UNSPECIFIED' + | 'BATCH_GRADIENT_DESCENT' + | 'NORMAL_EQUATION'; /** - * [Optional] How long to wait for the query to complete, in milliseconds, before the request times out and returns. Note that this is only a timeout for the request, not the query. If the query takes longer to run than the timeout value, the call returns without any results and with the 'jobComplete' flag set to false. You can call GetQueryResults() to wait for the query to complete and read the results. The default value is 10000 milliseconds (10 seconds). + * Whether to train a model from the last checkpoint. */ - timeoutMs?: number; + warmStart?: boolean; + }; + + /** + * Information about a single training query run for the model. + */ + type ITrainingRun = { /** - * The resource type of the request. + * The evaluation metrics over training/eval data that were computed at the + * end of training. */ - kind?: string; + evaluationMetrics?: IEvaluationMetrics; /** - * Standard SQL only. Set to POSITIONAL to use positional (?) query parameters or to NAMED to use named (@myparam) query parameters in this query. + * Output of each iteration run, results.size() <= max_iterations. */ - parameterMode?: string; + results?: Array; /** - * [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. The default value is true. + * The start time of this training run. */ - useQueryCache?: boolean; + startTime?: string; /** - * [Optional] Specifies the default datasetId and projectId to assume for any unqualified table names in the query. If not set, all table names in the query string must be qualified in the format 'datasetId.tableId'. + * Options that were used for this training run, includes + * user specified and default options that were used. */ - defaultDataset?: IDatasetReference; + trainingOptions?: ITrainingOptions; }; - type IErrorProto = { + type IUserDefinedFunctionResource = { /** - * A human-readable description of the error. + * [Pick one] An inline resource that contains code for a user-defined function (UDF). Providing a inline code resource is equivalent to providing a URI for a file containing the same code. */ - message?: string; + inlineCode?: string; /** - * Specifies where the error occurred, if present. + * [Pick one] A code resource to load from a Google Cloud Storage URI (gs://bucket/path). */ - location?: string; + resourceUri?: string; + }; + + type IViewDefinition = { /** - * Debugging information. This property is internal to Google and should not be used. + * [Required] A query that BigQuery executes when the view is referenced. */ - debugInfo?: string; + query?: string; /** - * A short error code that summarizes the error. + * Specifies whether to use BigQuery's legacy SQL for this view. The default value is true. If set to false, the view will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ Queries and views that reference this view must use the same flag value. */ - reason?: string; + useLegacySql?: boolean; + /** + * Describes user-defined function resources used in the query. + */ + userDefinedFunctionResources?: Array; }; - namespace tabledata { + namespace datasets { /** - * Retrieves table data from a specified set of rows. Requires the READER dataset role. + * Deletes the dataset specified by the datasetId value. Before you can delete a dataset, you must delete all its tables, either manually or by specifying deleteContents. Immediately after deletion, you can create another dataset with the same name. */ - type IListParams = { - /** - * List of fields to return (comma-separated). If unspecified, all fields are returned - */ - selectedFields?: string; - /** - * Zero-based index of the starting row to read - */ - startIndex?: string; - /** - * Page token, returned by a previous call, identifying the result set - */ - pageToken?: string; + type IDeleteParams = { /** - * Maximum number of results to return + * If True, delete all the tables in the dataset. If False and the dataset contains tables, the request will fail. Default is False */ - maxResults?: number; + deleteContents?: boolean; }; - } - namespace tables { /** - * Lists all tables in the specified dataset. Requires the READER dataset role. + * Lists all datasets in the specified project to which you have been granted the READER dataset role. */ type IListParams = { /** - * Maximum number of results to return + * Whether to list all datasets, including hidden ones + */ + all?: boolean; + /** + * An expression for filtering the results of the request by label. The syntax is "labels.[:]". Multiple filters can be ANDed together by connecting with a space. Example: "labels.department:receiving labels.active". See Filtering datasets using labels for details. + */ + filter?: string; + /** + * The maximum number of results to return */ maxResults?: number; /** @@ -2797,79 +2791,91 @@ declare namespace bigquery { */ pageToken?: string; }; + } + namespace jobs { /** - * Gets the specified table resource by table ID. This method does not return the data in the table, it only returns the table resource, which describes the structure of this table. + * Requests that a job be cancelled. This call will return immediately, and the client will need to poll for the job status to see if the cancel completed successfully. Cancelled jobs may still incur costs. */ - type IGetParams = { + type ICancelParams = { /** - * List of fields to return (comma-separated). If unspecified, all fields are returned + * The geographic location of the job. Required except for US and EU. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. */ - selectedFields?: string; + location?: string; }; - } - namespace routines { /** - * Gets the specified routine resource by routine ID. + * Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. */ type IGetParams = { /** - * If set, only the Routine fields in the field mask are returned in the - * response. If unset, all Routine fields are returned. + * The geographic location of the job. Required except for US and EU. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. */ - fieldMask?: string; + location?: string; }; /** - * Lists all routines in the specified dataset. Requires the READER dataset - * role. + * Retrieves the results of a query job. */ - type IListParams = { + type IGetQueryResultsParams = { /** - * Page token, returned by a previous call, to request the next page of - * results + * The geographic location where the job should run. Required except for US and EU. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. */ - pageToken?: string; + location?: string; /** - * The maximum number of results to return in a single response page. - * Leverage the page tokens to iterate through the entire collection. + * Maximum number of results to read */ maxResults?: number; - }; - } - - namespace datasets { - /** - * Deletes the dataset specified by the datasetId value. Before you can delete a dataset, you must delete all its tables, either manually or by specifying deleteContents. Immediately after deletion, you can create another dataset with the same name. - */ - type IDeleteParams = { /** - * If True, delete all the tables in the dataset. If False and the dataset contains tables, the request will fail. Default is False + * Page token, returned by a previous call, to request the next page of results */ - deleteContents?: boolean; + pageToken?: string; + /** + * Zero-based index of the starting row + */ + startIndex?: string; + /** + * How long to wait for the query to complete, in milliseconds, before returning. Default is 10 seconds. If the timeout passes before the job completes, the 'jobComplete' field in the response will be false + */ + timeoutMs?: number; }; /** - * Lists all datasets in the specified project to which you have been granted the READER dataset role. + * Lists all jobs that you started in the specified project. Job information is available for a six month period after creation. The job list is sorted in reverse chronological order, by job creation time. Requires the Can View project role, or the Is Owner project role if you set the allUsers property. */ type IListParams = { /** - * Whether to list all datasets, including hidden ones + * Whether to display jobs owned by all users in the project. Default false */ - all?: boolean; + allUsers?: boolean; /** - * An expression for filtering the results of the request by label. The syntax is "labels.[:]". Multiple filters can be ANDed together by connecting with a space. Example: "labels.department:receiving labels.active". See Filtering datasets using labels for details. + * Max value for job creation time, in milliseconds since the POSIX epoch. If set, only jobs created before or at this timestamp are returned */ - filter?: string; + maxCreationTime?: string; + /** + * Maximum number of results to return + */ + maxResults?: number; + /** + * Min value for job creation time, in milliseconds since the POSIX epoch. If set, only jobs created after or at this timestamp are returned + */ + minCreationTime?: string; /** * Page token, returned by a previous call, to request the next page of results */ pageToken?: string; /** - * The maximum number of results to return + * If set, retrieves only jobs whose parent is this job. Otherwise, retrieves only jobs which have no parent */ - maxResults?: number; + parentJobId?: string; + /** + * Restrict information returned to a set of selected fields + */ + projection?: 'full' | 'minimal'; + /** + * Filter for job state + */ + stateFilter?: 'done' | 'pending' | 'running'; }; } @@ -2879,108 +2885,102 @@ declare namespace bigquery { * role. */ type IListParams = { - /** - * Page token, returned by a previous call to request the next page of - * results - */ - pageToken?: string; /** * The maximum number of results to return in a single response page. * Leverage the page tokens to iterate through the entire collection. */ maxResults?: number; + /** + * Page token, returned by a previous call to request the next page of + * results + */ + pageToken?: string; }; } - namespace jobs { + namespace projects { /** - * Lists all jobs that you started in the specified project. Job information is available for a six month period after creation. The job list is sorted in reverse chronological order, by job creation time. Requires the Can View project role, or the Is Owner project role if you set the allUsers property. + * Lists all projects to which you have been granted any project role. */ type IListParams = { /** * Maximum number of results to return */ maxResults?: number; - /** - * Max value for job creation time, in milliseconds since the POSIX epoch. If set, only jobs created before or at this timestamp are returned - */ - maxCreationTime?: string; - /** - * Filter for job state - */ - stateFilter?: 'done' | 'pending' | 'running'; - /** - * Restrict information returned to a set of selected fields - */ - projection?: 'full' | 'minimal'; - /** - * If set, retrieves only jobs whose parent is this job. Otherwise, retrieves only jobs which have no parent - */ - parentJobId?: string; - /** - * Min value for job creation time, in milliseconds since the POSIX epoch. If set, only jobs created after or at this timestamp are returned - */ - minCreationTime?: string; /** * Page token, returned by a previous call, to request the next page of results */ pageToken?: string; + }; + } + + namespace routines { + /** + * Gets the specified routine resource by routine ID. + */ + type IGetParams = { /** - * Whether to display jobs owned by all users in the project. Default false + * If set, only the Routine fields in the field mask are returned in the + * response. If unset, all Routine fields are returned. */ - allUsers?: boolean; + fieldMask?: string; }; /** - * Retrieves the results of a query job. + * Lists all routines in the specified dataset. Requires the READER dataset + * role. */ - type IGetQueryResultsParams = { + type IListParams = { /** - * Zero-based index of the starting row + * The maximum number of results to return in a single response page. + * Leverage the page tokens to iterate through the entire collection. */ - startIndex?: string; + maxResults?: number; /** - * The geographic location where the job should run. Required except for US and EU. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. + * Page token, returned by a previous call, to request the next page of + * results */ - location?: string; + pageToken?: string; + }; + } + + namespace tabledata { + /** + * Retrieves table data from a specified set of rows. Requires the READER dataset role. + */ + type IListParams = { /** - * Page token, returned by a previous call, to request the next page of results + * Maximum number of results to return */ - pageToken?: string; + maxResults?: number; /** - * How long to wait for the query to complete, in milliseconds, before returning. Default is 10 seconds. If the timeout passes before the job completes, the 'jobComplete' field in the response will be false + * Page token, returned by a previous call, identifying the result set */ - timeoutMs?: number; + pageToken?: string; /** - * Maximum number of results to read + * List of fields to return (comma-separated). If unspecified, all fields are returned */ - maxResults?: number; - }; - - /** - * Requests that a job be cancelled. This call will return immediately, and the client will need to poll for the job status to see if the cancel completed successfully. Cancelled jobs may still incur costs. - */ - type ICancelParams = { + selectedFields?: string; /** - * The geographic location of the job. Required except for US and EU. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. + * Zero-based index of the starting row to read */ - location?: string; + startIndex?: string; }; + } + namespace tables { /** - * Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. + * Gets the specified table resource by table ID. This method does not return the data in the table, it only returns the table resource, which describes the structure of this table. */ type IGetParams = { /** - * The geographic location of the job. Required except for US and EU. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location. + * List of fields to return (comma-separated). If unspecified, all fields are returned */ - location?: string; + selectedFields?: string; }; - } - namespace projects { /** - * Lists all projects to which you have been granted any project role. + * Lists all tables in the specified dataset. Requires the READER dataset role. */ type IListParams = { /**