
    ʻ                     D   % S r SSKrSSKrSSKrSSKrSSKrSSKJrJrJ	r	J
r
JrJrJr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  \r\R8                  S:  a  \R:                  r\R<                  r/ SQr/ SQr  S@S\RB                  4S jjr" SAS\
\RB                     SS4S jjr#S\\$\$4   S\$4S jr%S\RL                  RN                  S\$4S jr(S\\$\$4   S\$4S jr)S\$4S jr*S\+S\$4S jr,S\$S\$4S jr-\$r.\\/S'   \$r0\\/S'   \\\$\$4   \\$\$4   \\$\$4   4   r1\\/S '   \\0\14   r2\\/S!'   \	\\$\\\$\$4   \$4   4      r3\\/S"'   S#\3S\$4S$ jr4S\$4S% jr5S&\$SS4S' jr6  SBS(\Rn                  S)\\RL                  Rp                     S&\Rr                  4S* jjr:S+\\RL                  Rp                     4S, jr;S- r<S. r=S/ r>S\$4S0 jr?S\$4S1 jr@S\$4S2 jrAS3 rBS4 rCS5 rDS6 rES7 rFS8 rGS9 rHS: rIS;\\$\4   S\\$\4   4S< jrJS= rKS> rLS? rMg)Cz.BQ CLI frontend formatting library for Python.    N)AnyDictListOptionalTupleTypeUnioncast)	TypeAlias)utils)bq_api_utils)	bq_consts)bq_error)bq_id_utils)bq_processor_utils)      )
updateTimeschedulerunTimescheduleTimeparamsendTimedataSourceIddestinationDatasetIdstate	startTimename)r   r   r   
obj_formatc                     SS/nUS:X  a  [        [        R                  " U SS95        g
US:X  a   [        [        R                  " U SSS95        g
[        SU< S	U< 35      e)zPrints obj in a JSON format according to the format argument.

Args:
  obj: The object to print.
  obj_format: The format to use: 'json' or 'prettyjson'.
json
prettyjson),:)
separatorsT   )	sort_keysindentz#Invalid json format for printing: 'z', expected one of: N)printr!   dumps
ValueError)objr   json_formatss      (platform/bq/frontend/utils_formatting.py_print_formatted_json_objectr/   0   s]     ,',6	$**SZ
01\!	$**SD
34
|	%     flag_formatreturnc           
      t   U (       d  gU R                  S5      (       a  U S   R                  S5      (       a  U S   S   R                  S5      U S   S   R                  S5      U S   S   R                  S5      S.nUS;   a
  [        X!S	9  OW[        S
U S   S   R                  S5      < SU S   S   R                  S5      < SU S   S   R                  S5      < S35        U R                  S5      (       a  U S   R                  S5      (       a}  U S   S   R                  S5      U S   S   R                  S5      S.nUS;   a
  [        X!S	9  O>[        S
U S   S   R                  S5      < SU S   S   R                  S5      < S35        U R                  S5      (       a  U S   R                  S5      (       ar  U S   R                  S5      U S   R                  S5      S.nUS;   a
  [        X!S	9  g[        SU S   R                  S5      < SU S   R                  S5      < S35        gU R                  S5      (       ar  U S   R                  S5      U S   R                  S5      S.nUS;   a
  [        X!S	9  g[        SU S   R                  S5      < SU S   R                  S5      < S35        gg)zAPrints follow-up instructions for created or updated connections.NawscrossAccountRole	iamRoleId	iamUserId
externalId)r6   r7   r8   )r"   r!   )r   z8Please add the following identity to your AWS IAM Role 'z'
IAM user: 'z'
External Id: 'z'

accessRoleidentity)r6   r:   z'
Identity: 'azurefederatedApplicationClientId)r<   r:   z=Please add the following identity to your Azure application 'clientIdapplication)r=   r>   z@Please create a Service Principal in your directory for appId: 'z(',
and perform role assignment to app: 'z0' to allow BigQuery to access your Azure data. 
)getr/   r)   )
connectionr1   r,   s      r.   .maybe_print_manual_instructions_for_connectionrA   F   s   
 

^^Ez%0445GHH&'9:>>{K&'9:>>{K '(:;??MC
 ,,"3?  2377D 2377D 2377E	 ^^Ez%044\BB&|488Eu%l377
CC ,,"3? -11+>-11*=	 ^^GG!4!8!8$" "
 w##$BCw'++J7	C ,,"3? !%%&DE!%%j1	 ~~gw'++J7!'*..}=C ,,"3? !%%j1!%%m4	 r0   labelsc                     / nU R                  5        H   u  p#U< SU< 3nUR                  U/5        M"     SR                  U5      $ )z(Format a resource's labels for printing.r$   
)itemsextendjoin)rB   result_lineskeyvalue	label_strs        r.   _format_labelsrL      sD    ,LLNjc&I$ # 
<	  r0   tablec                 .    U S   < SU S   < SU S   < 3$ )N	projectIdr$   	datasetId.tableId )rM   s    r.   _format_table_referencerT      s&     KKI
 r0   tagsc                     U R                  5        VVs/ s H  u  pSR                  X5      PM     nnnSR                  U5      $ s  snnf )z&Format a resource's tags for printing.z{}:{}rD   )rE   formatrG   )rU   rI   rJ   rH   s       r.   _format_resource_tagsrX      s<    ?Czz|L|'..,|,L	<	   Ms   Ac                     / nU  Ha  nUS   S   S:X  a  US   S   S   nOUS   S   nSUS   < SUR                  5       < 3nUS   S   S:X  a  US-  nUR                  U/5        Mc     S	R                  U5      $ )
zReturns a string with standard_sql_fields.

Currently only supports printing primitive field types and repeated fields.
Args:
  standard_sql_fields: A list of standard sql fields.

Returns:
  The formatted standard sql fields.
typetypeKindARRAYarrayElementTypez|- r   : z (repeated)rD   )lowerrF   rG   )standard_sql_fieldslinesfield
field_typeentrys        r.   _format_standard_sql_fieldsre      s     %"eV}Z G+=!34Z@j=,j =**:*:*<=EV}Z G+}e	LL% # 
5	r0   secsc                 X    [         R                  " S[         R                  " U 5      5      $ )Nz%d %b %H:%M:%S)timestrftime	localtime)rf   s    r.   format_timerk      s    	')=	>>r0   json_stringc                     [         R                   R                  U S5      nU[         R                   " SSS5      -
  R                  5       n[        U5      $ )zAConverts google.protobuf.Timestamp formatted string to BQ format.z%Y-%m-%dT%H:%M:%S.%fZi     )datetimestrptimetotal_secondsrk   )rl   parsed_datetimesecondss      r.   ,format_time_from_proto_timestamp_json_stringrt      sM    %%..*/ x00q!<<KKM'	W	r0   StringReferenceResourceType
