Suppose you want to create following Hive table, with the partitioned by Date column. Which is the correct syntax
id int, date date, name varchar
1. create table table_name ( id int, date date, name string ) ) partitioned by (date string) 2. create table table_name ( id int, date date, name string ) ) partitioned by (string) 3. Access Mostly Uused Products by 50000+ Subscribers 4. Only 2 and 3 correct
Coorect Answer : 3 Partitioned tables can be created using the PARTITIONED BY clause. A table can have one or more partition columns and a separate data directory is created for each distinct value combination in the partition columns. Further, tables or partitions can be bucketed using CLUSTERED BY columns, and data can be sorted within that bucket via SORT BY columns. This can improve performance on certain kinds of queries. If, when creating a partitioned table, you get this error: "FAILED: Error in semantic analysis: Column repeated in partitioning columns," it means you are trying to include the partitioned column in the data of the table itself. You probably really do have the column defined. However, the partition you create makes a pseudocolumn on which you can query, so you must rename your table column to something else (that users should not query on!).
Question :
You have following DDL to create Hive table
CREATE TABLE page_view(viewTime INT, userid BIGINT, page_url STRING, referrer_url STRING, ip STRING COMMENT 'IP Address of the User') COMMENT 'This is the page view table' PARTITIONED BY(dt STRING, country STRING) STORED AS SEQUENCEFILE
Select the correct statement which applies A. The statement above creates the page_view table with viewTime, userid, page_url, referrer_url, and ip columns (including comments). B. The table is also partitioned C. Data is stored in sequence files. D. The data format in the files is assumed to be field-delimited by ctrl-A and row-delimited by newline.
Correct Answer : Get Lastest Questions and Answer : CREATE TABLE page_view(viewTime INT, userid BIGINT, page_url STRING, referrer_url STRING, ip STRING COMMENT 'IP Address of the User') COMMENT 'This is the page view table' PARTITIONED BY(dt STRING, country STRING) STORED AS SEQUENCEFILE; The statement above creates the page_view table with viewTime, userid, page_url, referrer_url, and ip columns (including comments). The table is also partitioned and data is stored in sequence files. The data format in the files is assumed to be field-delimited by ctrl-A and row-delimited by newline.
Question :
Select the correct statement for the below command
CREATE TABLE new_key_value_store ROW FORMAT SERDE "org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe" STORED AS RCFile AS SELECT (key % 1024) new_key, concat(key, value) key_value_pair FROM key_value_store SORT BY new_key, key_value_pair
1. The above CTAS statement creates the target table new_key_value_store with the schema (new_key DOUBLE, key_value_pair STRING) derived from the results of the SELECT statement 2. If the SELECT statement does not specify column aliases, the column names will be automatically assigned to _col0, _col1, and _col2 3. Access Mostly Uused Products by 50000+ Subscribers 4. 1 and 2 is correct 5. All 1,2 and 3 are correct
Explanation: The above CTAS statement creates the target table new_key_value_store with the schema (new_key DOUBLE, key_value_pair STRING) derived from the results of the SELECT statement. If the SELECT statement does not specify column aliases, the column names will be automatically assigned to _col0, _col1, and _col2 etc. In addition, the new target table is created using a specific SerDe and a storage format independent of the source tables in the SELECT statement.