
                  4          d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlZddl	Z	ddl
mZmZmZmZmZmZ ddlZddlmZ ddlmZ ddlZdd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! 	 dsdejD                  dee#e#f   dee$   dee$   fdZ%dejD                  fdZ&	 	 	 	 	 	 	 	 dtdejD                  dee jN                  jP                     dee$   dee#   deeee#   e#f      dee#   dee#   dee)   dee#   fdZ*	 	 	 	 	 	 	 	 dtdejD                  dee jN                  jP                     dee$   dee#   deeee#   e#f      dee#   dee#   dee)   dee#   fdZ+	 	 	 	 	 	 dudejD                  d ee jN                  jX                     d!e jN                  jX                  d"ee#   d#ee#   d$ee)   d%ee#   d&ee#   fd'Z-dejD                  de jN                  j\                  d(e)fd)Z/	 dvdejD                  de jN                  j\                  d*ee)   fd+Z0	 	 	 	 dwdejD                  d,ee#   d-ee#   d.ee#   d/ee#   f
d0Z1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dxdejD                  d1e#d2ee)   d3ee)   d4ee)   d5ee#   d6ee$   dee$   d7ee$   d8ee$   d9ee$   d:ee2   d,ee#   d;ee)   d/ee#   d<eejD                  jf                     d=ee#   d>ee)   f$d?Z4	 	 	 	 	 dydejD                  d.ee#   d,ee#   dee$   d7ee$   d/ee#   fd@Z5	 	 	 	 dwdejD                  d,ee#   d-ee#   d.ee#   d/ee#   f
dAZ6	 	 	 	 	 dydejD                  dBee)   d,ee#   d-ee#   d.ee#   d/ee#   fdCZ7	 	 	 dzdejD                  d,ee#   d.ee#   d/ee#   fdDZ8dEejr                  dfdejD                  dFe jN                  j\                  dGe#dHe$dIeeg ejt                  f      f
dJZ;	 	 d{dejD                  dFe jN                  j\                  dGe#dHe$fdKZ<dejD                  de$de$fdLZ=ddddddejr                  dddddddddddfdejD                  d1e#d2ee)   d3ee)   d4ee)   d5ee#   d6ee$   dee$   dHe$d:ee2   dIeeg ejt                  f      dMee$   d/ee#   d<eejD                  jf                     d=ee#   d8ee$   d9ee$   f"dNZ>	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d|dejD                  d1e#dOee#   d"ee#   d#ee#   dPee#   d4ee)   dQee)   d2ee)   d3ee)   d:ee2   dRee)   dSee$   d6ee$   d;ee)   dTeee#      dUeee#e#f      d8ee$   d9ee$   d>ee)   d<eejD                  jf                     d=ee#   f,dVZ?	 d}dejD                  d=ee#   dWe)d(ee#   fdXZ@	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d~dejD                  dYe jN                  jX                  dZe#d"ee#   d#ee#   d[ee#   d\ee)   d]ee#   d^ee#   d_ee$   d`ee)   daee#   dbee)   dcee)   ddee)   deeee#      dfee)   dTeee#      dgee#   dheee#      diee)   djee#   d=ee#   dkee)   dlee#   f2dmZA	 	 	 	 	 	 	 	 dtdejD                  de jN                  jX                  dne#doee)   d[ee#   dpee#   dqee#   diee)   d=ee#   fdrZBy)z$The BigQuery CLI job client library.    )absolute_import)division)print_functionN)AnyCallableDictListOptionalUnion)flags)http)bigquery_client)table_reader)utils)wait_printer)bq_error)bq_id_utils)bq_processor_utilsbqclientjob_dict	start_rowmax_rowsc                    |t        d      |t        d      |sd}n)t        j                  j                  j                  di |}t
        j                  j                  r/|r-t        j                  | j                  | j                  ||      }n+t        j                  | j                  | j                  |      }|j                  ||      S )aS  Convenience method to get the schema and rows from job query result.

  Arguments:
    bqclient: A BigqueryClient to get state and request clients from.
    job_dict: job reference dictionary.
    start_row: first row to read.
    max_rows: number of rows to read.
    result_first_page: the first page of the result of a query job.

  Returns:
    A tuple where the first item is the list of fields and the
    second item a list of rows.
  Raises:
    ValueError: will be raised if start_row is not explicitly provided.
    ValueError: will be raised if max_rows is not explicitly provided.
  Nzstart_row is requiredzmax_rows is required )
ValueErrorr   ApiClientHelperJobReferenceCreater   FLAGS$jobs_query_use_results_from_responsebq_table_readerQueryTableReader	apiclientmax_rows_per_requestJobTableReaderReadSchemaAndRows)r   r   r   r   result_first_pagejob_refreaders          !platform/bq/clients/client_job.pyReadSchemaAndJobRowsr+      s    . 
,
--
+
,,	8<G))66==IIG
[[55:K--%%	F ++H997F 
	!	!
     c           
      \    t        t        t        j                  t	        | fi |            S N)listmapr   ConstructObjectReferenceListJobs)r   kwdss     r*   ListJobRefsr4   M   s-    		

5
5
8
$t
$
 r,   	referencemax_results
page_tokenstate_filtermin_creation_timemax_creation_time	all_usersparent_job_idc	                 .    t        | ||||||||	      d   S )an  Return a list of jobs.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    reference: The ProjectReference to list jobs for.
    max_results: The maximum number of jobs to return.
    page_token: Current page token (optional).
    state_filter: A single state filter or a list of filters to apply. If not
      specified, no filtering is applied.
    min_creation_time: Timestamp in milliseconds. Only return jobs created after
      or at this timestamp.
    max_creation_time: Timestamp in milliseconds. Only return jobs created
      before or at this timestamp.
    all_users: Whether to list jobs for all users of the project. Requesting
      user must be an owner of the project to list all jobs.
    parent_job_id: Retrieve only child jobs belonging to this parent; None to
      retrieve top-level jobs.

  Returns:
    A list of jobs.
  results)ListJobsWithTokenAndUnreachable)	r   r5   r6   r7   r8   r9   r:   r;   r<   s	            r*   r2   r2   V   s7    B 
)

 

 
r,   c	                    t        j                  | |      }t        j                  |t        j                  j
                  d       |#|t        j                  kD  rt        j                  }t        j                  |||      }	|>t        |t              r|j                         }n|D 
