DESCRIBE - Amazon Athena

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

DESCRIBE

Visualizza una o più colonne, tra cui quelle di partizione, per la tabella specificata. Questo comando è utile per esaminare gli attributi di colonne complesse.

Riepilogo

DESCRIBE [EXTENDED | FORMATTED] [db_name.]table_name [PARTITION partition_spec] [col_name ( [.field_name] | [.'$elem$'] | [.'$key$'] | [.'$value$'] )]
Importante

La sintassi per questa istruzione è DESCRIBE table_name, non DESCRIBE TABLE table_name. L'utilizzo di quest'ultima sintassi genera il messaggio di errore FAILED: SemanticException [Error 10001]: Tabella non trovata tabella.

Parametri

[EXTENDED | FORMATTED]

Determina il formato dell'output. L'omissione di questi parametri mostra i nomi delle colonne e i relativi tipi di dati, incluse le colonne di partizione, in formato tabulare. La specificazione FORMATTED non solo mostra i nomi delle colonne e i tipi di dati in formato tabulare, ma anche informazioni dettagliate sulla tabella e sull'archiviazione. EXTENDED mostra le informazioni sulle colonne e sui tipi di dati in formato tabulare e metadati dettagliati per la tabella in formato serializzato Thrift. Questo formato è meno leggibile ed è utile principalmente per il debug.

[PARTITION partition_spec]

Se incluso, elenca i metadati per la partizione specificata da partition_spec, dove partition_spec è nel formato (partition_column = partition_col_value, partition_column = partition_col_value, ...).

[col_name ( [.field_name] | [.'$elem$'] | [.'$key$'] | [.'$value$'] )* ]

Specifica la colonna e gli attributi da esaminare. Puoi specificare .field_name per un elemento di una struttura, '$elem$' per un elemento array, '$key$' per una chiave di mappatura e '$value$' per un valore di mappatura. È possibile specificare questi parametri in modo ricorsivo per esplorare ulteriormente la colonna complessa.

Esempi

DESCRIBE orders
DESCRIBE FORMATTED mydatabase.mytable PARTITION (part_col = 100) columnA;

La seguente query e il relativo output mostrano le informazioni relative alla colonna e al tipo di dati da una tabella impressions basata sui dati di esempio Amazon EMR.

DESCRIBE impressions
requestbegintime string from deserializer adid string from deserializer impressionid string from deserializer referrer string from deserializer useragent string from deserializer usercookie string from deserializer ip string from deserializer number string from deserializer processid string from deserializer browsercokie string from deserializer requestendtime string from deserializer timers struct<modellookup:string,requesttime:string> from deserializer threadid string from deserializer hostname string from deserializer sessionid string from deserializer dt string # Partition Information # col_name data_type comment dt string

La query e l'output di esempio riportati di seguito mostrano il risultato per la stessa tabella quando l'opzione FORMATTED viene utilizzata.

DESCRIBE FORMATTED impressions
requestbegintime string from deserializer adid string from deserializer impressionid string from deserializer referrer string from deserializer useragent string from deserializer usercookie string from deserializer ip string from deserializer number string from deserializer processid string from deserializer browsercokie string from deserializer requestendtime string from deserializer timers struct<modellookup:string,requesttime:string> from deserializer threadid string from deserializer hostname string from deserializer sessionid string from deserializer dt string # Partition Information # col_name data_type comment dt string # Detailed Table Information Database: sampledb Owner: hadoop CreateTime: Thu Apr 23 02:55:21 UTC 2020 LastAccessTime: UNKNOWN Protect Mode: None Retention: 0 Location: s3://us-east-1.elasticmapreduce/samples/hive-ads/tables/impressions Table Type: EXTERNAL_TABLE Table Parameters: EXTERNAL TRUE transient_lastDdlTime 1587610521 # Storage Information SerDe Library: org.openx.data.jsonserde.JsonSerDe InputFormat: org.apache.hadoop.mapred.TextInputFormat OutputFormat: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat Compressed: No Num Buckets: -1 Bucket Columns: [] Sort Columns: [] Storage Desc Params: paths requestbegintime, adid, impressionid, referrer, useragent, usercookie, ip serialization.format 1

La query e l'output di esempio riportati di seguito mostrano il risultato per la stessa tabella quando l'opzione EXTENDED viene utilizzata. Le informazioni dettagliate della tabella vengono visualizzate su una singola riga, ma qui sono formattate per la leggibilità.

DESCRIBE EXTENDED impressions
requestbegintime string from deserializer adid string from deserializer impressionid string from deserializer referrer string from deserializer useragent string from deserializer usercookie string from deserializer ip string from deserializer number string from deserializer processid string from deserializer browsercokie string from deserializer requestendtime string from deserializer timers struct<modellookup:string,requesttime:string> from deserializer threadid string from deserializer hostname string from deserializer sessionid string from deserializer dt string # Partition Information # col_name data_type comment dt string Detailed Table Information Table(tableName:impressions, dbName:sampledb, owner:hadoop, createTime:1587610521, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:requestbegintime, type:string, comment:null), FieldSchema(name:adid, type:string, comment:null), FieldSchema(name:impressionid, type:string, comment:null), FieldSchema(name:referrer, type:string, comment:null), FieldSchema(name:useragent, type:string, comment:null), FieldSchema(name:usercookie, type:string, comment:null), FieldSchema(name:ip, type:string, comment:null), FieldSchema(name:number, type:string, comment:null), FieldSchema(name:processid, type:string, comment:null), FieldSchema(name:browsercokie, type:string, comment:null), FieldSchema(name:requestendtime, type:string, comment:null), FieldSchema(name:timers, type:struct<modellookup:string,requesttime:string>, comment:null), FieldSchema(name:threadid, type:string, comment:null), FieldSchema(name:hostname, type:string, comment:null), FieldSchema(name:sessionid, type:string, comment:null)], location:s3://us-east-1.elasticmapreduce/samples/hive-ads/tables/impressions, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.openx.data.jsonserde.JsonSerDe, parameters:{serialization.format=1, paths=requestbegintime, adid, impressionid, referrer, useragent, usercookie, ip}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[FieldSchema(name:dt, type:string, comment:null)], parameters:{EXTERNAL=TRUE, transient_lastDdlTime=1587610521}, viewOriginalText:null, viewExpandedText:null, tableType:EXTERNAL_TABLE)