ConditionsResourceTypeAndConditionsDatasetAccessaclc           
      
	   [         R                  " [        5      nU  GH  nUR                  5       n[	        [
        [        [        4   UR                  SS5      5      n[	        [
        [        [
        [        [        4   4   UR                  SS5      5      n[	        [
        [        [        4   UR                  SS5      5      n[	        [        UR                  SS5      5      nU(       aO  US   R                  UR                  S5      < SUR                  S	5      < S
UR                  S5      < 35        GM  U(       a  [	        [
        [        [        4   UR                  S5      5      nUR                  S5       HD  nUSU-   S-   S4   R                  UR                  S5      < SUR                  S	5      < 35        MF     GM  U(       ab  [        [        R                  R                  " S0 UD65      n	U(       a  XS4   R                  SU	-  5        GM  US   R                  U	5        GM  [	        [
        [        [        4   UR                  SS5      5      n
U(       a&  [        [        UR                  5       5      5      S:w  a  [        R                   " SU -  0 / 5      eU
(       a=  X[#        U
R%                  5       5      4   R'                  UR                  5       5        GM  XS4   R'                  UR                  5       5        GM     SSSSS.n/ nUR%                  5        Hf  u  pmUR                  US4S5      nU(       d  M"  UR                  SU-  5        UR                  SR)                  S [+        U5       5       5      5        Mh     [+        UR%                  5       5       H  u  u  pjnXk;   a  UR                  SX   -  5        OUR                  SU-  5        UR                  SR)                  S [+        U5       5       5      5        U
(       d  Mq  UR                  S5        UR                  SR)                  S  [-        U
5      R%                  5        5       5      5        M     SR)                  U5      $ )!z*Format a server-returned ACL for printing.viewNdatasetroutinerole)VIEWrS   rO   r$   rP   rQ   rR   targetTypeszAll z in DATASETrS   zROUTINE: %s)ROUTINErS   	conditionrn   z"Invalid ACL returned by server: %sOwnersWritersReaderszAuthorized Views)OWNERWRITERREADERr   z%s:z,
c              3   ,   #    U  H
  nS U-  v   M     g7fz  %sNrS   .0ms     r.   	<genexpr>format_acl.<locals>.<genexpr>$  s     $IAVaZ   c              3   ,   #    U  H
  nS U-  v   M     g7fr   rS   r   s     r.   r   r   +  s     "G!6A:r   z    condition:rD   c              3   :   #    U  H  u  pS U< SU< 3v   M     g7f)z      r^   NrS   )r   rI   rJ   s      r.   r   r   /  s        7*#u !$U+ 7s   )collectionsdefaultdictlistcopyr
   r   strpopappendr?   r   ApiClientHelperRoutineReferencelenvaluesr   BigqueryInterfaceErrortuplerE   rF   rG   sorteddict)rz   acl_entriesrd   r|   r}   r~   r   dataset_referencetargetroutine_referencer   original_rolesrH   r   memberss                  r.   
format_aclr      s    d#  eJJLES#X		&$ 78D4T#s(^+,eii	4.HIG4S>599Y#=>GUYYvt,-D*$$XXk"DHH[$9488I;NP 
tCH~w{{9/EFKK.&FVOm3R78?? "%%k2!%%k2	
 / 


%
%
6
6
A
A 
"H$$]5F%FGM"))*;<tCH~uyyd'CDiSelln-.!3--036B
 	
 
5!2345<<U\\^L"H$$U\\^4M R  	. ,"((*jdootRj$/Gw%$,'%**$I$IIJ	 + %+;+<+<+>$? t%."667%$,'

"Gvg"GGHy*+
))  $Y 5 5 7  %@ 
<	  r0   c                    ^ SS[         [           4U4S jjjmSR                  T" U R                  S/ 5      5      5      $ )zFormat a schema for printing.r2   c           	      .  > / nU  GH
  nSU-  nUR                  SS5      S:w  a  SOSnU< SUS   < S	UR                  SS5      R                  5       < 3nS
U;   a  USUS
   -  -  nO=SU;   a7  SU;   a  USUS   < SUS   < S3-  nOUSUS   -  -  nSU;   a  USUS   -  -  nUR                  SS5      S:w  a  USUS   R                  5       < S3-  nUR                  XF-   5        SU;   d  M  UR                  T" US   US-   5      5        GM     U$ )z5Print all fields in a schema, recurring as necessary.z|  rZ   STRINGRECORD|+z- r   r^   	maxLengthz(%s)	precisionscale(, )roundingModez options(rounding_mode="%s")modeNULLABLE (fieldsrn   )r?   r_   r   rF   )r   r(   ra   rb   prefixjunctionrd   print_fieldss          r.   r   #format_schema.<locals>.print_fields:  s8   Ev~f		&(3x?Sh

-
))FH
%
+
+
-e 
	5-..%e
{!3U7^D
D%
6U;/0
0%U"
1U>5JK
K%	6:	&*	4E&M//133ll6>"	U	\%/6A:>?/ 0 Lr0   rD   r   )r   )r   r   rG   r?   )schemar   s    @r.   format_schemar   7  s9    S	  : 
<

8R 89	::r0   print_formatc                 .    U S;  a  [        SU < 35      eg )N)showr   r|   materialized_viewmaketable_replicazUnknown format: )r+   )r   s    r.   validate_print_formatr   Z  s$       \;
<<r0   	formatterreference_typec                    [        U5        U[        R                  R                  :X  a  US:X  a  U R	                  S5        U R	                  S5        US:X  aV  U R	                  S5        U R	                  S5        U R	                  S5        U R	                  S5        U R	                  S	5        g5g5U[        R                  R
                  :X  a)  US:X  a  U R	                  S
5        U R	                  S5        g5U[        R                  R                  :X  a  US:X  a  U R	                  S5        US:X  a  U R	                  S5        U R	                  S	5        SU;   nU=(       d    SU;   nU(       a  U R	                  S5        SU;   a  U R	                  S5        SU;   a  U R	                  S5        SU;   a  U R	                  S5        SU;   a  U R	                  S5        g5g5g5U[        R                  R                  :X  a  US:X  aD  U R	                  S5        U R	                  S5        U R	                  S5        U R	                  S5        US:X  a2  UR                  5        H  nUS:w  d  M  U R	                  U45        M     g5g5U[        R                  R                  :X  a  US:X  a(  [         H  nUS:w  d  M  U R	                  U45        M     g5US:X  a   [         H  nU R	                  U45        M     g5US:X  a,  [         H!  nU[        ;  d  M  U R	                  U45        M#     g5g5U[        R                  R                  :X  a4  U R	                  S5        U R	                  S 5        U R	                  S!5        g5U[        R                  R                  :X  a  U R	                  S"5        g5U[        R                  R                  :X  aH  US:X  a  U R	                  S#5        US:X  a*  U R	                  S$5        S%U;   a  U R	                  S5        g5g5g5U[        R                  R                  :X  a  US:X  a"  U R	                  S&5        U R	                  S'5        US:X  ao  U R	                  S(5        S)U;   a  U R	                  S*5        S+U;   a  U R	                  S,5        S-U;   a  U R	                  S.5        S/U;   a  U R	                  S05        g5g5g5U[        R                  R                   :X  a  US:X  d  US:X  a  U R	                  S15        g5g5U[        R                  R"                  :X  Ga:  US:X  a"  U R	                  S25        U R	                  S35        US:X  a  S4nUbi  US   S6:X  a  U R	                  S75        S8nOLUS   S9:X  a  U R	                  S:5        S8nO/S;U;   a  U R	                  S<5        OS=U;   a  U R	                  S>5        U(       a  U R	                  S?5        U R	                  S	5        S%U;   a  U R	                  S5        S@U;   a  U R	                  S5        USA:X  a  U R	                  SB5        USC:X  a  U R	                  SD5        USE:X  a  U R	                  SF5        g5g5U[        R                  R$                  :X  a)  U R	                  ['        UR                  5       5      5        g5U[        R                  R(                  :X  aQ  SGn[*        R,                  R.                  [*        R0                  R2                  ;   a  / UQSHP7nU R	                  U5        g5U[        R                  R4                  :X  a  U R	                  SI5        g5U[        R                  R6                  :X  a  U R	                  SJ5        g5U[        R                  R8                  :X  a  U R	                  S5        g5U[        R                  R:                  :X  a  U R	                  SK5        g5[=        SLUR>                  < 35      e)Ma  Configure a formatter for a given reference type.

If print_format is 'show', configures the formatter with several
additional fields (useful for printing a single record).

Arguments:
  formatter: TableFormatter object to configure.
  reference_type: Type of object this formatter will be used with.
  print_format: Either 'show' or 'list' to control what fields are included.
  object_info: Resource dict to format.

Raises:
  ValueError: If reference_type or format is unknown.
r   )jobId)Job TypeState
Start TimeDurationr   )
User Email)Bytes Processed)Bytes Billed)Billing Tier)Labels)rO   )friendlyName)rP   )Last modifiedACLsrU   resource_tags)TagsdefaultEncryptionConfiguration)
kmsKeyNamerZ   )r   linkedDatasetSource)Source datasetmaxTimeTravelHours)Max time travel (Hours))r   )displayName)r   )r   r   r   )messageText)messageTime)severity)nextPageToken)Id
Model Typer   Creation Time)r   r   Feature ColumnsLabel Columnsr   r   Expiration TimeencryptionConfiguration)r   Routine TypeLanguager   Last Modified Time)	Is Remote)r   r   r   	Signature
Definitionr   r   remoteFunctionOptions)Remote Function Endpoint
ConnectionUser Defined ContextsparkOptions)
r   Runtime VersionContainer Image
PropertiesMain File URI
Main ClassPyFile URIsJar URIs	File URIsArchive URIspythonOptions)Entry PointPackagesexternalRuntimeOptions)r   r   Container MemoryContainer CPU)r   Filter PredicateGranteesr   r   )rR   r   )r   Time PartitioningClustered FieldsTNr   )r   Schemar   
ExpirationFEXTERNAL)r   r
  r   