cg c]  }
|
j                          }}
t        j                  |	d|||       |||	d<   |||	d<    | j                  j                         j                  di |	j!                         }|j#                  dg       }|d	|v rt%        |      |k  r|t%        |      z
  |	d
<   |d	   |	d<    | j                  j                         j                  di |	j!                         }|j'                  |j#                  dg              d	|v rt%        |      |k  rt)        |      }d	|v r|d	   |d<   d|v r|d   |d<   |S c c}
w )a  Return a list of jobs.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    reference: The ProjectReference to list jobs for.
    max_results: The maximum number of jobs to return.
    page_token: Current page token (optional).
    state_filter: A single state filter or a list of filters to apply. If not
      specified, no filtering is applied.
    min_creation_time: Timestamp in milliseconds. Only return jobs created after
      or at this timestamp.
    max_creation_time: Timestamp in milliseconds. Only return jobs created
      before or at this timestamp.
    all_users: Whether to list jobs for all users of the project. Requesting
      user must be an owner of the project to list all jobs.
    parent_job_id: Retrieve only child jobs belonging to this parent; None to
      retrieve top-level jobs.

  Returns:
    A dict that contains enytries:
      'results': a list of jobs
      'token': nextPageToken for the last page, if present.
  )id_fallbacksr5   r2   methodfull)
projectionr8   r;   r<   minCreationTimemaxCreationTimejobsnextPageToken
maxResults	pageToken)r>   tokenunreachabler   )bq_client_utilsNormalizeProjectReferencer   	typecheckr   ProjectReferencer   MAX_RESULTSPrepareListRequest
isinstancestrlowerApplyParametersr#   rH   r/   executegetlenextenddict)r   r5   r6   r7   r8   r9   r:   r;   r<   requestsresultr>   responses                 r*   r?   r?      s
   F 77y) !!22
 '333&22k11j' ,$!'')l)56Aaggil6$$! "!2G"!2G)8""$))4G4<<>&JJvr"'
V
#G{(B)CL8gl#O4gk-x!!&&(--88@@BfnnVZZ+,	 V
#G{(B
 '"(/HW f$]3H]	/9 7s   +G5source_referencesdest_referencecreate_dispositionwrite_dispositionignore_already_existsoperation_typedestination_expiration_timec	                    |D ]2  }
t        j                  |
t         j                  j                  d       4 t        j                  |t         j                  j                  d       t	        |      |D 
cg c]  }
t	        |
       c}
d}|r||d<   |r||d<   |r||d<   t        j                  |||       	 t        | d|ifi |	S c c}
w # t        j                  $ r}|rY d	}~y	|d	}~ww xY w)
a  Copies a table.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    source_references: TableReferences of source tables.
    dest_reference: TableReference of destination table.
    create_disposition: Optional. Specifies the create_disposition for the
      dest_reference.
    write_disposition: Optional. Specifies the write_disposition for the
      dest_reference.
    ignore_already_exists: Whether to ignore "already exists" errors.
    encryption_configuration: Optional. Allows user to encrypt the table from
      the copy table command with Cloud KMS key. Passed as a dictionary in the
      following format: {'kmsKeyName': 'destination_kms_key'}
    **kwds: Passed on to ExecuteJob.

  Returns:
    The job description, or None for ignored errors.

  Raises:
    BigqueryDuplicateError: when write_disposition 'WRITE_EMPTY' is
      specified and the dest_reference table already exists.
  	CopyTablerB   )destinationTablesourceTables"destinationEncryptionConfigurationoperationTypedestinationExpirationTime)rc   rd   copyN)
r   rP   r   TableReferencer\   r   rW   
ExecuteJobr   BigqueryDuplicateError)r   ra   rb   rc   rd   re   encryption_configurationrf   rg   r3   src_refcopy_configes                r*   ri   ri      s   F #g##22 # !!00 ~.4EF4EtG}4EF+ 8PK45#1K  /JK+,$$+)h 5>>>% G& 
	(	( 
Gs$   6C
;C C0"C+)C++C0returnc                    t        j                  |t         j                  j                  d       	  | j                  j                         j                  di t        |      j                         S # t        j                  $ r Y yw xY w)zReturns true if the job exists.	JobExistsrB   Fr   )r   rP   r   r   r#   rH   rY   r\   rX   r   BigqueryNotFoundError)r   r5   s     r*   ry   ry   "  st    
 ,,99+(8""$((;4	?;CCEE		'	' s   A A3 3B	B	ignore_not_foundc                     t        j                  |t         j                  j                  d       	  | j                  j                         j                  di t        |      j                          y# t        j                  $ r |s Y yw xY w)a  Deletes JobReference reference.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    reference: the JobReference to delete.
    ignore_not_found: Whether to ignore "not found" errors.

  Raises:
    BigqueryTypeError: if reference is not a JobReference.
    bq_error.BigqueryNotFoundError: if reference does not exist and
      ignore_not_found is False.
  	DeleteJobrB   Nr   )r   rP   r   r   r#   rH   deleter\   rX   r   rz   )r   r5   r{   s      r*   r}   r}   0  sy    " ,,99+$H$$7tI7??A		'	'  s   AA4 4BB
project_idupload_filejob_idlocationc                    |xs | j                   }|st        j                  d      |j                         }| j                  rt        d | j                  D              |d<   d|i}|xs | j                  }t        |t        j                        r|j                  |      }|||d}||d<   |r||d<   d}|rH| j                  }	t        j                  |      j                  d	k(  rd
}	t        j                   |d|	      }| j"                  j%                         j'                  |||      }
|r	rt)        j*                  |
      }|S |
j-                         }|S )a  Start a job with the given configuration.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    configuration: The configuration for a job.
    project_id: The project_id to run the job under. If None,
      bqclient.project_id is used.
    upload_file: A file to include as a media upload to this request. Only valid
      on job requests that expect a media upload file.
    job_id: A unique job_id to use for this job. If a JobIdGenerator, a job id
      will be generated from the job configuration. If None, a unique job_id
      will be created for this request.
    location: Optional. The geographic location where the job should run.

  Returns:
    The job resource returned from the insert job request. If there is an
    error, the jobReference field will still be filled out with the job
    reference used in the request.

  Raises:
    bq_error.BigqueryClientConfigurationError: if project_id and
      bqclient.project_id are None.
  z(Cannot start a job without a project id.c              3   J   K   | ]  }|j                  d       ddd     yw)=r   N   )	partition).0props     r*   	<genexpr>zStartJob.<locals>.<genexpr>w  s)      '.CdsADqD!.Cs   !#
propertiesconfiguration)jobId	projectIdjobReferencer    r   Fzapplication/octet-stream)filenamemimetype	resumable)body
media_bodyr   )r   r    BigqueryClientConfigurationErrorro   job_propertyr\   job_id_generatorrT   rN   JobIdGeneratorGenerateenable_resumable_uploadsosstatst_sizehttp_requestMediaFileUploadr#   rH   insertr   execute_in_chunks_with_progressrX   )r   r   r   r   r   r   job_requestjob_referencemedia_uploadr   r]   r_   s               r*   StartJobr   Q  ss   > 0X00*	

3
32   $$&-"& '.6.C.C' #M, !-0+ .X..&667__]+F$:>M"/K"*mJ,11I 
ww{##q(i//+L
 ##%,,<: - ' Y99'BF 
- __F	-r,   querydry_run	use_cachepreserve_nulls
request_idmaximum_bytes_billed
timeout_msjob_timeout_ms	max_slotsmin_completion_ratiouse_legacy_sqljob_creation_modereservation_idcreate_sessionc                    |xs | j                   }|st        j                  d      d|i}|r||d<   |r||d<   | j                  r"t	        j
                  | j                        |d<   |7t        j                  j                  rt        t        j                               }t        | |      }t        j                  |fi d|d|d	|d
|d|d|	d|
d|d|d|d|d|d|d|d|d|d|dn|rdnd t        j                  ||       t        j                  ||       t        j                   d|||        | j"                  j%                         j&                  d||d|j)                         S )a  Executes the given query using the rpc-style query api.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    query: Query to execute.
    dry_run: Optional. Indicates whether the query will only be validated and
      return processing statistics instead of actually running.
    use_cache: Optional. Whether to use the query cache. Caching is best-effort
      only and you should not make assumptions about whether or how long a query
      result will be cached.
    preserve_nulls: Optional. Indicates whether to preserve nulls in input data.
      Temporary flag; will be removed in a future version.
    request_id: Optional. The idempotency token for jobs.query
    maximum_bytes_billed: Optional. Upper limit on the number of billed bytes.
    max_results: Maximum number of results to return.
    timeout_ms: Timeout, in milliseconds, for the call to query().
    job_timeout_ms: Optional. How long to let the job run.
    max_slots: Optional. Cap on target rate of slot consumption by the query.
    min_completion_ratio: Optional. Specifies the minimum fraction of data that
      must be scanned before a query returns. This value should be between 0.0
      and 1.0 inclusive.
    project_id: Project id to use.
    external_table_definitions_json: Json representation of external table
      definitions.
    udf_resources: Array of inline and external UDF code resources.
    use_legacy_sql: The 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.
    location: Optional. The geographic location where the job should run.
    connection_properties: Optional. Connection properties to use when running
      the query, presented as a list of key/value pairs. A key of "time_zone"
      indicates that the query will be run with the default timezone
      corresponding to the value.
    job_creation_mode: Optional. An option for job creation. The valid values
      are JOB_CREATION_REQUIRED and JOB_CREATION_OPTIONAL.
    reservation_id: Optional. An option to set the reservation to use when
      execute the job. Reservation should be in the format of
      "project_id:reservation_id", "project_id:location.reservation_id", or
      "reservation_id".
    create_session: Optional. True to create a session for the query.
    query_parameters: parameter values for use_legacy_sql=False queries.
    positional_parameter_mode: If true, set the parameter mode to POSITIONAL
      instead of the default NAMED.
    destination_encryption_configuration: Optional. Allows user to encrypt the
      table created from a query job with a Cloud KMS key.
    **kwds: Extra keyword arguments passed directly to jobs.Query().

  Returns:
    The query response.

  Raises:
    bq_error.BigqueryClientConfigurationError: if project_id and
      bqclient.project_id are None.
    bq_error.BigqueryError: if query execution fails.
  z(Cannot run a query without a project id.r   tableDefinitionsuserDefinedFunctionResourcesdefaultDatasetNr   r   r   use_query_cacher   r   r   r6   r   r   r   reservationr   r   query_parameters$destination_encryption_configurationparameter_mode
POSITIONALNAMEDconnection_properties)r   z3Calling bqclient.apiclient.jobs().query(%s, %s, %s))r   r   r   )r   r   r   
dataset_idrN   GetQueryDefaultDatasetr   r   jobs_query_use_request_idrU   uuiduuid4_GetReservationPathr   rW   loggingdebugr#   rH   r   rX   )r   r   r   r   r   r   r   r6   r   r   r   r   r   external_table_definitions_jsonudf_resourcesr   r   r   r   r   r   r   positional_parameter_moder   r3   r]   reservation_paths                              r*   _StartQueryRpcr     s   j 0X00*	

3
32  e'$"AG.;G*+ / F F!G EKKAATZZ\"J(
 $$#  0	
    $   $ 0 * #  $  (!" ,P#& 
#	* 5L7), $$%: $$Wg>	--;
	hu9Z9379wyr,   c                     |xs | j                   }|st        j                  d      i }t        j                  ||||||        | j
                  j                         j                  di |j                         S )aP  Waits for a query job to run and returns results if complete.

  By default, waits 10s for the provided job to complete and either returns
  the results or a response where jobComplete is set to false. The timeout can
  be increased but the call is not guaranteed to wait for the specified
  timeout.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    job_id: The job id of the query job that we are waiting to complete.
    project_id: The project id of the query job.
    max_results: The maximum number of results.
    timeout_ms: The number of milliseconds to wait for the query to complete.
    location: Optional. The geographic location of the job.

  Returns:
    The getQueryResults() result.

  Raises:
    bq_error.BigqueryClientConfigurationError: if project_id and
      bqclient.project_id are None.
  z.Cannot get query results without a project id.)r   r   r   r6   r   r   )	r   r   r   r   rW   r#   rH   getQueryResultsrX   )r   r   r   r6   r   r   r3   s          r*   GetQueryResultsr   2  s    < 0X00*	

