0

When we create using

Create external table employee (name string,salary float) row format delimited fields terminated by ',' location /emp

In /emp directory there are 2 emp files.

so when we run select * from employee, it get the data from both the file ad display.

What will be happen when there will be others file also having different kind of record which column is not matching with the employee table , so it will try to load all the files when we run "select * from employee"?

1.Can we specify the specific file name which we want to load? 2.Can we create other table also with the same location?

Thanks Prashant

2 Answers2

0

It will load all the files in emp directory even it doesn’t match with table.

for your first question. you can use Regex serde.if your data matches to regex.then it loads to the table. regex for access log in hive serde

https://github.com/apache/hive/blob/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/serde2/RegexSerDe.java

other options:I am pointing some links.these links has some ways.

when creating an external table in hive can I point the location to specific files in a direcotry?

https://issues.apache.org/jira/browse/HIVE-951

for your second question: yes we can create other tables also with the same location.

Community
  • 1
  • 1
Sravan K Reddy
  • 1,082
  • 1
  • 10
  • 19
0

Here are your answers 1. If the data in the file dosent match with table format, hive doesnt throw an error. It tries to read the data as best as it could. If data for some columns are missing it will put NULL for them.

  1. No we cannot specify the file name for any table to read data. Hive will consider all the files under the table directory.

  2. Yes, we can create other tables with the same location.

sunil
  • 1,259
  • 1
  • 14
  • 27