
    -                     r   S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJrJ	r	J
r
Jr  SSKJr  SSKJr  SSKrSSKrSS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   SSKJr!  SSKJ"r"  SSKJ#r#  SSKJ$r$  SSKJ%r&  SSKJ'r'  SSKJ(r(  SSKJ)r)   " S S\RT                  5      r+               S'S\RX                  S\(RZ                  R\                  S \\/   S!\\	\/\/4      S"\\
\/      S#\\0   S$\\/   S%\\Rb                     4S& jjr2g)( The BigQuery CLI update command.    )absolute_import)division)print_functionN)AnyDictListOptional)app)flags)bigquery_client_extended)client_connection)client_data_transfer)client_dataset)
client_job)client_model)client_reservation)client_row_access_policy)client_table)utils)bigquery_command)bq_cached_client)utils_data_transfer)utils_flags)utils_formatting)utils_id)bq_error)bq_id_utils)bq_processor_utilsc                      ^  \ rS rSrSrSrS\S\R                  4U 4S jjr	S\S\
4S	 jr SS
\S\S\\   4S jjrSrU =r$ )Update,   r   z(update [-d] [-t] <identifier> [<schema>]namefvc                   > [         [        U ]  X5        [        R                  " SSSSUS9  [        R                  " SSSSUS9  [        R                  " S	SS
SUS9  [        R                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS / SQSUS9  [        R                  " S S / S!QS"US9  [        R                  " S#S S$US9  [        R                  " S%S S&US9  [        R                  " S'S S(US9  [        R
                  " S)S S*US9  [        R                  " S+S / S,QS-US9  [        R
                  " S.S S/US9  [        R
                  " S0S S1US9  [        R                  " S2S S3US9  [        R                  " S4S S5US9  [        R                  " S6S S7US9  [        R                  " S8S S7US9  [        R                  " S9S S:US9  [        R                  " S;S S<US9  [        R                  " S=S S>US9  [        R                  " S?S / S@QSAUS9  [        R
                  " SBS SCUS9  [        R                  " SDSSEUS9  [        R
                  " SFSGSHUS9  [        R
                  " SISGSJUS9  [        R                  " SKS SLUS9  [        R
                  " SMS SNSOUS9  [        R                  " SPSSQUS9  [        R
                  " SRS SSUS9  [        R
                  " STS SUUS9  [        R
                  " SVS SWUS9  [        R                  " SXSSYUS9  [        R                  " US9U l        [        R
                  " SZSGS[US9  [        R
                  " S\SGS]US9  [        R
                  " S^SGS_US9  [        R
                  " S`S SaUS9  [        R                  " SbS ScUS9  [        R                  " SdS SeUS9  [        R                  " SfS SgUS9  [        R                  " ShS SiUS9  [        R                  " SjS SkUS9  [        R
                  " SlS SmUS9  [        R
                  " SnSGSoUS9  [        R
                  " SpS SqUS9  [        R                  " SrS SsUS9  [        R                  " StS SuUS9  [        R
                  " SvS SwUS9  [        R
                  " SxS SyUS9  [        R
                  " SzS S{US9  [        R
                  " S|S S}US9  [        R                  " S~S SS/SUS9  [        R                  " SS SS/SUS9  [        R                  " SS SUS9  [        R                  " SS SUS9  [        R
                  " SS SUS9  [        R                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS [        R                  SSR                  [        R                  5      -   US9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R                  " SSSUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS SS/SUS9  [        R                  " SSSUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R
                  " SS SUS9  [        R                  " SSSUS9  [        R                   " SS ["        R$                  SGR                  SSSSR                  ["        R$                   Vs/ s H  o3R&                  PM     sn5      S/5      US9  U R)                  U5        g s  snf )NdatasetFz!Updates a dataset with this name.d)
short_nameflag_valuestablezUpdates a table with this name.tmodelz#Updates a model with this model ID.mrow_access_policyzUpdates a row access policy.)r)   	policy_idz/Policy ID used to update row access policy for.target_tablez.The table to update the row access policy for.granteeszComma separated list of iam_member users or groups that specifies the initial members that the row-level access policy should be created with.filter_predicatezTA SQL boolean expression that represents the rows defined by this row access policy.reservationz3Updates a reservation described by this identifier.slotsz=The number of baseline slots associated with the reservation.capacity_commitmentz;Updates a capacity commitment described by this identifier.plan)MONTHLYANNUAL
THREE_YEARzCommitment plan for this capacity commitment. Plan can only be updated to the one with longer committed period. Options include:
 MONTHLY
 ANNUAL
 THREE_YEARrenewal_plan)FLEXr7   r8   r9   NONEzThe plan this capacity commitment is converted to after committed period ends. Options include:
 NONE
 FLEX
 MONTHLY
 ANNUAL
 THREE_YEAR
 NONE can only be used in conjunction with --edition, 
 while FLEX and MONTHLY cannot be used together with --edition.splitz[If true, splits capacity commitment into two. Split parts are defined by the --slots param.mergezvIf true, merges capacity commitments into one. At least two comma separated capacity commitment ids must be specified.reservation_assignmentzUpdates a reservation assignment and so that the assignee will use a new reservation. Used in conjunction with --destination_reservation_iddestination_reservation_idzNDestination reservation ID. Used in conjunction with --reservation_assignment.priority)HIGHINTERACTIVEBATCH zReservation assignment default job priority. Only available for whitelisted reservations. Options include:
 HIGH
 INTERACTIVE
 BATCH
 empty string to unset priorityreservation_sizez3DEPRECATED, Please use bi_reservation_size instead.bi_reservation_sizezBI reservation size. Can be specified in bytes (--bi_reservation_size=2147483648) or in GB (--bi_reservation_size=1G). Minimum 1GB. Use 0 to remove reservation.use_idle_slotszIf true, any query running in this reservation will be able to use idle slots from other reservations. Used if ignore_idle_slots is None.ignore_idle_slotszgIf false, any query running in this reservation will be able to use idle slots from other reservations.max_concurrencyz6Deprecated, please use target_job_concurrency instead.concurrencytarget_job_concurrencyzSets a soft upper bound on the number of jobs that can run concurrently in the reservation. Default value is 0 which means that concurrency target will be automatically computed by the system.autoscale_max_slotszVNumber of slots to be scaled when needed. Autoscale will be enabled when setting this.	max_slotszThe overall max slots for the reservation. It needs to be specified together with --scaling_mode. It cannot be used together with --autoscale_max_slots. It is a private preview feature.scaling_mode)SCALING_MODE_UNSPECIFIEDAUTOSCALE_ONLYIDLE_SLOTS_ONLY	ALL_SLOTSa*  The scaling mode for the reservation. Available only for reservations enrolled in the Max Slots Preview. It needs to be specified together with --max_slots. It cannot be used together with --autoscale_max_slots. Options include:
 SCALING_MODE_UNSPECIFIED
 AUTOSCALE_ONLY
 IDLE_SLOTS_ONLY
 ALL_SLOTSreservation_group_namezReservation group name used to create reservation for, it can be full path or just the reservation group name. Used in conjunction with --reservation.transfer_configzCUpdates a transfer configuration for a configuration resource name.target_datasetrE   z2Updated dataset ID for the transfer configuration.display_namezBUpdated display name for the transfer configuration or connection.refresh_window_dayszCUpdated refresh window days for the updated transfer configuration.paramszxUpdated parameters for the updated transfer configuration in JSON format.For example: --params='{"param":"param_value"}'pupdate_credentialsz.Update the transfer configuration credentials.schedule_start_timeaJ  Time to start scheduling transfer runs for the given transfer configuration. If empty, the default value for the start time will be used to start runs immediately.The format for the time stamp is RFC3339 UTC "Zulu". Read more: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestampschedule_end_timeaK  Time to stop scheduling transfer runs for the given transfer configuration. If empty, the default value for the end time will be used to schedule runs indefinitely.The format for the time stamp is RFC3339 UTC "Zulu". Read more: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestampschedulea  Data transfer schedule. If the data source does not support a custom schedule, this should be empty. If empty, the default value for the data source will be used. The specified times are in UTC. Examples of valid format: 1st,3rd monday of month 15:30, every wed,fri of jan,jun 13:15, and first sunday of quarter 00:00. See more explanation about the format here: https://cloud.google.com/appengine/docs/flexible/python/scheduling-jobs-with-cron-yaml#the_schedule_formatno_auto_schedulingzKDisables automatic scheduling of data transfer runs for this configuration.service_account_namez>Service account used as the credential on the transfer config.notification_pubsub_topiczKPub/Sub topic used for notification after transfer run completed or failed.schemazNEither a filename or a comma-separated list of fields in the form name[:type].descriptionz6Description of the dataset, table, view or connection.	set_labelzAA label to set on a dataset or a table. The format is "key:value"clear_labelz0A label key to remove from a dataset or a table.
expirationz_Expiration time, in seconds from now, of a table or view. Specifying 0 removes expiration time.default_table_expirationzDefault lifetime, in seconds, for newly-created tables in a dataset. Newly-created tables will have an expiration time of the current time plus this value. Specify "0" to remove existing expiration.default_partition_expirationaS  Default partition expiration for all partitioned tables in the dataset, in seconds. The storage in a partition will have an expiration time of its partition time plus this value. If this property is set, partitioned tables created in the dataset will use this instead of default_table_expiration. Specify "0" to remove existing expiration.sourcez,Path to file with JSON payload for an updateviewzSQL query of a view.materialized_viewz*Standard SQL query of a materialized view.enable_refreshz~Whether to enable automatic refresh of the materialized views when the base table is updated. If not set, the default is true.refresh_interval_mszMilliseconds that must have elapsed since last refresh until the materialized view can be automatically refreshed again. If not set, the default value is "1800000" (30 minutes).max_stalenessa  INTERVAL value that determines the maximum staleness allowed when querying a materialized view or an external table. By default no staleness is allowed. Examples of valid max_staleness values: 1 day: "0-0 1 0:0:0"; 1 hour: "0-0 0 1:0:0".See more explanation about the INTERVAL values: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#interval_type. To use this flag, the external_table_definition flag must be set.external_table_definitionzSpecifies a table definition to use to update an external table. The value can be either an inline table definition or a path to a file containing a JSON table definition.The format of inline definition is "schema@format=uri@connection".  external_catalog_dataset_optionsa  Options defining open source compatible datasets living in the BigQuery catalog. Contains metadata of open source database or default storage location represented by the current dataset. The value can be either an inline JSON definition or a path to a file containing a JSON definition.external_catalog_table_optionsa"  Options defining the metadata of an open source compatible table living in the BigQuery catalog. Contains metadata of open source table including serializer/deserializer information, table schema, etc. The value can be either an inline JSON or a path to a file containing a JSON definition.metadata_cache_mode	AUTOMATICMANUALzEnables metadata cache for an external table with a connection. Specify AUTOMATIC to automatically refresh the cached metadata. Specify MANUAL to stop the automatic refresh. To use this flag, the external_table_definition flag must be set.object_metadata	DIRECTORYSIMPLEzObject Metadata Type used to create Object Tables. SIMPLE is the only supported value to create an Object Table containing a directory listing of objects found at the uri in external_data_definition.view_udf_resourcezThe URI or local filesystem path of a code file to load and evaluate immediately as a User-Defined Function resource used by the view.use_legacy_sqlzThe choice of using Legacy SQL for the query is optional. If not specified, the server will automatically determine the dialect based on query information, such as dialect prefixes. If no prefixes are found, it will default to Legacy SQL.time_partitioning_typezEnables time based partitioning on the table and set the type. The default value is DAY, which will generate one partition per day. Other supported values are HOUR, MONTH, and YEAR.time_partitioning_expirationa  Enables time based partitioning on the table and sets the number of seconds for which to keep the storage for the partitions in the table. The storage in a partition will have an expiration time of its partition time plus this value. A negative number means no expiration.time_partitioning_fieldzEnables time based partitioning on the table and the table will be partitioned based on the value of this field. If time based partitioning is enabled without this value, the table will be partitioned based on the loading time.clustering_fieldszComma-separated list of field names that specifies the columns on which a table is clustered. To remove the clustering, set an empty value.etagzOnly update if etag matches.destination_kms_keyz;Cloud KMS key for encryption of the destination table data.require_partition_filterzaWhether to require partition filter for queries over this table. Only apply to partitioned table.
connectionzUpdate connection.connection_typez Connection type. Valid values:
 z
 
propertiesz%Connection properties in JSON format.connection_credentialz%Connection credential in JSON format.iam_role_idz[Experimental] IAM role id.federated_awsTz"[Experimental] Federated identity.	tenant_idz[Experimental] Tenant id.federated_app_client_idzt[Experimental] The application (client) id of the Active Directory application to use with Azure federated identity.range_partitioninga  Enables range partitioning on the table. The format should be "field,start,end,interval". The table will be partitioned based on the value of the field. Field must be a top-level, non-repeated INT64 field. Start, end, and interval are INT64 values defining the ranges.default_kms_keyzDefines default KMS key name for all newly objects created in the dataset. Table/Model creation request can override this default.max_time_travel_hourszOptional. Define the max time travel in hours. The value can be from 48 to 168 hours (2 to 7 days). The default value is 168 hours if this is not set.storage_billing_modelLOGICALPHYSICALzOptional. Sets the storage billing model for the dataset. 
LOGICAL - switches to logical billing model 
PHYSICAL - switches to physical billing model.autodetect_schemazDOptional. If true, schema is autodetected; else schema is unchanged.vertex_ai_model_idzXOptional. Define the Vertex AI model ID to register to Vertex AI for BigQuery ML models.kms_key_namez'Cloud KMS key name used for encryption.connector_configurationz6Connection configuration for connector in JSON format.add_tagszTags to attach to the dataset or table.The format is namespaced key:value pair like "1234567/my_tag_key:my_tag_value,test-project123/environment:production"remove_tagsz{Tags to remove from the dataset or tableThe format is namespaced keys like "1234567/my_tag_key,test-project123/environment"clear_all_tagsz/Clear all tags attached to the dataset or tableupdate_modez=Specifies which dataset fields are updated. By default, both z*metadata and ACL information are updated. zOptions include:
 z%
 If not set, defaults as UPDATE_FULL)superr!   __init__r   DEFINE_booleanDEFINE_stringDEFINE_integerDEFINE_enumDEFINE_boolfrontend_flagsdefine_event_driven_scheduleevent_driven_schedule_flagDEFINE_multi_stringr   CONNECTION_TYPESjoinDEFINE_enum_classbq_client_utils
UpdateModevalue_ProcessCommandRc)selfr#   r$   e	__class__s       &platform/bq/frontend/command_update.pyr   Update.__init__0   s%   	&$ *	+ 
) 
- 
&	 
9	 
8	 
	  
	 
=	 
G	 
E	 
+	
 
 
	
	L '* 
	  
	? 
 	@  
$	= 
	
	, " 
=	 
	P  
	  
	. 
@	 
@	 
 	K  
	 
	G  
	
	 #& 
 	  
M	 

<	 

L	 
M	 
	<  
8	 
	>  
	>  
 	`	 
	 	33C 	# 

H	 
#
	 

	 
@	 
K	 
:	 
	0 
"	  
&	O
 	 
6	 
$:K	4	 
	F 
	7  
	L  
#	N  
*	)
 	 
(	)
 	 
	h	7 	 
	h	K  
	  
B
 
 
 	<  
&	
 	 
!	1  
	  
4" 
E	 
"	+ 
d0b 
+++
**'88
9	: 
/	 
/	 
t:
 
,	 
T6B 
!	< 
	P  
	K 
	  
	J	9  
N	 
	 
1	 
!@	 
 	g	 
	<  
9	 
""
K8!JJ)C)CD)CA)CDE4
 	  	2 Es   c
object_name	referencec                 *    [        U< SU< S35        g )Nz 'z' successfully updated.)print)r   r   r   s      r   printSuccessMessageUpdate.printSuccessMessage  s    	 	
    
identifierrb   returnc                  +   [         R                  R                  5       nU R                  (       a'  U R                  (       a  [
        R                  " S5      e[        R                  " U R                  U R                  U R                  5      (       a  [
        R                  " S5      eU R                  (       a  [        R                  " X1S9nG	OU R                  (       a  [        R                  " X1S9nG	OU R                  (       a  [        R                  " X1S9nG	OxU R                  (       a  [        R                  " UU R                   U R"                  S9n [$        R&                  " UUU R(                  R+                  S5      U R,                  S9  U R5                  SU R"                  5        GOU R6                  (       Ga?  S
nS
nU R8                  b   [        R:                  " U R8                  5      nU R<                  b  [?        U R<                  5      n U R@                  c  U RB                  by  U RB                  nUc  U R@                  n[        RD                  " U[F        RH                  RJ                  S9n[L        RN                  " URQ                  5       UUS9n	[S        U	5        GOU RT                  b.  [V        RX                  " [F        RZ                  R\                  5        [        R^                  " UU[F        RH                  RJ                  S9nU R`                  n
U
c  U Rb                  b  U Rb                  (       + n
U Rd                  nUc%  U Rf                  b  U Rf                  OU Rh                  n[L        Rj                  " URQ                  5       [F        Rl                  RJ                  UU Rn                  U
UU Rp                  U Rr                  U Rt                  UUU RT                  S9n	[        Rv                  " XSS9  GOU Rx                  (       Ga   U R*                  (       a'  U Rz                  (       a  [0        R2                  " S5      e[        R|                  " UU[F        RH                  RJ                  U Rz                  S9nU R*                  (       a]  [L        R~                  " URQ                  5       UU Rn                  S9n[        R                  " U[        R                  R                  S9  GOU Rz                  (       a  [L        R                  " URQ                  5       UR                  UR                  UR                  R+                  S5      S9n	[        U	S   [        5      (       d  [        S5      e[        R|                  " X9S   S9n[        Rv                  " XSS9  GO[L        R                  " URQ                  5       UU R                  U R                  S9n	[        Rv                  " XSS9  GOU R                  (       Ga>   [        R                  " UU[F        RH                  RJ                  S9nU R                  (       a#  U R                  b  [0        R2                  " S5      eU R                  (       a`  [L        R                  " URQ                  5       UUU R                  [F        RH                  RJ                  S 9n	[        R                  " X9S   S9nORU R                  b/  [L        R                  " URQ                  5       UU R                  S!9n	O[0        R2                  " S"5      e[        Rv                  " XSS#S$9  GOMU R                  (       d  U(       d  [        R                  " X1S9nGOU R                  (       a  [        R                  " X1S9nGOU R                  (       a5  [        R                  " X15      n[        R                  R                  US&9nGOU R                  (       d  U R                  (       Ga-  [        R                  " UU[F        RH                  RJ                  S9nU R                  S':X  a6  U R                  (       a%  [        R                  " U R                  5      U lb        U R                  S(:X  a  U R                  (       aB  U R                  (       a1  [        R                  " U R                  U R                  5      U lb        OmU R                  (       a&  [        R                  " U R                  5      U lb        O6U R                  (       a%  [        R                  " U R                  5      U lb        U R                  (       dQ  U R                  (       d@  U R                  (       d/  U R                  (       d  U R                  (       d  U R                  b  [        R                  " UR                  5       UU R                  U R                  U R                  U R                  U R                  U R                  U R                  S)9	n[        R                  " U5        Ob[        R                  " X1S9n[        R                  " U[        R                  R                  [        R                  R                  4S*U< S+3S,S-9  S
nS
nU R8                  b   [        R:                  " U R8                  5      nU R<                  b  [?        U R<                  5      n[        U[        R                  R                  5      (       GaL  U R                  (       a  [
        R                  " S.5      eU R                  (       a  [
        R                  " S/5      eU R                  (       a  [
        R                  " S05      eU R                  (       a  [
        R                  " S15      eU R                  b  [
        R                  " S25      eU R                  (       a'  U R                  (       a  [
        R                  " S35      eU R                  b  [
        R                  " S45      eS
nU R                  b  U R                  S5-  nS
nU R                  b  U R                  S5-  nS
nU R                  (       a   [        R                  " U R                  5      nS
nU R                  (       a   [        R                  " U R                  5      nG[        UU4U R                  U R                  UUUUU GR                  U GR                  U GR                  U GR                  UUU GR
                  U GR                  U GR                  S6.6  U R5                  S7U5        g
[        U[        R                  R                  5      (       Ga  S8nU R                  (       a  S9nU R                  (       a  S:nU R                  (       a  [
        R                  " S;U-  5      eU(       a  [        GR                  " U5      nOS
nS
nU R                  bD  U R                  S<:X  a  S<nO1G[        U R                  G[        GR                  " 5       -   5      S5-  nU R                  (       a  [
        R                  " S=5      eU GR                  b  [
        R                  " S>5      eS
nU R                  bQ  [        GR                  " U R                  U GR                  U GR                  S?9nS@U;   a  SAU;  a  Uc  US@   SB   nUS@	 U R                  =(       d    S
nU R                  =(       d    S
nS
nU GR                  (       a"  [        GR                  " U GR                  5      n[        GR                   " U GR"                  U GR$                  U GR&                  S
U GR(                  5      n[        GR*                  " U GR,                  5      n[        GR.                  " U GR0                  5      nS
nU GR2                  (       a  SCU GR2                  0nS
nS
nU R                  (       a   [        R                  " U R                  5      nS
nU R                  (       a   [        R                  " U R                  5      nG[4        GR6                  " Si0 SDUGR8                  _SEU_S@U_SFU R                  _SGU_SHU_SIU_SJU GR:                  _SKU GR<                  _SLU GR>                  _SMU_SNU GR@                  _SOU_SPU R                  _SQU_SRU_SSU_STU_SUU_SVU GR(                  _SWU GR                  _SXU_SYU GRB                  _SZU_S[U_S\U_S]U GR
                  _6  U R5                  UU5        g
[        U[        R                  R                  5      (       Ga(  G[D        GRF                  " UGRI                  5       U5      (       Ga  0 nSn U GRJ                  (       a  U GRL                  (       a  U GRL                  n O[        R                  " X4GRN                  5      n!G[D        GRP                  " UGRI                  5       U!5      n"G[R        GRT                  " S^[        GRV                  " US_9R                  -   U"S`   UGRI                  5       5      nU GRX                  GRZ                  (       a  U GRX                  RJ                  OS
U l        G[D        GR^                  " U GR`                  U GRb                  U GRd                  U GRf                  U GR\                  Sa9n#G[D        GRh                  " UGRI                  5       UUU GRj                  U R                  U GRl                  U GRn                  UU U GR2                  U GRp                  U#Sb9  U R5                  ScU5        g
[0        GRr                  " SdU< 3SeSf0/ 5      e[        U[        R                  GRt                  5      (       a  S
nU R                  (       a2  G[        U R                  G[        GR                  " 5       -   5      S5-  nOU R                  nG[v        GRx                  " UGR{                  5       UU R                  UUUU GR|                  U GR                  Sg9  U R5                  ShU5        g
g
! [.         a;  n[0        R2                  " SU R"                  < SU R                   < S	U< 35      eS
nAff = f! [.         a#  n[0        R2                  " SU< S	U< 35      eS
nAff = f! [.         a>  nSnU Rz                  (       a  SU-  nO
SU< S	U< 3n[0        R2                  " U5      eS
nAff = f! [.         a#  n[0        R2                  " S%U< S	U< 35      eS
nAff = f)ja2  Updates a dataset, table, view or transfer configuration with this name.

See 'bq help update' for more information.

Examples:
  bq update --description "Dataset description" existing_dataset
  bq update --description "My table" existing_dataset.existing_table
  bq update --description "My model" -m existing_dataset.existing_model
  bq update -t existing_dataset.existing_table name:integer,value:string
  bq update --destination_kms_key
      projects/p/locations/l/keyRings/r/cryptoKeys/k
      existing_dataset.existing_table
  bq update --view='select 1 as num' existing_dataset.existing_view
     (--view_udf_resource=path/to/file.js)
  bq update --transfer_config --display_name=name -p='{"param":"value"}'
      projects/p/locations/l/transferConfigs/c
  bq update --transfer_config --target_dataset=dataset
      --refresh_window_days=5 --update_credentials
      projects/p/locations/l/transferConfigs/c
  bq update --reservation --location=US --project_id=my-project
      --bi_reservation_size=2G
  bq update --capacity_commitment --location=US --project_id=my-project
      --plan=MONTHLY --renewal_plan=FLEX commitment_id
  bq update --capacity_commitment --location=US --project_id=my-project
    --split --slots=500 commitment_id
  bq update --capacity_commitment --location=US --project_id=my-project
    --merge commitment_id1,commitment_id2
  bq update --reservation_assignment
      --destination_reservation_id=proj:US.new_reservation
      proj:US.old_reservation.assignment_id
  bq update --connection_credential='{"username":"u", "password":"p"}'
    --location=US --project_id=my-project existing_connection
  bq update --row_access_policy --policy_id=existing_policy
  --target_table='existing_dataset.existing_table'
  --grantees='user:user1@google.com,group:group1@google.com'
  --filter_predicate='Region="US"'
zCannot specify both -d and -t.zJCannot specify more than one of --schema or --view or --materialized_view.)id_fallbacksr   )r   table_identifierr/   ,)bqclientpolicy_referencer1   r2   z$Failed to update row access policy 'z' on 'z': NzRow access policy)r   default_location)clientr   rF   )r   r   r   )r   api_versionr   r4   rI   rL   rM   rN   rO   labels_to_setlabel_keys_to_removerT   show)custom_formatzFailed to update reservation 'z(Cannot specify both --split and --merge.)r   r   r   allow_commas)r   r   r4   )objects_type)r   
project_idlocationcapacity_commitment_idsr#   z/Parsed object does not have a name of type str.)r   path)r   r   r6   r:   rE   z%Capacity commitments merge failed: %sz&Failed to update capacity commitment 'z@Cannot specify both --destination_reservation_id and --priority.)r   r   r   r@   r   )r   r   rA   zDEither --destination_reservation_id or --priority must be specified.F)r   print_referencez)Failed to update reservation assignment ')transferConfigNameAWSAzure)	r   r   rW   rc   r   r   r   r   r   zInvalid identifier 'z' for update.T)is_usage_errorz%Cannot specify schema with a dataset.z#Cannot specify view with a dataset.z0Cannot specify materialized view with a dataset.z+Cannot specify an expiration for a dataset.z:Cannot specify an external_table_definition for a dataset.z)Cannot specify description with a source.z<Cannot specify external_catalog_table_options for a dataset.i  )rc   ri   default_table_expiration_msdefault_partition_expiration_msr   r   r   r~   r   r   tags_to_attachtags_to_remover   rp   r   DatasetTableViewzMaterialized Viewz$%s update does not support --source.r   z.Cannot specify default expiration for a table.z<Cannot specify external_catalog_dataset_options for a table.)rr   ru   rb   hivePartitioningOptionsfields
kmsKeyName	apiclientr   rc   rf   
view_querymaterialized_view_queryrl   rm   rn   view_udf_resourcesry   external_data_configrq   r   r   time_partitioningr   
clusteringr   r~   encryption_configurationr   table_constraintsr   r   r   z	projects/)r   dataSourceId)r^   
start_timeend_timedisable_auto_schedulingevent_driven_schedule)transfer_clientr   r   rV   rW   rX   rY   	auth_infor`   r   ra   schedule_argszTransfer configurationzNot found: reasonnotFound)model_clientr   rc   rf   r   r   r   r~   Model )r   ClientGetr'   r+   r   
UsageErrorfrontend_utilsValidateAtMostOneSelectedrb   rj   rk   r   GetTableReferencer.   GetRowAccessPolicyReferencer0   r/   r   update_row_access_policyr1   r=   r2   BaseExceptionr   BigqueryErrorr   r3   rd   ParseLabelsre   setrF   rG   GetBiReservationReferencebq_flagsLOCATIONr   r   UpdateBiReservationGetReservationApiClientr   rT   r   fail_if_not_using_alpha_featureAlphaFeaturesRESERVATION_GROUPSGetReservationReferencerI   rH   rL   rK   rJ   UpdateReservationAPI_VERSIONr4   rM   rN   rO   PrintObjectInfor5   r>   GetCapacityCommitmentReferenceSplitCapacityCommitmentPrintObjectsArrayr   ApiClientHelperCapacityCommitmentReferenceMergeCapacityCommitments	projectIdr   capacityCommitmentId
isinstancestr
ValueErrorUpdateCapacityCommitmentr6   r:   r?   !GetReservationAssignmentReferencer@   rA   MoveReservationAssignmentUpdateReservationAssignmentGetDatasetReferencer-   GetModelReferencerU   frontend_id_utilsFormatDataTransferIdentifiersTransferConfigReferencer   r   GetConnectionReferencer   r   r   MakeAccessRolePropertiesJsonr   r   r   4MakeAzureFederatedAppClientAndTenantIdPropertiesJson+MakeAzureFederatedAppClientIdPropertiesJsonMakeTenantIdPropertiesJsonrW   rc   r   r   r   UpdateConnectionGetConnectionV1ApiClientr   .maybe_print_manual_instructions_for_connectionGetReference	typecheckDatasetReferenceTableReferencerf   ro   ri   rq   rg   rh   r   bq_utils	ParseTagsr   ParseTagKeys_UpdateDatasetr   r~   r   r   r   rp   r   
ReadSchemainttimeGetExternalDataConfigrr   ru   rx   ParseUdfResourcesParseTimePartitioningrz   r{   r|   r   ParseRangePartitioningr   ParseClusteringr}   r   r   update_tabler   rl   rm   rn   ry   r   r   transfer_existsGetTransferV1ApiClientr[   r`   r   get_transfer_configr   RetrieveAuthorizationInfoGetProjectReferencer   presentr   TransferScheduleArgsr^   r\   r]   r_   update_transfer_configrV   rX   rY   ra   BigqueryNotFoundErrorModelReferencer   update_modelGetModelsApiClientr   )$r   r   rb   r   r   r   r   r   sizeobject_infoignore_idle_argrK   responseerrformatted_identifierupdated_connectiondefault_table_exp_msdefault_partition_exp_msr   r   r   rf   r   view_query_argmaterialized_view_query_argr   r   r   r   r   r   r   r`   transfer_config_namecurrent_configr   s$                                       r   RunWithArgsUpdate.RunWithArgs  s   R $$((*Fvv$&&NN;<<//TYY 6 6  NN8  vv!33i 
!33i 
		!33i 
		!==,,NNi

 99&]]((-!22		
 2DNNC				!m		#&224>>B				%"4#3#349
!!-''3))$\((D%??!H4E4E4K4K) +>>335!#+
 
((477&&99 &==!#'0066)
 !22/$)<)<)H"&"5"55O33+  ##/   )) 
 +<<335"..44!JJ /%0"&":":,,)#7%)%@%@+ 
(
(F 
	!	!	!8*::$**&&8  $BB!%..44	
	 ::'??335!JJ(
 
*
*&66RR ZZ*CC335",, ))&/&D&D&J&J3&O	+ K/55NOO%DD!F(;) 
(
(F +CC335!99,,	+ 
(
(F 
	$	$	$'
#EE!%..44
	
 **t}}/H&&P  ***DD335!!)-)H)H'0066+ &GG!F(;) ]]&*FF335!}}+ && 
 	&&&%	
 
z!55i 
!33i 
		.LL
 --EE1 F i 
D666!88#,,22i
 
			&4+;+;,II
 
			(>>d::.ccnnd::$/ )) LL.. /
 ^^.IInn$/ //''))*.??224**(( 00"&"<"<**$($@$@

 	GG	

 "..i 
))::))88 4>
?  M~~!$00@m# !1!12)[88IIJJ	nnDEE	nnBCC			nnOPP	nnJKK		'	'	3nnH
 	
 
))nnHII		,	,	8nnJ
 	
 "		&	&	2#<<tC!%		*	*	6#'#D#Dt#K n	!++DMM:n			!..t/?/?@

 &&&:*B%3..yy $ : : $ : :'',,+/+P+P&&#& y)4	I{::II	J	Jk				)	nn2[@
 	
 
 ++F3j		$??a*4??TYY[89D@*		&	&nnMNN		.	.	:nnJ
 	
 "		'	'	3-CC** $ 8 8 00 
 ,,%-AA^)(3H=F"8,yy(Dn$($:$:$Bd!				+==""
 )>>

%
%

+
+

&
&


'
' *@@

!
! "11$2H2HIj!%		!	!	!$0$2J2J#K n	!++DMM:n			!..t/?/?@ $$  &&	
   $ #> ,, #66 ** 0 ,,  4 *.)L)L &   4!" .#$ 0%&  '( $(#@#@)* yy+, $<-. !22/0 .12 (34 (56 ,,7< {I6	;..FF
 
 
	-	-

'
'
)9
 
 	!"""&&&#'#<#<  "??88 !
 2EE--/1EN ,EE!55!') ~.--/I ..666 ++11 	"
 -AA]]//++$($;$;"&"<"<
 	33"99;..** $ 8 8;;!5 $ 8 8&*&D&D'	
 	  !99E,,(*Xz,BB
 	
 
I{::II	J	Jj	499;67$>
__
002&&%3!44yy	 w	2! 
Ko  
$$~~t00!5
 	

F  
$$7A1E
 	

f  
*::71=#  # $$S))
*`  
$$BLaP
 	

s   :AR BAS *EAS CAT 4B2AT (AAT D;AU R
ASR6ASSASS
ATSAS=S=ATT
AUT9AUUAUU
AU=UAU8U8AU=)r   r   r   )rE   rE   )__name__
__module____qualname____firstlineno____doc__usager  r   
FlagValuesr   r   r   r
   r,  rM  __static_attributes____classcell__)r   s   @r   r!   r!   ,   sk    (
8%h
3 h
E$4$4 h
TS S  13s3s3*-s3}s3 s3r   r!   r   r   rc   r   r   r   rp   r   c                     [         R                  " X#5      u  nn[        R                  " S0 SU R                  _SU_SU_SU_SU_SU_SU_SU_S	U_S
U	_SU
_SU_SU_SU_SU_SU_SU_6  g)a  Updates a dataset.

Reads JSON file if specified and loads updated values, before calling bigquery
dataset update.

Args:
  client: The BigQuery client.
  reference: The DatasetReference to update.
  description: An optional dataset description.
  source: An optional filename containing the JSON payload.
  default_table_expiration_ms: An optional number of milliseconds for the
    default expiration duration for new tables created in this dataset.
  default_partition_expiration_ms: An optional number of milliseconds for the
    default partition expiration duration for new partitioned tables created
    in this dataset.
  labels_to_set: An optional dict of labels to set on this dataset.
  label_keys_to_remove: an optional list of label keys to remove from this
    dataset.
  default_kms_key: An optional CMEK encryption key for all new tables in the
    dataset.
  max_time_travel_hours: Optional. Define the max time travel in hours. The
    value can be from 48 to 168 hours (2 to 7 days). The default value is 168
    hours if this is not set.
  storage_billing_model: Optional. Sets the storage billing model for the
    dataset.
  tags_to_attach: An optional dict of tags to attach to the dataset.
  tags_to_remove: An optional list of tag keys to remove from the dataset.
  clear_all_tags: If set, clears all the tags attached to the dataset.
  external_catalog_dataset_options: An optional JSON string or file path
    containing the external catalog dataset options to update.

Raises:
  UsageError: when incorrect usage or invalid args are used.
r   r   rc   aclr   r   r   r   r~   r   r   r   r   r   r   rp   r   Nr   )r   ProcessSourcer   UpdateDatasetr   )r   r   rc   ri   r   r   r   r   r~   r   r   r   r   r   r   rp   r   rY  s                     r   r*  r*    s    j $11+F+s     	
 #> 'F " 0  & 2 2 $ $ $  (H!" #r   )NNNNNNNNNNNNNNN)3rS  
__future__r   r   r   jsonr-  typingr   r   r	   r
   abslr   r   r   r'  clientsr   r   r   r   r   r   r   r   r   r   r   frontendr   r   r   r   r   r   r   r   r  r   r   r   BigqueryCmdr!   BigqueryClientExtendedr
  r%  r  boolr   r*  r   r   r   <module>re     sF   & &  %   , ,     , % ( "    & ,   , % % , , (   % 2   $j3)) j3`' "& $$(	/3*.%)6:8<#H$;;H**;;H #H T#s(^,H T#Y'H TNH  '/sm!H" /445#Hr   