简体   繁体   English

AWS Athena Javascript SDK - 根据查询结果 (CTAS) 创建表 - 指定输出格式

[英]AWS Athena Javascript SDK - Create table from query result (CTAS) - Specifiy otuput format

I am trying using the AWS JavaScript Node.JS SDK to make a query using AWS Athena and store the results in a table in AWS Glue with Parquet format (not just a CSV file)我正在尝试使用 AWS JavaScript Node.JS SDK 使用 AWS Athena 进行查询,并将结果存储在具有 Parquet 格式的 AWS Glue 表中(不仅仅是 CSV 文件)

If I am using the conosle, it is pretty simple with a CTAS query :如果我使用的是控制台,则使用 CTAS 查询非常简单:

CREATE TABLE tablename
WITH (
    external_location = 's3://bucket/tablename/',
    FORMAT = 'parquet')
    AS
SELECT *
FROM source

But with AWS Athena JavaScript SDK I am only able to set an output file destination using the Workgoup or Output parameters and make a basic select query, the results would output to a CSV file and would not be indexed properly in AWS Glue so it breaks a bigger process it is part of, if I try to call that query using the JavaScript SDK I get :但是使用 AWS Athena JavaScript SDK,我只能使用 Workgoup 或 Output 参数设置输出文件目标并进行基本的选择查询,结果将输出到 CSV 文件并且不会在 AWS Glue 中正确索引,因此它破坏了它是更大的过程的一部分,如果我尝试使用 JavaScript SDK 调用该查询,我会得到:

Table properties [FORMAT] are not supported.

I would be able to call that DDL statement using the Java SDK JDBC driver connection option.我将能够使用 Java SDK JDBC 驱动程序连接选项调用该 DDL 语句。

Is anyone familiar with a solution or workaround with the Javascript SDK for Node.JS?是否有人熟悉 Node.JS 的 Javascript SDK 的解决方案或变通方法?

There is no difference between running the SQL you posted in the Athena web console, AWS SDK for JavaScript, AWS SDK for Java, or the JDBC driver, none of these will process the SQL, so if the SQL works in one of these it will work in all of them.运行您在 Athena Web 控制台中发布的 SQL、适用于 JavaScript 的 AWS 开发工具包、适用于 Java 的 AWS 开发工具包或 JDBC 驱动程序之间没有区别,这些都不会处理 SQL,因此如果 SQL 在其中之一中工作,它将在所有这些工作。 It's only the Athena service that reads the SQL.只有 Athena 服务读取 SQL。

Check your SQL and make sure you really use the same in your code as you have tried in the web console.检查您的 SQL 并确保您在代码中确实使用了与您在 Web 控制台中尝试过的相同的内容。 If they are indeed the same, the error is somewhere else in your code, so post that too.如果它们确实相同,则错误在您的代码中的其他位置,因此也将其发布。


Update the problem is the upper case FORMAT .更新问题是大写FORMAT If you paste the code you posted into the Athena web console, it bugs out and doesn't run the query, but if you run it with the CLI or an SDK you get the error you posted.如果您将发布的代码粘贴到 Athena Web 控制台中,它会出错并且不会运行查询,但是如果您使用 CLI 或 SDK 运行它,则会收到您发布的错误。 You did not run the same SQL in the console as in the SDK, if you had you would have gotten the same error in both.您没有在控制台中运行与 SDK 中相同的 SQL,如果您这样做了,您会在两者中得到相同的错误。

Use lower case format and it will work.使用小写format ,它会起作用。

This is definitely a bug in Athena, these properties should not be case sensitive.这绝对是 Athena 中的一个错误,这些属性不应该区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM