
                         j   S r SSKJr  SSKJr  SSKJr  SSK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  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\RF                  5      r$g)zThe BigQuery CLI make command.    )absolute_import)division)print_functionN)Optional)app)flags)client_connection)client_data_transfer)client_dataset)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$ )Make(   zCreates a dataset or a table.z9mk [-d] <identifier>  OR  mk [-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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-US9  [        R                  " S.SS/US9  [        R                  " US9U l
        [        R
                  " S0SS1US9  [        R
                  " S2S S3US9  [        R
                  " S4S S5US9  [        R                  " S6S S7US9  [        R                  " S8S S9U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 SAUS9  [        R                  " SBS SC/SDUS9  [        R                  " SES SF/SGUS9  [        R
                  " SHSSIUS9  [        R                  " SJS SKUS9  [        R
                  " SLS SMUS9  [        R                  " SNS SOU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_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
                  " SnS SoUS9  [        R                  " SpS SqUS9  [        R                  " SrS SsUS9  [        R                  " StS / SuQSvUS9  [        R                  " SwS / SxQSyUS9  [        R                  " SzSS{US9  [        R                  " S|SS}US9  [        R                  " S~S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 / SQSUS9  [        R                  " SS / SQSUS9  [        R
                  " SS SUS9  [        R                  " SS SUS9  [        R                  " SS / SQSUS9  [        R
                  " SS SUS9  [        R                  " SS / SQSUS9  [        R                  " SS SUS9  [        R                  " SS / SQ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
                  " 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SUS9  [        R                  " SS[         R"                  US9  [        R                  " SS SUS9  [        R                  " SS SS/SUS9  [        R                  " SS SS/SUS9  [        R                  " SS 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$                  " US9U l        [        R(                  " US9U l        [        R,                  " US9U l        [        R0                  " US9U l        [        R4                  " US9U l        [        R8                  " US9U l        [        R<                  " US9U l        [        R@                  " US9U l!        [        RD                  " US9U l#        [        RH                  " US9U l%        [        R                  " SS SUS9  [        R
                  " SS SUS9  U RM                  U5        g )NforceFzIBypass existence checks and ignore errors that the object already exists.f)
short_nameflag_valuesdatasetzCreate dataset with this name.dtablezCreate table with this name.ttransfer_configzCreate transfer config.)r"   target_dataset z6Target dataset for the created transfer configuration.display_namezBDisplay name for the created transfer configuration or connection.data_sourcez3Data source for the created transfer configuration.refresh_window_daysr   z;Refresh window days for the created transfer configuration.paramszqParameters for the created transfer configuration in JSON format. For example: --params='{"param":"param_value"}'p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.transfer_runz'Creates transfer runs for a time range.
start_timezStart time of the range of transfer runs. The format for the time stamp is RFC3339 UTC "Zulu". Example: 2019-01-20T06:50:0Z. Read more: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp end_timezExclusive end time of the range of transfer runs. The format for the time stamp is RFC3339 UTC "Zulu". Example: 2019-01-20T06:50:0Z. Read more: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp run_timezSpecific time for a transfer run. The format for the time stamp is RFC3339 UTC "Zulu". Example: 2019-01-20T06:50:0Z. Read more: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp 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.schemazNEither a filename or a comma-separated list of fields in the form name[:type].descriptionz0Description of the dataset, table or connection.data_locationzaGeographic location of the data. See details at https://cloud.google.com/bigquery/docs/locations.
expirationz1Expiration time, in seconds from now, of a table.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.default_partition_expirationa(  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.external_table_definitionaf  Specifies a table definition to use to create 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", where "schema@", "format=", and "connection" are optional and "format"has the default value of "CSV" if not specified. connection_idzThe connection specifying the credentials to be used to read external storage. The connection_id can have the form "<project_id>.<location_id>.<connection_id>" or "projects/<project_id>/locations/<location_id>/connections/<connection_id>". storage_urizThe fully qualified location prefix of the external folder where the table data of a BigLake table is stored. The "*" wildcard character is not allowed. The URI should be in the format "gs://bucket/path_to_table/". file_formatPARQUETz@The file format the table data of a BigLake table is stored in. table_formatICEBERGzOThe table format the metadata only snapshots of a BigLake table are stored in. viewz Create view with this SQL query.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.materialized_viewzE[Experimental] Create materialized view with this Standard SQL query.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_stalenessas  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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_expirationzEnables 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.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.destination_kms_keyz;Cloud KMS key for encryption of the destination table data.labelzAA label to set on the table or dataset. The format is "key:value"require_partition_filterzaWhether to require partition filter for queries over this table. Only apply to partitioned table.clustering_fieldsz]Comma-separated list of field names that specifies the columns on which a table is clustered.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.row_access_policyzCreates a row access policy.	policy_idz/Policy ID used to create row access policy for.target_tablez.The table to create 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.reservationz4Creates a reservation described by this identifier. capacity_commitmentzxCreates a capacity commitment. You do not need to specify a capacity commitment id, this will be assigned automatically.plan)FLEXMONTHLYANNUAL
THREE_YEARzCommitment plan for this capacity commitment. Plans cannot be deleted before their commitment period is over. Options include:
 FLEX
 MONTHLY
 ANNUAL
 THREE_YEARrenewal_plan)r]   r^   r_   r`   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.slotsz=The number of baseline slots associated with the reservation.multi_region_auxiliaryzIf true, capacity commitment or reservation is placed in the organizations auxiliary region which is designated for disaster recovery purposes. Applicable only for US and EU locations. Available only for allow-listed projects.use_idle_slotsTzIf 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.job_type)	QUERYPIPELINEML_EXTERNAL
BACKGROUNDSPARK
CONTINUOUSBACKGROUND_CHANGE_DATA_CAPTURE BACKGROUND_COLUMN_METADATA_INDEXBACKGROUND_SEARCH_INDEX_REFRESHaQ  Type of jobs to create reservation assignment for. Options include:
 QUERY
 PIPELINE
 Note if PIPELINE reservations are created, then load jobs will just use the slots from this reservation and slots from shared pool won't be used.
 ML_EXTERNAL
 BigQuery ML jobs that use services external to BQ for model training will use slots from this reservation. Slots used by these jobs are not preemptible, i.e., they are not available for other jobs running in the reservation. These jobs will not utilize idle slots from other reservations.
 BACKGROUND
 BACKGROUND_CHANGE_DATA_CAPTURE
 BigQuery CDC background merge will use BACKGROUND_CHANGE_DATA_CAPTURE reservations to execute if created, but will fall back to using BACKGROUND reservations if one does not exist.
 BACKGROUND_COLUMN_METADATA_INDEX
 BACKGROUND_SEARCH_INDEX_REFRESH
 SPARK
 BigQuery Spark jobs that use services external to BQ for executing SPARK procedure job. Slots used by these jobs are not preemptible, i.e., they are not available for other jobs running in the reservation. These jobs will not utilize idle slots from other reservations.priority)HIGHINTERACTIVEBATCHzReservation assignment default job priority. Only available for whitelisted reservations. Options include:
 HIGH
 INTERACTIVE
 BATCHreservation_idzlReservation ID used to create reservation assignment for. Used in conjunction with --reservation_assignment.reservation_assignmentz Create a reservation assignment.assignee_type)PROJECTFOLDERORGANIZATIONzType of assignees for the reservation assignment. Options include:
 PROJECT
 FOLDER
 ORGANIZATION
 Used in conjunction with --reservation_assignment.assignee_idzxProject/folder/organization ID, to which the reservation is assigned. Used in conjunction with --reservation_assignment.edition)STANDARD
ENTERPRISEENTERPRISE_PLUSzType of editions for the reservation or capacity commitment. Options include:
 STANDARD
 ENTERPRISE
 ENTERPRISE_PLUS
 Used in conjunction with --reservation or --capacity_commitment.
 STANDARD cannot be used together with --capacity_commitment.	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)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:
 AUTOSCALE_ONLY
 IDLE_SLOTS_ONLY
 ALL_SLOTSreservation_groupz:Creates a reservation group described by this identifier. 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.
connectionzCreate a connection.connection_typez Connection type. Valid values:
 z
 
propertiesz%Connection properties in JSON format.connection_credentialz%Connection credential in JSON format.connector_configurationz6Connection configuration for connector in JSON format.iam_role_idz[Experimental] IAM role id.federated_awsz"[Experimental] Federated identity.federated_azurez,[Experimental] Federated identity for Azure.	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.default_kms_keyzDefines default KMS key name for all newly objects created in the dataset. Table/Model creation request can override this default.use_avro_logical_typeszIf 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).source_datasetzYWhen set to a dataset reference, creates a Linked Dataset pointing to the source dataset.external_sourcezExternal source that backs this dataset. Currently only AWS Glue databases are supported (format aws-glue://<AWS_ARN_OF_GLUE_DATABASE>) 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 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.parquet_enum_as_stringzHInfer Parquet ENUM logical type as STRING (instead of BYTES by default).parquet_enable_list_inference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.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.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.!preserve_ascii_control_characterszLWhether to preserve embedded Ascii Control characters in CSV External table reference_file_schema_urizfprovide a reference file with the table schema, currently enabled for the formats: AVRO, PARQUET, ORC.file_set_spec_typeFILE_SYSTEM_MATCHNEW_LINE_DELIMITED_MANIFESTaU  Specifies how to discover files given source URIs. Options include: 
 FILE_SYSTEM_MATCH: expand source URIs by listing files from the underlying object store. This is the default behavior.
 NEW_LINE_DELIMITED_MANIFEST: indicate the source URIs provided are new line delimited manifest files, where each line contains a URI with no wild-card.kms_key_namez'Cloud KMS key name used for encryption.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" sourcez,Path to file with JSON payload for an updatemigration_workflowzCreate a migration workflow.config_filezAThe file containing the JSON of the migration workflow to create.)'superr   __init__r   DEFINE_booleanDEFINE_stringDEFINE_integerDEFINE_boolfrontend_flagsdefine_event_driven_scheduleevent_driven_schedule_flagDEFINE_enumDEFINE_multi_stringr   CONNECTION_TYPESjoinfrontend_utils"PARQUET_LIST_INFERENCE_DESCRIPTIONdefine_null_markernull_marker_flagdefine_null_markersnull_markers_flagdefine_time_zonetime_zone_flagdefine_date_formatdate_format_flagdefine_datetime_formatdatetime_format_flagdefine_time_formattime_format_flagdefine_timestamp_formattimestamp_format_flag!define_timestamp_target_precisiontimestamp_target_precision_flagdefine_source_column_matchsource_column_match_flagdefine_parquet_map_target_typeparquet_map_target_type_flag_ProcessCommandRc)selfr   r   	__class__s      $platform/bq/frontend/command_make.pyr   Make.__init__-   s   	$t(		 
( 
& 
4!: 

@	 

L	 

=	 
	E	 
	< 

H	 
#
	 
1	 
	?
 	 
	?
 	 
	?
 	 
	>  
	>  
 	`	 
	 	33C 	# 

	 
:	 
	< 
;	 
"	,  
&	$
 	 
#	< 
 
 	{	 
.
 
 
	J 
	 	 
6B 
	  
O	 
	F 
	7  
 	~	 
B
 
 
 	<  
&	*  
!	1  
E	 
K	 
"	+ 
	& 
	P  
&	 
9	 
8	 
	  
	 
>	 
	> 
	
	2  
	
	L '* 
	G	 
 	*
 	 
	  
	. 
@	 
@	 
 	K  
	 

	
I8 W,Z 
	

	
  
	= 
 *	 
-	@
 
 
	= 
5	J  
	G  
	

	 " 
D	 
 	  
d2 
+++
**'88
9	: 
/	 
/	 
!@	 
t:
 
,	 
6	 
T6B 
!	< 
	K 
 	P  
	 
6 	 
*	
 	 
(	)
 	 
 	) 
'99	 
	  
	J	9  
	h	8  
	h	K  
+	 
#	7 
	;<	  
1	 
 	i	 
6	 +=="MD+??BOD(99bID*=="MD . E E!D +=="MD!/!G!G"D 	88RH 	( %3$M$M%D! 	55"E 	% 
&	 
K	 	2    object_name	referencec                 *    [        U< SU< S35        g )N 'z' successfully created.)print)r   r   r   s      r   printSuccessMessageMake.printSuccessMessage  s    	 	
r   
identifierr9   returnc                 4   [         R                  R                  5       nS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OU 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ae  Sn[        R8                  " UU[:        R<                  R>                  S9n U R@                  b.  [B        RD                  " [:        RF                  RH                  5        U RJ                  nUc  U RL                  (       + nU RN                  nUc%  U RP                  b  U RP                  OU RR                  n[T        RV                  " URY                  5       [:        RZ                  R>                  UU R\                  UU R^                  UU R`                  U Rb                  U Rd                  U Rf                  U R@                  S9nUb  [        Rh                  " XdSS9  G
OU Rj                  (       a  [        Rl                  " UU[:        R<                  R>                  SS9n [T        Rn                  " URY                  5       UU R^                  U R\                  U Rp                  U Rr                  U R`                  S9nUb  [        Rh                  " XdSS9  G	OU Rt                  (       a   [        R8                  " U[:        R<                  R>                  U Rv                  S9n[T        Rx                  " URY                  5       UU Rz                  U R|                  U R~                  U R                  S9n[        R                  " X6S   S9n[        Rh                  " XdSS9  G	OU R                  (       a   [B        RD                  " [:        RF                  RH                  5        [        R                  " UU[:        R<                  R>                  S9n[T        R                  " URY                  5       US9n[        Rh                  " XdSS9  GO\U R                  (       Ga  UR                  5       n	S[        R                  " US9R                  -   nSn
U R                  (       a"  [        R                  " X@R                  U	5      n
O[0        R2                  " S5      e0 nU
(       dB  U R                  S :w  a2  U R                  (       d!  [        R                  " X@R                  U	5      nU R                  =(       d    [:        R<                  R>                  nU R                  R                  (       a  U R                  R>                  OSU lQ        [        R                  " U R                  U R                  U R                  U R                  U R                  S!9n[        R                  " UR                  5       UU R                  U R                  U R                  U R                  U R                  UU R                  U R                  U R                  UUS"9nU R5                  S#U5        GOBU R                  (       Ga  [B        R                  " 5       n[        R                  " X15      n[        R                  R                  US$9nU R                  =(       d    U R                  =(       a    U R                  nU R                  (       + =(       d    U R                  (       + =(       a    U R                  (       + nU(       d  U(       a  [
        R                  " S%5      e[        [        [        R                  [        R                  " UR                  5       UU R                  U R                  U R                  S&95      5      n[        R                  " U[        R                  R                  S'US(   S)9  U H  nUR                  U5        M     UR                  5         GOU R                  (       Ga  U R                  nU=(       d    U R                  nU(       d  S*n[
        R                  " U5      eU R                  S+:X  a]  U R                  (       aL  [        R                  " U R                  5      U lx        U R                  (       d  [
        R                  " S,5      eU R                  S-:X  a  U R                  (       a  U R                  (       aX  U R                  (       d  [
        R                  " S.5      e[        R                  " U R                  U R                  5      U lx        O%[        R                  " U R                  5      U lx        U R                  nU(       d  U R                  S/:X  a  S0nU(       d  U R                  S1:X  a  S0nUnU=(       d    U R                  nU(       d  S2n[
        R                  " U5      e[        GR                   " UGR                  5       [:        GR                  R>                  [:        R<                  R>                  U R                  UU GR                  U R                  U GR                  UU GR
                  U R                  S39nU(       aW  [        GR                  " UUS   S9nG[        S4U-  5        [        GR                  " U[:        GR                  R>                  S59  GOU GR                  (       a  [:        R<                  R>                  (       d  [
        R                  " S65      eU GR                  (       d  [
        R                  " S75      eSnU GR                  S8S9U[:        R<                  R>                  U GR                  [:        GR                  R>                  [:        GR                  R>                  S:.S;9  OU R                  (       d  U(       dQ  [        GR                  " X1S9nUGR                  (       a)  U(       a"  [        GR                   " UGR                  5        Of[        GR"                  " X1S9n[        GR$                  " U[        R                  GR&                  [        R                  GR(                  4S<U< S=3S>S?9  G[+        U[        R                  GR&                  5      (       Ga  U R                  (       a  [
        R                  " S@5      eU GR,                  (       a(  U GR                  (       a  [
        R                  " SA5      eU GR.                  (       a  [
        R                  " SB5      eU GR0                  b  [
        R                  " SC5      eU GR2                  (       dc  G[4        GR6                  " UGR8                  USD9(       a<  SEU< SF3nU GR:                  (       d  [0        R2                  " U5      eG[        U5        gSnU GR<                  b  U GR<                  SG-  nSnU GR>                  b  U GR>                  SG-  nU R                  =(       d    [:        R<                  R>                  nSnU GR@                  b"  [        GRB                  " U GR@                  5      nU GRD                  (       a!  [        GR                  " X0GRD                  S9nOSnU GRF                  (       a(  U GRD                  (       a  [
        R                  " SH5      eU GRH                  b  [
        R                  " SI5      eU GRF                  (       aJ  U GRJ                  (       d8  U GRF                  GRM                  SJ5      (       d  [
        R                  " SK5      eSnU GRN                  b#  G[P        GRR                  " U GRN                  5      n[        GRT                  " U GR                  U GR,                  5      u  U l        n U GR                  U GR2                  SL.n!U(       a  USM:w  d  USN:w  a  UU!SO'   U GRW                  SPS9UU!SQ9  G[4        GRX                  " S0 SRUGR8                  _SSU_STU GR2                  _SUU GR                  _SVU _SWU_SXU_SYU_SZU GRZ                  _S[U_S\U_S]U GRF                  _S^U GRJ                  _S_U GR\                  _S`U GR^                  _SaU GR`                  _SbU_6  U R5                  ScU5        gG[+        U[        R                  GR(                  5      (       Ga  U GRD                  (       a  [
        R                  " Sd5      eSen"U R                  (       a  Sfn"U R                  (       a  Sgn"U GR2                  (       df  G[b        GRd                  " UGR8                  USD9(       a?  U"< ShU< Si3nU GR:                  (       d  [0        R2                  " U5      eG[        U5        gU(       a  [        GRf                  " U5      nOSnSn#SnU GR@                  b"  [        GRB                  " U GR@                  5      nU R                  (       a  [
        R                  " Sj5      eU GR<                  (       a  [
        R                  " Sk5      eU GR\                  b  [
        R                  " Sl5      eU GR.                  (       a2  G[i        U GR.                  G[j        GRj                  " 5       -   5      SG-  n#U R                  =(       d    Sn$U R                  =(       d    Sn%Sn&U GR0                  Gb  [        GRl                  " U GR0                  U GRn                  U GRp                  U GRr                  U GRt                  U GRv                  U GRx                  U GRz                  U GR|                  U GR~                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  U GR                  R>                  Sm9n&U GR                  b  SnU&;   a  [
        R                  " So5      eSpU&;   a  [        GR                  " U&Sp   5      U&Sp'   Sn'U GRJ                  =(       a!    U GR                  =(       a    U GR                  n(U GRJ                  =(       d5    U GR                  =(       d!    U GR                  =(       d    U GR                  n)U((       a4  U GRJ                  U GR                  U GR                  U GR                  Sq.n'OU)(       a  / n*U GRJ                  (       d  U*GR                  S^5        U GR                  (       d  U*GR                  Sr5        U GR                  (       d  U*GR                  Ss5        StGR                  U*5      n*[
        R                  " SuU* Sv35      e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R                  5      n.Sn/SnU GRN                  b#  G[P        GRR                  " U GRN                  5      nG[b        GR                  " S0 SRUGR8                  _SSU_STS>_SwU_SUU GR                  _SxU#_SyU$_SzU%_S{U GR                  _S|U GR                  _S}U GR                  _S~U+_SU GR                  _SU&_SU'_SU GRH                  _S[U_SU,_SU-_SU._SU GR                  _SU R                  _SU/_SbU_6  U R5                  U"U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[0        R2                  " SU< 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[0        R2                  " SU< S
U< 35      eSnAff = f)a  Create a dataset, table, view, or transfer configuration with this name.

See 'bq help mk' for more information.

Examples:
  bq mk new_dataset
  bq mk new_dataset.new_table
  bq --dataset_id=new_dataset mk table
  bq mk -t new_dataset.newtable name:integer,value:string
  bq mk --view='select 1 as num' new_dataset.newview
     (--view_udf_resource=path/to/file.js)
  bq mk --materialized_view='select sum(x) as sum_x from dataset.table'
      new_dataset.newview
  bq mk -d --data_location=EU new_dataset
  bq mk -d --source_dataset=src_dataset new_dataset (requires allowlisting)
  bq mk -d
    --external_source=aws-glue://<aws_arn_of_glue_database>
    --connection_id=<connection>
    new_dataset
  bq mk --transfer_config --target_dataset=dataset --display_name=name
      -p='{"param":"value"}' --data_source=source
      --schedule_start_time={schedule_start_time}
      --schedule_end_time={schedule_end_time}
  bq mk --transfer_run --start_time={start_time} --end_time={end_time}
      projects/p/locations/l/transferConfigs/c
  bq mk --transfer_run --run_time={run_time}
      projects/p/locations/l/transferConfigs/c
  bq mk --reservation --project_id=project --location=us reservation_name
  bq mk --reservation_assignment --reservation_id=project:us.dev
      --job_type=QUERY --assignee_type=PROJECT --assignee_id=myproject
  bq mk --reservation_assignment --reservation_id=project:us.dev
      --job_type=QUERY --assignee_type=FOLDER --assignee_id=123
  bq mk --reservation_assignment --reservation_id=project:us.dev
      --job_type=QUERY --assignee_type=ORGANIZATION --assignee_id=456
  bq mk --reservation_group --project_id=project --location=us
      reservation_group_name
  bq mk --connection --connection_type='CLOUD_SQL'
    --properties='{"instanceId" : "instance",
    "database" : "db", "type" : "MYSQL" }'
    --connection_credential='{"username":"u", "password":"p"}'
    --project_id=proj --location=us --display_name=name new_connection
  bq mk --row_access_policy --policy_id=new_policy
  --target_table='existing_dataset.existing_table'
  --grantees='user:user1@google.com,group:group1@google.com'
  --filter_predicate='Region="US"'
  bq mk --source=file.json
  bq mk --migration_workflow --location=us --config_file=file.json
NzCannot specify both -d and -t.zJCannot specify more than one of --schema or --view or --materialized_view.)id_fallbacksr   )r   table_identifierrV   ,)bqclientpolicy_referencerX   rY   z$Failed to create row access policy 'z' on 'z': zRow access policy)r   r   default_location)clientapi_versionr   rc   rf   r   ri   rd   rj   r   r   r   zFailed to create reservation 'show)custom_format )r   r   r   default_capacity_commitment_id)r   r   r   rc   r\   ra   rd   z)Failed to create capacity commitment in ')r   r   r   )r   r   rk   ru   r{   r   r   )r   pathz)Failed to create reservation assignment ')reservation_group_clientr   z$Failed to create reservation group 'z	projects/)r   FzA data source must be provided.loadtesting)r7   r2   r3   disable_auto_schedulingevent_driven_schedule)transfer_clientr   r+   r(   r*   r,   r-   	auth_infor/   rP   r0   schedule_argslocationzTransfer configuration)transferConfigNamezKNeed to specify either both --start_time and --end_time or only --run_time.)r   r   r2   r3   r4   maker   )print_formatobject_infoz?Need to specify --connection_type or --connector_configuration.AWSz-Non-federated AWS connections are deprecated.AzurezGMust specify --federated_app_client_id for federated Azure connections.CLOUD_RESOURCEz{}rp   z9Need to specify --properties or --connector_configuration)r   
project_idr   r   r   r   r*   r:   r@   r   r   z"Connection %s successfully created)flag_formatz:Need to specify location for creating migration workflows.z=Need to specify config file for creating migration workflows.migration_workflowsmk)r   r   syncsynchronous_mode)command_flags_for_this_resourcezInvalid identifier 'z	' for mk.T)is_usage_errorz%Cannot specify schema with a dataset.z)Cannot specify description with a source.z+Cannot specify an expiration for a dataset.z:Cannot specify an external_table_definition for a dataset.)	apiclientr   z	Dataset 'z' already exists.i  z7Cannot specify both external_source and linked dataset.z<Cannot specify external_catalog_table_options for a dataset.zgoogle-cloudspanner:/z<connection_id is required when external_source is specified.)r:   r   usUSr   datasets)resource
bq_commandr   r  r  r   ignore_existingr:   acldefault_table_expiration_msdefault_partition_expiration_msr;   r   labelssource_dataset_referencer   r@   r   r   r   resource_tagsDatasetz,Cannot specify --source_dataset for a table.TableViewzMaterialized Viewr   z>' could not be created; a table with this name already exists.z)Cannot specify data location for a table.z.Cannot specify default expiration for a table.z<Cannot specify external_catalog_dataset_options for a table.)parquet_map_target_typetimestamp_target_precisionhivePartitioningOptionszBCannot specify require_partition_filter for hive partition tables.fileSetSpecType)r@   rA   rB   rD   rA   rD   z, zBigLake tables require z to be specifiedr9   r<   
view_querymaterialized_view_queryrI   rJ   rK   view_udf_resourcesrL   external_data_configbiglake_configr   time_partitioning
clusteringrT   rR   rP   table_constraints )r   ClientGetr$   r&   r   
UsageErrorr   ValidateAtMostOneSelectedr9   rF   rH   bq_client_utilsGetTableReferencerU   GetRowAccessPolicyReferencerW   rV   r   create_row_access_policyrX   splitrY   BaseExceptionr   BigqueryErrorr   rZ   GetReservationReferencebq_flagsLOCATIONvaluer   r   fail_if_not_using_alpha_featureAlphaFeaturesRESERVATION_GROUPSrf   re   ri   rh   rg   r   CreateReservationGetReservationApiClientAPI_VERSIONrc   r   rd   rj   r   r   PrintObjectInfor[   GetCapacityCommitmentReferenceCreateCapacityCommitmentr\   ra   rz   ry   CreateReservationAssignmentrk   ru   r{   r   !GetReservationAssignmentReferencer   GetReservationGroupReferenceCreateReservationGroupr'   GetTransferV1ApiClientGetProjectReference	projectIdr+   r   CheckValidCredsr/   RetrieveAuthorizationInfor;   r   presentr   r
   TransferScheduleArgsr7   r5   r6   r8   create_transfer_configr(   r*   r,   r-   rP   r0   r1   get_formatter_from_flagsfrontend_id_utilsFormatDataTransferIdentifiersr   ApiClientHelperTransferConfigReferencer2   r3   r4   listmapr   format_transfer_run_infostart_manual_transfer_runsconfigure_formatterTransferRunReferenceAddDictPrintr   r   r   r   r   MakeAccessRolePropertiesJsonr   r   r   r   r   4MakeAzureFederatedAppClientAndTenantIdPropertiesJsonMakeTenantIdPropertiesJsonr	   CreateConnectionGetConnectionV1ApiClient
PROJECT_IDr   r:   r   GetConnectionReferencer   .maybe_print_manual_instructions_for_connectionFORMATr   r   DelegateToGcloudAndExitSYNCHRONOUS_MODEGetDatasetReference	datasetIdValidateDatasetNameGetReference	typecheckDatasetReferenceTableReference
isinstancer   r<   r?   r   r   DatasetExistsr  r    r=   r>   rQ   ParseLabelsr   r   r   r@   
startswithr   bq_utils	ParseTagsProcessSourcePossiblyDelegateToGcloudAndExitCreateDatasetr   r   r   r   r   table_exists
ReadSchemainttimeGetExternalDataConfigr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rR   ParseFileSetSpecTyperA   rD   rB   appendr   rG   ParseUdfResourcesParseTimePartitioningrM   rN   rO   ParseClusteringrS   ParseRangePartitioningrT   create_tablerI   rJ   rK   rL   )0r   r   r9   r   r   er   ignore_idle_argrh   r   credentialsr   r   r   transfer_name	formatterformatted_identifierincompatible_optionsincomplete_optionsresultsresultconnection_type_definederrorparam_propertiesproperties_definedcreated_connectionmessagedefault_table_exp_msdefault_partition_exp_msr  r  r  r  r  r   r<   view_query_argmaterialized_view_query_argr  r   has_all_required_biglake_config has_some_required_biglake_configmissing_fieldsr  r!  r"  rT   r#  s0                                                   r   RunWithArgsMake.RunWithArgs  s   j $$((*FI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				k!99#,,22i
 
&&2

5
5$$77 00" $ 3 33/11 !!- '' 
 )::113 ,,22**-LL#.#'#>#> $ 8 8nn**#'#>#>
$ 
	 &&&	
 
	!	!!@@#,,22),	i
(AA113LL****#'#>#>
 
	 &&&	
 
	$	$
#;;%..44**
	
 )DD113]]]],,((
 $EE&&9
	 	&&&	
 
		
33""55	
 $@@!%..44
	
 )??%+%C%C%E
 	&&&	
 
			557o

-
-6
B
L
Li k			)99''
 $$%FGGi-/++'AA''
	 ##>x'8'8'>'>h ,,44 
)
)
/
/  
 +??==--))"&"9"9 $ : :m +AA 779&&,,(("66#88"66$($B$B%m 7G				668i.LL
 --EE1 F i //
*T]]MM  oo

2T]]!2  
!3nn"
 	
 
77"=="("?"?"A%!__====	g **


%
%
:
:aj	 &&! oo	 $ 4 4
!
AT%A%A  %M 	 nnU##				&4+;+;,II
 !!NO
O				(T^^--..  /ccnnd::$/ /IInn$/  $"6"6:J"J $"6"6'"A+-M1M1MKnnU##,==002((..$$**..% $ : :((&&"(("&">"> 
#::&8&@
	 	2Y>?GGHOO,A,A	
 
	 	 	 $$nnH
 	
 nnK
 	
 i
""


"++11!--//55"*";";"A"A	+	 # 
 
z!55i 
			**9+>+>?!..i 
))::))88 0:
; )[88IIJJ	nnDEE	)))nnHII	nnJKK		'	'	3nnH
 	
 jjjn::$$  5>?vvv&&w/
/
.
!		&	&	2#<<tC!%		*	*	6#'#D#Dt#K ##>x'8'8'>'>hf		++DJJ7				#2#F#F,?,?$
  $( 				$"5"5"5nnE
 	
 
	,	,	8nnJ
 	
 
			!!!%%001HII..N  m		" **4==9,::


DKKd ))::)%
 
x4'8t+;6>'
3
***I	 +  "" $$ ** &&	
  '; +C ! ..  $< .. ** ,0+P+P !% : :  !% : :!" &#& y)4	I{::II	J	J				nnKLLk				)jjjl77$$	 
 vvv&&w/
/
.
	 ++F3jf		++DJJ7			nnHII		&	&	&nnMNN		.	.	:nnJ
 	
 
499;67$>
yy(Dn$($:$:$Bd!!		'	'	3-CC**''''..$$  22**##!!''""((%%!!''%%++!!''&&,,))//$($E$E$K$K'+'K'K'Q'Q' 
* ))5%)==   4411&'89 0
1 n


 66$($5$5 &
 

  	 ' 
)!//++++ --	
 ,!!!



0



.   			~	.>2nn%n%55EF
 	
  				+==""
 )>>

%
%

+
+

&
&


'
' "11$2H2HIj)@@

!
! m		" **4==9 $$  	
 &&   $ #> ,, #66 ** 0 ,,  4 (  *.)L)L!" #$ .%&  '( 0)* $(#@#@+,  $77-. ./0 &14 {I6} 
K}  
$$~~t00!5
 	

T  
$$7A1E
 	

2  
$$BLaP
 	

:  
$$BLaP
 	

*  
$$=GK
 	

s   :Ac> 6DAe +AAe6 1B3Af& 8BAg c>
Aed6Ad>d>Aee
Ae3eAe.e.Ae3e6
Af#f AffAf#f&
Agf0AggAgg
Ahg Ag>g>Ah)r   r   r:   r   r   r   r   r   r   r   r   r   r   r   )r)   r)   )__name__
__module____qualname____firstlineno____doc__usagestrr   
FlagValuesr   r   r   rs  r  __static_attributes____classcell__)r   s   @r   r   r   (   sk    %
I%_3 _E$4$4 _BS S  13V
7V
7*-V
7}V
7 V
7r   r   )%r  
__future__r   r   r   rt  typingr   abslr   r   r1  rl  clientsr	   r
   r   r   r   r   r   r)  frontendr   r   r   r   r   r   r   r   rJ  r   r   r   BigqueryCmdr   r$  r   r   <module>r     sn    $ &  %       % ( " & ,   , % % , , (   % 2   $E7'' E7r   