如何清除 Amazon Redshift 中的以下语法错误

Posted

技术标签:

【中文标题】如何清除 Amazon Redshift 中的以下语法错误【英文标题】:How do I clear the following Syntax Error in Amazon Redshift 【发布时间】:2019-01-24 16:45:45 【问题描述】:

我在尝试运行以下命令时收到以下错误消息: 数据库报语法错误:

亚马逊无效操作:“.”处或附近的语法错误位置:3952;

select a.*,
b.*,
c.*,
a1."lte_tbl_employee_first_name" as "lte_idb_relocation.sent_by_first_name",
a1."lte_tbl_employee_last_name" as "lte_idb_relocation.sent_by_last_name",
a2."lte_tbl_employee_first_name" as "lte_idb_return.received_by_first_name",
a2."lte_tbl_employee_last_name" as "lte_idb_return.received_by_last_name",
a3."lte_tbl_employee_first_name" as "lte_idb_shipment.order_filler_first_name",
a3."lte_tbl_employee_last_name" as "lte_idb_shipment.order_filler_last_name",
a4."lte_tbl_employee_first_name" as "lte_idb_shipment.order_taker_first_name",
a4."lte_tbl_employee_last_name" as "lte_idb_shipment.order_taker_last_name",
a5."lte_tbl_employee_first_name" as "lte_idb_shipment.shipped_by_first_name",
a5."lte_tbl_employee_last_name" as "lte_idb_shipment.shipped_by_last_name",
a6."lte_tbl_employee_first_name" as "lte_idb_shipment.requestor_first_name",
a6."lte_tbl_employee_last_name" as "lte_idb_shipment.requestor_last_name",
a7."lte_tbl_employee_first_name" as "lte_idb_shipment.shipped_by_first_name",
a7."lte_tbl_employee_last_name" as "lte_idb_shipment.shipped_by_last_name",
a8."lte_tbl_employee_first_name" as "lte_idb_transaction.entered_by_first_name",
a8."lte_tbl_employee_last_name" as "lte_idb_transaction.entered_by_last_name",

b1."lte_tbl_hospital.name" as "lte_idb_invoice.customer_name",
b2."lte_tbl_hospital.name" as "lte_idb_return.returned_by_customer_name",
b3."lte_tbl_hospital.name" as "lte_idb_relocation.relocate_from_customer_name",
b4."lte_tbl_hospital.name" as "lte_idb_transaction.invoiced_customer_name",
b5."lte_tbl_hospital.name" as "lte_idb_shipment.shipped_to_customer_name",

c1."lte_tbl_return_code.description" as "lte_tbl_return_code.return_reason_description",
c2."lte_tbl_return_code.hold_code",
c3."lte_tbl_return_code.destroyed_at_hospital",
c4."lte_tbl_inventory_type.inventory_type",
c5."lte_tbl_inventory_type.description",
c6."tbl_transaction_status.status_description",
c7."lte_idb_transaction.transaction_id",
c8.CONCAT("lte_idb_transaction.transaction_number_prefix", "lte_idb_transaction.transaction_number_sequence") as "lte_idb_transaction.transaction",
c9."lte_idb_transaction.transaction_datetime",
c10."lte_idb_transaction.invoice_number",
c11."lte_idb_transaction.entered_by",
c12."lte_idb_transaction.transaction_status",
c13."lte_idb_transaction.invoiced_customer",
c14."lte_idb_invoice.total_amount",
c15."lte_idb_invoice.invoice_status",
c16."lte_idb_invoice.date_generated",
c17."lte_idb_invoice.customer_code",
c18."lte_idb_line_item.line_item_id",
c19."lte_idb_line_item.product_id",
c20."lte_idb_line_item.price",
c21."lte_idb_line_item.product_code",
c22."lte_idb_line_item.quantity",
c23."lte_idb_line_item.comments",
c24."lte_idb_line_item.expires",
c25."lte_idb_line_item.blood_type",
c26."lte_idb_line_item.biohazard",
c27."lte_idb_line_item.licensed",
c28."lte_idb_service.po_number",
c29."lte_idb_service.auto_price",
c30."lte_idb_service.debit",
c31."lte_idb_relocation.sent_by",
c32."lte_idb_relocation.auto_price",
c33."lte_idb_relocation.po_number",
c34."lte_idb_relocation.relocate_from",
c35."lte_idb_return.returned_by",
c36."lte_idb_return.received_by",
c37."lte_idb_return.return_code" as "lte_idb_return.return_reason",
c38."lte_idb_return.ra_number" as "lte_idb_return.r/a_number",
c39."lte_idb_return.auto_price",
c40."lte_idb_shipment.shipped_to",
c41."lte_idb_shipment.shipped_by",
c42."lte_idb_shipment.order_date",
c43."lte_idb_shipment.order_filler",
c44."lte_idb_shipment.order_taker",
c45."lte_idb_shipment.requestor",
c46."lte_idb_shipment.transportation_code",
c47."lte_idb_shipment.po_number",
c48."lte_idb_shipment.autologous",
c49."lte_idb_shipment.auto_price",
c50."lte_idb_shipment.emergency_shipment",
c51."lte_idb_shipment.order_number_external"
from "lte_idb_transaction_joined" c., "raw_lte_tbl_employee" a., 
"raw_lte_tbl_hospital" b.,

left JOIN "raw_lte_tbl_employee" a1
on c."lte_idb_relocation.sent_by" = a1."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a2
on c. "lte_idb_return.received_by" = a2."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a3
on c."lte_idb_shipment.order_filler" = a3."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a4
on c."lte_idb_shipment.order_taker" = a4."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a5
on c."lte_idb_shipment.shipped_by" = a5."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a6
on c."lte_idb_shipment.requestor" = a6."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a7
on c."lte_idb_shipment.shipped_by"= a7."lte_tbl_employee_code"

left join "raw_lte_tbl_employee" a8
on c."lte_idb_transaction.entered_by" = a8."lte_tbl_employee_code"

left join "raw_lte_tbl_hospital" b1
on c."lte_idb_invoice.customer_code" = b1."lte_tbl_hospital.code"

left join "raw_lte_tbl_hospital" b2
on c."lte_idb_return.returned_by" = b2."lte_tbl_hospital.code"

left join "raw_lte_tbl_hospital" b3
on c."lte_idb_relocation.relocate_from" = b3."lte_tbl_hospital.code"

left join "raw_lte_tbl_hospital" b4
on c."lte_idb_transaction.invoiced_customer" = b4."lte_tbl_hospital.code"

left join "raw_lte_tbl_hospital" b5 
on c."lte_idb_shipment.shipped_to" = b5."lte_tbl_hospital.code"

【问题讨论】:

删除所有点后的空格。我猜你的文本编辑器把它们放进去,以为你在输入一个句子,点是句号(句号)。 完成了,仍然返回相同的语法错误 @JenniferWhite 我编辑了您的问题以删除句号后的空格。 【参考方案1】:

这很可能会导致此类问题:

from "lte_idb_transaction_joined" c.,
     "raw_lte_tbl_employee" a., 
     "raw_lte_tbl_hospital" b.,

别名后不应有句点。

【讨论】:

以上是关于如何清除 Amazon Redshift 中的以下语法错误的主要内容,如果未能解决你的问题,请参考以下文章

amazon-redshift 中的 CONCAT 函数

如何解决 Amazon Redshift 中的数字溢出问题

Amazon redshift 中的每月保留

如何更改 Amazon Redshift 中的默认时区?

使用引号将数据从 S3 加载到 Amazon Redshift

如何在 Amazon Redshift 中使用 Hibernate 插入实体