Total URIsr  snapshotDefinition)
Base TableSnapshot TimeStampcloneDefinition)r  Clone TimeStamp)	r   r
  
Total RowsTotal Bytesr  r  r	  Total Logical BytesTotal Physical BytesresourceTagsr|   )Queryr   )r  Enable RefreshRefresh Interval MsLast Refresh Timer   )r   r   r
  Source TableSource Last Refresh TimeReplication Interval SecondsReplication StatusReplication Error)r   slotCapacitytargetJobConcurrencyignoreIdleSlotscreationTimer   multiRegionAuxiliaryeditionautoscaleMaxSlotsautoscaleCurrentSlotsmaxSlotsscalingModereservationGroup)
r   	slotCountplanrenewalPlanr   commitmentStartTimecommitmentEndTimer%  r&  
isFlatRate)r   jobTypeassignee)r   r   descriptionr   rZ   hasCredential
propertieszUnknown reference type: ) r   r   r   JobReference
AddColumnsProjectReferenceDatasetReferenceTransferConfigReferencekeysTransferRunReference$_COLUMNS_TO_INCLUDE_FOR_TRANSFER_RUN'_COLUMNS_EXCLUDED_FOR_MAKE_TRANSFER_RUNTransferLogReferenceNextPageTokenReferenceModelReferencer   RowAccessPolicyReferenceTableReferenceEncryptionServiceAccountr   ReservationReferencebq_flagsAlphaFeaturesRESERVATION_GROUPSALPHArJ   CapacityCommitmentReferenceReservationAssignmentReferenceReservationGroupReferenceConnectionReferencer+   __name__)	r   r   r   object_infoadd_tagsrI   columnuse_defaultshared_columnss	            r.   configure_formatterrU  f  s   ( %{22???v:&   v?+/0,-,-;'  44EEEv>**+44EEEv>*v  	 ;';&h;_;h	Y'	)[	8_-	;	Y'	+	-01		,9: 
-! $ 44LLLv9%+,,-:&v!!##&=


v
& $  44IIIv8&V


y
) 9 
	8&fY' 9		8&AB