3
38  
$$$
 
3			 	 	"	2	2	:T	:	B	B	DDr,   c                     t        | |||||      }|d   d   dk7  r!t        j                  |      }t        | |      }t	        j
                  |      S )a  Starts a job and waits for it to complete.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    configuration: The configuration for a job.
    project_id: The project_id to run the job under. If None,
      bqclient.project_id is used.
    upload_file: A file to include as a media upload to this request. Only valid
      on job requests that expect a media upload file.
    job_id: A unique job_id to use for this job. If a JobIdGenerator, a job id
      will be generated from the job configuration. If None, a unique job_id
      will be created for this request.
    location: Optional. The geographic location where the job should run.

  Returns:
    job, if it did not fail.

  Raises:
    BigQueryError: if the job fails.
  r   r   r   r   statusstateDONE)r   r   r1   WaitJobrN   RaiseIfJobError)r   r   r   r   r   r   r_   r   s           r*   RunJobSynchronouslyr   a  sa    8 & Hg&(&??GMX}-F		(	(	00r,   syncc                     || j                   }|rt        | |||||      }|S t        | |||||      }t        j                  |       |S )z,Execute a job, possibly waiting for results.r   )r   r   r   rN   r   )r   r   r   r   r   r   r   jobs           r*   rq   rq     sk     
\==D	
C$ 
* C ##C(	*r,   c                    |xs | j                   }|st        j                  d      |st        j                  d      t        j                  j
                  j                  |||      } | j                  j                         j                  d	i t        |      j                         d   }|d   d   dk7  r.| j                  r"t        j                  |      }t        | |      }|S )
a  Attempt to cancel the specified job if it is running.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    project_id: The project_id to the job is running under. If None,
      bqclient.project_id is used.
    job_id: The job id for this job.
    location: Optional. The geographic location of the job.

  Returns:
    The job resource returned for the job for which cancel is being requested.

  Raises:
    bq_error.BigqueryClientConfigurationError: if project_id or job_id
      are None.
  z)Cannot cancel a job without a project id.z%Cannot cancel a job without a job id.)r   r   r   r   r   r   r   )r   r   )r   r   r   r   r   r   r   r#   rH   cancelr\   rX   r   r   r1   r   )r   r   r   r   r   r_   s         r*   	CancelJobr     s    , 0X00*	

3
33  


3
3/  --::AA&8 B - 'h&&=m)<=EEGN 	 Hg&(X]]&??GMX];F	-r,   r   r   r   waitwait_printer_factoryc                    t        j                  |t         j                  j                  d       t	        j                         }d}|r |       }n| j                         }t        j                  t        j                  dd      t        ddd      t        j                  d            }d	}	d
}
d}|	|k  r	 t        | |||      \  }}|d   d   }
d}|r|j                  |j                  |	|
       nw	 t        t'        |            D ]K  }t	        j                         |z
  }	|j                  |j                  |	|
       t	        j(                  d       M |	|k  rt+        d|
      |j-                          |S # t        j                  $ r }t        j                   d|       Y d}~d}~wt        j"                  $ r }t        j                   d|       Y d}~d}~wt        j$                  $ r}|r d}Y d}~d}~ww xY w)a  Poll for a job to run until it reaches the requested status.

  Arguments:
    bqclient: A BigqueryClient to get state and request clients from.
    job_reference: JobReference to poll.
    status: (optional, default 'DONE') Desired job status.
    wait: (optional, default maxint) Max wait time.
    wait_printer_factory: (optional, defaults to bqclient.wait_printer_factory)
      Returns a subclass of WaitPrinter that will be called after each job poll.

  Returns:
    The job object returned by the final status call.

  Raises:
    StopIteration: If polling does not reach the desired state before
      timing out.
    ValueError: If given an invalid wait value.
  r   rB   N      r         r   UNKNOWNF)r   r   r   r   z+Transient error during job status check: %sTz1Wait timed out. Operation not finished, in state )r   rP   r   r   timer   	itertoolschainrepeatrangePollJobprintr   r   BigqueryCommunicationErrorr   warningBigqueryBackendErrorBigqueryServiceErrornextsleepStopIterationdone)r   r   r   r   r   
start_timer   printerwaitscurrent_waitcurrent_statusin_error_stater   rv   _s                  r*   r   r     s   6 !!..
 yy{*#"$G++-G
 //aU1b!_b% ,..(M&tLidC8}W-nn	m))<H 
" 4;YY[:-lmmM''~F
jjm  - 	6 	  
,,.	*1 .. HooCQGG(( HooCQGG((  
ns0   6;E; ;H F))H ?GH 0G;;H c                 ,   t        j                  |t         j                  j                  d       t	        j
                  |      } | j                  j                         j                  di t        |      j                         }|d   d   }||k(  |fS )a  Poll a job once for a specific status.

  Arguments:
    bqclient: A BigqueryClient to get state and request clients from.
    job_reference: JobReference to poll.
    status: (optional, default 'DONE') Desired job status.
    wait: (optional, default 0) Max server-side wait time for one poll call.

  Returns:
    Tuple (in_state, job) where in_state is True if job is
    in the desired state.

  Raises:
    ValueError: If given an invalid wait value.
  r   rB   r   r   r   )r   rP   r   r   rN   NormalizeWaitr#   rH   rY   r\   rX   )r   r   r   r   r   currents         r*   r   r   -  s    * !!..
 
	&	&t	,$%!%%<](;<DDF#M'"'
V
S	!!r,   c                 ^    t        |      }d|d<   t        | fi |}t        | |d   ||      S )aZ  Run a query job synchronously, and return the result.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    start_row: first row to read.
    max_rows: number of rows to read.
    **kwds: Passed on to Query.

  Returns:
    A tuple where the first item is the list of fields and the
    second item a list of rows.
  Tr   r   )r   r   )r\   Queryr+   )r   r   r   r3   new_kwdsr   s         r*   RunQueryr  R  sD    $ $Z((6h#(##		.	
 r,   max_single_waitc                    | j                   st        j                  d      |st        j                  d      |/t        j                  j
                  st        j                  d      |
r |
       }n| j                         }t        j                         }d}d}d}	 	 |dnt        j                         |z
  }||z
  }|-t        t        ||      dz        }|dk  rt        j                  }|dk  rt        d      ||}| j                  .|| j                  }nt        | j                  t        |            }t        d)i d| d	|d
