1

我找不到关于如何将带有外部表的 CSV 文件直接加载到 Sql 数据仓库中的完整示例。该文件位于存储帐户https://tstodummy.blob.core.windows.net/ Blob 容器参考数据中,文件夹 csv-uploads,文件 something.csv。这是我的代码

CREATE DATABASE SCOPED CREDENTIAL tstodummy_refdata_credential
  WITH IDENTITY = 'USER',
  SECRET = '....'
GO

CREATE EXTERNAL DATA SOURCE tstodummy_referencedata
  WITH ( TYPE = HADOOP,
         LOCATION = 'wasb://referencedata-in@tstodummy.blob.core.windows.net',
         CREDENTIAL = tstodummy_refdata_credential);
GO

CREATE EXTERNAL FILE FORMAT aps_bma_referencedata_ff
WITH (FORMAT_TYPE = DELIMITEDTEXT,
      FORMAT_OPTIONS(
          FIELD_TERMINATOR = ';',
          STRING_DELIMITER = '"',
          FIRST_ROW = 2, 
          USE_TYPE_DEFAULT = True)
)

CREATE EXTERNAL TABLE [stg_aps_bma_refdata].[PlanDeMaintenance]
  ( [Version]     VARCHAR(255) NULL
  , [Description] VARCHAR(255) NULL
  , [Date_Start]  VARCHAR(255) NULL
  , [Date_Stop]   VARCHAR(255) NULL
  ) WITH ( LOCATION = '\referencedata-in\csv-uploads\PlanDeMaintanance'
         , DATA_SOURCE = tstodummy_referencedata
         , FILE_FORMAT = aps_bma_referencedata_ff
         , REJECT_TYPE = VALUE
         , REJECT_VALUE = 0
         )

我一直在使用 Location 中的各种组合......但是,Nogo 错误是

Msg 105002, Level 16, State 1, Line 26
EXTERNAL TABLE access failed because the specified path name '/referencedata-in/csv-uploads/PlanDeMaintanance.csv' does not exist. Enter a valid path and try again.
4

2 回答 2

0

我看不到您的存储结构,但我想您会发现问题在于外部表位置中包含“/referencedata-in”。

一件小事,您可能还想在存储 URL 上考虑“wasbs”前缀,以便将 SSL 加密应用于传输。

于 2018-09-12T06:00:15.730 回答
0

最后,这在其他人遇到销售麻烦的情况下起到了作用。我还没有在这段代码中添加我收到的评论,同时完成了。

CREATE EXTERNAL DATA SOURCE tsto_referencedata
  WITH ( TYPE = HADOOP,
         LOCATION = 'wasb://referencedata-in@tsto.blob.core.windows.net',
         CREDENTIAL = tsto_refdata_credential);
GO

CREATE EXTERNAL FILE FORMAT aps_bma_referencedata_ff
WITH (FORMAT_TYPE = DELIMITEDTEXT,
      FORMAT_OPTIONS(
          FIELD_TERMINATOR = ',',
          STRING_DELIMITER = '"',
          FIRST_ROW = 2, 
          USE_TYPE_DEFAULT = True)
)

CREATE EXTERNAL TABLE [stg_aps_bma_refdata].[PlanDeMaintenance.csv]
  ( [Version]     VARCHAR(255) NULL
  , [Description] VARCHAR(255) NULL
  , [Date_Start]  VARCHAR(255) NULL
  , [Date_Stop]   VARCHAR(255) NULL
  ) WITH ( LOCATION = '/csv-uploads/PlanDeMaintenance.csv'
         , DATA_SOURCE = tsto_referencedata
         , FILE_FORMAT = aps_bma_referencedata_ff
         , REJECT_TYPE = VALUE
         , REJECT_VALUE = 0
         )
于 2018-09-12T09:05:56.950 回答