y
) 9 
  44III)*)*'44KKK+,44CCCvJKv  	 
#k	1_- 
2  44EEEv  	 >*v  	 
!K	/ 
 	
 
;	& 
 	 
K	' 
 	 
"[	0 
 	 
1E R 44MMMv!7  	 "8 44CCCv  	 NOvk		 v&(


? + J.


M +![0


C
D+-


@
A	 	 

 
	 ;'	"k	1_-	;	&Y'v:&**  	 & 	 		 ' 44MMMk..01244IIIN 00HNN4H4HH
n (33OOO   		$	$	C	CD 8944NNN#44HHH   ^5L5LN
OOr0   object_typec                    U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                  :X  a  [        U 5      $ U[         R                  R                   :X  a  [#        U 5      $ U[         R                  R$                  :X  a  ['        U 5      $ U[         R                  R(                  :X  a  [+        U 5      $ U[         R                  R,                  :X  a  U $ [/        U[         R                  R0                  5      (       a	  [3        U S9$ [/        U[         R                  R4                  5      (       a  [7        U 5      $ [/        U[         R                  R8                  5      (       a  [;        U 5      $ [/        U[         R                  R<                  5      (       a  [?        U 5      $ U[         R                  R@                  :X  a  [C        U 5      $ [E        SU< 35      e)z<Format a single object_info (based on its 'kind' attribute).)reservationzUnknown object type: )#r   r   r7  format_job_infor9  format_project_infor:  format_dataset_inforD  format_table_inforB  format_model_infor   format_routine_inforC  format_row_access_policy_infor;  format_transfer_config_infor=  format_transfer_run_infor@  format_transfer_log_inforE  
issubclassrF  format_reservation_inforK  format_capacity_commitment_inforL  "format_reservation_assignment_inforM  format_reservation_group_inforN  format_connection_infor+   )rP  rV  s     r.   format_info_by_typeri    s-    K//<<<;''k11BBB{++k11BBB{++k11@@@[))k11@@@[))k11BBB{++k11JJJ(55k11III&{33k11FFF#K00k11FFF#K00k11JJJ;..CC  #{;;;..JJ  +;77;..MM  .k::;..HH  )55k11EEE!+..
+?
@@r0   c                    U R                  5       n[        R                  " U5      nUR                  [	        U5      5        UR                  S0 5      n[        R                  " U5      US'   US   S   US'   SU;   a  US   US'   US   S:X  a   [        R                  " U5        S	US'   SU;   aY  [        US   5      S-  nSU;   a4  [        US   5      S-  U-
  n[        [        R                  " US95      US'   [        U5      US'   [        R                   " U 5      nU(       a  XaS'   UR                  S0 5      nSU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   UR                  S0 5      nSU;   a  [#        US   5      US'   SU;   a  US   US'   SU;   a  US   US'   S U;   a  [	        US    5      US!'   S"U;   a  [	        US"   5      US#'   S$U;   a  [	        US$   5      US%'   S&U;   a  US&   US''   S(U;   a  US(   US)'   US(   S*:X  a  S+US,'   S-U;   a  [	        US-   5      US.'   U$ ! [        R                   a	    S
US'    GNf = f)/zkPrepare a job_info for printing.

Arguments:
  job_info: Job dict to format.

Returns:
  The new job_info.

statisticsr   statusr   r   
user_emailr   DONESUCCESSFAILUREr     r   )rs   r   r   z
Session IdquerytotalBytesProcessedr   totalBytesBilledr   billingTierr   configurationrB   r   numDmlAffectedRowszAffected RowsddlOperationPerformedzDDL Operation PerformedddlTargetTablezDDL Target TableddlTargetRoutinezDDL Target RoutineddlTargetRowAccessPolicyzDDL Target Row Access PolicyddlAffectedRowAccessPolicyCountz$DDL Affected Row Access Policy CountstatementTypezStatement TypeASSERTT	AssertiondefaultConnectionStatszDefault Connection Stats)r   r   ConstructObjectReferenceupdater   r?   GetJobTypeNamebq_client_utilsRaiseIfJobErrorr   BigqueryErrorintr   ro   	timedeltark   GetSessionIdrL   )	job_inforesult	referencestatsstartduration_seconds
session_idquery_statsconfigs	            r.   rY  rY    s    ==?& 99&A)--Y 
**\2
&%)88@&8$W-&/V!,/F<G_"%%f-!fWo Ek"#d*EEU9-.5=x11:JKLfZ&u-F< "..x8*%<		'2&+k) +,A BF;&();<F>k!(7F>::or*&%fX&67F8[()*>?F?+(34K(LF$%$!%k2B&C!DF;&#'4F(G#HF ;.-1./.F)* '+55@)6F12 #*?;F?#x/ f[,)-,-*F%& 
-c !! "!fWo"s   H3 3IIc                     U R                  5       n[        R                  " U5      nUR                  [	        U5      5        U$ )z{Prepare a project_info for printing.

Arguments:
  project_info: Project dict to format.

Returns:
  The new project_info.
)r   r   r  r  r   )project_infor  r  s      r.   rZ  rZ    s7     & 99&A)--Y 	-r0   c                 ~   0 nU S   S   US'   SUS'   SU ;   a  U S   US'   SU ;   a  [        U S   5      US'   S	U ;   a  [        [        U S	   5      S
-  5      US'   SU ;   a  [        [        U S   5      S
-  5      US'   SU ;   a  [        U S   5      US'   SU ;   a  [        U S   5      US'   SU ;   a  U S   S   US'   U$ )z|Prepare a model for printing.

Arguments:
  model_info: Model dict to format.

Returns:
  A dictionary of model properties.
modelReferencemodelIdr    r   	modelTyperB   r   r$  rq  r   expirationTimer   featureColumnsr   labelColumnsr   r   r   )rL   rk   r  re   )
model_infor  s     r.   r]  r]    s    &,-i8&,&J%k2F<%j&:;F8z!)J~&'$.F? # +J'()D0!F # ;#$!F z!9>"F? *,%&?@NF<	-r0   c           
         U S   nUS:X  a  SR                  U[        U S   5      5      $ US:X  aX  U S   S    Vs/ s H$  nSR                  US	   [        US
   5      5      PM&     nnSR                  USR                  U5      5      $ U$ s  snf )zConverts a routine data type to a pretty string representation.

Arguments:
  data_type: Routine data type dict to format.

Returns:
  A formatted string.
r[   r\   z{}<{}>r]   STRUCT
structTyper   {} {}r   rZ   r   rW   format_routine_data_typerG   )	data_type	type_kindrb   struct_fieldss       r.   r  r  5  s     
#)'??+I6H,IJ  H |,X66E 	uV}&>uV}&MN6   ??9dii&>??s   +B
c           
          U S    Vs/ s H$  nSR                  US   [        US   5      5      PM&     nnSR                  SR                  U5      5      $ s  snf )zConverts a routine table type to a pretty string representation.

Arguments:
  table_type: Routine table type dict to format.

Returns:
  A formatted string.
columnsr  r   rZ   z	TABLE<{}>r   r  )
table_typerR  r  s      r.   format_routine_table_typer  M  sc     y))& nnVF^%=fVn%MN) 
  
		DIIg.	//	s   +Ac                 ~   SU;   a  [        US   5      nOPUR                  S5      S:X  a  SnO8U S:X  a  SU;   a  [        US   5      nOU S:X  a  UR                  S5      S:X  a  SnS	U;   aQ  S
nSU;   a  US   S-   nU S:X  a&  SU;   a   US   (       d  SR                  X1S	   WS5      $ SR                  X1S	   W5      $ W$ )aD  Converts a routine argument to a pretty string representation.

Arguments:
  routine_type: The routine type of the corresponding routine. It's of string
    type corresponding to the string value of enum
    cloud.bigquery.v2.Routine.RoutineType.
  argument: Routine argument dict to format.

Returns:
  A formatted string.
dataTypeargumentKindANY_TYPEzANY TYPETABLE_VALUED_FUNCTION	tableType	ANY_TABLEz	ANY TABLEr   r  r    AGGREGATE_FUNCTIONisAggregatez
{}{} {} {}zNOT AGGREGATEz{}{} {})r  r?   r  rW   )routine_typeargumentdisplay_typeargument_modes       r.   format_routine_argument_infor  ]  s     8+HZ,@AL||N#z1L..;(3J,Xk-BCL--
,,~
&+
5LxMv&,m,,X%'  
&)<  mf-=|LLr0   c                   ^  0 nT S   S   US'   T S   US'   T R                  SS5      US'   S	nT R                  S
5      nT R                  S5      nST ;   a/  T S   nSR                  SR                  U 4S jU 5       5      5      nU(       a  SR                  U[        U5      5      nU(       a  SR                  U[	        U5      5      nU(       d  U(       d  ST ;   a  X!S'   ST ;   a  T S   US'   ST ;   a  [        [        T S   5      S-  5      US'   ST ;   a  [        [        T S   5      S-  5      US'   SUS'   ST ;   a3  SUS'   T S   S   US'   T S   S   US '   T S   R                  S!S5      US"'   S#T ;   a6  T S#   S$   US%'   T S#   R                  S&5      US''   T R                  S(5      US)'   S*T ;   as  T S*   R                  S+5      US,'   T S*   R                  S-5      US.'   T S*   R                  S/5      US0'   T S*   R                  S15      US '   T S*   R                  S25      US3'   S4T ;   a!  T S4   n/ S5QnU H  u  pX;   d  M  Xh   X'   M     U$ )6zPrepare a routine for printing.

Arguments:
  routine_info: Routine dict to format.

Returns:
  A dictionary of routine properties.
routineReference	routineIdr   routineTyper   languager  r   z()
returnTypereturnTableType	argumentsz({})r   c              3   B   >#    U  H  n[        TS    U5      v   M     g7f)r  N)r  )r   r  routine_infos     r.   r   &format_routine_info.<locals>.<genexpr>  s'      
) )m)DhOO)s   z{} -> {}r   definitionBodyr   r$  rq  r   lastModifiedTimer   Nor   r   Yesendpointr   r@   r   userDefinedContextr   r   
entryPointr  packagesr  importedLibraries	Librariesr  runtimeVersionr   containerMemoryr  containerCpur  runtimeConnectionmaxBatchingRowszMax Batching Rowsr   )
)r@   r   )r  r   )containerImager   )r6  r   )mainFileUrir   )	mainClassr   )
pyFileUrisr   )jarUrisr   )fileUrisr   )archiveUrisr   )r?   rW   rG   r  r  rk   r  )
r  r  	signaturereturn_typereturn_table_typeargument_listspark_optionsoptions	spark_key
result_keys
   `         r.   r^  r^    s    &01+>&,'6&#''
B7&)  .+"&&'89L  -M		 
)
 	
I !!+K8I !!,->?I %+*E#;%'(89F<|#)L()D0F? <'#.L+,-4$F  &,F;)56M)N*F%& ((?@NF<%12I%J%N%Nb&F!" $(9,GF=%o6:::FF: '**+>?F;- ,-E F J J!F "..F!G!K!K"F ++CDHHF? ((@AEEF< #//G"H"L"L#F |# 0MG ")			#*5 ") 
-r0   c                     0 nU S   S   US'   U S   US'   SR                  U S   5      US'   S	U ;   a  [        U S	   5      US
'   SU ;   a  [        U S   5      US'   U$ )zPrepare a row access policy for printing.

Arguments:
  row_access_policy_info: Row access policy dict to format.

Returns:
  A dictionary of row access policy properties.
rowAccessPolicyReferencepolicyIdr   filterPredicater  r   granteesr  r$  r   r  r   )rG   rt   )row_access_policy_infor  s     r.   r_  r_    s     &'(BCJO&,56GH&	yy!7
!CD&--J~.F? 11#O12$F  
-r0   c                    U R                  5       n[        R                  " U5      nUR                  [	        U5      5        SU;   a  [        [        US   5      S-  5      US'   SU;   a  [        US   5      US'   SU;   a  [        US   5      US'   SU;   a  [        US   5      US	'   S
U;   a  US
   S   US'   SU;   a  US   US'   US   S:X  aD  SU;   a>  US   S   n[        [        R                  R                  R                  " S0 UD65      US'   US   S:X  a'  SU;   a!  US   nSU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   U$ )z{Prepare a dataset_info for printing.

Arguments:
  dataset_info: Dataset dict to format.

Returns:
  The new dataset_info.
r  rq  r   accessr   rB   r   r  r   r   r   rZ   r   LINKEDr   sourceDatasetr   r  externalDatasetReferenceexternal_sourcezExternal sourcer@   r   r   r   rS   )r   r   r  r  r   rk   r  r   rL   rX   r   r   r   r:  Create)dataset_infor  r  source_datasetexternal_dataset_references        r.   r[  r[    s    & 99&A)--Y 6!)F%&'$.F? x 01F6N%fX&67F8v*6.+ABF6N%/!"BCF< vF^F6Nf~!&;v&E34_En!$

%
%
6
6
=
=
O
O"f f~#(Bf(L#)*D#E 	8	8$>%
 ! 
3	39,G|V#(./C(DF$%	-r0   c                    U R                  5       n[        R                  " U5      nUR                  [	        U5      5        SU;   a  [        [        US   5      S-  5      US'   SU;   a  [        US   5      US'   SU;   a  US   US'   SU;   a  US   US	'   S
U;   a  US
   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  US   US'   SU;   a  [        [        US   5      S-  5      US'   SU;   a  [        US   5      US'   SU;   a  [        US   5      US'   S U;   a  S!US    ;   a  US    S!   US"'   OS#US"'   / nS$US    ;   a  US    S$   nUR                  S%U-  5        S&US    ;   a&  [        US    S&   5      nUR                  S'U4-  5        U(       a!  US"==   S(S)R                  U5      < S*3-  ss'   S+U;   a#  S,US+   ;   a  S)R                  US+   S,   5      US-'   S!U;   GaA  US!   US.'   S/U;   a  S0US/   ;   a  US/   S0   US1'   S2U;   aq  S0US2   ;   ah  US2   S0   US1'   S3US2   ;   a  US2   S3   US4'   S5US2   ;   a  US2   S5   US6'   S7US2   ;   a,  US2   S7   S8:w  a   [        [        US2   S7   5      S-  5      US9'   S:U;   a  [        US:   S;   5      US<'   [        [        US:   S=   5      S-  5      US>'   US:   S?   US@'   SAUS:   ;   a   [        [        US:   SA   5      S-  5      USB'   SCUS:   ;   a  US:   SC   SD   USE'   US!   SF:X  a  SGU;   a  [        USG   SH   5      USI'   SJU;   a  SKUSJ   ;   a  USJ   SK   USK'   SLU;   a  USL   SM   USN'   [        USL   SO   5      USP'   SQU;   a  USQ   SM   USN'   [        USQ   SR   5      USS'   U$ )TzsPrepare a table_info for printing.

Arguments:
  table_info: Table dict to format.

Returns:
  The new table_info.
r  rq  r   r   r
  numBytesr  numTotalLogicalBytesr  numLongTermLogicalByteszLong-Term Logical BytesnumActiveLogicalByteszActive Logical BytesnumPartitionszTotal PartitionsnumTotalPhysicalBytesr  numActivePhysicalByteszActive Physical BytesnumLongTermPhysicalByteszLong-Term Physical BytesnumTimeTravelByteszTime Travel BytesnumRowsr  r  r  rB   r   r  r   timePartitioningrZ   r  DAYrb   z	field: %sexpirationMszexpirationMs: %dr   r   r   
clusteringr   r	  r   r|   rr  r  materializedViewenableRefreshr  refreshIntervalMsr  lastRefreshTime0r  tableReplicationInfosourceTabler  replicationIntervalMsr  replicationStatusr  replicatedSourceLastRefreshTimer  replicationErrormessager   r  externalDataConfiguration
sourceUrisr  r   r   r  baseTableReferencer  snapshotTimer  r  	cloneTimer  )r   r   r  r  r   rk   r  r   rL   rX   r   rG   rT   r   rt   )
table_infor  r  
extra_infopartitioning_fieldexpiration_mss         r.   r\  r\  -  s    ??& 99&A)--Y 6!)F%&'$.F? $VH%56F86":.F=v%$*+A$BF !&((./H(IF$%&%+,C%DF!"!'!8F&%+,C%DF!"'&,-E&FF"#6))/0J)KF%&V#"()=">F&!),F<&s62B+C'Dt'KLF<%fX&67F8v*6.+ABF6N6!*++$*+=$>v$Ff !$)f !J&+,,!"45g>&889 233&!34^DEm*m-==> !		*0E%GG!V6,''#'99VL-A(-K#Lf vF^F6NGvf~5vw/fWoV#6:L3M(M127;fWo	F#56	6#)*<#=o#N 	'9 :	:(./A(B)
$% v&89
9'():;sB&1)*+<=>E'
"# '6
'
(
7 f^ 03
f+,-DE
F
M0f+, &,,B%C
&f!" 
+f5K.L	L-8-.5
 .
)* 
v&<=	=&,-C&D'

'"# f~#	$	."./= 
|  6)
&!:;
;!";<\JF<V#!"678LMF<#O#$^4$F  & !"345IJF< L !+.!F 
-r0   c                 D    0 nU R                  5        H	  u  p#X1U'   M     U$ )zPrepare transfer config info for printing.

Arguments:
  transfer_config_info: transfer config info to format.

Returns:
  The new transfer config info.
rE   )transfer_config_infor  rI   rJ   s       r.   r`  r`    s,     &(..0jc3K 1 
-r0   c                 D    0 nU R                  5        H	  u  p#X1U'   M     U$ )zPrepare transfer log info for printing.

Arguments:
  transfer_log_info: transfer log info to format.

Returns:
  The new transfer config log.
r  )transfer_log_infor  rI   rJ   s       r.   rb  rb    s,     &%++-jc3K . 
-r0   c                 \    0 nU R                  5        H  u  p#U[        ;   d  M  X1U'   M     U$ )zPrepare transfer run info for printing.

Arguments:
  transfer_run_info: transfer run info to format.

Returns:
  The new transfer run info.
)rE   r>  )transfer_run_infor  rI   rJ   s       r.   ra  ra    s5     &%++-jc
22Sk . 
-r0   c                    0 nU R                  5        Hd  u  p#US:X  aU  [        R                  " U5      u  pEn[        R                  R
                  R                  XEUS9nUR                  5       X'   M`  X1U'   Mf     S[        UR                  5       5      ;  a  SUS'   S[        UR                  5       5      ;  a  SUS'   S[        UR                  5       5      ;  a  SUS'   S[        UR                  5       5      ;   a  US   US	'   UR                  SS
5        OSUS	'   S[        UR                  5       5      ;   a?  SUS   ;   a$  US   S   US'   SUS'   SUS   ;   a  US   S   US'   UR                  SS
5        U$ )zPrepare a reservation for printing.

Arguments:
  reservation: reservation to format.

Returns:
  A dictionary of reservation properties.
r   )rO   locationreservationIdr!  r  r#  Falser%  concurrencyr"  Nz0 (auto)	autoscaler)  r'  r(  currentSlots)rE   r  ParseReservationPathr   r   rF  r  __str__r   r<  r   )rX  r  rI   rJ   
project_idr  reservation_idr  s           r.   rd  rd    s    &%%'jc
f}