|d|d|d|d|d|	d|d|d|d|d|d|d|d|d||}|rLt        t        t        |d                     }d|v r|d   |d   d	   d<   d|v r|d   |d   d	   d<   g g |fS d |v rdt!        j"                  j$                  j&                  d)i |d    }n7|j)                  |j*                  |d!       t-        | |j*                  |||"      }|d#   r9t/        | |rt        |      ni d||$      \  }}i } d%|v r|d%   | d%<   d&| |d'}|||fS 	 # t        j0                  $ r }!t3        j4                  d(|!       Y d}!~!0d}!~!wt        j6                  $ r }!t3        j4                  d(|!       Y d}!~!ad}!~!ww xY w)*a  Executes the given query using the rpc-style query api.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    query: Query to execute.
    dry_run: Optional. Indicates whether the query will only be validated and
      return processing statistics instead of actually running.
    use_cache: Optional. Whether to use the query cache. Caching is best-effort
      only and you should not make assumptions about whether or how long a query
      result will be cached.
    preserve_nulls: Optional. Indicates whether to preserve nulls in input data.
      Temporary flag; will be removed in a future version.
    request_id: Optional. Specifies the idempotency token for the request.
    maximum_bytes_billed: Optional. Upper limit on maximum bytes billed.
    max_results: Optional. Maximum number of results to return.
    wait: (optional, default maxint) Max wait time in seconds.
    min_completion_ratio: Optional. Specifies the minimum fraction of data that
      must be scanned before a query returns. This value should be between 0.0
      and 1.0 inclusive.
    wait_printer_factory: (optional, defaults to bqclient.wait_printer_factory)
      Returns a subclass of WaitPrinter that will be called after each job poll.
    max_single_wait: Optional. Maximum number of seconds to wait for each call
      to query() / getQueryResults().
    external_table_definitions_json: Json representation of external table
      definitions.
    udf_resources: Array of inline and remote UDF resources.
    location: Optional. The geographic location where the job should run.
    connection_properties: Optional. Connection properties to use when running
      the query, presented as a list of key/value pairs. A key of "time_zone"
      indicates that the query will be run with the default timezone
      corresponding to the value.
    job_creation_mode: Optional. An option for job creation. The valid values
      are JOB_CREATION_REQUIRED and JOB_CREATION_OPTIONAL.
    reservation_id: Optional. An option to set the reservation to use when
      execute the job. Reservation should be in the format of
      "project_id:reservation_id", "project_id:location.reservation_id", or
      "reservation_id".
    job_timeout_ms: Optional. How long to let the job run.
    max_slots: Optional. Cap on target rate of slot consumption by the query.
    **kwds: Passed directly to ExecuteSyncQuery.

  Raises:
    bq_error.BigqueryClientError: if no query is provided.
    StopIteration: if the query does not complete within wait seconds.
    bq_error.BigqueryError: if query fails.

  Returns:
    A tuple (schema fields, row results, execution metadata).
      For regular queries, the execution metadata dict contains
      the 'State' and 'status' elements that would be in a job result
      after FormatJobInfo().
      For dry run queries schema and rows are empty, the execution metadata
      dict contains statistics
  z7Running RPC-style query asynchronously is not supportedNo query string providedNzrequest_id is not yet supportedr   i  z#Wait timed out. Query not finished.r   r   r   r   r   r   r   r   r   r   r6   r   r   r   r   r   r   totalBytesProcessed)r  )r   )
statisticscacheHitr	  schemar   RUNNING)r6   r   r   jobComplete)r   r   r'   errorsSUCCESS)Stater   r   z Transient error during query: %sr   )r   r   BigqueryClientErrorr   r   r   r   r   intminsysmaxsizer   r$   r   r\   r   r   r   r   r   r   r   r+   r   r   r   r   )"r   r   r   r   r   r   r   r6   r   r   r   r  r   r   r   r   r   r   r   r   r3   r   r   elapsed_timer   current_wait_msremaining_timerows_to_readr_   	executionr  rowsr   rv   s"                                     r*   RunQueryRpcr  p  s   b 


&
&A  


&
&'A
BBEKK$I$I

&
&'H
II"$G++-Gyy{*,-/\='/QTYY[:5Mll*n		$ c./BTIJQKK/	!	ABB		 #((4!#88Lx<<c,>OPL 


 *
 "	

 "6
  
 
 "6
 *
  
 %
 -L
 (
 
 #8
  0!
" *%
( *01F*G) 6!;A*;MIl#G,Z89?9IIl#G,X6b)$
$V#%55BBII ~&- 	m))<C #&
 
	-#0Db $
 v#H-&
)
	
 i((% 
K 	p .. =oo8!<<(( =oo8!<<=s,    D(I2 	B%I2 2KJ  K6KKdestination_tablepriorityallow_large_resultsflatten_resultsmaximum_billing_tierschema_update_optionslabelsc                     |st        j                  d      d|i}!| j                  r"t        j                  | j                        |!d<   |r||!d<   |r||!d<   |r&	 t        j
                  | |      }"t        |"      |!d
<   |r||!d<   |r||!d<   |r|j                  |!d<   t        j                  |!fi d|d|d|d|d|d|	d|d|d|d|d|d|d|d|d|d|
d|d|d | t        j                  |!|!       d|!i}$t        | |d"#      }%t        j                  |$||||%$       t        j                  |$|%       t        | |$fi | S # t         j                  $ r }#t        j                  d|d|#      d	}#~#ww xY w)&a  Execute the given query, returning the created job.

  The job will execute synchronously if sync=True is provided as an
  argument or if bqclient.sync is true.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    query: Query to execute.
    destination_table: (default None) If provided, send the results to the given
      table.
    create_disposition: Optional. Specifies the create_disposition for the
      destination_table.
    write_disposition: Optional. Specifies the write_disposition for the
      destination_table.
    priority: Optional. Priority to run the query with. Either 'INTERACTIVE'
      (default) or 'BATCH'.
    preserve_nulls: Optional. Indicates whether to preserve nulls in input data.
      Temporary flag; will be removed in a future version.
    allow_large_results: Enables larger destination table sizes.
    dry_run: Optional. Indicates whether the query will only be validated and
      return processing statistics instead of actually running.
    use_cache: Optional. Whether to use the query cache. If create_disposition
      is CREATE_NEVER, will only run the query if the result is already cached.
      Caching is best-effort only and you should not make assumptions about
      whether or how long a query result will be cached.
    min_completion_ratio: Optional. Specifies the minimum fraction of data that
      must be scanned before a query returns. This value should be between 0.0
      and 1.0 inclusive.
    flatten_results: Whether to flatten nested and repeated fields in the result
      schema. If not set, the default behavior is to flatten.
    external_table_definitions_json: Json representation of external table
      definitions.
    udf_resources: Array of inline and remote UDF resources.
    maximum_billing_tier: Upper limit for billing tier.
    maximum_bytes_billed: Upper limit for bytes billed.
    use_legacy_sql: The 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.
    schema_update_options: schema update options when appending to the
      destination table or truncating a table partition.
    labels: an optional dict of labels to set on the query job.
    query_parameters: parameter values for use_legacy_sql=False queries.
    time_partitioning: Optional. Provides time based partitioning specification
      for the destination table.
    clustering: Optional. Provides clustering specification for the destination
      table.
    destination_encryption_configuration: Optional. Allows user to encrypt the
      table created from a query job with a Cloud KMS key.
    range_partitioning: Optional. Provides range partitioning specification for
      the destination table.
    script_options: Optional. Options controlling script execution.
    job_timeout_ms: Optional. How long to let the job run.
    continuous: Optional. Whether the query should be executed as continuous
      query.
    job_creation_mode: Optional. An option for job creation. The valid values
      are JOB_CREATION_REQUIRED and JOB_CREATION_OPTIONAL.
    reservation_id: Optional. An option to set the reservation to use when
      execute the job. Reservation should be in the format of
      "project_id:reservation_id", "project_id:location.reservation_id", or
      "reservation_id". If reservation_id is "none", the job will be executed
      without assigned reservation using the on-demand slots.
    **kwds: Passed on to ExecuteJob.

  Raises:
    bq_error.BigqueryClientError: if no query is provided.

  Returns:
    The resulting job info.
  r  r   r   r   r   )rA   
identifierzInvalid value z for destination_table: Nrj   rl   scriptOptionsjobCreationModer  rc   r   r  rd   r   r   r!  r   r   r"  r   time_partitioning
clusteringr   r   
continuousr   range_partitioningr   F)check_reservation_project)r   r#  r   r   )r   )r   r  r   rN   r   GetTableReferenceBigqueryErrorr\   namer   rW   r   rq   )&r   r   r  rc   rd   r  r   r  r   r   r   r   r   r   r!  r   r   r"  r#  r   r(  r   r)  r+  script_optionsr   r   r   r   r*  r   r   r3   query_configr5   rv   r]   r   s&                                         r*   r  r  4  sM   X 


&
&'A
BB5!,%4%K%K&L!" %'FL#$3@L/0!33,=i (,IL#$), 56 $2L!&7&<&<L"#$$- , $	
  *   & 0 0 $ 2 ( *   $!" 0#$ %& *'( ,), $$*? l#'( %
 $$#" $$ 
Hg	.	..o !! "":KQ
O s   E F&FFr,  c                     ||dk(  r|S t        j                  | |t        j                  j                  |      }|j                         S )a&  Converts the reservation_id from the format `<project_id>:<location>.<reservation_id>` to the fully qualified reservation path `projects/<project_id>/locations/<location>/reservations/<reservation_id>`.

  The special value "none" is returned as is.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    reservation_id: The reservation id to convert.
    check_reservation_project: Whether to validate the reservation project.

  Returns:
    The fully qualified reservation path or "none" if reservation_id is "none".
  nonerA   r%  default_locationr,  )rN   GetReservationReferencebq_flagsLOCATIONvaluepath)r   r   r,  r5   s       r*   r   r     sN    " ~755((.. 9	) 
	r,   destination_table_referencesourcefield_delimiterskip_leading_rowsencodingquotemax_bad_recordsallow_quoted_newlinessource_formatallow_jagged_rows!preserve_ascii_control_charactersignore_unknown_valuesprojection_fields
autodetectnull_markernull_markersuse_avro_logical_typesjson_extensioncopy_files_onlysource_column_matchc+                 h   t        j                  |t         j                  j                         dt	        |      i},t        j                  |      }-|-d   j                  t
        j                        r|-|,d<   d}.n|-d   }.|dt        j                  |      i|,d<   |||,d<   |||,d<   |$|$|,d	<   |||,d
