如何从元数据中检索数据在 Glue Script 中创建表

How data retrieved from metadata created tables in Glue Script

在 AWS Glue 中,虽然我阅读了文档,但我没有弄清楚一件事。以下是我的理解。

关于爬虫:这将为 S3 或 DynamoDB table 创建一个元数据 table。但我不明白的是:Scala/Python 脚本如何使用创建的元数据 tables.

从实际来源(比如 DynamoDB or S3)检索数据
val input = glueContext
      .getCatalogSource(database = "my_data_base", tableName = "my_table")
      .getDynamicFrame()

上一行是否通过元数据 tables 从实际来源检索数据?

如果有人能向我解释通过元数据在 Glue 脚本中检索数据的幕后情况,我会很高兴 tables。

当您 运行 Glue 爬虫时,它将从 S3 或 JDBC(取决于您的要求)获取元数据并在 AWS Glue 数据目录中创建 tables。

现在,如果您想从 Glue ETL 作业连接到此 data/tables,则可以根据您的要求以多种方式进行连接:

  1. [from_options][1] :如果您想直接从 S3/JDBC 加载而不连接到 Glue 目录。

  2. [from_catalog][1] :如果您想从 Glue 目录加载数据,那么您需要使用 getCatalogSource 方法将其与目录一起 link显示在您的代码中。顾名思义,它将使用 Glue 数据目录作为源并加载您传递给此方法的特定 table。

一旦它查看了指向某个位置的 table 定义,它就会建立连接并加载源中存在的数据。

是的,如果您想从 Glue 目录加载 tables,您需要使用 getCatalogSource

  1. Catalog 是否会查看 Crawler 并参考实际的源和加载数据?

Check out the diagram in this [link][2] . It will give you an idea about the flow.

  1. 如果在 运行 getCatalogSource 之前删除了爬虫,那么在这种情况下我可以加载数据吗?

Crawler and Table are two different components. It all depends on when the table is deleted. If you delete the table after your job start to execute then there will not be any problem. If you delete it before execution starts then you will encounter an error.

  1. 如果我的源有数百万条记录怎么办?那么这会加载所有记录吗?或者在这种情况下如何加载?

It is good to have large files to be present in source so it will avoid most of the small files problem. Glue based on Spark and it will read files which can be fit in memory and then do the computations. Check this [answer][3] and [this][4] for best practices while reading larger files in AWS Glue. [1]: https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-extensions-dynamic-frame-reader.html [2]: https://docs.aws.amazon.com/athena/latest/ug/glue-athena.html [3]: [4]: https://aws.amazon.com/blogs/big-data/optimize-memory-management-in-aws-glue/#:~:text=Incremental%20processing:%20Processing%20large%20datasets