.
.u
5 +jN --BBII J i %%'fkSk ( 4.. F>d6;;=11 'F4#66%,F!"d6;;=))%+M%:F!"
JJ}d#%/F!"D''VK(($*;$7
$Cf !(+f$%	6+.	.*0*=n*M&'
JJ{D!	-r0   reservation_groupc                     0 nU R                  5        He  u  p#US:X  aV  [        R                  " U5      u  pEn[        R                  R
                  R                  UUUS9nUR                  5       X'   Ma  X1U'   Mg     U$ )zPrepare a reservation group for printing.

Arguments:
  reservation_group: reservation group to format.

Returns:
  A dictionary of reservation group properties.
r   )rO   r  reservationGroupId)rE   r  ParseReservationGroupPathr   r   rM  r  r&  )r)  r  rI   rJ   r'  r  reservation_group_idr  s           r.   rg  rg    s     &%++-jc
f}

3
3E
: 1j0 --GGNN1 O i
 %%'fkSk . 
-r0   c                    0 nU R                  5        He  u  p#US:X  aV  [        R                  " U5      u  pEn[        R                  R
                  R                  UUUS9nUR                  5       X'   Ma  X1U'   Mg     S[        UR                  5       5      ;  a  SUS'   S[        UR                  5       5      ;  a  SUS'   U$ )zPrepare a capacity commitment for printing.

Arguments:
  capacity_commitment: capacity commitment to format.

Returns:
  A dictionary of capacity commitment properties.
r   )rO   r  capacityCommitmentIdr,  r  r%  r!  )
rE   r  ParseCapacityCommitmentPathr   r   rK  r  r&  r   r<  )capacity_commitmentr  rI   rJ   r'  r  capacity_commitment_idr  s           r.   re  re  '  s     &'--/jc
f}

5
5e
< 3j2 
%
%
A
A
H
H"#9 I   %%'fkSk 0  V[[]++F;4#66%,F!"	-r0   c                     0 nU R                  5        Hf  u  p#US:X  aW  [        R                  " U5      u  pEpg[        R                  R
                  R                  UUUUS9nUR                  5       X'   Mb  X1U'   Mh     U$ )zPrepare a reservation_assignment for printing.

Arguments:
  reservation_assignment: reservation_assignment to format.

Returns:
  A dictionary of reservation_assignment properties.
r   )rO   r  r   reservationAssignmentId)rE   r  ParseReservationAssignmentPathr   r   rL  r  r&  )	reservation_assignmentr  rI   rJ   r'  r  r(  reservation_assignment_idr  s	            r.   rf  rf  H  s     &*002jc
f}

8
8
? FjN 
%
%
D
D
K
K"*&?	 L   %%'fkSk 3  
-r0   c                 
   0 nU R                  5        H  u  p#US:X  aU  [        R                  " U5      u  pEn[        R                  R
                  R                  XEUS9nUR                  5       X'   M`  US:X  a  [        [        U5      S-  5      US'   M  U[        R                  ;   a=  [        R                  R                  U5      US'   [        R                  " U5      US'   M  X1U'   M     U R                  SS	5      US'   U$ )
zPrepare a connection object for printing.

Arguments:
  connection: connection to format.

Returns:
  A dictionary of connection properties.
r   )rO   r  connectionIdr  rq  r   rZ   r6  r5  F)rE   r  ParseConnectionPathr   r   rN  r  r&  rk   r  r   CONNECTION_PROPERTY_TO_TYPE_MAPr?   r!   r*   )r@   r  rI   rJ   r'  r  connection_idr  s           r.   rh  rh  e  s     &$$&jc
f},;,O,O
-)jM --AAHH I i %%'fk	"	" +CJ,= >f_	"BB	B)IIMM
fVn "ZZ.f\Sk# '$ 'NN?EB&	-r0   )r!   )N)r   N)N__doc__r   ro   r!   sysrh   typingr   r   r   r   r   r   r	   r
   typing_extensionsr   table_formatterrG  clientsr   r  r   r   r   r   r   collections_abcversion_infoabcServicer>  r?  
FormatTyper/   rA   r   rL   r   rD  rT   rX   re   floatrk   rt   ru   __annotations__rv   rw   rx   ry   r   r   r   TableFormatter	ReferenceCustomPrintFormatrU  ri  rY  rZ  r]  r  r  r  r^  r_  r[  r\  r`  rb  ra  rd  rg  re  rf  rh  rS   r0   r.   <module>rM     s   4    
  F F F '   ,     $fOO/


( $" +O ' -3)). ?CZ%i&:&:;Z	Zz!4S> !c !&&55!S#X !3 ! .?e ? ?c c  !  i 
 eCHouS#Xc3hOP
I P',\:-E'F 9 FS%S#X0C*D%D EFy FI!M I!c I!X ;S  ;F	= 	= 	= 17	]P--]P44>>?]P --]P@	-A";#>#>#H#HI-A`HV"J3 00S 0 'C 'T]@0+\{|"  ,^CH~	#s(^8B:r0   