<   |||,d<   |&|&|,d<   ||,d<   |r||,d<   |||,d<   | | |,d<   |!|!|,d<   |"|"|,d<   |#|#|,d<   |*|*|,d<   t        j                  |,fi d|d|d|d|d|d|	d|
d|d|d|d|d |d!|d"|d#|d$|d%|d&|d'|d(|d)|d*|%d+|'d,|)d-|& d.|,i}/|(Dt        j                  | |(t        j                  j                  d/0      }0|0j!                         |/d1<   t#        | f|/|.d2|+S )3a  Load the given data into BigQuery.

  The job will execute synchronously if sync=True is provided as an
  argument or if bqclient.sync is true.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    destination_table_reference: TableReference to load data into.
    source: String specifying source data to load.
    schema: (default None) Schema of the created table. (Can be left blank for
      append operations.)
    create_disposition: Optional. Specifies the create_disposition for the
      destination_table_reference.
    write_disposition: Optional. Specifies the write_disposition for the
      destination_table_reference.
    field_delimiter: Optional. Specifies the single byte field delimiter.
    skip_leading_rows: Optional. Number of rows of initial data to skip.
    encoding: Optional. Specifies character encoding of the input data. May be
      "UTF-8" or "ISO-8859-1". Defaults to UTF-8 if not specified.
    quote: Optional. Quote character to use. Default is '"'. Note that quoting
      is done on the raw binary data before encoding is applied.
    max_bad_records: Optional. Maximum number of bad records that should be
      ignored before the entire job is aborted. Only supported for CSV and
      NEWLINE_DELIMITED_JSON file formats.
    allow_quoted_newlines: Optional. Whether to allow quoted newlines in CSV
      import data.
    source_format: Optional. Format of source data. May be "CSV",
      "DATASTORE_BACKUP", or "NEWLINE_DELIMITED_JSON".
    allow_jagged_rows: Optional. Whether to allow missing trailing optional
      columns in CSV import data.
    preserve_ascii_control_characters: Optional. Whether to preserve embedded
      Ascii Control characters in CSV import data.
    ignore_unknown_values: Optional. Whether to allow extra, unrecognized values
      in CSV or JSON data.
    projection_fields: Optional. If sourceFormat is set to "DATASTORE_BACKUP",
      indicates which entity properties to load into BigQuery from a Cloud
      Datastore backup.
    autodetect: Optional. If true, then we automatically infer the schema and
      options of the source files if they are CSV or JSON formats.
    schema_update_options: schema update options when appending to the
      destination table or truncating a table partition.
    null_marker: Optional. String that will be interpreted as a NULL value.
    null_markers: Optional. List of strings that will be interpreted as a NULL
      value.
    time_partitioning: Optional. Provides time based partitioning specification
      for the destination table.
    clustering: Optional. Provides clustering specification for the destination
      table.
    destination_encryption_configuration: Optional. Allows user to encrypt the
      table created from a load job with Cloud KMS key.
    use_avro_logical_types: Optional. Allows user to override default behaviour
      for Avro logical types. If this is set, Avro fields with logical types
      will be interpreted into their corresponding types (ie. TIMESTAMP),
      instead of only using their raw types (ie. INTEGER).
    reference_file_schema_uri: Optional. Allows user to provide a reference file
      with the reader schema, enabled for the format: AVRO, PARQUET, ORC.
    range_partitioning: Optional. Provides range partitioning specification for
      the destination table.
    hive_partitioning_options: (experimental) Options for configuring hive is
      picked if it is in the specified list and if it supports the precision and
      the scale. STRING supports all precision and scale values. If none of the
      listed types supports the precision and the scale, the type supporting the
      widest range in the specified list is picked, and if a value exceeds the
      supported range when reading the data, an error will be returned. This
      field cannot contain duplicate types. The order of the
    decimal_target_types: (experimental) Defines the list of possible SQL data
      types to which the source decimal values are converted. This list and the
      precision and the scale parameters of the decimal field determine the
      target type. In the order of NUMERIC, BIGNUMERIC, and STRING, a type is
      picked if it is in the specified list and if it supports the precision and
      the scale. STRING supports all precision and scale values. If none of the
      listed types supports the precision and the scale, the type supporting the
      widest range in the specified list is picked, and if a value exceeds the
      supported range when reading the data, an error will be returned. This
      field cannot contain duplicate types. The order of the types in this field
      is ignored. For example, ["BIGNUMERIC", "NUMERIC"] is the same as
      ["NUMERIC", "BIGNUMERIC"] and NUMERIC always takes precedence over
      BIGNUMERIC. Defaults to ["NUMERIC", "STRING"] for ORC and ["NUMERIC"] for
      the other file formats.
    json_extension: (experimental) Specify alternative parsing for JSON source
      format. To load newline-delimited JSON, specify 'GEOJSON'. Only applicable
      if `source_format` is 'NEWLINE_DELIMITED_JSON'.
    column_name_character_map: Indicates the character map used for column
      names. Specify 'STRICT' to use the latest character map and reject invalid
      column names. Specify 'V1' to support alphanumeric + underscore and name
      must start with a letter or underscore. Invalid column names will be
      normalized. Specify 'V2' to support flexible column name. Invalid column
      names will be normalized.
    file_set_spec_type: Set how to discover files for loading. Specify
      'FILE_SYSTEM_MATCH' (default behavior) to expand source URIs by listing
      files from the underlying object store. Specify
      'NEW_LINE_DELIMITED_MANIFEST' to parse the URIs as new line delimited
      manifest files, where each line contains a URI (No wild-card URIs are
      supported).
    thrift_options: (experimental) Options for configuring Apache Thrift load,
      which is required if `source_format` is 'THRIFT'.
    parquet_options: Options for configuring parquet files load, only applicable
      if `source_format` is 'PARQUET'.
    connection_properties: Optional. ConnectionProperties for load job.
    reservation_id: Optional. An option to set the reservation to use when
      execute the job. Reservation should be in the format of
      "project_id:reservation_id", "project_id:location.reservation_id", or
      "reservation_id".
    copy_files_only: Optional. True to configures the load job to only copy
      files to the destination BigLake managed table, without reading file
      content and writing them to new files.
    source_column_match: Optional. Controls the strategy used to match loaded
      columns to the schema.
    **kwds: Passed on to ExecuteJob.

  Returns:
    The resulting job info.
  rj   r   
sourceUrisNfieldsr  useAvroLogicalTypesreference_file_schema_urifileSetSpecTypejsonExtensioncolumnNameCharacterMapparquetOptionsdecimalTargetTypesrl   timeZone
dateFormatdatetimeFormat
timeFormattimestampFormatsourceColumnMatchrc   rd   r=  r>  r?  r@  rA  rC  rB  rD  rE  rF  rG  r"  rI  rJ  r(  r)  rH  r+  hive_partitioning_optionsthrift_optionsr   rM  parquet_optionsloadFr4  r   )r   r   )r   rP   r   rp   r\   r   ProcessSources
startswithGCS_SCHEME_PREFIXrN   
ReadSchemarW   r6  r7  r8  r9  r:  rq   )1r   r;  r<  r  rc   rd   r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  r"  rI  rJ  r(  r)  r   rK  rS  r+  r_  decimal_target_typesrL  column_name_character_map	time_zonedate_formatdatetime_formattime_formattimestamp_formatfile_set_spec_typer`  ra  r   r   rM  rN  r3   load_configsourcesr   r   r5   s1                                                    r*   Loadrq    s   ~ !;#>#>#M#M $T*E%FG+--f5'QZ-??@ 'KK!*K%'A'A&'IJK')?K%&*/HK+,#%7K!"#1K *,EK() $3K !&:+"#), 45 'K
 +K $3K ! +K!%5K!"$':K#$$$+ * &	
 *   & " 2 * )J 2 * 2  !"  #$ *%& '( )* ,+, !:-. $/0 212 &34 &58 ;'-77!!**00"'	I $->>#3M- 	
