[英]Create Glue data catalog via Athena SDK
I would like to use Athena to run queries on data in an S3 bucket in another AWS account.我想使用 Athena 对另一个 AWS 账户中 S3 存储桶中的数据运行查询。 I am using Javascript SDK. Reading through the documentation , I understand that I must first create a data catalog that will point Athena to the correct S3 location.
我正在使用 Javascript SDK。通过阅读文档,我明白我必须首先创建一个数据目录,将 Athena 指向正确的 S3 位置。
I think that I have to call the createDataCatalog method.我认为我必须调用createDataCatalog方法。 Most of the arguments for this method are self-explanatory, except for the "parameters" argument, which seems to contain information about how the data catalog will be created.
此方法的大部分 arguments 都是不言自明的,除了“参数”参数,它似乎包含有关如何创建数据目录的信息。 But I am unable to find anywhere how these parameters should look.
但我无法在任何地方找到这些参数的外观。
So my questions are:所以我的问题是:
For a simple use case with static S3 data,对于具有 static S3 数据的简单用例,
Here is an example to create Glue Database and Table下面是创建 Glue 数据库和表的示例
const AWS = require("aws-sdk");
AWS.config.update({ region: "us-east-1" });
const glue = new AWS.Glue();
const dbName = "test-db";
glue.createDatabase(
{
DatabaseInput: {
Name: dbName,
},
},
function (dbCrtErr, dbRsp) {
if (dbCrtErr.message === "Database already exists." || dbRsp) {
console.log("dbRsp", dbRsp);
glue.createTable(
{
DatabaseName: dbName,
TableInput: {
Name: "my-table",
Parameters: {
classification: "json",
compressionType: "none",
},
TableType: "EXTERNAL_TABLE",
StorageDescriptor: {
Location: "s3://my-s3-bucket-with-events/",
InputFormat:
"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat",
OutputFormat:
"org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat",
Columns: [
{
Name: "id",
Type: "string",
},
{
Name: "name",
Type: "string",
},
],
},
},
},
function (error, response) {
console.log("error", error, "response", response);
}
);
} else {
console.log("dbCrtErr", dbCrtErr);
}
}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.