[英]Creating Table from Partitioned Parquet data by using conditions
我正在嘗試從databricks cluster中的 Amazon s3的分區數據創建表。 現在我擁有的數據在以下分區
ID
, report
和date
所以我已經安裝了數據:
%python
ACCESS_KEY = "xxxxxxxxx"
SecretKey = "xxxxxxxxxx"
ENCODED_SECRET_KEY = SecretKey.replace("/", "%2F")
AWS_BUCKET_NAME = "path/parent_directory"
MOUNT_NAME = "parent"
dbutils.fs.mount("s3a://%s:%s@%s" % (ACCESS_KEY, ENCODED_SECRET_KEY,
AWS_BUCKET_NAME), "/mnt/%s" % MOUNT_NAME)
現在,按照我的數據路徑的結構,將如下所示:
/dbfs/parent/id/report/date
現在,我想基於分區創建表。 我想在創建表中指定where條件,並在其中指定report_name。 id文件夾中有5個報告。 我的查詢是這樣的:
%sql
Create table if not exists abc
(col1 string,
col2 string,
col3 bigint)using parquet
OPTIONS (path "/mnt/parent/")
partitioned by (id,report,date) where
report="report1" ;
我收到語法錯誤 :
Error in SQL statement: ParseException:mismatched input 'where' expecting <EOF>
我也試過
Create table if not exists report1
(
col1 string,
col2 string,
col3 bigint )using parquet
OPTIONS (path "/mnt/parent/")
partitioned by (id,report="report1",date)
誰能幫我這個? 還是有人可以幫助我通過spark-shell加載?
謝謝
我認為您真正想要的是數據的非托管表和根據該分區條件進行過濾的視圖。
create table report
using parquet
options (
path '/mnt/parent'
);
msck repair table report;
create or replace view report1
as select * from report where report = 'report1';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.