使用 Spectrify 以 Parquet 格式将数据从 Redshift 卸载到 S3
Using Spectrify to offload data from Redshift to S3 in Parquet format
我正在尝试使用 Spectrify 以 Parquet 格式将数据从 Redshift 卸载到 S3,但我被困在这个过程中,因为我无法理解一些事情。 Spectrify 文档不是很好,我在互联网上找不到任何实施示例。我还在 Whosebug 上发现了一个类似的问题,但公认的答案是建议使用 Spectrify,这并没有多大帮助。
这是问题所在(这是他们文档中的代码):
from spectrify.export import RedshiftDataExporter
from spectrify.convert import ConcurrentManifestConverter
from spectrify.utils.schema import SqlAlchemySchemaReader
RedshiftDataExporter(sa_engine, s3_config).export_to_csv('my_table')
csv_path_template = 's3://my-bucket/my-table/csv/{start.year}/{start.month:02d}/{start.day:02d}'
spectrum_path_template = 's3://my-bucket/my-table/spectrum/partition_key={start}'
csv_path = csv_path_template.format(start=start_date)
spectrum_path = spectrum_path_template.format(start=start_date)
s3_config = SimpleS3Config(csv_path, spectrum_path)
sa_table = SqlAlchemySchemaReader(engine).get_table_schema('my_table')
ConcurrentManifestConverter(sa_table, s3_config).convert_manifest()
RedshiftDataExporter
用于将数据导出为CSV,sa_engine
用于连接Redshift引擎。
他们的文档对转换过程含糊不清。在 Python 3.x 脚本中使用 Spectrify 时应该使用什么过程将数据卸载到 CSV,然后将其转换为 Parquet 格式?我应该如何修改上面的代码以及我遗漏了什么?
您现在可以将 Redshift 数据以 Parquet 格式卸载到 S3,而无需任何第三方应用程序。 Redshift 现在支持新功能:
UNLOAD ('select-statement')
TO 's3://object-path/name-prefix'
FORMAT PARQUET
找到文档
我正在尝试使用 Spectrify 以 Parquet 格式将数据从 Redshift 卸载到 S3,但我被困在这个过程中,因为我无法理解一些事情。 Spectrify 文档不是很好,我在互联网上找不到任何实施示例。我还在 Whosebug 上发现了一个类似的问题,但公认的答案是建议使用 Spectrify,这并没有多大帮助。
这是问题所在(这是他们文档中的代码):
from spectrify.export import RedshiftDataExporter
from spectrify.convert import ConcurrentManifestConverter
from spectrify.utils.schema import SqlAlchemySchemaReader
RedshiftDataExporter(sa_engine, s3_config).export_to_csv('my_table')
csv_path_template = 's3://my-bucket/my-table/csv/{start.year}/{start.month:02d}/{start.day:02d}'
spectrum_path_template = 's3://my-bucket/my-table/spectrum/partition_key={start}'
csv_path = csv_path_template.format(start=start_date)
spectrum_path = spectrum_path_template.format(start=start_date)
s3_config = SimpleS3Config(csv_path, spectrum_path)
sa_table = SqlAlchemySchemaReader(engine).get_table_schema('my_table')
ConcurrentManifestConverter(sa_table, s3_config).convert_manifest()
RedshiftDataExporter
用于将数据导出为CSV,sa_engine
用于连接Redshift引擎。
他们的文档对转换过程含糊不清。在 Python 3.x 脚本中使用 Spectrify 时应该使用什么过程将数据卸载到 CSV,然后将其转换为 Parquet 格式?我应该如何修改上面的代码以及我遗漏了什么?
您现在可以将 Redshift 数据以 Parquet 格式卸载到 S3,而无需任何第三方应用程序。 Redshift 现在支持新功能:
UNLOAD ('select-statement')
TO 's3://object-path/name-prefix'
FORMAT PARQUET
找到文档