-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Obtain account and container names from provided path in Azure Blob S…
…torage. (#55) * Use Azure Blob path to obtain container and account name. When accessing Azure Blob Storage, currently we require users to provide the `container` and `account` names as separate parameters even though they can be found in the provided data path. With this change it is not require to explicitly set additional `AZURE_ACCOUNT_NAME` and `AZURE_CONTAINER_NAME` properties, these values are obtained from `BUCKET_PATH` value. For example, the new import statement: ``` IMPORT INTO RETAIL.SALES_POSITIONS FROM SCRIPT ETL.IMPORT_PATH WITH BUCKET_PATH = 'wasbs://<AZURE_CONTAINER_NAME>@<AZURE_ACCOUNT_NAME>.blob.core.windows.net/data/orc/*' AZURE_SAS_TOKEN = '<AZURE_SAS_TOKEN>' DATA_FORMAT = 'ORC' PARALLELISM = 'nproc()'; ``` Previously users had to set additional two properties: ``` IMPORT INTO RETAIL.SALES_POSITIONS FROM SCRIPT ETL.IMPORT_PATH WITH BUCKET_PATH = 'wasbs://<AZURE_CONTAINER_NAME>@<AZURE_ACCOUNT_NAME>.blob.core.windows.net/data/orc/*' DATA_FORMAT = 'ORC' AZURE_ACCOUNT_NAME = '<AZURE_ACCOUNT_NAME>' AZURE_CONTAINER_NAME = '<AZURE_CONTAINER_NAME>' AZURE_SAS_TOKEN = '<AZURE_SAS_TOKEN>' PARALLELISM = 'nproc()'; ``` Fixes #50.
- Loading branch information
Showing
4 changed files
with
125 additions
and
26 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import org.apache.hadoop.fs.azure.Wasbs | |
class AzureBlobBucketTest extends AbstractBucketTest { | ||
|
||
private[this] val defaultProperties = Map( | ||
PATH -> "wasbs://container@account1.windows.net/orc-data/", | ||
PATH -> "wasbs://container1@account1.blob.core.windows.net/orc-data/", | ||
FORMAT -> "ORC" | ||
) | ||
|
||
|
@@ -31,16 +31,17 @@ class AzureBlobBucketTest extends AbstractBucketTest { | |
} | ||
} | ||
|
||
test("apply throws if account name is not provided") { | ||
properties = defaultProperties | ||
test("apply throws if Azure Blob path is not valid") { | ||
val path = "wasb://[email protected]/data/" | ||
properties = defaultProperties ++ Map(PATH -> path, "AZURE_SECRET_KEY" -> "secret") | ||
val thrown = intercept[IllegalArgumentException] { | ||
assertAzureBlobBucket(getBucket(properties), Map.empty[String, String]) | ||
} | ||
assert(thrown.getMessage === "Please provide a value for the AZURE_ACCOUNT_NAME property!") | ||
assert(thrown.getMessage === s"Invalid Azure blob wasb(s) path: $path!") | ||
} | ||
|
||
test("apply throws if no connection name or credential (secret key or sas token) is provided") { | ||
properties = defaultProperties ++ Map("AZURE_ACCOUNT_NAME" -> "account1") | ||
properties = defaultProperties | ||
val thrown = intercept[IllegalArgumentException] { | ||
assertAzureBlobBucket(getBucket(properties), Map.empty[String, String]) | ||
} | ||
|
@@ -49,7 +50,7 @@ class AzureBlobBucketTest extends AbstractBucketTest { | |
assert(thrown.getMessage === expected) | ||
} | ||
|
||
test("apply returns AzureBlobBucket with secret key") { | ||
test("apply returns AzureBlobBucket with account name and secret key") { | ||
properties = defaultProperties ++ Map( | ||
"AZURE_ACCOUNT_NAME" -> "account1", | ||
"AZURE_SECRET_KEY" -> "secret" | ||
|
@@ -61,18 +62,16 @@ class AzureBlobBucketTest extends AbstractBucketTest { | |
) | ||
} | ||
|
||
test("apply throws if container name is not provided when using with sas token") { | ||
properties = defaultProperties ++ Map( | ||
"AZURE_ACCOUNT_NAME" -> "account1", | ||
"AZURE_SAS_TOKEN" -> "token" | ||
test("apply returns AzureBlobBucket with secret key") { | ||
properties = defaultProperties ++ Map("AZURE_SECRET_KEY" -> "secret") | ||
val bucket = getBucket(properties) | ||
assertAzureBlobBucket( | ||
bucket, | ||
Map("fs.azure.account.key.account1.blob.core.windows.net" -> "secret") | ||
) | ||
val thrown = intercept[IllegalArgumentException] { | ||
assertAzureBlobBucket(getBucket(properties), Map.empty[String, String]) | ||
} | ||
assert(thrown.getMessage === "Please provide a value for the AZURE_CONTAINER_NAME property!") | ||
} | ||
|
||
test("apply returns AzureBlobBucket with sas token") { | ||
test("apply returns AzureBlobBucket with account, container name and sas token") { | ||
properties = defaultProperties ++ Map( | ||
"AZURE_ACCOUNT_NAME" -> "account1", | ||
"AZURE_SAS_TOKEN" -> "token", | ||
|
@@ -85,7 +84,16 @@ class AzureBlobBucketTest extends AbstractBucketTest { | |
) | ||
} | ||
|
||
test("apply returns secret from password of connection object") { | ||
test("apply returns AzureBlobBucket with sas token") { | ||
properties = defaultProperties ++ Map("AZURE_SAS_TOKEN" -> "token") | ||
val bucket = getBucket(properties) | ||
assertAzureBlobBucket( | ||
bucket, | ||
Map("fs.azure.sas.container1.account1.blob.core.windows.net" -> "token") | ||
) | ||
} | ||
|
||
test("apply returns secret from password of connection object with account name") { | ||
properties = defaultProperties ++ Map( | ||
"AZURE_ACCOUNT_NAME" -> "account1", | ||
"CONNECTION_NAME" -> "connection_info" | ||
|
@@ -98,7 +106,17 @@ class AzureBlobBucketTest extends AbstractBucketTest { | |
) | ||
} | ||
|
||
test("apply returns sas token from password of connection object") { | ||
test("apply returns secret from password of connection object") { | ||
properties = defaultProperties ++ Map("CONNECTION_NAME" -> "connection_info") | ||
val exaMetadata = mockConnectionInfo("", "AZURE_SECRET_KEY=secret") | ||
val bucket = getBucket(properties, exaMetadata) | ||
assertAzureBlobBucket( | ||
bucket, | ||
Map("fs.azure.account.key.account1.blob.core.windows.net" -> "secret") | ||
) | ||
} | ||
|
||
test("apply returns sas token from password of connection with account, container name") { | ||
properties = defaultProperties ++ Map( | ||
"AZURE_ACCOUNT_NAME" -> "account1", | ||
"AZURE_CONTAINER_NAME" -> "container1", | ||
|
@@ -112,6 +130,16 @@ class AzureBlobBucketTest extends AbstractBucketTest { | |
) | ||
} | ||
|
||
test("apply returns sas token from password of connection object") { | ||
properties = defaultProperties ++ Map("CONNECTION_NAME" -> "connection_info") | ||
val exaMetadata = mockConnectionInfo("", "AZURE_SAS_TOKEN=token") | ||
val bucket = getBucket(properties, exaMetadata) | ||
assertAzureBlobBucket( | ||
bucket, | ||
Map("fs.azure.sas.container1.account1.blob.core.windows.net" -> "token") | ||
) | ||
} | ||
|
||
test("apply returns sas from connection object if both sas and secret are provided") { | ||
properties = defaultProperties ++ Map( | ||
"AZURE_ACCOUNT_NAME" -> "account1", | ||
|
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