ravibhat
ravibhat

Reputation: 931

Choosing few columns in external table

I have a scenario wherein, I have a file(resides in ADLS) which contains 30 columns , but when i am creating external table.. i wanted to pick only 5 columns.

My question is : is it possible to selectively choose the columns while creating external table.

Right now creating external table works.. but when i do select query on top of that ext table.. it throws an exception

HadoopExecutionException: Too many columns in the line

Thanks in advance.

Upvotes: 0

Views: 2644

Answers (2)

lukaszFD
lukaszFD

Reputation: 99

Create a view that contains 5 columns instead of 30. This view can be used as a source for external tables.

Upvotes: 1

Itay Podhajcer
Itay Podhajcer

Reputation: 2654

Unfortunately, according to CREATE EXTERNAL TABLE (Transact-SQL), column selection when creating external tables is not supported:

The column definitions, including the data types and number of columns, must match the data in the external files. If there is a mismatch, the file rows will be rejected when querying the actual data.

Hope it helps!

Upvotes: 3

Related Questions