+
HL
 r,   destination_urisprint_headerdestination_formatcompressionc           	      x   t        j                  |t         j                  j                  t         j                  j                  fd       |j                  d      }|D ]T  }|j                  t        j                        r#t        j                  dj                  |t        j                               i }t        |t         j                  j                        rdt        |      i}n_t        |t         j                  j                        r;dt        |      i}|r|j                  dd|ii       |r|j                  dd	|ii       t        j                  |||||||	
       d|i}|
Dt!        j"                  | |
t$        j&                  j(                  d      }|j+                         |d<   t-        | fd|i|S )a  Extract the given table from BigQuery.

  The job will execute synchronously if sync=True is provided as an
  argument or if bqclient.sync is true.

  Args:
    bqclient: A BigqueryClient to get state and request clients from.
    reference: TableReference to read data from.
    destination_uris: String specifying one or more destination locations,
      separated by commas.
    print_header: Optional. Whether to print out a header row in the results.
    field_delimiter: Optional. Specifies the single byte field delimiter.
    destination_format: Optional. Format to extract table to. May be "CSV",
      "AVRO" or "NEWLINE_DELIMITED_JSON".
    trial_id: Optional. 1-based ID of the trial to be exported from a
      hyperparameter tuning model.
    add_serving_default_signature: Optional. Whether to add serving_default
      signature for BigQuery ML trained tf based models.
    compression: Optional. The compression type to use for exported files.
      Possible values include "GZIP" and "NONE". The default value is NONE.
    use_avro_logical_types: Optional. Whether to use avro logical types for
      applicable column types on extract jobs.
    reservation_id: Optional. An option to set the reservation to use when
      execute the job. Reservation should be in the format of
      "project_id:reservation_id", "project_id:location.reservation_id", or
      "reservation_id".
    **kwds: Passed on to ExecuteJob.

  Returns:
    The resulting job info.

  Raises:
    bq_error.BigqueryClientError: if required parameters are invalid.
  ExtractrB   ,z2Illegal URI: {}. Extract URI must start with "{}".sourceTablesourceModelmodelExtractOptionstrialIdaddServingDefaultSignature)rr  rt  rs  r=  ru  rK  extractFr4  r   r   )r   rP   r   rp   ModelReferencesplitrd  r   re  r   r  formatrT   r\   updaterW   rN   r6  r7  r8  r9  r:  rq   )r   r5   rr  rs  r=  rt  trial_idadd_serving_default_signatureru  rK  r   r3   urisuriextract_configr   s                   r*   rw  rw    s   ` 

%
%
4
4

%
%
4
4  
			$$c>>,>>?((
>
E
E%77   .	;66EEF#T)_5N)[88GGH#T)_5N2Y4IJK$
*,I" 	
 $$+%3 n--77!!**00"'	I $->>#3M- 	H	BM	BT	BBr,   r.   )NNNNNNNN)NNFNCOPYN)F)NNNN)NNNNNNNNNNNNNNNNNNNNNN)NNNNN)NNN)r   r   )NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN)T)(NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN)C__doc__
__future__r   r   r   r   r   r   r  r   typingr   r   r   r	   r
   r   r   abslr   googleapiclientr   r   r7  clientsr   r   r!   r   rN   r   r   r   r   BigqueryClientrU   r  r+   r4   r   rQ   boolr2   r?   rp   ri   r   ry   r}   r   floatJobCreationModer   r   r   rq   r   r  WaitPrinterr   r   r  r  r  r   rq  rw  r   r,   r*   <module>r     sx   * &  %   	 
  = =   0  # 3 ,     $ ,,,,38n, }, sm	,^/88  IM!% $48'+'+ $#'+,,+33DDE+ #+ 	+
 5cC01+  }+  }+ ~+ C=+` IM!% $48'+'+ $#'R,,R33DDER #R 	R
 5cC01R  }R  }R ~R C=Rr )-'+,1!$*15F,,FK77FFGF  //>>F !	F
  }F $D>F SMF "*#FR,,**77 
" (-,,**77 tnH !%!% "I,,I I #	I
 SMI smI^ # $%) $*.!% $$(#,0 $$(%)" 	$(%)")-5R,,RR d^R ~	R
 TNR R #3-R #R R SMR }R #5/R R  TN!R" sm#R&  &&66'R, SM-R. TN/Rn ! $!% $",E,,,ESM,E ,E #	,E
 ,E sm,Ed !%!% "'1,,'1 '1 #	'1
 SM'1 sm'1Z   $!% " ,,  4.  	 
 #  SM  sm J !% "	),,)) SM) sm	)^  	P,,P..;;P P 	P
 #\---.Pl 	",,"..;;" " 	"J,, B # $%) $*.!%,0 	%)$(" 	$($(#1A=,,A=A= d^A= ~	A=
 TNA= A= #3-A= #A= A= #5/A= #\---.A= c]A=" sm#A=&  &&66'A=, SM-A=. SM/A=0 }1A=N (,(,'+"%)*." $,0&*$(*.*.%)15'+)-$(#%) 	$(Es/,,s/s/  }s/ !	s/
  }s/ sms/ TNs/ "$s/ d^s/ ~s/ #5/s/ d^s/ #3-s/  #3-!s/" TN#s/$ $DI.%s/& T#s(^$'s/4 SM5s/6 }7s/8 TN9s/>  &&66?s/D SMEs/r '+,,SM  $ c]	@ (,'+%)(,"%),0#'(,8<,0-1!%15!%(,)--1""$("$(&*)-Wr,,r!,!<!<!K!Kr r
 !r  }r c]r  ~r smr C=r c]r $D>r C=r  ~r (0~r  $D>!r"  S	*#r$ %r& $DI.'r( #)r* 49%+r2 %TN3r< SM=rR SMSrT d^UrV "#Wrv $(%)(,"&!%-1$(_C,,_C**99_C _C 4.	_C
 c]_C !_C #_C %TN_C SM_Cr,   