
    '                         S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSKJr  SSKJ
r  SS	KJr   " S
 S\R                   5      rg)zThe BigQuery CLI mkdef command.    )absolute_import)division)print_functionN)Optional)flags)bigquery_command)utilsc                   t   ^  \ rS rSrSrS\S\R                  4U 4S jjr SS\S\	\   S\	\
   4S	 jjrS
rU =r$ )MakeExternalTableDefinition   zmkdef <source_uri> [<schema>]namefvc           	      `  > [         [        U ]  X5        [        R                  " SS SUS9  [        R                  " SS SSUS9  [        R
                  " SS S	US9  [        R
                  " S
S SUS9  [        R                  " SS SUS9  [        R                  " SS/ SQSUS9  [        R
                  " SS SUS9  [        R                  " SSSUS9  [        R                  " SSSUS9  [        R                  " SS[        R                  US9  [        R                  " SS SS/SUS9  [        R                  " SS S S!/S"US9  [        R                  " S#SS$US9  [        R
                  " S%S S&US9  [        R                  " S'S / S(QS)S*US9  [        R                  " S+S S,S-/S.US9  [        R                  " US9U l        [        R                  " US9U l        [        R                  " US9U l        [        R                   " US9U l        [        R$                  " US9U l        [        R(                  " US9U l        [        R,                  " US9U l        [        R0                  " US9U l        [        R4                  " US9U l        [        R8                  " US9U l        U R=                  U5        g )/N
autodetectz1Should schema and format options be autodetected.)flag_valuesignore_unknown_valuesz>Ignore any values in a row that are not present in the schema.i)
short_namer   hive_partitioning_modezEnables hive partitioning.  AUTO indicates to perform automatic type inference.  STRINGS indicates to treat all hive partition keys as STRING typed.  No other values are accepted#hive_partitioning_source_uri_prefixzPrefix after which hive partition encoding begins.  For URIs like gs://bucket/path/key1=value/file, the value should be gs://bucket/path.require_hive_partition_filterzbWhether queries against a table are required to include a hive partition key in a query predicate.source_formatCSV)	r   GOOGLE_SHEETSNEWLINE_DELIMITED_JSONDATASTORE_BACKUP
DELTA_LAKEORCPARQUETAVROICEBERGzFormat of source data. Options include:
 CSV
 GOOGLE_SHEETS
 NEWLINE_DELIMITED_JSON
 DATASTORE_BACKUP
 DELTA_LAKE
 ORC
 PARQUET
 ICEBERG
 AVROconnection_ida  The connection specifying the credentials to be used to read external storage, such as Azure Blob, Cloud Storage, or S3. The connection_id can have the form "<project_id>.<location_id>.<connection_id>" or "projects/<project_id>/locations/<location_id>/connections/<connection_id>".use_avro_logical_typesTzIf sourceFormat is set to "AVRO", indicates whether to enable interpreting logical types into their corresponding types (ie. TIMESTAMP), instead of only using their raw types (ie. INTEGER).parquet_enum_as_stringFzHInfer Parquet ENUM logical type as STRING (instead of BYTES by default).parquet_enable_list_inferencemetadata_cache_mode	AUTOMATICMANUALzEnables metadata cache for an external table with a connection. Specify AUTOMATIC to automatically refresh the cached metadata. Specify MANUAL to stop the automatic refresh.object_metadata	DIRECTORYSIMPLEz/Object Metadata Type. Options include:
 SIMPLE.!preserve_ascii_control_characterszLWhether to preserve embedded Ascii Control characters in CSV External table reference_file_schema_urizqprovide a referencing file with the expected table schema, currently enabled for the formats: AVRO, PARQUET, ORC.encoding)zUTF-8z
ISO-8859-1zUTF-16BEzUTF-16LEzUTF-32BEzUTF-32LEzThe character encoding used by the input file.  Options include:
 ISO-8859-1 (also known as Latin-1)
 UTF-8
 UTF-16BE (UTF-16 BigEndian)
 UTF-16LE (UTF-16 LittleEndian)
 UTF-32BE (UTF-32 BigEndian)
 UTF-32LE (UTF-16 LittleEndian)Efile_set_spec_typeFILE_SYSTEM_MATCHNEW_LINE_DELIMITED_MANIFESTaU  Specifies how to discover files given source URIs. Options include: 
 FILE_SYSTEM_MATCH: expand source URIs by listing files from the underlying object store. This is the default behavior.
 NEW_LINE_DELIMITED_MANIFEST: indicate the source URIs provided are new line delimited manifest files, where each line contains a URI with no wild-card.)superr   __init__r   DEFINE_booleanDEFINE_stringDEFINE_enumfrontend_utils"PARQUET_LIST_INFERENCE_DESCRIPTIONfrontend_flagsdefine_null_markernull_marker_flagdefine_null_markersnull_markers_flagdefine_time_zonetime_zone_flagdefine_date_formatdate_format_flagdefine_datetime_formatdatetime_format_flagdefine_time_formattime_format_flagdefine_timestamp_formattimestamp_format_flagdefine_source_column_matchsource_column_match_flagdefine_parquet_map_target_typeparquet_map_target_type_flag!define_timestamp_target_precisiontimestamp_target_precision_flag_ProcessCommandRc)selfr   r   	__class__s      %platform/bq/frontend/command_mkdef.pyr4   $MakeExternalTableDefinition.__init__   s   	
%t5d?	;	 
H 
 	H  
-	0  
'	= 

	
		 14 
	
 	 
 	P  
 	) 
'99	 
	h	8  
	h: 
+	 
#	7 
O	,  
	;<	  +=="MD+??BOD(99bID*=="MD . E E!D +=="MD!/!G!G"D %3$M$M%D! 	55"E 	% 	88RH 	( 	2    source_urisschemareturnc                    [         R                  " [        R                  " S!0 SU R                  _SU_SU_SU R
                  _SU R                  _SU R                  _SU R                  _SU R                  _S	U R                  _S
U R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                   _SU R"                  _SU R$                  _SU R&                  _SU R(                  R*                  _SU R,                  R*                  _SU R.                  R*                  _SU R0                  R*                  _SU R2                  R*                  _SU R4                  R*                  _SU R6                  R*                  _SU R8                  R*                  _SU R:                  R*                  _SU R<                  R*                  _6[>        R@                  SSS9  g )"aY  Emits a definition in JSON for an external table, such as GCS.

The output of this command can be redirected to a file and used for the
external_table_definition flag with the "bq query" and "bq mk" commands.
It produces a definition with the most commonly used values for options.
You can modify the output to override option values.

The <source_uris> argument is a comma-separated list of URIs indicating
the data referenced by this external table.

The <schema> argument should be either the name of a JSON file or a text
schema.

In the case that the schema is provided in text form, it should be a
comma-separated list of entries of the form name[:type], where type will
default to string if not specified.

In the case that <schema> is a filename, it should be a JSON file
containing a single array, each entry of which should be an object with
properties 'name', 'type', and (optionally) 'mode'. For more detail:
https://cloud.google.com/bigquery/docs/schemas#specifying_a_json_schema_file

Note: the case of a single-entry schema with no type specified is
ambiguous; one can use name:string to force interpretation as a
text schema.

Usage:
  mkdef <source_uris> [<schema>]

Examples:
  bq mkdef 'gs://bucket/file.csv' field1:integer,field2:string

Arguments:
  source_uris: Comma-separated list of URIs.
  schema: Either a text schema or JSON file, as above.
r   rU   rV   r   r"   r   r   r   r   r#   r$   r%   r&   r)   r,   r-   r.   r0   null_markernull_markers	time_zonedate_formatdatetime_formattime_formattimestamp_formatsource_column_matchparquet_map_target_typetimestamp_target_precisionT   )	sort_keysindentN )!jsondumpr8   CreateExternalTableDefinitionr   r   r"   r   r   r   r   r#   r$   r%   r&   r)   r,   r-   r.   r0   r<   valuer>   r@   rB   rD   rF   rH   rJ   rL   rN   sysstdout)rP   rU   rV   s      rR   RunWithArgs'MakeExternalTableDefinition.RunWithArgs   s   P 	II44 	
,,	
#	
 	
 		

 ,,	
 #'"<"<	
 $(#>#>	
 150X0X	
 +/*L*L	
 $(#>#>	
 $(#>#>	
 +/*L*L	
 !% 8 8	
 !00	
 /3.T.T	
  '+&D&D!	
" ]]#	
$  $66%	
& --33'	
( //55)	
* ))//+	
, --33-	
. !55;;/	
0 --331	
2 "77==3	
4 !% = = C C5	
6 %)$E$E$K$K7	
8 (,'K'K'Q'Q9	
< 	

C"rT   )
rB   rD   r<   r>   rL   rJ   rF   r@   rH   rN   )N)__name__
__module____qualname____firstlineno__usagestrr   
FlagValuesr4   r   intrm   __static_attributes____classcell__)rQ   s   @rR   r   r      sY    
-%m3 mE$4$4 m` 7;JJ&.smJ}J JrT   r   )__doc__
__future__r   r   r   rg   rk   typingr   abslr   frontendr   r:   r	   r8   BigqueryCmdr   rf   rT   rR   <module>r      s;    % &  %  
   % , ,|"2">"> |rT   