[英]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.