我正在使用以下 python 脚本从 CSV 文件创建镶木地板文件:
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
csv_file = '~/Desktop/SWA_UK_Pickup_Forecast_HOURLY_M1_at_2017-11-28-04_20_21-UTC_from_28-Nov-2017_to_28-Nov-2017.csv'
chunksize = 10
csv_stream = pd.read_csv(csv_file, sep=',', chunksize=chunksize, low_memory=False)
for i, chunk in enumerate(csv_stream):
if i == 0:
parquet_schema = pa.Table.from_pandas(df=chunk).schema
parquet_writer = pq.ParquetWriter('/Users/kohujwal/Desktop/parquet_forecast_file.parquet', parquet_schema, compression='snappy')
table = pa.Table.from_pandas(chunk, schema=parquet_schema);
parquet_writer.write_table(table)
parquet_writer.close();
然后我手动将它上传到某个 s3 位置,并在 Athena 中创建一个表。用于创建表的查询:
CREATE EXTERNAL TABLE IF NOT EXISTS forecast_report_lom_parquet (
`forecast_week` int,
`for_date` string,
`forecast_day_of_week` string,
`merchant_id` string,
`shipper_account_id` string,
`shipper_name` string,
`node_id` string,
`routing_preference` string,
`forecast_shipment_count` int,
`forecast_pallet_count` int,
`forecast_volume` double )
STORED AS PARQUET
LOCATION 's3://prevoir-athena-input-prod/spike-computation/forecast-reports/parquet/live-order-model/'
tblproperties ("parquet.compress"="SNAPPY")
表创建成功,但是当我尝试查询表时,它不显示内容。它只显示行的索引和列名。这是CSV和镶木地板文件。镶木地板上的查询:
SELECT * FROM prevoir_prod.forecast_report_lom_parquet
我在控制台上看到的结果。
谁能指出这里出了什么问题?