简体   繁体   English

AWS Athena 从选择查询创建表

[英]AWS Athena create table from select query

I am trying to create table using the query below.我正在尝试使用下面的查询创建表。 If I do not create table, but just run the part from SELECT *, the query can be run.如果我不创建表,而只是从 SELECT * 运行部分,则可以运行查询。

    (SELECT *
    FROM "MyDatabase"."2007" A
    WHERE A."column name a" NOT IN ('U','A+','A','A-')
            AND A."column name b" NOT IN ('SHH','CTP')
            AND NOT EXISTS 
        (SELECT *
        FROM "MyDatabase"."2008" B
        WHERE (B."column name a" = A."column name a"
                AND B."column name b" = A."column name b"
                AND B."column name c" = A."column name c")))

The error message is "GENERIC_INTERNAL_ERROR: field ended by ';': expected ';'错误消息是“GENERIC_INTERNAL_ERROR:字段以';'结尾:预期为';' but got 'partOfAColName' at line 1:..."但是在第 1 行得到了 'partOfAColName':...”

From google search, space in column names seems to be the problem.从谷歌搜索来看,列名中的空格似乎是问题所在。 But I am not sure.但我不确定。 I have space in column names.我在列名中有空格。 The column names are automatically detected by Glue Crawler. Glue Crawler 会自动检测列名称。 So I am not sure if I can do anything about it.所以我不确定我是否能做些什么。 I have around 20 columns, all having space in the middle though.我有大约 20 列,但中间都有空间。 Could someone suggest a fix?有人可以建议修复吗? Thanks.谢谢。

When you execute CREATE TABLE AS...you are telling Athena to create a table with the same column names in your SELECT, but in this case those column names contain spaces, and Athena won't allow you to create a column name with a space.当您执行 CREATE TABLE AS...时,您是在告诉 Athena 在 SELECT 中创建一个具有相同列名的表,但在这种情况下,这些列名包含空格,并且 Athena 不允许您创建带有空间。 To avoid this you can create the table with column names that adhere to the Athena's specifications then populate that table with INSERT INTO SELECT...FROM为避免这种情况,您可以使用符合 Athena 规范的列名创建表,然后使用 INSERT INTO SELECT...FROM 填充该表

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

相关问题 从 AWS Athena 的表中选择每组 1000 个样本 - Select 1000 samples per group from a table in AWS Athena 通过 AWS Athena 分桶表中的多个值进行查询 - Query by multiple values from an AWS Athena bucketed table 是否可以从 AWS Athena 中的嵌套 json object 创建平面表? - Is it possible to create flat table from nested json object in AWS Athena? AWS Athena 查询将结果附加到表中? - AWS Athena query appending results to table? 如何在 AWS Athena 中编写多个 SQL 语句,如 CREATE 表(使用 CLI 命令 - aws athena start-query-execution --query-string {value})? - How to write multiple SQL statements like CREATE table in AWS Athena ( using CLI command - aws athena start-query-execution --query-string {value} )? 从Select查询创建表 - Create a table from a Select query 是否存在sql查询的等效函数:来自aws athena的from_unixtime(unix_timestamp($ {TABLE} .dt,“yyyyMMdd”)) - Is there any equivalent function for an sql query: from_unixtime(unix_timestamp(${TABLE}.dt,“yyyyMMdd”) in aws athena) AWS Athena - 使用 CREATE AS SELECT 时添加新列 - AWS Athena - Add new column when using CREATE AS SELECT 从雅典娜查询中的两个表创建视图 - create a view from two tables in athena query 如何查询在使用Presto的AWS Athena中的列上分区的表 - How to query a table partitioned on a column in AWS Athena that uses Presto
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM