Created
June 11, 2020 07:51
-
-
Save casperlehmann/0cc1b2c1b7e56b6fa10ace784b95a313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP EXTERNAL TABLE tests_external_table | |
DROP EXTERNAL FILE FORMAT file_format_name | |
DROP EXTERNAL DATA SOURCE extdatasource; | |
DROP DATABASE SCOPED CREDENTIAL ADLSCredential; | |
CREATE DATABASE SCOPED CREDENTIAL ADLSCredential | |
WITH IDENTITY = 'User Identity', | |
SECRET = '...............==' | |
CREATE EXTERNAL DATA SOURCE extdatasource | |
WITH | |
( LOCATION = 'abfss://data-lake-name@storageaccountname.dfs.core.windows.net/path/to/data/dir' | |
, CREDENTIAL = ADLSCredential | |
, TYPE = HADOOP | |
); | |
CREATE EXTERNAL FILE FORMAT file_format_name | |
WITH ( | |
FORMAT_TYPE = DELIMITEDTEXT | |
--[ , DATA_COMPRESSION = 'org.apache.hadoop.io.compress.GzipCodec' ] | |
, FORMAT_OPTIONS ( | |
FIELD_TERMINATOR = '|' | |
, STRING_DELIMITER = '' | |
, First_Row = 1 | |
, USE_TYPE_DEFAULT = TRUE | |
, Encoding = 'UTF8' | |
) | |
); | |
CREATE EXTERNAL TABLE tests_external_table | |
( | |
Test varchar(1000) | |
) | |
WITH ( | |
LOCATION = '/path/in/subfolders/filename.csv', | |
DATA_SOURCE = extdatasource, | |
FILE_FORMAT = file_format_name | |
) | |
GO | |
SELECT * FROM tests_external_table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment