摄取 s3 文件以红移维护行顺序

问题描述 投票:0回答:1

我在 s3 中有文件需要读入 redshift,但我需要以某种方式维护文件中的行号。我尝试从一个光谱表插入到一个带有标识列的表中,但它插入的顺序是乱序的。除了用行号作为每行的一部分重写文件之外,还有其他想法吗?

amazon-redshift amazon-redshift-spectrum
1个回答
0
投票

如果有可能你可以在 S3 的文件中添加行号,那么你可以像这样添加它:

INSERT INTO your_table (line_number, other_columns)
SELECT line_number, other_columns
FROM spectrum_s3_table
ORDER BY line_number;

或者,您可以尝试通过您的identity_column来订购:

INSERT INTO your_table (line_number, other_columns)
SELECT line_number, other_columns
FROM spectrum_s3_table
ORDER BY identity_column;
© www.soinside.com 2019 - 2024. All rights reserved.