SQL Language Guide : 8. SQL Statements : CREATE EXTERNAL TABLE : CREATE EXTERNAL TABLE Examples
 
Share this page                  
CREATE EXTERNAL TABLE Examples
Note:  The column names in the Vector external table must match the column names in the reference source.
1. Define an external table for a CSV data source:
CREATE EXTERNAL TABLE ext_csv (col1 INT4 NOT NULL, col2 VARCHAR(20) NOT NULL)
USING SPARK
WITH REFERENCE='user/mark/file.csv'
 OPTIONS=('delimiter' = '|', 'header' = 'true');
Note:  If the CSV file does not have a header, the name of the columns in the external table must match those in spark-csv, that is, C0, C1, .... If the option 'header' = 'true' is not specified and the Vector external table definition has different names, you will get an error like:
E_VW1213 External table provider reported an error
'org.apache.spark.sql.AnalysisException: cannot resolve 'a' given input columns C0, C1; line 1
pos 38'.